]> git.saurik.com Git - wxWidgets.git/blame - src/osx/button_osx.cpp
minor fixes; replace references to Windows95 with references to wxMSW where possible
[wxWidgets.git] / src / osx / button_osx.cpp
CommitLineData
e53b3d16
SC
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
524c47aa 95 m_peer = wxWidgetImpl::CreateDisclosureTriangle(this, parent, id, label, pos, size, style, GetExtraStyle() );
e53b3d16
SC
96
97 MacPostControlCreate( pos, size );
98 // passing the text in the param doesn't seem to work, so lets do if again
99 SetLabel( label );
100
101 return true;
102}
103
104void wxDisclosureTriangle::SetOpen( bool open )
105{
e53b3d16 106 m_peer->SetValue( open ? 1 : 0 );
e53b3d16
SC
107}
108
109bool wxDisclosureTriangle::IsOpen() const
110{
e53b3d16 111 return m_peer->GetValue() == 1;
e53b3d16
SC
112}
113
114bool wxDisclosureTriangle::HandleClicked( double timestampsec )
115{
116 // Just emit button event for now
117 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId);
118 event.SetEventObject(this);
119 ProcessCommand(event);
120
121 return true;
122}
123
124wxSize wxDisclosureTriangle::DoGetBestSize() const
125{
126 return wxSize(16,16);
127}
128