about sizer

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
happywilma
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Nov 17, 2011 3:30 am

about sizer

Post by happywilma »

5 (2).jpg
5 (2).jpg (19.48 KiB) Viewed 1831 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!
DerKleineNik
Knows some wx things
Knows some wx things
Posts: 29
Joined: Fri Sep 09, 2011 9:59 am

Re: about sizer

Post 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.
happywilma
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Nov 17, 2011 3:30 am

Re: about sizer

Post 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 1817 times
but when I cliked the maximize button, the distance didn't change , like this:
12.jpg
12.jpg (15.59 KiB) Viewed 1817 times
I want to make the distance changed with the whole panel size changing, what can I do?
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: about sizer

Post 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
Use the source, Luke!
happywilma
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Nov 17, 2011 3:30 am

Re: about sizer

Post by happywilma »

Thank you very much, I learned a lot .
Post Reply