]>
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 #include "wx/os2/private.h"
33 // ============================================================================
35 // ============================================================================
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 bool wxSpinButton::Create(
47 , const wxString
& rsName
53 int nHeight
= rSize
.y
;
59 m_windowId
= NewControlId();
64 m_backgroundColour
= pParent
->GetBackgroundColour();
65 m_foregroundColour
= pParent
->GetForegroundColour();
69 m_windowStyle
= lStyle
;
72 // Get the right size for the control
74 if (nWidth
<= 0 || nHeight
<= 0 )
76 wxSize vSize
= DoGetBestSize();
90 lSstyle
= WS_VISIBLE
|
92 SPBS_MASTER
| // We use only single field spin buttons
93 SPBS_NUMERICONLY
; // We default to numeric data
95 if (m_windowStyle
& wxCLIP_SIBLINGS
)
96 lSstyle
|= WS_CLIPSIBLINGS
;
98 m_hWnd
= (WXHWND
)::WinCreateWindow( GetWinHwnd(pParent
)
113 SetRange(m_min
, m_max
);
115 pParent
->AddChild((wxSpinButton
*)this);
117 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
119 SetYComp(vSwp
.y
-5); // compensate for the associated TextControl border
121 SetFont(*wxSMALL_FONT
);
123 // For OS/2 we want to hide the text portion so we can substitute an
124 // independent text ctrl in its place.
125 // Therefore we must override any user given width with our best guess.
127 SetSize( nX
- GetXComp()
132 wxAssociateWinWithHandle( m_hWnd
137 // Apparently, this does not work, as it crashes in setvalue/setrange calls
138 // What's it supposed to do anyway?
139 ::WinSetWindowULong(GetHwnd(), QWL_USER
, (LONG
)this);
140 fnWndProcSpinCtrl
= (WXFARPROC
)::WinSubclassWindow(m_hWnd
, (PFNWP
)wxSpinCtrlWndProc
);
143 } // end of wxSpinButton::Create
145 wxSpinButton::~wxSpinButton()
147 } // end of wxSpinButton::~wxSpinButton
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
153 wxSize
wxSpinButton::DoGetBestSize() const
156 // OS/2 PM does not really have system metrics so we'll just set it to
157 // a square based on its height.
160 ::WinQueryWindowRect(GetHwnd(),&vRect
);
161 return wxSize(vRect
.yTop
,vRect
.yTop
);
162 } // end of wxSpinButton::DoGetBestSize
164 // ----------------------------------------------------------------------------
166 // ----------------------------------------------------------------------------
168 int wxSpinButton::GetValue() const
173 ::WinSendMsg( GetHwnd()
176 ,MPFROM2SHORT( (USHORT
)10
182 } // end of wxSpinButton::GetValue
184 bool wxSpinButton::OS2OnScroll( int WXUNUSED(nOrientation
),
185 WXWORD
WXUNUSED(wParam
),
189 wxCHECK_MSG(hControl
, false, wxT("scrolling what?") );
191 wxSpinEvent
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId
);
192 int nVal
= (int)wPos
; // cast is important for negative values!
194 vEvent
.SetPosition(nVal
);
195 vEvent
.SetEventObject(this);
196 return(HandleWindowEvent(vEvent
));
197 } // end of wxSpinButton::OS2OnScroll
199 bool wxSpinButton::OS2Command( WXUINT
WXUNUSED(uCmd
),
200 WXWORD
WXUNUSED(wId
) )
203 } // end of wxSpinButton::OS2Command
205 void wxSpinButton::SetRange(
213 ::WinSendMsg( GetHwnd()
218 } // end of wxSpinButton::SetRange
220 void wxSpinButton::SetValue(
224 ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0));
225 } // end of wxSpinButton::SetValue
227 #endif //wxUSE_SPINBTN