]>
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
92 void wxSpinButton::SetValue(int val
)
97 void wxSpinButton::SetRange(int minVal
, int maxVal
)
101 SetControl32BitMaximum( (ControlHandle
) m_macControl
, maxVal
) ;
102 SetControl32BitMinimum((ControlHandle
) m_macControl
, minVal
) ;
105 void wxSpinButton::MacHandleValueChanged( int inc
)
108 wxEventType scrollEvent
= wxEVT_NULL
;
109 int oldValue
= m_value
;
111 m_value
= oldValue
+ inc
;
115 if ( m_windowStyle
& wxSP_WRAP
)
123 if ( m_windowStyle
& wxSP_WRAP
)
129 if ( m_value
- oldValue
== -1 )
130 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
131 else if ( m_value
- oldValue
== 1 )
132 scrollEvent
= wxEVT_SCROLL_LINEUP
;
134 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
136 wxSpinEvent
event(scrollEvent
, m_windowId
);
138 event
.SetPosition(m_value
);
139 event
.SetEventObject( this );
140 if ((GetEventHandler()->ProcessEvent( event
)) &&
145 SetControl32BitValue( (ControlHandle
) m_macControl
, m_value
) ;
147 /* always send a thumbtrack event */
148 if (scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
150 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
151 wxSpinEvent
event2( scrollEvent
, GetId());
152 event2
.SetPosition( m_value
);
153 event2
.SetEventObject( this );
154 GetEventHandler()->ProcessEvent( event2
);
158 void wxSpinButton::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
160 if ( (ControlHandle
) m_macControl
== NULL
)
165 switch( controlpart
)
167 case kControlUpButtonPart
:
170 case kControlDownButtonPart
:
174 MacHandleValueChanged( nScrollInc
) ;
178 // ----------------------------------------------------------------------------
180 // ----------------------------------------------------------------------------
182 wxSize
wxSpinButton::DoGetBestSize() const
184 return wxSize(16,24);
187 #endif // wxUSE_SPINBTN