]>
Commit | Line | Data |
---|---|---|
489468fe | 1 | ///////////////////////////////////////////////////////////////////////////// |
524c47aa | 2 | // Name: src/osx/carbon/button.cpp |
489468fe SC |
3 | // Purpose: wxButton |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
489468fe SC |
7 | // Copyright: (c) Stefan Csomor |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #include "wx/button.h" | |
14 | ||
15 | #ifndef WX_PRECOMP | |
16 | #include "wx/panel.h" | |
17 | #include "wx/toplevel.h" | |
18 | #include "wx/dcclient.h" | |
19 | #endif | |
20 | ||
21 | #include "wx/stockitem.h" | |
22 | ||
524c47aa | 23 | #include "wx/osx/private.h" |
489468fe | 24 | |
524c47aa SC |
25 | // |
26 | // | |
27 | // | |
489468fe | 28 | |
ca910e1a VZ |
29 | wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer, |
30 | wxWindowMac* parent, | |
31 | wxWindowID id, | |
524c47aa | 32 | const wxString& label, |
ca910e1a | 33 | const wxPoint& pos, |
524c47aa | 34 | const wxSize& size, |
ca910e1a VZ |
35 | long WXUNUSED(style), |
36 | long WXUNUSED(extraStyle)) | |
489468fe | 37 | { |
524c47aa SC |
38 | OSStatus err; |
39 | Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ) ; | |
40 | wxMacControl* peer = new wxMacControl(wxpeer) ; | |
41 | if ( id == wxID_HELP ) | |
42 | { | |
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() ); | |
50 | } | |
51 | else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND) | |
52 | { | |
53 | // Button height is static in Mac, can't be changed, so we need to force it here | |
54 | int maxHeight; | |
ca910e1a | 55 | switch (wxpeer->GetWindowVariant() ) |
524c47aa | 56 | { |
ca910e1a VZ |
57 | default: |
58 | wxFAIL_MSG( "unknown window variant" ); | |
59 | // fall through | |
60 | ||
524c47aa SC |
61 | case wxWINDOW_VARIANT_NORMAL: |
62 | case wxWINDOW_VARIANT_LARGE: | |
63 | maxHeight = 20 ; | |
64 | break; | |
65 | case wxWINDOW_VARIANT_SMALL: | |
66 | maxHeight = 17; | |
af8dcb5e | 67 | break; |
524c47aa SC |
68 | case wxWINDOW_VARIANT_MINI: |
69 | maxHeight = 15; | |
524c47aa SC |
70 | } |
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() ); | |
76 | } | |
77 | else | |
78 | { | |
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() ); | |
85 | } | |
86 | verify_noerr( err ); | |
87 | return peer; | |
489468fe SC |
88 | } |
89 | ||
524c47aa | 90 | void wxMacControl::SetDefaultButton( bool isDefault ) |
ca910e1a | 91 | { |
524c47aa | 92 | SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) isDefault ) ; |
489468fe SC |
93 | } |
94 | ||
ca910e1a VZ |
95 | wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer, |
96 | wxWindowMac* parent, | |
97 | wxWindowID WXUNUSED(id), | |
524c47aa | 98 | const wxString& label, |
ca910e1a | 99 | const wxPoint& pos, |
524c47aa | 100 | const wxSize& size, |
ca910e1a VZ |
101 | long WXUNUSED(style), |
102 | long WXUNUSED(extraStyle)) | |
489468fe | 103 | { |
524c47aa SC |
104 | Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ) ; |
105 | wxMacControl* peer = new wxMacControl(wxpeer) ; | |
489468fe SC |
106 | |
107 | OSStatus err = CreateDisclosureTriangleControl( | |
ca910e1a | 108 | MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds, |
489468fe SC |
109 | kControlDisclosureTrianglePointDefault, |
110 | wxCFStringRef( label ), | |
111 | 0, // closed | |
112 | TRUE, // draw title | |
113 | TRUE, // auto toggle back and forth | |
524c47aa | 114 | peer->GetControlRefAddr() ); |
ca910e1a | 115 | |
489468fe | 116 | verify_noerr( err ); |
524c47aa | 117 | return peer; |
489468fe | 118 | } |
ca910e1a | 119 | |
489468fe | 120 |