1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/button.cpp
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/button.h"
18 #include "wx/toplevel.h"
19 #include "wx/dcclient.h"
22 #include "wx/stockitem.h"
24 #include "wx/osx/private.h"
30 wxWidgetImplType
* wxWidgetImpl::CreateButton( wxWindowMac
* wxpeer
,
33 const wxString
& label
,
37 long WXUNUSED(extraStyle
))
40 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
) ;
41 wxMacControl
* peer
= new wxMacControl(wxpeer
) ;
42 if ( id
== wxID_HELP
)
44 ControlButtonContentInfo info
;
45 info
.contentType
= kControlContentIconRef
;
46 GetIconRef(kOnSystemDisk
, kSystemIconsCreator
, kHelpIcon
, &info
.u
.iconRef
);
47 err
= CreateRoundButtonControl(
48 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()),
49 &bounds
, kControlRoundButtonNormalSize
,
50 &info
, peer
->GetControlRefAddr() );
52 else if ( label
.Find('\n' ) == wxNOT_FOUND
&& label
.Find('\r' ) == wxNOT_FOUND
)
54 // Button height is static in Mac, can't be changed, so we need to force it here
56 switch (wxpeer
->GetWindowVariant() )
59 wxFAIL_MSG( "unknown window variant" );
62 case wxWINDOW_VARIANT_NORMAL
:
63 case wxWINDOW_VARIANT_LARGE
:
66 case wxWINDOW_VARIANT_SMALL
:
69 case wxWINDOW_VARIANT_MINI
:
72 bounds
.bottom
= bounds
.top
+ maxHeight
;
73 wxpeer
->SetMaxSize( wxSize( wxpeer
->GetMaxWidth() , maxHeight
));
74 err
= CreatePushButtonControl(
75 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()),
76 &bounds
, CFSTR(""), peer
->GetControlRefAddr() );
80 ControlButtonContentInfo info
;
81 info
.contentType
= kControlNoContent
;
82 err
= CreateBevelButtonControl(
83 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()) , &bounds
, CFSTR(""),
84 kControlBevelButtonLargeBevel
, kControlBehaviorPushbutton
,
85 &info
, 0, 0, 0, peer
->GetControlRefAddr() );
91 void wxMacControl::SetDefaultButton( bool isDefault
)
93 SetData(kControlButtonPart
, kControlPushButtonDefaultTag
, (Boolean
) isDefault
) ;
96 wxWidgetImplType
* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac
* wxpeer
,
98 wxWindowID
WXUNUSED(id
),
99 const wxString
& label
,
102 long WXUNUSED(style
),
103 long WXUNUSED(extraStyle
))
105 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
) ;
106 wxMacControl
* peer
= new wxMacControl(wxpeer
) ;
108 OSStatus err
= CreateDisclosureTriangleControl(
109 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()) , &bounds
,
110 kControlDisclosureTrianglePointDefault
,
111 wxCFStringRef( label
),
114 TRUE
, // auto toggle back and forth
115 peer
->GetControlRefAddr() );