]> git.saurik.com Git - wxWidgets.git/blame - src/mac/button.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / mac / button.cpp
CommitLineData
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
19IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
20#endif
21
519cb848 22#include <wx/mac/uma.h>
e9576ca5
SC
23// Button
24
519cb848 25
e9576ca5
SC
26bool 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
48void 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
69wxSize 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
7c74e7fe
SC
77wxSize wxButton::GetDefaultSize()
78{
79 int wBtn = 15 * 8 + 12 + 2 * 2;
80 int hBtn = 13 + 2 * 2;
81
82 return wxSize(wBtn, hBtn);
83}
84
519cb848 85void wxButton::Command (wxCommandEvent & event)
e9576ca5 86{
519cb848 87 ProcessCommand (event);
e9576ca5
SC
88}
89
519cb848 90void wxButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
e9576ca5 91{
519cb848
SC
92 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId );
93 event.SetEventObject(this);
94 ProcessCommand(event);
e9576ca5
SC
95}
96