]> git.saurik.com Git - wxWidgets.git/blob - src/osx/spinbutt_osx.cpp
route all Cairo calls in GTK printing code through gs_cairo (is this still needed?)
[wxWidgets.git] / src / osx / spinbutt_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: spinbutt.cpp
3 // Purpose: wxSpinButton
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id: spinbutt.cpp 54129 2008-06-11 19:30:52Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_SPINBTN
15
16 #include "wx/spinbutt.h"
17 #include "wx/osx/private.h"
18
19
20 IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
21 IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
22
23
24 wxSpinButton::wxSpinButton()
25 : wxSpinButtonBase()
26 {
27 }
28
29 bool wxSpinButton::Create( wxWindow *parent,
30 wxWindowID id, const wxPoint& pos, const wxSize& size,
31 long style, const wxString& name )
32 {
33 m_macIsUserPane = false;
34
35 if ( !wxSpinButtonBase::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
36 return false;
37
38 m_min = 0;
39 m_max = 100;
40
41 if (!parent)
42 return false;
43
44 m_peer = wxWidgetImpl::CreateSpinButton( this , parent, id, 0, m_min, m_max, pos, size,
45 style, GetExtraStyle() );
46
47 MacPostControlCreate( pos, size );
48
49 return true;
50 }
51
52 wxSpinButton::~wxSpinButton()
53 {
54 }
55
56 void wxSpinButton::SetValue( int val )
57 {
58 m_peer->SetValue( val );
59 }
60
61 int wxSpinButton::GetValue() const
62 {
63 return m_peer->GetValue();
64 }
65
66 void wxSpinButton::SetRange(int minVal, int maxVal)
67 {
68 m_min = minVal;
69 m_max = maxVal;
70 m_peer->SetMaximum( maxVal );
71 m_peer->SetMinimum( minVal );
72 }
73
74 void wxSpinButton::SendThumbTrackEvent()
75 {
76 wxSpinEvent event( wxEVT_SCROLL_THUMBTRACK, GetId() );
77 event.SetPosition( GetValue() );
78 event.SetEventObject( this );
79 HandleWindowEvent( event );
80 }
81
82 bool wxSpinButton::HandleClicked( double timestampsec )
83 {
84 #if wxOSX_USE_CARBON
85 // these have been handled by the live action proc already
86 #else
87 SendThumbTrackEvent() ;
88 #endif
89
90 return true;
91 }
92
93 wxSize wxSpinButton::DoGetBestSize() const
94 {
95 return wxSize( 16, 24 );
96 }
97
98 #endif // wxUSE_SPINBTN