X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4dcaf11a7b5189be78e52e1412febd7689a959f8..2e1a688e3e9c6c265620e4f05d579077367e9fdb:/src/gtk1/button.cpp?ds=sidebyside diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index dc7dd01c59..39d94b37b1 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -78,7 +78,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { - wxFAIL_MSG( _T("wxButton creation failed") ); + wxFAIL_MSG( wxT("wxButton creation failed") ); return FALSE; } @@ -92,9 +92,22 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, SetLabel(label); + int x = 0; int y = 0; + wxFont new_font( parent->GetFont() ); + GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font ); + wxSize newSize = size; - if (newSize.x == -1) newSize.x = 15+gdk_string_measure( m_widget->style->font, label.mbc_str() ); - if (newSize.y == -1) newSize.y = 26; + if (newSize.x == -1) + { + newSize.x = 12+x; + if (newSize.x < 80) newSize.x = 80; + } + if (newSize.y == -1) + { + newSize.y = 11+y; + if (newSize.x < 26) newSize.x = 26; + } + SetSize( newSize.x, newSize.y ); gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", @@ -129,7 +142,7 @@ wxSize wxButton::GetDefaultSize() void wxButton::SetLabel( const wxString &label ) { - wxCHECK_RET( m_widget != NULL, _T("invalid button") ); + wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); wxControl::SetLabel( label );