]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/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 m_macIsUserPane
= FALSE
;
43 if ( !wxSpinButtonBase::Create(parent
, id
, pos
, size
,
44 style
, wxDefaultValidator
, name
) )
53 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
55 verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()) , &bounds
, 0 , m_min
, m_max
, 1 ,
56 (ControlRef
*) &m_macControl
) ) ;
58 MacPostControlCreate(pos
,size
) ;
63 wxSpinButton::~wxSpinButton()
68 ////////////////////////////////////////////////////////////////////////////
70 int wxSpinButton::GetMin() const
75 int wxSpinButton::GetMax() const
80 int wxSpinButton::GetValue() const
85 void wxSpinButton::SetValue(int val
)
90 void wxSpinButton::SetRange(int minVal
, int maxVal
)
94 SetControl32BitMaximum( (ControlRef
) m_macControl
, maxVal
) ;
95 SetControl32BitMinimum((ControlRef
) m_macControl
, minVal
) ;
98 void wxSpinButton::MacHandleValueChanged( int inc
)
101 wxEventType scrollEvent
= wxEVT_NULL
;
102 int oldValue
= m_value
;
104 m_value
= oldValue
+ inc
;
108 if ( m_windowStyle
& wxSP_WRAP
)
116 if ( m_windowStyle
& wxSP_WRAP
)
122 if ( m_value
- oldValue
== -1 )
123 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
124 else if ( m_value
- oldValue
== 1 )
125 scrollEvent
= wxEVT_SCROLL_LINEUP
;
127 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
129 wxSpinEvent
event(scrollEvent
, m_windowId
);
131 event
.SetPosition(m_value
);
132 event
.SetEventObject( this );
133 if ((GetEventHandler()->ProcessEvent( event
)) &&
138 SetControl32BitValue( (ControlRef
) m_macControl
, m_value
) ;
140 /* always send a thumbtrack event */
141 if (scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
143 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
144 wxSpinEvent
event2( scrollEvent
, GetId());
145 event2
.SetPosition( m_value
);
146 event2
.SetEventObject( this );
147 GetEventHandler()->ProcessEvent( event2
);
151 wxInt32
wxSpinButton::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF event
)
154 wxMacCarbonEvent
cEvent( (EventRef
) event
) ;
156 switch( cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
,typeControlPartCode
) )
158 case kControlUpButtonPart
:
161 case kControlDownButtonPart
:
165 MacHandleValueChanged( nScrollInc
) ;
169 // ----------------------------------------------------------------------------
171 // ----------------------------------------------------------------------------
173 wxSize
wxSpinButton::DoGetBestSize() const
175 return wxSize(16,24);