1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinButton
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "spinbutt.h"
14 #pragma implementation "spinbutbase.h"
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
25 // Can't resolve reference to CreateUpDownControl in
26 // TWIN32, but could probably use normal CreateWindow instead.
29 #include "wx/spinbutt.h"
30 #include "wx/os2/private.h"
32 // ============================================================================
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 IMPLEMENT_DYNAMIC_CLASS(wxSpinButton
, wxControl
)
42 bool wxSpinButton
::Create(
48 , const wxString
& name
53 m_windowStyle
= style
;
57 m_windowId
= (id
== -1) ?
NewControlId() : id
;
59 // TODO create spin button
63 wxSpinButton
::~wxSpinButton()
67 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
71 wxSize wxSpinButton
::DoGetBestSize() const
75 if ( (GetWindowStyle() & wxSP_VERTICAL) != 0 )
78 return wxSize(GetSystemMetrics(SM_CXVSCROLL),
79 2*GetSystemMetrics(SM_CYVSCROLL));
84 return wxSize(2*GetSystemMetrics(SM_CXHSCROLL),
85 GetSystemMetrics(SM_CYHSCROLL));
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 int wxSpinButton
::GetValue() const
101 void wxSpinButton
::SetValue(int val
)
106 void wxSpinButton
::SetRange(int minVal
, int maxVal
)
111 bool wxSpinButton
::OS2OnScroll(int orientation
, WXWORD wParam
,
112 WXWORD pos
, WXHWND control
)
114 wxCHECK_MSG( control
, FALSE
, wxT("scrolling what?") )
117 if ( wParam != SB_THUMBPOSITION )
119 // probable SB_ENDSCROLL - we don't react to it
123 wxSpinEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId);
124 event.SetPosition((short)pos); // cast is important for negative values!
125 event.SetEventObject(this);
127 return GetEventHandler()->ProcessEvent(event);
132 bool wxSpinButton
::OS2OnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
136 LPNM_UPDOWN lpnmud = (LPNM_UPDOWN)lParam;
138 wxSpinEvent event(lpnmud->iDelta > 0 ? wxEVT_SCROLL_LINEUP
139 : wxEVT_SCROLL_LINEDOWN,
141 event.SetPosition(lpnmud->iPos + lpnmud->iDelta);
142 event.SetEventObject(this);
144 bool processed = GetEventHandler()->ProcessEvent(event);
146 *result = event.IsAllowed() ? 0 : 1;
153 bool wxSpinButton
::OS2Command(WXUINT cmd
, WXWORD id
)
155 // No command messages