Hi!
Essentially, one does not actually hard code in sizes, minimum or otherwise,
at the time child elements are created. This would make it difficult to
retain a reasonable look and feel as one moves from platform to platform.
wxSizer::Add
wxSizerItem* Add(wxWindow* window, int proportion = 0,int flag = 0, int
border = 0, wxObject* userData = NULL)
...
proportion
Although the meaning of this parameter is undefined in wxSizer, it is used
in wxBoxSizer to indicate if a child of a sizer can change its size in the
main orientation of the wxBoxSizer - where 0 stands for not changeable and a
value of more than zero is interpreted relative to the value of other
children of the same wxBoxSizer. For example, you might have a horizontal
wxBoxSizer with three children, two of which are supposed to change their
size with the sizer. Then the two stretchable windows would get a value of 1
each to make them grow and shrink equally with the sizer's horizontal
dimension.
<<<<<
To have your separate wxTextCtrl's take on relative sizes, you would use the
proportion argument. As far as "How do I tell a wxTextCtrl how much text
it's supposed to hold... ", that's rather like "How big is big" or "How
small is small", i.e., it's a subjective call. In this case, the subject is
a wxTextCtrl. Because individual platforms have different dimensions for
things like frames and dialogs, client space varies. Because an individual
user may specify a font and size, how much text they'll see or the
wxTextCtrl will hold, the amount of text the wxTextCtrl is "supposed to
hold" will vary.
In my projects, I decide on a 'pleasing' layout and assign proportions to
each element which give the basic layout I would like to have, uniformly
across platforms. If, let's say, I have a particular element, a wxTextCtrl,
which I would like to have a uniform number of columns and rows, I set this
value dynamically in the code immediately following the creation of all
elements. I do this by checking the current font which will be used, and
sometimes I also need to check the client area size and/or display size,
using this information to determine a 'minimal' size that will suit.
You may find this tutorial, "A Simple Editor: Sizers Tutorial", helpful. It
uses only one size, the initial dimensions of the top level frame. All other
sizes are governed by sizers and proportions. You can get a copy of the
tutorial (pdf, html, and chm) along with a copy of the project code from:
http://wxcodex.net/
In the green menu at the top left, enter "Sizers Tutorial" in the search
box, check the box next to Title (immediately below the search box), and
click the 'Go' button at the bottom of the same green menu. From the
pulldown next to the titles, select 'dnld' for each type of tutorial/code
packages you wish. When you're done selecting which packages you would like
to download, click the 'Download Selections' button in the floating main
tool bar. Then just click on each link you've selected to download it!;)
HTH:
thx,
Dave S.
Development with wxWidgets on MSWindows
http://tech.groups.yahoo.com/group/wxMS_developers/
wxWidgets Code Exchange
http://wxcodex.net/
----- Original Message -----
From: "David Björkevik" <***@bjorkevik.se>
To: <wx-***@lists.wxwidgets.org>
Sent: Friday, May 08, 2009 3:56 AM
Subject: wxTextCtrl in sized dialogs
Post by David BjörkevikHi list,
How do I tell a wxTextCtrl how much text it's supposed to hold, so that
it reports a decent best size to the sizer that manages it?
At the moment, all of my wxTextCtrls become equally sized, holding
roughly 8 digits (in wxGTK).
Regards,
David
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users