From 4f819fe40a8061e1226f896564d70305ac83d2ba Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 Apr 2004 14:15:15 +0000 Subject: [PATCH] fixed DoGetBestSize() for default buttons git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26550 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/button.cpp | 19 +++++++++++++++++-- src/gtk1/button.cpp | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index a3f1123908..86b455462f 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -149,8 +149,6 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, SetSize( new_size ); - Show( TRUE ); - return TRUE; } @@ -210,8 +208,25 @@ 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 diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index a3f1123908..86b455462f 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -149,8 +149,6 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, SetSize( new_size ); - Show( TRUE ); - return TRUE; } @@ -210,8 +208,25 @@ 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 -- 2.45.2