wxGTK: Another layout problem
Tommy W
tommy at svearike.sytes.net
Fri Aug 4 14:33:45 PDT 2006
So this is ANOTHER (new) question.
I have 1 panel and 2 spinctrls/stattext in this layout
________
| panel |
|_______|
|___|___| <-- 2 spin ctrls/stattext
What I want to do is make the panel expand and become as large as possible.
I make the layout happen using wxFlexGridSizer
topSizer and controlSizer
topSizer har growable row/col (0)
worth mentioning is that all this is bundled together in a wxControl which I
call ClockCtrl, which is in it's turn placed in a
wxBoxSizer->Add(clockCtrl,0,wxEXPAND);
the clockctrl has green background so that I can actually see that all the
space I want to be used IS used. and it is.
The PROBLEM is that the PANEL in the clockctrl (mentioned above) is NOT
expanded to become as large as possible..
I get a layout like this instead
________
| panel |
|_______|
|___|___| <-- 2 spinctrls/stattext
| |
|_______| <-- empty space (green, this is actually part of the ClockCtrl)
... what the heck am I doing wrong?
this is the code for the ClockCtrl
ClockCtrl::ClockCtrl(wxWindow *parent, wxWindowID id, const wxDateTime
&d,const wxPoint &pos, const wxSize &size, long style):
wxControl(parent,id,pos,size,style,wxDefaultValidator,(const wxString &)
"ClockCtrl")
{
SetBackgroundColour(*wxGREEN);
wxFlexGridSizer *topSizer = new wxFlexGridSizer(0,1,0,0);
topSizer->AddGrowableRow(0);
topSizer->AddGrowableCol(0);
clockPanel = new ClockPanel(this,1,wxDefaultPosition,wxDefaultSize);
clockPanel->SetMinSize(wxSize(50,50));
topSizer->Add(clockPanel,1,wxALIGN_CENTER);
wxFlexGridSizer *controlSizer = new wxFlexGridSizer(2,2,0,0);
topSizer->Add(controlSizer,0);
wxStaticText *hourText = new wxStaticText(this,wxID_ANY,_("Hour"));
controlSizer->Add(hourText,1,wxEXPAND|wxGROW|wxALIGN_BOTTOM|wxALIGN_LEFT);
wxSpinCtrl *spinHour = new
wxSpinCtrl(this,4,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxSP_WRAP,0,23,clockPanel->GetTime().GetHour());
spinHour->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED,
wxSpinEventHandler(ClockCtrl::OnSpin), NULL,this);
controlSizer->Add(spinHour,0);
wxStaticText *minuteText = new wxStaticText(this,wxID_ANY,_("Minute"));
controlSizer->Add(minuteText,1,wxEXPAND|wxALIGN_BOTTOM|wxALIGN_LEFT);
wxSpinCtrl *spinMinute = new
wxSpinCtrl(this,5,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxSP_WRAP,0,59,clockPanel->GetTime().GetMinute());
spinMinute->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED,
wxSpinEventHandler(ClockCtrl::OnSpin), NULL,this);
controlSizer->Add(spinMinute,0,wxALIGN_CENTER_VERTICAL);
SetSizer(topSizer);
topSizer->Fit(this);
topSizer->Layout();
topSizer->SetSizeHints(this);
Layout();
}
More information about the wx-users
mailing list