X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7074ce3577987748739169a9475ffdc0f9873595..258bcbfbd3b519d2498c6f0218ee938181170900:/src/gtk1/control.cpp diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index c12735e39b..06eaec261b 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -33,7 +33,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow) wxControl::wxControl() { m_needParent = TRUE; - m_createComplete = false; } bool wxControl::Create( wxWindow *parent, @@ -44,7 +43,6 @@ 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,14 +66,7 @@ void wxControl::SetLabel( const wxString &label ) } m_label << *pc; } -} - -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); + InvalidateBestSize(); } wxString wxControl::GetLabel() const @@ -95,7 +86,9 @@ wxSize wxControl::DoGetBestSize() const (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) (m_widget, &req ); - return wxSize(req.width, req.height); + wxSize best(req.width, req.height); + CacheBestSize(best); + return best; } @@ -110,10 +103,8 @@ void wxControl::PostCreation(const wxSize& size) // GetBestSize is called. gtk_widget_ensure_style(m_widget); - InheritAttributes(); ApplyWidgetStyle(); SetInitialBestSize(size); - m_createComplete = true; } @@ -212,7 +203,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, if ( style && style->font_desc ) { wxNativeFontInfo info; - info.description = style->font_desc; + info.description = pango_font_description_copy(style->font_desc); attr.font = wxFont(info); } else @@ -245,9 +236,12 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(void), int state) { wxVisualAttributes attr; + // NB: we need toplevel window so that GTK+ can find the right style + GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* widget = widget_new(); + gtk_container_add(GTK_CONTAINER(wnd), widget); attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state); - gtk_widget_destroy(widget); + gtk_widget_destroy(wnd); return attr; } @@ -258,9 +252,12 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(const gcha int state) { wxVisualAttributes attr; + // NB: we need toplevel window so that GTK+ can find the right style + GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* widget = widget_new(""); + gtk_container_add(GTK_CONTAINER(wnd), widget); attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state); - gtk_widget_destroy(widget); + gtk_widget_destroy(wnd); return attr; } @@ -272,9 +269,12 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustm int state) { wxVisualAttributes attr; + // NB: we need toplevel window so that GTK+ can find the right style + GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* widget = widget_new(NULL); + gtk_container_add(GTK_CONTAINER(wnd), widget); attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state); - gtk_widget_destroy(widget); + gtk_widget_destroy(wnd); return attr; }