]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/spinbutt.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinButton
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "spinbutt.h"
14 #pragma implementation "spinbuttbase.h"
17 #include "wx/spinbutt.h"
18 #include "wx/mac/uma.h"
20 // ============================================================================
22 // ============================================================================
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxSpinButton
, wxControl
)
30 IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent
, wxScrollEvent
)
33 wxSpinButton::wxSpinButton()
38 bool wxSpinButton::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
39 long style
, const wxString
& name
)
41 if ( !wxSpinButtonBase::Create(parent
, id
, pos
, size
,
42 style
, wxDefaultValidator
, name
) )
54 MacPreControlCreate( parent
, id
, wxEmptyString
, pos
, size
,style
,*( (wxValidator
*) NULL
) , name
, &bounds
, title
) ;
56 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , 100,
57 kControlLittleArrowsProc
, (long) this ) ;
59 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
61 MacPostControlCreate() ;
66 wxSpinButton::~wxSpinButton()
71 ////////////////////////////////////////////////////////////////////////////
73 int wxSpinButton::GetMin() const
78 int wxSpinButton::GetMax() const
83 int wxSpinButton::GetValue() const
88 void wxSpinButton::SetValue(int val
)
93 void wxSpinButton::SetRange(int minVal
, int maxVal
)
97 SetControl32BitMaximum( (ControlHandle
) m_macControl
, maxVal
) ;
98 SetControl32BitMinimum((ControlHandle
) m_macControl
, minVal
) ;
101 void wxSpinButton::MacHandleValueChanged( int inc
)
104 wxEventType scrollEvent
= wxEVT_NULL
;
105 int oldValue
= m_value
;
107 m_value
= oldValue
+ inc
;
111 if ( m_windowStyle
& wxSP_WRAP
)
119 if ( m_windowStyle
& wxSP_WRAP
)
125 if ( m_value
- oldValue
== -1 )
126 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
127 else if ( m_value
- oldValue
== 1 )
128 scrollEvent
= wxEVT_SCROLL_LINEUP
;
130 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
132 wxSpinEvent
event(scrollEvent
, m_windowId
);
134 event
.SetPosition(m_value
);
135 event
.SetEventObject( this );
136 if ((GetEventHandler()->ProcessEvent( event
)) &&
141 SetControl32BitValue( (ControlHandle
) m_macControl
, m_value
) ;
143 /* always send a thumbtrack event */
144 if (scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
146 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
147 wxSpinEvent
event2( scrollEvent
, GetId());
148 event2
.SetPosition( m_value
);
149 event2
.SetEventObject( this );
150 GetEventHandler()->ProcessEvent( event2
);
154 void wxSpinButton::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
156 if ( (ControlHandle
) m_macControl
== NULL
)
161 switch( controlpart
)
163 case kControlUpButtonPart
:
166 case kControlDownButtonPart
:
170 MacHandleValueChanged( nScrollInc
) ;
174 // ----------------------------------------------------------------------------
176 // ----------------------------------------------------------------------------
178 wxSize
wxSpinButton::DoGetBestSize() const
180 return wxSize(16,24);