Sizer help (min sizes, proportionality, and window resizing)
Harvey Chapman
hchapman-wx-users at 3gfp.com
Wed May 7 07:15:29 PDT 2008
Hello,
I'm trying to create a header of sorts at the top of a window using a
horizontal box sizer. I want something like this:
Left Label <expandable space> Center Label <expandable space> Right
Label
I can create that, but when a user resizes the window small enough the
labels all start to overlap each other than just disappear off-screen
as I would desire (and would happen if I used fixed sizes for the
spaces with no proportionality).
So:
How can I have both proportionality and minimum sizes? Do I have to
always set the minimum sizes myself?
Below, I've included code (generated by wxDesigner) that illustrates
the problem (parent is an empty wxFrame). Worth noting is the fact
that the text control does n fact limit the minimum size of the
window(frame).
Thank you,
Harvey
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, _("Some
Longer Text Indeed"), wxDefaultPosition, wxSize(160,10), 0 );
item1->Add( item2, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
item1->Add( 25, 20, 1, wxALIGN_CENTER|wxALL, 5 );
wxStaticText *item3 = new wxStaticText( parent, ID_TEXT, _("Some
Longer Text Indeed"), wxDefaultPosition, wxDefaultSize, 0 );
item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
item1->Add( 20, 20, 1, wxALIGN_CENTER|wxALL, 5 );
wxStaticText *item4 = new wxStaticText( parent, ID_TEXT, _("Some
Longer Text Indeed"), wxDefaultPosition, wxDefaultSize, 0 );
item1->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxTextCtrl *item5 = new wxTextCtrl( parent, ID_TEXTCTRL, wxT(""),
wxDefaultPosition, wxSize(400,200), wxTE_MULTILINE );
item0->Add( item5, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
if (set_sizer)
{
parent->SetSizer( item0 );
if (call_fit)
item0->SetSizeHints( parent );
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
Url : http://lists.wxwidgets.org/pipermail/wx-users/attachments/20080507/4cfc5ecb/PGP.pgp
More information about the wx-users
mailing list