Fix crash when auto-sizing a wxDataViewCtrl column.
[wxWidgets.git] / src / osx / cocoa / anybutton.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        src/osx/cocoa/anybutton.mm
3 // Purpose:     wxAnyButton
4 // Author:      Stefan Csomor
5 // Created:     1998-01-01 (extracted from button.mm)
6 // Copyright:   (c) Stefan Csomor
7 // Licence:     wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/wxprec.h"
11
12 #ifndef WX_PRECOMP
13 #include "wx/object.h"
14 #endif
15
16 #include "wx/button.h"
17
18 #include "wx/osx/private.h"
19
20 wxSize wxAnyButton::DoGetBestSize() const
21 {
22     // We only use help button bezel if we don't have any (non standard) label
23     // to display in the button. Otherwise even wxID_HELP buttons look like
24     // normal push buttons.
25     if ( GetId() == wxID_HELP && GetLabel().empty() )
26         return wxSize( 23 , 23 ) ;
27
28     wxRect r ;
29     GetPeer()->GetBestRect(&r);
30
31     wxSize sz = r.GetSize();
32     sz.x  = sz.x  + MacGetLeftBorderSize() +
33     MacGetRightBorderSize();
34     sz.y = sz.y + MacGetTopBorderSize() +
35     MacGetBottomBorderSize();
36
37     const int wBtnStd = GetDefaultSize().x;
38
39     if ( (sz.x < wBtnStd) && !HasFlag(wxBU_EXACTFIT) )
40         sz.x = wBtnStd;
41
42     return sz ;
43 }
44
45 wxSize wxAnyButton::GetDefaultSize()
46 {
47     return wxSize(84, 20);
48 }