layout management

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
HighCommander4
Experienced Solver
Experienced Solver
Posts: 52
Joined: Wed Jul 18, 2007 3:41 am
Location: Ontario, Canada

layout management

Post by HighCommander4 » Fri Nov 23, 2007 6:43 am

Does wxWidgets have any sizer with functionality comparable to FlowLayout in Java? That is, add components (which have fixed size) left-to-right in a row until you reach the end of the row, then start a new row? In particular, it is important that when the window is resized, the layout is adjusted accordingly. (e.g. suppose my window was originally 300 pixels in width, my components were each 100 pixels and I had 5 components - it would put the first three in a row and the second two in a second row. But if I resize the window to have width 500 pixels, it now re-layouts to put all 5 components in one row. Anything of the sort?

vdell
Moderator
Moderator
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Post by vdell » Fri Nov 23, 2007 7:57 am

AFAIK, wxFlexGridSizer should be the sizer your looking for.

HTH
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere

blitzkriegten
Earned a small fee
Earned a small fee
Posts: 20
Joined: Wed Mar 28, 2007 5:55 pm
Location: Baltimore, MD
Contact:

You can get this layout using wxGridBagSizer.

Post by blitzkriegten » Wed Nov 28, 2007 8:37 pm

Hi,

You can get the layout you need using wxGridBagSizer. Assume that your wxGridBagSize as the main(Top) sizer and then add two more box Sizers with HORIZONTAL orientation. Then add the first 3 controls to the first box sizer and remaining to the next sizer. Obviously you have to add these two box sizers to your main sizer.

If not clear let me know, I will try to wirte give one example.

Regards
CG

HighCommander4
Experienced Solver
Experienced Solver
Posts: 52
Joined: Wed Jul 18, 2007 3:41 am
Location: Ontario, Canada

Post by HighCommander4 » Thu Nov 29, 2007 5:45 am

Thanks for your answer. The problem is, I don't know ahead of time how many components I have, so I don't know how many horizontal sizers I'd create and so on.

If you use Windows, try this and you'll see what I mean about how I want my components laid out: open Windows Explorer to a folder with pictures and choose 'Thumbnails' as your view. Un-maximize the window and resize it at will. Notice how there is only ever a vertical scrollbar (if necessary) and the number of columns is automatically updated to fill the width of the window.

That's the effect I'm looking for. I'm hoping that there's a way to do it automatically, without having to manually handle every window resize event and manually change the number of rows/columns in the layout.

Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: layout management

Post by Tapsa » Sat Aug 01, 2015 9:45 am

I know it's an old thread, but is this achievable?

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

Re: layout management

Post by doublemax » Sat Aug 01, 2015 10:03 am

Use the source, Luke!

Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: layout management

Post by Tapsa » Sun Aug 02, 2015 1:01 pm

Thanks, I'll keep that in mind.

Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: layout management

Post by Tapsa » Thu Aug 06, 2015 12:57 pm

I am experimenting with wxWrapSizer. The boxes do align as expected, but once a box has moved one row up, it will never descend back down, even when my window doesn't have enough space for one row. This happens with the default constructor of wxWrapSizer. I add a bunch of derived text controls and check boxes into it using proportion 1 and wxEXPAND.

How do I get items go back down?

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

Re: layout management

Post by doublemax » Thu Aug 06, 2015 1:11 pm

Can you show some code that demonstrates the problem? When checking the "wrapsizer" sample everything looks fine when making the window smaller and bigger.
Use the source, Luke!

Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: layout management

Post by Tapsa » Thu Aug 06, 2015 1:18 pm

That would be making a minimal sample then. My program is too complex around this. I can try to look up all related code pieces though. It will be few "pages" then.

Post Reply