]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/spinbutt.cpp
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"
31 IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent
, wxNotifyEvent
)
33 #include "wx/os2/private.h"
35 // ============================================================================
37 // ============================================================================
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 IMPLEMENT_DYNAMIC_CLASS(wxSpinButton
, wxControl
)
45 bool wxSpinButton::Create(
51 , const wxString
& name
56 m_windowStyle
= style
;
60 m_windowId
= (id
== -1) ? NewControlId() : id
;
62 // TODO create spin button
66 wxSpinButton::~wxSpinButton()
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 wxSize
wxSpinButton::DoGetBestSize() const
78 if ( (GetWindowStyle() & wxSP_VERTICAL) != 0 )
81 return wxSize(GetSystemMetrics(SM_CXVSCROLL),
82 2*GetSystemMetrics(SM_CYVSCROLL));
87 return wxSize(2*GetSystemMetrics(SM_CXHSCROLL),
88 GetSystemMetrics(SM_CYHSCROLL));
94 // ----------------------------------------------------------------------------
96 // ----------------------------------------------------------------------------
98 int wxSpinButton::GetValue() const
104 void wxSpinButton::SetValue(int val
)
109 void wxSpinButton::SetRange(int minVal
, int maxVal
)
114 bool wxSpinButton::OS2OnScroll(int orientation
, WXWORD wParam
,
115 WXWORD pos
, WXHWND control
)
117 wxCHECK_MSG( control
, FALSE
, wxT("scrolling what?") )
120 if ( wParam != SB_THUMBPOSITION )
122 // probable SB_ENDSCROLL - we don't react to it
126 wxSpinEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId);
127 event.SetPosition((short)pos); // cast is important for negative values!
128 event.SetEventObject(this);
130 return GetEventHandler()->ProcessEvent(event);
135 bool wxSpinButton::OS2OnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
139 LPNM_UPDOWN lpnmud = (LPNM_UPDOWN)lParam;
141 wxSpinEvent event(lpnmud->iDelta > 0 ? wxEVT_SCROLL_LINEUP
142 : wxEVT_SCROLL_LINEDOWN,
144 event.SetPosition(lpnmud->iPos + lpnmud->iDelta);
145 event.SetEventObject(this);
147 bool processed = GetEventHandler()->ProcessEvent(event);
149 *result = event.IsAllowed() ? 0 : 1;
156 bool wxSpinButton::OS2Command(WXUINT cmd
, WXWORD id
)
158 // No command messages