1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "button.h"
16 #include "wx/button.h"
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxButton
, wxControl
)
23 #include <wx/mac/uma.h>
27 bool wxButton::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
29 const wxSize
& size
, long style
,
30 const wxValidator
& validator
,
36 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
38 m_macControl
= UMANewControl( parent
->GetMacRootWindow() , &bounds
, title
, false , 0 , 0 , 1,
39 kControlPushButtonProc
, (long) this ) ;
40 wxASSERT_MSG( m_macControl
!= NULL
, "No valid mac control" ) ;
42 MacPostControlCreate() ;
47 void wxButton::SetDefault()
49 wxWindow
*parent
= GetParent();
50 wxButton
*btnOldDefault
= NULL
;
51 wxPanel
*panel
= wxDynamicCast(parent
, wxPanel
);
54 btnOldDefault
= panel
->GetDefaultItem();
55 panel
->SetDefaultItem(this);
60 if ( btnOldDefault
&& btnOldDefault
->m_macControl
)
63 UMASetControlData( btnOldDefault
->m_macControl
, kControlButtonPart
,
64 kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)(&inData
) ) ;
69 UMASetControlData( m_macControl
, kControlButtonPart
,
70 kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)(&inData
) ) ;
73 if ( btnOldDefault
&& btnOldDefault
->m_macControl
)
75 UMASetControlData( btnOldDefault
->m_macControl
, kControlButtonPart
,
76 kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)((Boolean
)0) ) ;
80 UMASetControlData( m_macControl
, kControlButtonPart
,
81 kControlPushButtonDefaultTag
, sizeof( Boolean
) , (char*)((Boolean
)1) ) ;
86 wxSize
wxButton::DoGetBestSize() const
88 wxSize sz
= GetDefaultSize() ;
90 int wBtn
= m_label
.Length() * 8 + 12 ;
93 if (wBtn
> sz
.x
) sz
.x
= wBtn
;
94 if (hBtn
> sz
.y
) sz
.y
= hBtn
;
99 wxSize
wxButton::GetDefaultSize()
101 int wBtn
= 70 /* + 2 * m_macHorizontalBorder */ ;
102 int hBtn
= 20 /* + 2 * m_macVerticalBorder */ ;
104 return wxSize(wBtn
, hBtn
);
107 void wxButton::Command (wxCommandEvent
& event
)
111 HiliteControl( m_macControl
, kControlButtonPart
) ;
112 unsigned long finalTicks
;
113 Delay( 8 , &finalTicks
) ;
114 HiliteControl( m_macControl
, 0 ) ;
116 ProcessCommand (event
);
119 void wxButton::MacHandleControlClick( ControlHandle control
, SInt16 controlpart
)
121 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, m_windowId
);
122 event
.SetEventObject(this);
123 ProcessCommand(event
);