]>
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::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
)
99 if ( (ControlHandle
) m_macControl
== NULL
)
102 int oldValue
= m_value
;
103 wxEventType scrollEvent
= wxEVT_NULL
;
106 switch( controlpart
)
108 case kControlUpButtonPart
:
110 scrollEvent
= wxEVT_SCROLL_LINEUP
;
112 case kControlDownButtonPart
:
114 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
118 m_value
= m_value
+ nScrollInc
;
122 if ( m_windowStyle
& wxSP_WRAP
)
130 if ( m_windowStyle
& wxSP_WRAP
)
136 wxSpinEvent
event(scrollEvent
, m_windowId
);
138 event
.SetPosition(m_value
);
139 event
.SetEventObject( this );
140 if ((GetEventHandler()->ProcessEvent( event
)) &&
145 SetControlValue( (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 // ----------------------------------------------------------------------------
160 // ----------------------------------------------------------------------------
162 wxSize
wxSpinButton::DoGetBestSize() const
164 return wxSize(16,24);