1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "button.h"
16 #include "wx/button.h"
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_DYNAMIC_CLASS(wxButton
, wxControl
)
22 #include <wx/mac/uma.h>
26 bool wxButton::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
28 const wxSize
& size
, long style
,
29 const wxValidator
& validator
,
34 m_macHorizontalBorder
= 2 ; // additional pixels around the real control
35 m_macVerticalBorder
= 2 ;
37 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
39 m_macControl
= UMANewControl( parent
->GetMacRootWindow() , &bounds
, title
, true , 0 , 0 , 1,
40 kControlPushButtonProc
, (long) this ) ;
41 wxASSERT_MSG( m_macControl
!= NULL
, "No valid mac control" ) ;
43 MacPostControlCreate() ;
48 void wxButton::SetDefault()
50 wxWindow
*parent
= GetParent();
51 wxButton
*btnOldDefault
= NULL
;
52 wxPanel
*panel
= wxDynamicCast(parent
, wxPanel
);
55 btnOldDefault
= panel
->GetDefaultItem();
56 panel
->SetDefaultItem(this);
59 if ( btnOldDefault
&& btnOldDefault
->m_macControl
)
61 UMASetControlData( btnOldDefault
->m_macControl
, kControlButtonPart
, kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)((Boolean
)0) ) ;
65 UMASetControlData( m_macControl
, kControlButtonPart
, kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)((Boolean
)1) ) ;
69 wxSize
wxButton::DoGetBestSize()
71 int wBtn
= m_label
.Length() * 8 + 12 + 2 * m_macHorizontalBorder
;
72 int hBtn
= 13 + 2 * m_macVerticalBorder
;
74 return wxSize(wBtn
, hBtn
);
77 wxSize
wxButton::GetDefaultSize()
79 int wBtn
= 15 * 8 + 12 + 2 * 2;
80 int hBtn
= 13 + 2 * 2;
82 return wxSize(wBtn
, hBtn
);
85 void wxButton::Command (wxCommandEvent
& event
)
87 ProcessCommand (event
);
90 void wxButton::MacHandleControlClick( ControlHandle control
, SInt16 controlpart
)
92 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, m_windowId
);
93 event
.SetEventObject(this);
94 ProcessCommand(event
);