]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/spinbutt.cpp
08e6da47fa64cde7bfaa4ef141400b042bb46b8f
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"
21 #include "wx/spinbutt.h"
22 #include "wx/mac/uma.h"
24 // ============================================================================
26 // ============================================================================
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 IMPLEMENT_DYNAMIC_CLASS(wxSpinButton
, wxControl
)
33 IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent
, wxScrollEvent
)
35 wxSpinButton::wxSpinButton()
40 bool wxSpinButton::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
41 long style
, const wxString
& name
)
43 if ( !wxSpinButtonBase::Create(parent
, id
, pos
, size
,
44 style
, wxDefaultValidator
, name
) )
56 MacPreControlCreate( parent
, id
, wxEmptyString
, pos
, size
,style
,*( (wxValidator
*) NULL
) , name
, &bounds
, title
) ;
58 m_macControl
= (WXWidget
) ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , 100,
59 kControlLittleArrowsProc
, (long) this ) ;
61 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
63 MacPostControlCreate() ;
68 wxSpinButton::~wxSpinButton()
73 ////////////////////////////////////////////////////////////////////////////
75 int wxSpinButton::GetMin() const
80 int wxSpinButton::GetMax() const
85 int wxSpinButton::GetValue() const
89 if (n
< m_min
) n
= m_min
;
90 if (n
> m_max
) n
= m_max
;
95 void wxSpinButton::SetValue(int val
)
100 void wxSpinButton::SetRange(int minVal
, int maxVal
)
104 SetControl32BitMaximum( (ControlHandle
) m_macControl
, maxVal
) ;
105 SetControl32BitMinimum((ControlHandle
) m_macControl
, minVal
) ;
108 void wxSpinButton::MacHandleValueChanged( int inc
)
111 wxEventType scrollEvent
= wxEVT_NULL
;
112 int oldValue
= m_value
;
114 m_value
= oldValue
+ inc
;
118 if ( m_windowStyle
& wxSP_WRAP
)
126 if ( m_windowStyle
& wxSP_WRAP
)
132 if ( m_value
- oldValue
== -1 )
133 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
134 else if ( m_value
- oldValue
== 1 )
135 scrollEvent
= wxEVT_SCROLL_LINEUP
;
137 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
139 wxSpinEvent
event(scrollEvent
, m_windowId
);
141 event
.SetPosition(m_value
);
142 event
.SetEventObject( this );
143 if ((GetEventHandler()->ProcessEvent( event
)) &&
148 SetControl32BitValue( (ControlHandle
) m_macControl
, m_value
) ;
150 /* always send a thumbtrack event */
151 if (scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
153 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
154 wxSpinEvent
event2( scrollEvent
, GetId());
155 event2
.SetPosition( m_value
);
156 event2
.SetEventObject( this );
157 GetEventHandler()->ProcessEvent( event2
);
161 void wxSpinButton::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
163 if ( (ControlHandle
) m_macControl
== NULL
)
168 switch( controlpart
)
170 case kControlUpButtonPart
:
173 case kControlDownButtonPart
:
177 MacHandleValueChanged( nScrollInc
) ;
181 // ----------------------------------------------------------------------------
183 // ----------------------------------------------------------------------------
185 wxSize
wxSpinButton::DoGetBestSize() const
187 return wxSize(16,24);
190 #endif // wxUSE_SPINBTN