Align text to Center in StatusBar
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Align text to Center in StatusBar
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:
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.
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:
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
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Align text to Center in StatusBar
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. When by ACTION we need to change it text, then worngly the item changes the style
I mean, changes from RAISED to FLAT...
See demo expressing this bug:
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 !
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. When by ACTION we need to change it text, then worngly the item changes the style
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
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
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: Align text to Center in StatusBar
Hi Pablo,Pablo César wrote:I come here to say there is a litle bug around SetStatusItemText() at c_status.c.
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 ) ;
}
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Align text to Center in StatusBar
Perfecto !
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 ?
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
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Align text to Center in StatusBar
Hi HMG DT,
I have two questions regarding StatusBar for posible enhance:
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.
If Width becomes assignable, then we can use it to fix all widths sizes.
Here we find a solution for this second case.
I have two questions regarding StatusBar for posible enhance:
- Is it posible to set text at StatusBar's items to be aligned to center ?
Like as to include at anWidths:={ LEFT, CENTER, RIGHT}
- 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:
- When just one of cell is Nil Width size.
It will take this cell for trimming. - When all Width sizes are defined.
It will take the bigger width size cell for trimming. - When all Width sizes are equally.
It will take the first cell for trimming, as ever done.
Actually we have:Please note always is taking the most left cell for trimming.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
I propose to change as follows:As you can see three options wil be considered for trimming.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
- When just one of cell is Nil Width size.
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.
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
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- 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
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.
South or North HMG is worth.
...the possibilities are endless.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Align text to Center in StatusBar
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.
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
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- 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
Thanks all for this improvement!
Serge
Serge
There's nothing you can do that can't be done...
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Align text to Center in StatusBar
Dank u Serge !serge_girard wrote:Thanks all for this improvement!
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.
Here are two more resources to the StatusBar at: viewtopic.php?p=40634#p40634
I hope you enjoy it !
@ Dr. Claudio,
I have two frustrations in this my last example: (These I already solved, not more fustrations around)
- 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...
- 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)
Probably at our library, this could be fixed ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- 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
Pablo,
I know it is an indication; your suggestions of improvements are great!
Serge
I know it is an indication; your suggestions of improvements are great!
Serge
There's nothing you can do that can't be done...