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
,
35 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
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" ) ;
41 MacPostControlCreate() ;
46 void wxButton::SetDefault()
48 wxWindow
*parent
= GetParent();
49 wxButton
*btnOldDefault
= NULL
;
50 wxPanel
*panel
= wxDynamicCast(parent
, wxPanel
);
53 btnOldDefault
= panel
->GetDefaultItem();
54 panel
->SetDefaultItem(this);
57 if ( btnOldDefault
&& btnOldDefault
->m_macControl
)
59 UMASetControlData( btnOldDefault
->m_macControl
, kControlButtonPart
, kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)((Boolean
)0) ) ;
63 UMASetControlData( m_macControl
, kControlButtonPart
, kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)((Boolean
)1) ) ;
67 wxSize
wxButton::DoGetBestSize() const
69 int wBtn
= m_label
.Length() * 8 + 12 ;
75 return wxSize(wBtn
, hBtn
);
78 wxSize
wxButton::GetDefaultSize()
80 int wBtn
= 80 /* + 2 * m_macHorizontalBorder */ ;
81 int hBtn
= 20 /* + 2 * m_macVerticalBorder */ ;
83 return wxSize(wBtn
, hBtn
);
86 void wxButton::Command (wxCommandEvent
& event
)
90 HiliteControl( m_macControl
, kControlButtonPart
) ;
91 unsigned long finalTicks
;
92 Delay( 8 , &finalTicks
) ;
93 HiliteControl( m_macControl
, 0 ) ;
95 ProcessCommand (event
);
98 void wxButton::MacHandleControlClick( ControlHandle control
, SInt16 controlpart
)
100 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, m_windowId
);
101 event
.SetEventObject(this);
102 ProcessCommand(event
);