X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8e24dfa9322702d56a125586a7d4a37f4a5dfd7..86b79b93fbbb0c2e90e6595f7fea0f979b80881c:/src/gtk/button.cpp diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 68e6eb5346..177356a071 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -149,13 +149,16 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, SetSize( new_size ); - Show( TRUE ); - return TRUE; } void wxButton::SetDefault() { + wxWindow *parent = GetParent(); + wxCHECK_RET( parent, _T("button without parent?") ); + + wxWindow *winOldDefault = parent->SetDefaultItem(this); + GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); gtk_widget_grab_default( m_widget ); @@ -210,8 +213,29 @@ void wxButton::ApplyWidgetStyle() wxSize wxButton::DoGetBestSize() const { + // the default button in wxGTK is bigger than the other ones because of an + // extra border around it, but we don't want to take it into account in + // our size calculations (otherwsie the result is visually ugly), so + // always return the size of non default button from here + const bool isDefault = GTK_WIDGET_HAS_DEFAULT(m_widget); + if ( isDefault ) + { + // temporarily unset default flag + GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_DEFAULT ); + } + wxSize ret( wxControl::DoGetBestSize() ); + if ( isDefault ) + { + // set it back again + GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); + } + +#ifndef __WXGTK20__ + ret.x += 10; // add a few pixels for sloppy (but common) themes +#endif + if (!HasFlag(wxBU_EXACTFIT)) { if (ret.x < 80) ret.x = 80;