]>
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"
21 #include "wx/spinbutt.h"
22 #include "wx/mac/uma.h"
24 // ============================================================================
26 // ============================================================================
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 #if !USE_SHARED_LIBRARY
33 IMPLEMENT_DYNAMIC_CLASS(wxSpinButton
, wxControl
)
34 IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent
, wxScrollEvent
)
37 wxSpinButton::wxSpinButton()
42 bool wxSpinButton::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
43 long style
, const wxString
& name
)
45 if ( !wxSpinButtonBase::Create(parent
, id
, pos
, size
,
46 style
, wxDefaultValidator
, name
) )
58 MacPreControlCreate( parent
, id
, wxEmptyString
, pos
, size
,style
,*( (wxValidator
*) NULL
) , name
, &bounds
, title
) ;
60 m_macControl
= (WXWidget
) ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , 100,
61 kControlLittleArrowsProc
, (long) this ) ;
63 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, wxT("No valid mac control") ) ;
65 MacPostControlCreate() ;
70 wxSpinButton::~wxSpinButton()
75 ////////////////////////////////////////////////////////////////////////////
77 int wxSpinButton::GetMin() const
82 int wxSpinButton::GetMax() const
87 int wxSpinButton::GetValue() const
91 if (n
< m_min
) n
= m_min
;
92 if (n
> m_max
) n
= m_max
;
97 void wxSpinButton::SetValue(int val
)
102 void wxSpinButton::SetRange(int minVal
, int maxVal
)
106 SetControl32BitMaximum( (ControlHandle
) m_macControl
, maxVal
) ;
107 SetControl32BitMinimum((ControlHandle
) m_macControl
, minVal
) ;
110 void wxSpinButton::MacHandleValueChanged( int inc
)
113 wxEventType scrollEvent
= wxEVT_NULL
;
114 int oldValue
= m_value
;
116 m_value
= oldValue
+ inc
;
120 if ( m_windowStyle
& wxSP_WRAP
)
128 if ( m_windowStyle
& wxSP_WRAP
)
134 if ( m_value
- oldValue
== -1 )
135 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
136 else if ( m_value
- oldValue
== 1 )
137 scrollEvent
= wxEVT_SCROLL_LINEUP
;
139 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
141 wxSpinEvent
event(scrollEvent
, m_windowId
);
143 event
.SetPosition(m_value
);
144 event
.SetEventObject( this );
145 if ((GetEventHandler()->ProcessEvent( event
)) &&
150 SetControl32BitValue( (ControlHandle
) m_macControl
, m_value
) ;
152 /* always send a thumbtrack event */
153 if (scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
155 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
156 wxSpinEvent
event2( scrollEvent
, GetId());
157 event2
.SetPosition( m_value
);
158 event2
.SetEventObject( this );
159 GetEventHandler()->ProcessEvent( event2
);
163 void wxSpinButton::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
165 if ( (ControlHandle
) m_macControl
== NULL
)
170 switch( controlpart
)
172 case kControlUpButtonPart
:
175 case kControlDownButtonPart
:
179 MacHandleValueChanged( nScrollInc
) ;
183 // ----------------------------------------------------------------------------
185 // ----------------------------------------------------------------------------
187 wxSize
wxSpinButton::DoGetBestSize() const
189 return wxSize(16,24);
192 #endif // wxUSE_SPINBTN