]> git.saurik.com Git - wxWidgets.git/blob - src/mac/button.cpp
Fixed broken compilation due to Ove's last nice changes :-(
[wxWidgets.git] / src / mac / button.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: button.cpp
3 // Purpose: wxButton
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "button.h"
14 #endif
15
16 #include "wx/button.h"
17
18 IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
19
20 #include <wx/mac/uma.h>
21 // Button
22
23
24 bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
25 const wxPoint& pos,
26 const wxSize& size, long style,
27 const wxValidator& validator,
28 const wxString& name)
29 {
30 Rect bounds ;
31 Str255 title ;
32 m_macHorizontalBorder = 2 ; // additional pixels around the real control
33 m_macVerticalBorder = 2 ;
34
35 MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
36
37 m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
38 kControlPushButtonProc , (long) this ) ;
39 wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
40
41 MacPostControlCreate() ;
42
43 return TRUE;
44 }
45
46 void wxButton::SetDefault()
47 {
48 wxWindow *parent = GetParent();
49 wxButton *btnOldDefault = NULL;
50 wxPanel *panel = wxDynamicCast(parent, wxPanel);
51 if ( panel )
52 {
53 btnOldDefault = panel->GetDefaultItem();
54 panel->SetDefaultItem(this);
55 }
56
57 if ( btnOldDefault && btnOldDefault->m_macControl )
58 {
59 UMASetControlData( btnOldDefault->m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)0) ) ;
60 }
61 if ( m_macControl )
62 {
63 UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;
64 }
65 }
66
67 wxSize wxButton::DoGetBestSize() const
68 {
69 int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder;
70 int hBtn = 13 + 2 * m_macVerticalBorder;
71
72 return wxSize(wBtn, hBtn);
73 }
74
75 wxSize wxButton::GetDefaultSize()
76 {
77 int wBtn = 15 * 8 + 12 + 2 * 2;
78 int hBtn = 13 + 2 * 2;
79
80 return wxSize(wBtn, hBtn);
81 }
82
83 void wxButton::Command (wxCommandEvent & event)
84 {
85 ProcessCommand (event);
86 }
87
88 void wxButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
89 {
90 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId );
91 event.SetEventObject(this);
92 ProcessCommand(event);
93 }
94