1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/button.cpp
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
13 #include "wx/button.h"
17 #include "wx/toplevel.h"
18 #include "wx/dcclient.h"
21 #include "wx/stockitem.h"
23 #include "wx/osx/private.h"
29 wxWidgetImplType
* wxWidgetImpl::CreateButton( wxWindowMac
* wxpeer
,
32 const wxString
& label
,
36 long WXUNUSED(extraStyle
))
39 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
) ;
40 wxMacControl
* peer
= new wxMacControl(wxpeer
) ;
41 if ( id
== wxID_HELP
)
43 ControlButtonContentInfo info
;
44 info
.contentType
= kControlContentIconRef
;
45 GetIconRef(kOnSystemDisk
, kSystemIconsCreator
, kHelpIcon
, &info
.u
.iconRef
);
46 err
= CreateRoundButtonControl(
47 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()),
48 &bounds
, kControlRoundButtonNormalSize
,
49 &info
, peer
->GetControlRefAddr() );
51 else if ( label
.Find('\n' ) == wxNOT_FOUND
&& label
.Find('\r' ) == wxNOT_FOUND
)
53 // Button height is static in Mac, can't be changed, so we need to force it here
55 switch (wxpeer
->GetWindowVariant() )
58 wxFAIL_MSG( "unknown window variant" );
61 case wxWINDOW_VARIANT_NORMAL
:
62 case wxWINDOW_VARIANT_LARGE
:
65 case wxWINDOW_VARIANT_SMALL
:
68 case wxWINDOW_VARIANT_MINI
:
71 bounds
.bottom
= bounds
.top
+ maxHeight
;
72 wxpeer
->SetMaxSize( wxSize( wxpeer
->GetMaxWidth() , maxHeight
));
73 err
= CreatePushButtonControl(
74 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()),
75 &bounds
, CFSTR(""), peer
->GetControlRefAddr() );
79 ControlButtonContentInfo info
;
80 info
.contentType
= kControlNoContent
;
81 err
= CreateBevelButtonControl(
82 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()) , &bounds
, CFSTR(""),
83 kControlBevelButtonLargeBevel
, kControlBehaviorPushbutton
,
84 &info
, 0, 0, 0, peer
->GetControlRefAddr() );
90 void wxMacControl::SetDefaultButton( bool isDefault
)
92 SetData(kControlButtonPart
, kControlPushButtonDefaultTag
, (Boolean
) isDefault
) ;
95 wxWidgetImplType
* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac
* wxpeer
,
97 wxWindowID
WXUNUSED(id
),
98 const wxString
& label
,
101 long WXUNUSED(style
),
102 long WXUNUSED(extraStyle
))
104 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
) ;
105 wxMacControl
* peer
= new wxMacControl(wxpeer
) ;
107 OSStatus err
= CreateDisclosureTriangleControl(
108 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()) , &bounds
,
109 kControlDisclosureTrianglePointDefault
,
110 wxCFStringRef( label
),
113 TRUE
, // auto toggle back and forth
114 peer
->GetControlRefAddr() );