]> git.saurik.com Git - wxWidgets.git/blob - src/mac/button.cpp
cb447864436f46509010b71e92df25801593cfa2
[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 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
20 #endif
21
22 #include <wx/mac/uma.h>
23 // Button
24
25
26 bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
27 const wxPoint& pos,
28 const wxSize& size, long style,
29 const wxValidator& validator,
30 const wxString& name)
31 {
32 Rect bounds ;
33 Str255 title ;
34 m_macHorizontalBorder = 2 ; // additional pixels around the real control
35 m_macVerticalBorder = 2 ;
36
37 MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
38
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" ) ;
42
43 MacPostControlCreate() ;
44
45 return TRUE;
46 }
47
48 void wxButton::SetDefault()
49 {
50 wxWindow *parent = (wxWindow *)GetParent();
51 if (parent)
52 parent->SetDefaultItem(this);
53
54 if ( m_macControl )
55 {
56 UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;
57 }
58 }
59
60 void wxButton::Command (wxCommandEvent & event)
61 {
62 ProcessCommand (event);
63 }
64
65 void wxButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
66 {
67 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId );
68 event.SetEventObject(this);
69 ProcessCommand(event);
70 }
71