X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e71aec80fd2c0d55067dd726ad1abbf5c102e168..e8fd252ef87d8ff6409d405218ff02c91b980e0a:/src/gtk/button.cpp diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 2ce3e1d0a1..5255a240ff 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -105,8 +105,6 @@ wxgtk_button_style_set_callback(GtkWidget* widget, GtkStyle*, wxButton* win) // wxButton //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) - bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString &label, @@ -264,19 +262,35 @@ void wxButton::SetLabel( const wxString &lbl ) GTKApplyWidgetStyle( false ); } -bool wxButton::Enable( bool enable ) +#if wxUSE_MARKUP +bool wxButton::DoSetLabelMarkup(const wxString& markup) { - bool isEnabled = IsEnabled(); + wxCHECK_MSG( m_widget != NULL, false, "invalid button" ); - if ( !wxControl::Enable( enable ) ) + const wxString stripped = RemoveMarkup(markup); + if ( stripped.empty() && !markup.empty() ) + return false; + + wxControl::SetLabel(stripped); + + GtkLabel * const label = GTKGetLabel(); + wxCHECK_MSG( label, false, "no label in this button?" ); + + GTKSetLabelWithMarkupForLabel(label, markup); + + return true; +} +#endif // wxUSE_MARKUP + +bool wxButton::Enable( bool enable ) +{ + if (!base_type::Enable(enable)) return false; gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable); - if (!isEnabled && enable) - { + if (enable) GTKFixSensitivity(); - } GTKUpdateBitmap(); @@ -288,6 +302,25 @@ GdkWindow *wxButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const return GTK_BUTTON(m_widget)->event_window; } +GtkLabel *wxButton::GTKGetLabel() const +{ + GtkWidget *child = GTK_BIN(m_widget)->child; + if ( GTK_IS_ALIGNMENT(child) ) + { + GtkWidget *box = GTK_BIN(child)->child; + for (GList* item = GTK_BOX(box)->children; item; item = item->next) + { + GtkBoxChild* boxChild = static_cast(item->data); + if ( GTK_IS_LABEL(boxChild->widget) ) + return GTK_LABEL(boxChild->widget); + } + + return NULL; + } + + return GTK_LABEL(child); +} + void wxButton::DoApplyWidgetStyle(GtkRcStyle *style) { gtk_widget_modify_style(m_widget, style); @@ -668,6 +701,7 @@ void wxButton::DoSetBitmapPosition(wxDirection dir) } gtk_button_set_image_position(GTK_BUTTON(m_widget), gtkpos); + InvalidateBestSize(); } #endif // GTK+ 2.10+ }