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 » Tue Nov 22, 2011 3:21 am

5 (2).jpg
5 (2).jpg (19.48 KiB) Viewed 1019 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 » Tue Nov 22, 2011 7:43 am

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 » Tue Nov 22, 2011 11:46 am

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 1005 times
but when I cliked the maximize button, the distance didn't change , like this:
12.jpg
12.jpg (15.59 KiB) Viewed 1005 times
I want to make the distance changed with the whole panel size changing, what can I do?

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

Re: about sizer

Post by doublemax » Tue Nov 22, 2011 12:06 pm

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 » Tue Nov 22, 2011 12:21 pm

Thank you very much, I learned a lot .

Post Reply