]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/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
= UMANewControl( parent
->GetMacRootWindow() , &bounds
, title
, false , 0 , 0 , 100,
53 kControlLittleArrowsProc
, (long) this ) ;
55 wxASSERT_MSG( 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
)
87 wxScrollEvent
event(wxEVT_SCROLL_THUMBTRACK
, m_windowId
);
89 event
.SetPosition(m_value
);
90 event
.SetEventObject( this );
91 GetEventHandler()->ProcessEvent(event
);
94 void wxSpinButton::SetRange(int minVal
, int maxVal
)
98 SetControlMaximum( m_macControl
, maxVal
) ;
99 SetControlMinimum( m_macControl
, minVal
) ;
102 void wxSpinButton::MacHandleControlClick( ControlHandle control
, SInt16 controlpart
)
104 if ( m_macControl
== NULL
)
107 int oldValue
= m_value
;
108 wxEventType scrollEvent
= wxEVT_NULL
;
111 switch( controlpart
)
113 case kControlUpButtonPart
:
115 scrollEvent
= wxEVT_SCROLL_LINEUP
;
117 case kControlDownButtonPart
:
119 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
123 m_value
= m_value
+ nScrollInc
;
127 if ( m_windowStyle
& wxSP_WRAP
)
135 if ( m_windowStyle
& wxSP_WRAP
)
141 wxSpinEvent
event(scrollEvent
, m_windowId
);
143 event
.SetPosition(m_value
);
144 event
.SetEventObject( this );
145 if ((GetEventHandler()->ProcessEvent( event
)) &&
150 SetControlValue( m_macControl
, m_value
) ;
152 /* always send a thumbtrack event */
153 if (scrollEvent
!= wxEVT_SCROLL_THUMBTRACK
)
155 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
156 wxSpinEvent
event2( scrollEvent
, GetId());
157 event2
.SetPosition( m_value
);
158 event2
.SetEventObject( this );
159 GetEventHandler()->ProcessEvent( event2
);
163 // ----------------------------------------------------------------------------
165 // ----------------------------------------------------------------------------
167 wxSize
wxSpinButton::DoGetBestSize() const
169 if ( (GetWindowStyle() & wxSP_VERTICAL
) != 0 )
177 // horizontal control