Page 1 of 1

about sizer

Posted: Tue Nov 22, 2011 3:21 am
by happywilma
5 (2).jpg
5 (2).jpg (19.48 KiB) Viewed 1010 times
I want to create a top sizer, and a left sizer and a right sizer embedded onto it , but I want that left sizer locates the leftmost and right sizer locates the rightmost ,but they are in the same line. I use wxFlexGridsizer as top_sizer and wxBoxSizer as left or right sizer ,but that's no use , how should I do?

thanks!

Re: about sizer

Posted: Tue Nov 22, 2011 7:43 am
by DerKleineNik
Hey,
Sizers always expand the most possible so if you want to have some space between them you have to fill in a spacer:

Code: Select all

SizerXY->Add( 0, 0, 1, wxEXPAND, 5 );
By that you can force the Sizer to leave an empty space between your left and your right sizer.
Hope that helped.

Re: about sizer

Posted: Tue Nov 22, 2011 11:46 am
by happywilma
I have added some spacer, like this :

Code: Select all

	int w,h;
	GetClientSize(&w,&h);
	user_sizer->Add(w*0.6,-1);
and the effect like :
11.jpg
11.jpg (13.33 KiB) Viewed 996 times
but when I cliked the maximize button, the distance didn't change , like this:
12.jpg
12.jpg (15.59 KiB) Viewed 996 times
I want to make the distance changed with the whole panel size changing, what can I do?

Re: about sizer

Posted: Tue Nov 22, 2011 12:06 pm
by doublemax
Adding a hard-coded sizer based on the window size is pretty ugly ;)
Also this is not what Nik suggested.

Use wxSizer::AddStretchSpacer instead.
http://docs.wxwidgets.org/stable/wx_wxs ... etchspacer

Re: about sizer

Posted: Tue Nov 22, 2011 12:21 pm
by happywilma
Thank you very much, I learned a lot .