]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
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 | ||
519cb848 | 22 | #include <wx/mac/uma.h> |
e9576ca5 SC |
23 | // Button |
24 | ||
519cb848 | 25 | |
e9576ca5 SC |
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 | { | |
519cb848 SC |
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; | |
e9576ca5 SC |
46 | } |
47 | ||
48 | void wxButton::SetDefault() | |
49 | { | |
e7549107 SC |
50 | wxWindow *parent = GetParent(); |
51 | wxButton *btnOldDefault = NULL; | |
52 | wxPanel *panel = wxDynamicCast(parent, wxPanel); | |
53 | if ( panel ) | |
54 | { | |
55 | btnOldDefault = panel->GetDefaultItem(); | |
56 | panel->SetDefaultItem(this); | |
57 | } | |
58 | ||
59 | if ( btnOldDefault && btnOldDefault->m_macControl ) | |
60 | { | |
61 | UMASetControlData( btnOldDefault->m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)0) ) ; | |
62 | } | |
519cb848 SC |
63 | if ( m_macControl ) |
64 | { | |
65 | UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ; | |
e7549107 | 66 | } |
e9576ca5 SC |
67 | } |
68 | ||
51abe921 SC |
69 | wxSize wxButton::DoGetBestSize() |
70 | { | |
71 | int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; | |
72 | int hBtn = 13 + 2 * m_macVerticalBorder; | |
73 | ||
74 | return wxSize(wBtn, hBtn); | |
75 | } | |
76 | ||
519cb848 | 77 | void wxButton::Command (wxCommandEvent & event) |
e9576ca5 | 78 | { |
519cb848 | 79 | ProcessCommand (event); |
e9576ca5 SC |
80 | } |
81 | ||
519cb848 | 82 | void wxButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) |
e9576ca5 | 83 | { |
519cb848 SC |
84 | wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId ); |
85 | event.SetEventObject(this); | |
86 | ProcessCommand(event); | |
e9576ca5 SC |
87 | } |
88 |