X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/519cb848a8f4c91c73421bb75314754284e593a4..f5ba273ecd799f652736ce2bc830283787302a56:/src/mac/button.cpp?ds=sidebyside diff --git a/src/mac/button.cpp b/src/mac/button.cpp index cb44786443..4635492a17 100644 --- a/src/mac/button.cpp +++ b/src/mac/button.cpp @@ -15,9 +15,7 @@ #include "wx/button.h" -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl) -#endif #include // Button @@ -47,14 +45,39 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, void wxButton::SetDefault() { - wxWindow *parent = (wxWindow *)GetParent(); - if (parent) - parent->SetDefaultItem(this); - + wxWindow *parent = GetParent(); + wxButton *btnOldDefault = NULL; + wxPanel *panel = wxDynamicCast(parent, wxPanel); + if ( panel ) + { + btnOldDefault = panel->GetDefaultItem(); + panel->SetDefaultItem(this); + } + + if ( btnOldDefault && btnOldDefault->m_macControl ) + { + UMASetControlData( btnOldDefault->m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)0) ) ; + } if ( m_macControl ) { UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ; - } + } +} + +wxSize wxButton::DoGetBestSize() const +{ + int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; + int hBtn = 13 + 2 * m_macVerticalBorder; + + return wxSize(wBtn, hBtn); +} + +wxSize wxButton::GetDefaultSize() +{ + int wBtn = 15 * 8 + 12 + 2 * 2; + int hBtn = 13 + 2 * 2; + + return wxSize(wBtn, hBtn); } void wxButton::Command (wxCommandEvent & event)