X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9d522606d0a1dfd22bcdc1a386b3dca01fa985e3..82baa5e4f1992b701e183544c935bcb424503f5b:/src/gtk/control.cpp?ds=inline diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index dfbfe4b9c0..c12735e39b 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -33,6 +33,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow) wxControl::wxControl() { m_needParent = TRUE; + m_createComplete = false; } bool wxControl::Create( wxWindow *parent, @@ -43,6 +44,7 @@ bool wxControl::Create( wxWindow *parent, const wxValidator& validator, const wxString &name ) { + m_createComplete = false; bool ret = wxWindow::Create(parent, id, pos, size, style, name); #if wxUSE_VALIDATORS @@ -68,6 +70,14 @@ void wxControl::SetLabel( const wxString &label ) } } +void wxControl::PostSetLabel() +{ + // make sure the widget has been created, and that PostCreate has already + // been called + if (m_widget && m_createComplete && GetAdjustMinSizeFlag()) + SetBestSize(wxDefaultSize); +} + wxString wxControl::GetLabel() const { return m_label; @@ -92,9 +102,18 @@ wxSize wxControl::DoGetBestSize() const void wxControl::PostCreation(const wxSize& size) { wxWindow::PostCreation(); + + // NB: GetBestSize needs to know the style, otherwise it will assume + // default font and if the user uses a different font, determined + // best size will be different (typically, smaller) than the desired + // size. This call ensure that a style is available at the time + // GetBestSize is called. + gtk_widget_ensure_style(m_widget); + InheritAttributes(); ApplyWidgetStyle(); SetInitialBestSize(size); + m_createComplete = true; } @@ -259,6 +278,5 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustm return attr; } - #endif // wxUSE_CONTROLS