X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9d522606d0a1dfd22bcdc1a386b3dca01fa985e3..03d51a2d4095e3a2da174f8d6963c4802e636e95:/src/gtk/control.cpp?ds=sidebyside diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index dfbfe4b9c0..e638c35d8d 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -92,6 +92,14 @@ 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); @@ -259,6 +267,21 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustm return attr; } +void wxControl::ApplyWidgetStyle() +{ + GtkRcStyle *style = CreateWidgetStyle(); + if ( style ) + { + DoApplyWidgetStyle(style); + gtk_rc_style_unref(style); + } +} + +void wxControl::DoApplyWidgetStyle(GtkRcStyle *style) +{ + gtk_widget_modify_style(m_widget, style); +} + #endif // wxUSE_CONTROLS