]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/spinbutt.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinButton
8 // Copyright: (c) AUTHOR
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
)
50 MacPreControlCreate( parent
, id
, "" , pos
, size
,style
,*( (wxValidator
*) NULL
) , name
, &bounds
, title
) ;
52 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , 100,
53 kControlLittleArrowsProc
, (long) this ) ;
55 wxASSERT_MSG( (ControlHandle
) m_macControl
!= NULL
, "No valid mac control" ) ;
57 MacPostControlCreate() ;
62 wxSpinButton::~wxSpinButton()
67 ////////////////////////////////////////////////////////////////////////////
69 int wxSpinButton::GetMin() const
74 int wxSpinButton::GetMax() const
79 int wxSpinButton::GetValue() const
84 void wxSpinButton::SetValue(int val
)
89 void wxSpinButton::SetRange(int minVal
, int maxVal
)
93 SetControlMaximum( (ControlHandle
) m_macControl
, maxVal
) ;
94 SetControlMinimum((ControlHandle
) m_macControl
, minVal
) ;
97 void wxSpinButton::MacHandleValueChanged( int inc
)
100 wxEventType scrollEvent
= wxEVT_NULL
;
101 int oldValue
= m_value
;
103 m_value
= oldValue
+ inc
;
107 if ( m_windowStyle
& wxSP_WRAP
)
115 if ( m_windowStyle
& wxSP_WRAP
)
121 if ( oldValue
- m_value
== -1 )
122 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
123 else if ( oldValue
- m_value
== 1 )
124 scrollEvent
= wxEVT_SCROLL_LINEUP
;
126 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
128 wxSpinEvent
event(scrollEvent
, m_windowId
);
130 event
.SetPosition(m_value
);
131 event
.SetEventObject( this );
132 if ((GetEventHandler()->ProcessEvent( event
)) &&
137 SetControlValue( (ControlHandle
) m_macControl
, m_value
) ;
139 /* always send a thumbtrack event */
140 if (scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
142 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
143 wxSpinEvent
event2( scrollEvent
, GetId());
144 event2
.SetPosition( m_value
);
145 event2
.SetEventObject( this );
146 GetEventHandler()->ProcessEvent( event2
);
150 void wxSpinButton::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
)
152 if ( (ControlHandle
) m_macControl
== NULL
)
157 switch( controlpart
)
159 case kControlUpButtonPart
:
162 case kControlDownButtonPart
:
166 MacHandleValueChanged( nScrollInc
) ;
170 // ----------------------------------------------------------------------------
172 // ----------------------------------------------------------------------------
174 wxSize
wxSpinButton::DoGetBestSize() const
176 return wxSize(16,24);