Text in a StatusBar aligned left/right/center

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
lola
In need of some credit
In need of some credit
Posts: 3
Joined: Thu Jul 28, 2005 7:30 pm

Text in a StatusBar aligned left/right/center

Post by lola » Tue Aug 16, 2005 6:47 pm

Hi,

I am creating a status bar with 2 fields. The text in one field should be right-aligned, and the text in the second field should be left-aligned. Is there a way to achieve this?

I create my StatusBar like this:

Code: Select all

int widths[2] = { -1, -1 };
stat = new wxStatusBar (parent, -1);
stat->SetFieldsCount (2);
stat->SetStatusWidths (2, widths);
Please help! How can I align my text??

Thanks a lot!

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Tue Aug 16, 2005 7:22 pm

I know of no way to change the alignment with the standard wxStatusBar. You'll probably need to derive a new class from wxStatusBar. In the OnSize for this new class use GetFieldRect to position and size a left/right/center aligned wxStaticText (and remember to Skip() the event). Create a new function to set the text of this wxStaticText. Finally, override your frame's OnCreateStatus bar to return a pointer of an instances of this new status bar class. It may be possible to do this in a way that keeps SetStatusText() working but you'd probably have to do some wxStatusBar dissection/code analysis to see how it all works.

I'm sure the status bar sample can fill in any details I left out.

Post Reply