]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/osx/button_osx.cpp
fix undefined variable color to colour
[wxWidgets.git] / src / osx / button_osx.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/button_osx.cpp
3// Purpose: wxButton
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id: button.cpp 54845 2008-07-30 14:52:41Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#include "wx/button.h"
15
16#ifndef WX_PRECOMP
17 #include "wx/panel.h"
18 #include "wx/toplevel.h"
19 #include "wx/dcclient.h"
20#endif
21
22#include "wx/stockitem.h"
23
24#include "wx/osx/private.h"
25
26IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
27
28bool wxButton::Create(wxWindow *parent,
29 wxWindowID id,
30 const wxString& lbl,
31 const wxPoint& pos,
32 const wxSize& size,
33 long style,
34 const wxValidator& validator,
35 const wxString& name)
36{
37 wxString label(lbl);
38 if (label.empty() && wxIsStockID(id))
39 label = wxGetStockLabel(id);
40
41 m_macIsUserPane = false ;
42
43 if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
44 return false;
45
46 m_labelOrig = m_label = label ;
47
48 m_peer = wxWidgetImpl::CreateButton( this, parent, id, label, pos, size, style, GetExtraStyle() );
49
50 MacPostControlCreate( pos, size );
51
52 return true;
53}
54
55wxWindow *wxButton::SetDefault()
56{
57 wxWindow *btnOldDefault = wxButtonBase::SetDefault();
58
59 if ( btnOldDefault )
60 {
61 btnOldDefault->GetPeer()->SetDefaultButton( false );
62 }
63
64 m_peer->SetDefaultButton( true );
65
66 return btnOldDefault;
67}
68
69void wxButton::Command (wxCommandEvent & event)
70{
71 m_peer->PerformClick() ;
72 // ProcessCommand(event);
73}
74
75bool wxButton::HandleClicked( double timestampsec )
76{
77 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId);
78 event.SetEventObject(this);
79 ProcessCommand(event);
80 return true;
81}
82
83//-------------------------------------------------------
84// wxDisclosureTriangle
85//-------------------------------------------------------
86
87bool wxDisclosureTriangle::Create(wxWindow *parent, wxWindowID id, const wxString& label,
88 const wxPoint& pos, const wxSize& size, long style,const wxValidator& validator, const wxString& name )
89{
90 m_macIsUserPane = false ;
91
92 if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
93 return false;
94
95#if wxOSX_USE_CARBON
96 Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
97 m_peer = new wxMacControl(this) ;
98
99 OSStatus err = CreateDisclosureTriangleControl(
100 MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds,
101 kControlDisclosureTrianglePointDefault,
102 wxCFStringRef( label ),
103 0, // closed
104 TRUE, // draw title
105 TRUE, // auto toggle back and forth
106 m_peer->GetControlRefAddr() );
107
108 verify_noerr( err );
109#endif
110 wxASSERT_MSG( m_peer != NULL && m_peer->IsOk() , wxT("No valid Mac control") ) ;
111
112 MacPostControlCreate( pos, size );
113 // passing the text in the param doesn't seem to work, so lets do if again
114 SetLabel( label );
115
116 return true;
117}
118
119void wxDisclosureTriangle::SetOpen( bool open )
120{
121#if wxOSX_USE_CARBON
122 m_peer->SetValue( open ? 1 : 0 );
123#endif
124}
125
126bool wxDisclosureTriangle::IsOpen() const
127{
128#if wxOSX_USE_CARBON
129 return m_peer->GetValue() == 1;
130#endif
131}
132
133bool wxDisclosureTriangle::HandleClicked( double timestampsec )
134{
135 // Just emit button event for now
136 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId);
137 event.SetEventObject(this);
138 ProcessCommand(event);
139
140 return true;
141}
142
143wxSize wxDisclosureTriangle::DoGetBestSize() const
144{
145 return wxSize(16,16);
146}
147