Can't determine wxStaticText size in wxMac 2.80
Alicia da Conceicao
alicia454 at gmail.com
Fri Dec 15 08:04:17 PST 2006
I use the following code to determine the rendered size of a multi-line
(split up with line-feeds [ascii=0x0A]) block of text with the desired
font size:
// ====================================================
int X, Y;
wxStaticText *MyText = new wxStaticText (MyParent, wxID_ANY,
MyStr, wxDefaultPosition, wxSize (-1, -1), wxALIGN_LEFT);
item21->SetFont (wxFont (MYFONTSIZE, wxMODERN, wxNORMAL,
wxNORMAL));
MyText->SetSize (MyText->GetBestSize());
MyText->GetSize (&X, &Y);
delete MyText;
// ====================================================
Once I know the text rendered size from (X & Y values), I then know
the mimimal width to make widgets like wxTextCtrl that can display
the multi-line text without any scrollbars. I have been using this code
for a long time on the wxMSW, wxWince, wxGTK, & wxMac ports
versions 2.6.* and 2.5.*.
However, when I upgraded to the wxMac version 2.8.0 port, I
discovered that for some reason, the values I get for the height appear
to correspond to a single line, regardless of how many lines are in the
text.
This is weird, since it worked perfectly in wxMac versions 2.6.*, and the
same code still works fine in wxMSW 2.8.0 and wxGTK 2.8.0rc1.
Any ideas on what changed for wxMac in 2.8.0 that broke the above
code? Any suggestions on a better way to get the rendered size of
multi-line text that will work on all ports of wxWidgets 2.8.0? Any
assistance is greatly appreciated.
Thank you in advance,
Alicia.
More information about the wx-users
mailing list