]>
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 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 // Can't resolve reference to CreateUpDownControl in
22 // TWIN32, but could probably use normal CreateWindow instead.
25 #include "wx/spinbutt.h"
27 extern void wxAssociateWinWithHandle( HWND hWnd
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
& rsName
57 int nHeight
= rSize
.y
;
63 m_windowId
= NewControlId();
66 m_backgroundColour
= pParent
->GetBackgroundColour();
67 m_foregroundColour
= pParent
->GetForegroundColour();
70 m_windowStyle
= lStyle
;
73 // Get the right size for the control
75 if (nWidth
<= 0 || nHeight
<= 0 )
77 wxSize vSize
= DoGetBestSize();
91 lSstyle
= WS_VISIBLE
|
93 SPBS_MASTER
| // We use only single field spin buttons
94 SPBS_NUMERICONLY
; // We default to numeric data
96 if (m_windowStyle
& wxCLIP_SIBLINGS
)
97 lSstyle
|= WS_CLIPSIBLINGS
;
99 m_hWnd
= (WXHWND
)::WinCreateWindow( GetWinHwnd(pParent
)
114 SetRange(m_min
, m_max
);
116 pParent
->AddChild((wxSpinButton
*)this);
118 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
120 SetYComp(vSwp
.y
-5); // compensate for the associated TextControl border
121 wxFont
* pTextFont
= new wxFont( 10
128 // For OS/2 we want to hide the text portion so we can substitute an
129 // independent text ctrl in its place.
130 // Therefore we must override any user given width with our best guess.
132 SetSize( nX
- GetXComp()
137 wxAssociateWinWithHandle( m_hWnd
142 // Apparently, this does not work, as it crashes in setvalue/setrange calls
143 // What's it supposed to do anyway?
144 ::WinSetWindowULong(GetHwnd(), QWL_USER
, (LONG
)this);
145 fnWndProcSpinCtrl
= (WXFARPROC
)::WinSubclassWindow(m_hWnd
, (PFNWP
)wxSpinCtrlWndProc
);
149 } // end of wxSpinButton::Create
151 wxSpinButton::~wxSpinButton()
153 } // end of wxSpinButton::~wxSpinButton
155 // ----------------------------------------------------------------------------
157 // ----------------------------------------------------------------------------
159 wxSize
wxSpinButton::DoGetBestSize() const
162 // OS/2 PM does not really have system metrics so we'll just set it to
163 // 26x20 which is the size of the buttons and the borders.
164 // Also we have no horizontal spin buttons.
168 } // end of wxSpinButton::DoGetBestSize
170 // ----------------------------------------------------------------------------
172 // ----------------------------------------------------------------------------
174 int wxSpinButton::GetValue() const
179 ::WinSendMsg( GetHwnd()
182 ,MPFROM2SHORT( (USHORT
)10
188 } // end of wxSpinButton::GetValue
190 bool wxSpinButton::OS2OnScroll( int WXUNUSED(nOrientation
),
191 WXWORD
WXUNUSED(wParam
),
195 wxCHECK_MSG(hControl
, false, wxT("scrolling what?") )
197 wxSpinEvent
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId
);
198 int nVal
= (int)wPos
; // cast is important for negative values!
200 vEvent
.SetPosition(nVal
);
201 vEvent
.SetEventObject(this);
202 return(GetEventHandler()->ProcessEvent(vEvent
));
203 } // end of wxSpinButton::OS2OnScroll
205 bool wxSpinButton::OS2Command( WXUINT
WXUNUSED(uCmd
),
206 WXWORD
WXUNUSED(wId
) )
209 } // end of wxSpinButton::OS2Command
211 void wxSpinButton::SetRange(
219 ::WinSendMsg( GetHwnd()
224 } // end of wxSpinButton::SetRange
226 void wxSpinButton::SetValue(
230 ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0));
231 } // end of wxSpinButton::SetValue
233 #endif //wxUSE_SPINBTN