X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/39bc0347fda3505f7fb43447f21efd84b9e00b3c..1975440bf70ce99b0b27b496f110224fff0efdb8:/src/motif/stattext.cpp?ds=sidebyside diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index fce5aaf4f0..5ddee74390 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -12,10 +12,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __VMS -#define XtDisplay XTDISPLAY -#endif - #if wxUSE_STATTEXT #include "wx/stattext.h" @@ -42,6 +38,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, if( !CreateControl( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; + m_labelWidget = (WXWidget) 0; + PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); @@ -49,7 +47,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style ); m_labelWidget = - XtVaCreateManagedWidget (wxConstCast(name.mb_str(), char), + XtVaCreateManagedWidget (name.mb_str(), xmLabelWidgetClass, borderWidget ? borderWidget : parentWidget, wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)), @@ -61,12 +59,15 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, m_mainWidget = borderWidget ? borderWidget : m_labelWidget; - AttachWidget (parent, m_mainWidget, (WXWidget) NULL, - pos.x, pos.y, size.x, size.y); + SetLabel(label); - ChangeBackgroundColour (); + wxSize best = GetBestSize(); + if( size.x != -1 ) best.x = size.x; + if( size.y != -1 ) best.y = size.y; - SetLabel(label); + PostCreation(); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, + pos.x, pos.y, best.x, best.y); return true; } @@ -108,4 +109,12 @@ void wxStaticText::DoSetLabel(const wxString& str) dynamic ellipsizing of the label */ +wxSize wxStaticText::DoGetBestSize() const +{ + int w, h; + GetTextExtent(GetLabelText(), &w, &h, NULL, NULL, NULL); + + return wxSize(w, h); +} + #endif // wxUSE_STATTEXT