]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/spinbutt.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinButton
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/spinbutt.h"
17 #include "wx/osx/private.h"
20 wxWidgetImplType
* wxWidgetImpl::CreateSpinButton( wxWindowMac
* wxpeer
,
31 Rect bounds
= wxMacGetBoundsForControl( wxpeer
, pos
, size
);
33 wxMacControl
* peer
= new wxMacControl( wxpeer
);
34 OSStatus err
= CreateLittleArrowsControl(
35 MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, value
,
36 minimum
, maximum
, 1, peer
->GetControlRefAddr() );
39 peer
->SetActionProc( GetwxMacLiveScrollbarActionProc() );
43 void wxSpinButton::MacHandleControlClick(WXWidget
WXUNUSED(control
),
45 bool WXUNUSED(mouseStillDown
))
49 switch ( controlpart
)
51 case kControlUpButtonPart
:
55 case kControlDownButtonPart
:
63 // trigger scroll events
65 wxEventType scrollEvent
= wxEVT_NULL
;
66 int oldValue
= GetValue() ;
68 int newValue
= oldValue
+ inc
;
72 if ( m_windowStyle
& wxSP_WRAP
)
80 if ( m_windowStyle
& wxSP_WRAP
)
86 if ( newValue
- oldValue
== -1 )
87 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
88 else if ( newValue
- oldValue
== 1 )
89 scrollEvent
= wxEVT_SCROLL_LINEUP
;
91 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
93 // Do not send an event if the value has not actually changed
94 // (Also works for wxSpinCtrl)
95 if ( newValue
== oldValue
)
98 if ( scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
100 wxSpinEvent
event( scrollEvent
, m_windowId
);
102 event
.SetPosition( newValue
);
103 event
.SetEventObject( this );
104 if ((HandleWindowEvent( event
)) && !event
.IsAllowed())
108 m_peer
->SetValue( newValue
);
110 // always send a thumbtrack event
111 SendThumbTrackEvent() ;
114 #endif // wxUSE_SPINBTN