Formatting a wxTextCtrl

78 views
Skip to first unread message

Matthew Kettlewell

unread,
Nov 7, 2004, 12:21:27 AM11/7/04
to wx-u...@lists.wxwidgets.org

All,

wxGTK: 2.5.3
OS: Fedora Core 2 Linux

This is probably silly, but I can't seem to get a text box to display all
of the defaults
(neither is the text sample though on my system).

Im trying to get something like the following, in a horizontally centered
manner:

StaticText: [Text Control Message]


but what I get is (notice the end of the text is missing):

StaticText: [Text Con]


The relevant snippet of code is:

wxBoxSizer* myTestSizer = new wxBoxSizer (wxHORIZONTAL);
wxBoxSizer* myMainSizer = new wxBoxSizer( wxVERTICAL );

myTestSizer = new wxBoxSizer (wxHORIZONTAL);
myTestSizer->Add(new wxStaticText(this, wxID_ANY, _T("Static Text:
")),0);
myTestSizer->Add(new wxTextCtrl(this, wxID_ANY, _T("Variable Input
Text")), 0 );
myMainSizer->Add(myTestSizer);


I've tried various runs of proportion and flag settings (wxGROW,
wxALIGN_CENTER, etc,)
but I don't seem to get it right.

So either I'm really not understanding the sizer concept, or I'm not
reading the textCtrl correctly.

Either way, I'm not getting a pretty picture.

Any help would be considered a kind gesture,


Thanks,
Matt


Robin Dunn

unread,
Nov 8, 2004, 3:28:44 PM11/8/04
to wx-u...@lists.wxwidgets.org
Matthew Kettlewell wrote:
>
> All,
>
> wxGTK: 2.5.3
> OS: Fedora Core 2 Linux
>
> This is probably silly, but I can't seem to get a text box to display
> all of the defaults
> (neither is the text sample though on my system).
>
> Im trying to get something like the following, in a horizontally
> centered manner:
>
> StaticText: [Text Control Message]
>
>
> but what I get is (notice the end of the text is missing):
>
> StaticText: [Text Con]
>
>
> The relevant snippet of code is:
>
> wxBoxSizer* myTestSizer = new wxBoxSizer (wxHORIZONTAL);
> wxBoxSizer* myMainSizer = new wxBoxSizer( wxVERTICAL );
>
> myTestSizer = new wxBoxSizer (wxHORIZONTAL);
> myTestSizer->Add(new wxStaticText(this, wxID_ANY, _T("Static Text:
> ")),0);
> myTestSizer->Add(new wxTextCtrl(this, wxID_ANY, _T("Variable Input
> Text")), 0 );
> myMainSizer->Add(myTestSizer);
>
>
> I've tried various runs of proportion and flag settings (wxGROW,
> wxALIGN_CENTER, etc,)
> but I don't seem to get it right.


The textctrl is being sized according to it's DoGetBestSize method, and
since they are scrollable the DoGetBestSize for textctrl's just returns
a fixed width. Using wxGROW will cause it to expand to fill the space
given to the sizer, alhtough for a box sizer it is only in the sizer's
alternate dimension so in this case that will be vertically. (Use the
proportion parameter for box sizers to get the items to grow in the
primary dimension.) But in your case the ultimate problem is that the
horizontal box sizer will never size its items beyond their minimal size
because the vertical box sizer will never allow it to. You need to add
the myTestSizer to the main sizer with a wxGROW flag too.


--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


Robin Dunn

unread,
Nov 8, 2004, 3:28:44 PM11/8/04
to wx-u...@lists.wxwidgets.org
Matthew Kettlewell wrote:
>
> All,
>
> wxGTK: 2.5.3
> OS: Fedora Core 2 Linux
>
> This is probably silly, but I can't seem to get a text box to display
> all of the defaults
> (neither is the text sample though on my system).
>
> Im trying to get something like the following, in a horizontally
> centered manner:
>
> StaticText: [Text Control Message]
>
>
> but what I get is (notice the end of the text is missing):
>
> StaticText: [Text Con]
>
>
> The relevant snippet of code is:
>
> wxBoxSizer* myTestSizer = new wxBoxSizer (wxHORIZONTAL);
> wxBoxSizer* myMainSizer = new wxBoxSizer( wxVERTICAL );
>
> myTestSizer = new wxBoxSizer (wxHORIZONTAL);
> myTestSizer->Add(new wxStaticText(this, wxID_ANY, _T("Static Text:
> ")),0);
> myTestSizer->Add(new wxTextCtrl(this, wxID_ANY, _T("Variable Input
> Text")), 0 );
> myMainSizer->Add(myTestSizer);
>
>
> I've tried various runs of proportion and flag settings (wxGROW,
> wxALIGN_CENTER, etc,)
> but I don't seem to get it right.
Reply all
Reply to author
Forward
0 new messages