Discussion:
wxFlexGridSizer question
Robert Dailey
2009-08-25 15:59:29 UTC
Permalink
Hello,

I have a 2x3 flex grid sizer and I'm setting elements in the second
column to "wxEXPAND" and "wxALIGN_CENTER_VERTICAL", however, they only
align vertically when I do not have wxEXPAND set. But if I omit
wxEXPAND, they will not stretch across the available horizontal length
of the window.

How can I get both to work properly? How does the proportion of child
widgets in the flex grid sizer affect the behavior of the sizer?
--~--~---------~--~----~------------~-------~--~----~
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
-~----------~----~----~----~------~----~------~--~---
Vadim Zeitlin
2009-08-25 16:55:42 UTC
Permalink
On Tue, 25 Aug 2009 08:59:29 -0700 (PDT) Robert Dailey <***@gmail.com> wrote:

RD> I have a 2x3 flex grid sizer and I'm setting elements in the second
RD> column to "wxEXPAND" and "wxALIGN_CENTER_VERTICAL", however, they only
RD> align vertically when I do not have wxEXPAND set. But if I omit
RD> wxEXPAND, they will not stretch across the available horizontal length
RD> of the window.
RD>
RD> How can I get both to work properly? How does the proportion of child
RD> widgets in the flex grid sizer affect the behavior of the sizer?

It doesn't, proportion is only used for 1D sizers. For 2D ones wxEXPAND
works in both directions so if you need to align it vertically you should
put your real window inside a vertical box sizer with stretchable spacers
before and after it and then add this sizer to the grid sizer.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Robert Dailey
2009-08-25 17:16:15 UTC
Permalink
I don't understand what you mean. Stretchable spacers? I'm trying to
get a column to stretch horizontally, so I'm assuming you meant a
horizontal sizer? Could you explain in detail what role the spacers
play in this? I'm still pretty new to sizers. I understand the basics,
but advanced setups like this need some explaining :)

I've always been a little confused about something that might have
something to do with understanding your suggestion. When I create a
horizontal box sizer and place 2 buttons in it. I set the left button
to 0 proportion, and no expand. This places the button at its original
size to the left, this is what I expect. I then set the right button's
proportion to 1 and no expand. This makes it stretch left/right fully
but the height of that widget is not changed.

I have trouble understanding how proportion and wxEXPAND work together
in a vertical sizer.

Thank you.
Post by Vadim Zeitlin
RD> I have a 2x3 flex grid sizer and I'm setting elements in the second
RD> column to "wxEXPAND" and "wxALIGN_CENTER_VERTICAL", however, they only
RD> align vertically when I do not have wxEXPAND set. But if I omit
RD> wxEXPAND, they will not stretch across the available horizontal length
RD> of the window.
RD>
RD> How can I get both to work properly? How does the proportion of child
RD> widgets in the flex grid sizer affect the behavior of the sizer?
 It doesn't, proportion is only used for 1D sizers. For 2D ones wxEXPAND
works in both directions so if you need to align it vertically you should
put your real window inside a vertical box sizer with stretchable spacers
before and after it and then add this sizer to the grid sizer.
 Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/
 application_pgp-signature_part
< 1KViewDownload
--~--~---------~--~----~------------~-------~--~----~
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
-~----------~----~----~----~------~----~------~--~---
Vadim Zeitlin
2009-08-25 17:22:59 UTC
Permalink
On Tue, 25 Aug 2009 10:16:15 -0700 (PDT) Robert Dailey <***@gmail.com> wrote:

RD> I don't understand what you mean. Stretchable spacers? I'm trying to
RD> get a column to stretch horizontally, so I'm assuming you meant a
RD> horizontal sizer? Could you explain in detail what role the spacers
RD> play in this? I'm still pretty new to sizers. I understand the basics,
RD> but advanced setups like this need some explaining :)

If you have a vertical sizer like this:

+--------+
| Spacer |
+--------+
| Window |
+--------+
| Spacer |
+--------+

and you give a proportion of 1 to 2 spacers (i.e. make them stretchable,
see also wxSizer::AddStretchSpacer()) then you window will be vertically
centered inside it. Now all you have to do is to add the entire sizer drawn
above to your grid sizer with wxEXPAND.

RD> I have trouble understanding how proportion and wxEXPAND work together
RD> in a vertical sizer.

In a vertical sizer proportion determines the behaviour in the vertical
direction and wxEXPAND or wxALIGN_LEFT/RIGHT/CENTRE what happens in the
horizontal one.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Dave Silvia
2009-08-25 18:37:25 UTC
Permalink
Hi!

A firm understanding of what a sizer will do and when is essential to
wxWidgets design, as I'm sure you've noticed. I seldom use sizers within
grid sizers, especially wxFlexGridSizer and wxGridBagSizer, since a
judicious selection for grid sizer type usually fits the bill.

There is a basic tutorial for sizers illustrating how they work and 'free'
the designer/developer from hard coding size and position. It is called:

A Simple Editor: Sizers Tutorial

You may obtain it from:

http://www.wxCodex.net

Simply select the Tutorial radio button, enter Sizers into the search text
input and check the Title box, and click the Go button (all of these are in
the green floating menu on the far upper left on the web page).

Once there, just pick the tutorial format you prefer, i.e., html, chm, pdf,
and pick the project files downloads (complete code for the tutorial,
although, being a tutorial, it works much better if you use these for
reference and actually construct your own project from the tutorial
document!;).

I find it easier to grasp a topic like sizers with a concrete illustration
in the form of a project in front of me (picture worth a thousand words and
all that!;)

HTH:

Dave S.

Development with wxWidgets on MSWindows
http://tech.groups.yahoo.com/group/wxMS_developers/

wxWidgets Code Exchange
http://www.wxcodex.net/

BTW, my experience has been that one may most frequently use a simple
wxGridSizer, rather than the slightly more complicated flex and grab bag
types. These each introduce 'other' resizing concepts that are not exactly
the same as wxSizer concepts, i.e., in wxFlexGridSizer, you have the concept
of 'growable' columns and rows.


----- Original Message -----
From: "Robert Dailey" <***@gmail.com>
To: "wx-users" <wx-***@googlegroups.com>
Sent: Tuesday, August 25, 2009 12:16 PM
Subject: Re: wxFlexGridSizer question



I don't understand what you mean. Stretchable spacers? I'm trying to
get a column to stretch horizontally, so I'm assuming you meant a
horizontal sizer? Could you explain in detail what role the spacers
play in this? I'm still pretty new to sizers. I understand the basics,
but advanced setups like this need some explaining :)

I've always been a little confused about something that might have
something to do with understanding your suggestion. When I create a
horizontal box sizer and place 2 buttons in it. I set the left button
to 0 proportion, and no expand. This places the button at its original
size to the left, this is what I expect. I then set the right button's
proportion to 1 and no expand. This makes it stretch left/right fully
but the height of that widget is not changed.

I have trouble understanding how proportion and wxEXPAND work together
in a vertical sizer.

Thank you.
Post by Vadim Zeitlin
On Tue, 25 Aug 2009 08:59:29 -0700 (PDT) Robert Dailey
RD> I have a 2x3 flex grid sizer and I'm setting elements in the second
RD> column to "wxEXPAND" and "wxALIGN_CENTER_VERTICAL", however, they only
RD> align vertically when I do not have wxEXPAND set. But if I omit
RD> wxEXPAND, they will not stretch across the available horizontal length
RD> of the window.
RD>
RD> How can I get both to work properly? How does the proportion of child
RD> widgets in the flex grid sizer affect the behavior of the sizer?
It doesn't, proportion is only used for 1D sizers. For 2D ones wxEXPAND
works in both directions so if you need to align it vertically you should
put your real window inside a vertical box sizer with stretchable spacers
before and after it and then add this sizer to the grid sizer.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
application_pgp-signature_part
< 1KViewDownload
--~--~---------~--~----~------------~-------~--~----~
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
-~----------~----~----~----~------~----~------~--~---

Loading...