sizer won't expand buttons [solved]

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
Tony0945
Experienced Solver
Experienced Solver
Posts: 96
Joined: Wed Oct 21, 2009 4:02 pm

sizer won't expand buttons [solved]

Post by Tony0945 » Sat Oct 17, 2015 8:38 pm

I have a Frame with six buttons on the left and a picture on the right. It looks correct when first launched but when maximized, all the buttons and the picture stay the same size.

Code: Select all

	
	////GUI Items Creation End

    wxBoxSizer *WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
	WxBoxSizer1->Add(RecordingsListButton,1);
    WxBoxSizer1->Add(ProgramGuideButton,1);
	WxBoxSizer1->Add(ScheduleRecordingsButton,1);
	WxBoxSizer1->Add(SearchButton,1);
	WxBoxSizer1->Add(SetupButton,1);
	WxBoxSizer1->SetSizeHints(this);
	
	wxBoxSizer *WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
	WxBoxSizer2->Add(WxBoxSizer1,1);
	WxBoxSizer2->Add(Picture,1);
	WxBoxSizer2->SetSizeHints(this);
Shouldn't the buttons and the picture expand? What am I doing wrong?
Last edited by Tony0945 on Mon Oct 19, 2015 8:26 pm, edited 1 time in total.

Manolo
Can't get richer than this
Can't get richer than this
Posts: 709
Joined: Mon Apr 30, 2012 11:07 pm

Re: sizer won't expand buttons

Post by Manolo » Sun Oct 18, 2015 12:01 am

Your adding a wxWindow (yeah, a wxButton is a wxWindow) with proportion=1, which is used to calculate how much of available space is given to your button.
But you are NOT defining any flag (wxTOP, wxLEFT, wxALL, etc). So the default value (=0) is used. With this value, the sizer can not determine in which direction the button should grow.
Read wxSizer::Add docs: http://docs.wxwidgets.org/trunk/classwx ... 3faa54840d

User avatar
7_of_9
Earned a small fee
Earned a small fee
Posts: 13
Joined: Fri Oct 16, 2015 9:56 am

Re: sizer won't expand buttons

Post by 7_of_9 » Mon Oct 19, 2015 10:16 am

try the following:

Code: Select all

wxBoxSizer *WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer ->Add(RecordingsListButton, 0 ,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
wxBoxSizer ->Add(ProgramGuideButton, 0 ,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
wxBoxSizer ->Add(ScheduleRecordingsButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL ,5);
wxBoxSizer ->Add(SearchButton, 10, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
wxBoxSizer ->Add(SetupButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
wxBoxSizer ->SetSizeHints(this);

Tony0945
Experienced Solver
Experienced Solver
Posts: 96
Joined: Wed Oct 21, 2009 4:02 pm

Re: sizer won't expand buttons

Post by Tony0945 » Mon Oct 19, 2015 2:57 pm

Thank you Gentlemen. Changing proportion to 1 from 0 and adding wxALL to the flags did not change anything. Making the proportions uneven was worse. Commenting out the whole code section had no effect either.

User avatar
doublemax
Moderator
Moderator
Posts: 14509
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: sizer won't expand buttons

Post by doublemax » Mon Oct 19, 2015 3:14 pm

You'll definitely need a wxEXPAND flag somewhere. Please provide compilable code (something that can be pasted directly into the "minimal" sample and that compiles out of the box) and maybe a screenshot.
Use the source, Luke!

Post Reply