Align text to Center in StatusBar

Creative ideas/suggestions for HMG

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Align text to Center in StatusBar

Post by Pablo César »

Hi all,

Is it posible to set text at StatusBar's items to be aligned to center ?

I found this in code C# for right align text. I do not know how to do it in C and for center aligment:
Screen1.png
Screen1.png (27.9 KiB) Viewed 4363 times
I would like to see this in our library will be nice to have it.

I used the Courrier New (monospaced font) with PADC. But sometimes we do not know how long in characters would it can be applied for StatusBar when Window is not fixed sizes.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Align text to Center in StatusBar

Post by Pablo César »

I come here to say there is a litle bug around SetStatusItemText() at c_status.c.

Normally when we need to change the text in one cell of StatusBar, we use:

<WindowName>.<ControlName>. Item (<nItem>) := ItemText

And this is interpreted by _SetItem() identifying de type of control and redirect to SetStatusItemText()

The problem is when one or more item is RAISED style.
Screen1.png
Screen1.png (26.51 KiB) Viewed 4289 times
When by ACTION we need to change it text, then worngly the item changes the style :o
I mean, changes from RAISED to FLAT... :(

See demo expressing this bug:

Code: Select all

#include "hmg.ch"

Function Main
DEFINE WINDOW Form_1 ;
    AT 0,0 ;
    WIDTH 600 HEIGHT 400 ;
    TITLE 'HMG StatusBar Demo' ;
    MAIN ;
    FONT 'Arial' SIZE 10 

    DEFINE STATUSBAR 
        STATUSITEM "Item 1" ACTION {|| Form_1.StatusBar.Item(1):="Changed !"} RAISED 
        STATUSITEM "Item 2" WIDTH 100 ACTION MsgInfo('Click! 2') TOOLTIP "Item 2"
        STATUSITEM 'A Car!' WIDTH 100
        CLOCK 
        DATE  TOOLTIP "Item date"
    END STATUSBAR

END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
Sorry Claudio to ask indirectly to you, but I couldn't fails to inform about it.
If you can do something to correct this, is very appreciated, as always ! :)
..by the way, in case you have to work on that c function, would you add that new implement (CENTER text) ?

Thank you in advanced !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Align text to Center in StatusBar

Post by srvet_claudio »

Pablo César wrote:I come here to say there is a litle bug around SetStatusItemText() at c_status.c.
Hi Pablo,
change in file c_status.c the original SETSTATUSITEMTEXT() function for this:

Code: Select all

HB_FUNC (SETSTATUSITEMTEXT)
{  
   TCHAR * text = (TCHAR *) HMG_parc(2);
   WORD nDraw = HIWORD ( SendMessage ((HWND) HMG_parnl (1), SB_GETTEXTLENGTH, (WPARAM) hb_parnl (3), 0) );
   SendMessage( (HWND) HMG_parnl (1) , SB_SETTEXT , (WPARAM) (nDraw | hb_parnl (3)) , (LPARAM) text ) ;
}
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Align text to Center in StatusBar

Post by Pablo César »

Perfecto ! :D

Thank you Claudio, you are great ! Now RAISED style is respected as accordingly, thanks to you ! :)

And what about the probably to include JUSTIFY ( JTFY_LEFT, JTFY_RIGHT, JTFY_RIGHT ), is it very complexed for implementation ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Align text to Center in StatusBar

Post by Pablo César »

Hi HMG DT,

I have two questions regarding StatusBar for posible enhance:
  1. Is it posible to set text at StatusBar's items to be aligned to center ?
    Like as to include at anWidths:={ LEFT, CENTER, RIGHT}
     
  2. StatusBar when there is more than on item, always it takes the first cell at most left for trimming propose.
    Is it posible to expand as possibilities selecting which cell it could be used for trimming ?

    I've got an idea and I make some test already by changing StatuBar in our library with three options:
    1. When just one of cell is Nil Width size.
      It will take this cell for trimming.
    2. When all Width sizes are defined.
      It will take the bigger width size cell for trimming.
    3. When all Width sizes are equally.
      It will take the first cell for trimming, as ever done.

      Actually we have:

      Code: Select all

      	For i := 2 To HMG_LEN (anWidths)
      		If ValType ( anWidths [i] ) <> 'N'
      			anWidths [i] := 120
      		EndIf
      		nTotWidth := nTotWidth + anWidths [i]
      	Next i
      	anWidths [1] := GetWindowWidth ( nParentHandle ) - nTotWidth
      Please note always is taking the most left cell for trimming.

      I propose to change as follows:

      Code: Select all

      Local nMaxWidth:=0
      Local aNil:={}
      Local nP:=1
      
      	For i := 1 To HMG_LEN (anWidths)
      		If ValType ( anWidths [i] ) <> 'N'
      			anWidths [i] := 120
      			Aadd(aNil,i)
      		EndIf
      		If anWidths[i] > nMaxWidth
      		   nMaxWidth := anWidths[i]
      		   nP := i
      		Endif
      		nTotWidth := nTotWidth + anWidths [i]
      	Next i
      	If HMG_Len(aNil)=1
      	   nP := aNil[1]
      	ElseIf HMG_Len(aNil)>1
      	   nP := 1
      	Endif
      	nTotWidth := nTotWidth - anWidths [nP]
      	anWidths[nP] := GetWindowWidth ( nParentHandle ) - nTotWidth
      As you can see three options wil be considered for trimming.
As it's now for trimming widths cells at first cell, it's quite imposible to adjust midle cells... :(
Screen1.png
Screen1.png (21.34 KiB) Viewed 4169 times
By this way midle cell will be easy let with width size for trimming. Specially when we have different screen resolutions.

I'm asking these features in order to leave more versatile StatuBar control.

I do not know colleagues here has experienced the same difficulty. It is very annoying to have to leave the fixed windows for the StatusBar do not be disproportionated ...

If is not possible to accept these implementations at Width size, I shall ask if is not posible to let Widths assignable like as is in Minigui Extended.
Screen2.png
Screen2.png (7.2 KiB) Viewed 4169 times
If Width becomes assignable, then we can use it to fix all widths sizes.
Here we find a solution for this second case.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Align text to Center in StatusBar

Post by Rathinagiri »

Thank you for the suggestion Pablo. Nice improvement.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Align text to Center in StatusBar

Post by Pablo César »

Thank you Rathi, all for HMG.

It also will be a big and old wish if we can get aligments in StatusBar's Items, this is important too IMO.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Align text to Center in StatusBar

Post by serge_girard »

Thanks all for this improvement!

Serge
There's nothing you can do that can't be done...
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Align text to Center in StatusBar

Post by Pablo César »

serge_girard wrote:Thanks all for this improvement!

Serge
Dank u Serge !
But it's just an indication of implementation.
I do not know yet whether it will be approved by HMG DT.

But that does not stop me or what else by providing routines that may be useful to the community, to improve and get a more concistent looking of the StatusBar. :D

Here are two more resources to the StatusBar at: viewtopic.php?p=40634#p40634

I hope you enjoy it ! :D

@ Dr. Claudio,

I have two frustrations in this my last example: (These I already solved, not more fustrations around)
  1. I can not make trimming in other fonts. I only handle with monospaced fonts.
    (This I already solved)
    Is there any other way to do it ? I saw something like Add a ToolstripLabel to the StatusStrip (but I do not know how to do it... :oops:
     
  2. When at ON SIZE event, I can not make My_SetStatusBarSize properly.
    (This I also already solved)
    I believe this is happening probably due to this event calls the FIXED internal routine of:

    For i := 2 To HMG_LEN (anWidths) :cry:

    Probably at our library, this could be fixed ?
All of us will appreciate once again your efforts, knowledges and a helping hand... :P
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Align text to Center in StatusBar

Post by serge_girard »

Pablo,

I know it is an indication; your suggestions of improvements are great!

Serge
There's nothing you can do that can't be done...
Post Reply