]>
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();
68 m_backgroundColour
= pParent
->GetBackgroundColour();
69 m_foregroundColour
= pParent
->GetForegroundColour();
73 m_windowStyle
= lStyle
;
76 // Get the right size for the control
78 if (nWidth
<= 0 || nHeight
<= 0 )
80 wxSize vSize
= DoGetBestSize();
94 lSstyle
= WS_VISIBLE
|
96 SPBS_MASTER
| // We use only single field spin buttons
97 SPBS_NUMERICONLY
; // We default to numeric data
99 if (m_windowStyle
& wxCLIP_SIBLINGS
)
100 lSstyle
|= WS_CLIPSIBLINGS
;
102 m_hWnd
= (WXHWND
)::WinCreateWindow( GetWinHwnd(pParent
)
117 SetRange(m_min
, m_max
);
119 pParent
->AddChild((wxSpinButton
*)this);
121 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
123 SetYComp(vSwp
.y
-5); // compensate for the associated TextControl border
125 SetFont(*wxSMALL_FONT
);
127 // For OS/2 we want to hide the text portion so we can substitute an
128 // independent text ctrl in its place.
129 // Therefore we must override any user given width with our best guess.
131 SetSize( nX
- GetXComp()
136 wxAssociateWinWithHandle( m_hWnd
141 // Apparently, this does not work, as it crashes in setvalue/setrange calls
142 // What's it supposed to do anyway?
143 ::WinSetWindowULong(GetHwnd(), QWL_USER
, (LONG
)this);
144 fnWndProcSpinCtrl
= (WXFARPROC
)::WinSubclassWindow(m_hWnd
, (PFNWP
)wxSpinCtrlWndProc
);
147 } // end of wxSpinButton::Create
149 wxSpinButton::~wxSpinButton()
151 } // end of wxSpinButton::~wxSpinButton
153 // ----------------------------------------------------------------------------
155 // ----------------------------------------------------------------------------
157 wxSize
wxSpinButton::DoGetBestSize() const
160 // OS/2 PM does not really have system metrics so we'll just set it to
161 // a square based on its height.
164 ::WinQueryWindowRect(GetHwnd(),&vRect
);
165 return wxSize(vRect
.yTop
,vRect
.yTop
);
166 } // end of wxSpinButton::DoGetBestSize
168 // ----------------------------------------------------------------------------
170 // ----------------------------------------------------------------------------
172 int wxSpinButton::GetValue() const
177 ::WinSendMsg( GetHwnd()
180 ,MPFROM2SHORT( (USHORT
)10
186 } // end of wxSpinButton::GetValue
188 bool wxSpinButton::OS2OnScroll( int WXUNUSED(nOrientation
),
189 WXWORD
WXUNUSED(wParam
),
193 wxCHECK_MSG(hControl
, false, wxT("scrolling what?") );
195 wxSpinEvent
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId
);
196 int nVal
= (int)wPos
; // cast is important for negative values!
198 vEvent
.SetPosition(nVal
);
199 vEvent
.SetEventObject(this);
200 return(HandleWindowEvent(vEvent
));
201 } // end of wxSpinButton::OS2OnScroll
203 bool wxSpinButton::OS2Command( WXUINT
WXUNUSED(uCmd
),
204 WXWORD
WXUNUSED(wId
) )
207 } // end of wxSpinButton::OS2Command
209 void wxSpinButton::SetRange(
217 ::WinSendMsg( GetHwnd()
222 } // end of wxSpinButton::SetRange
224 void wxSpinButton::SetValue(
228 ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0));
229 } // end of wxSpinButton::SetValue
231 #endif //wxUSE_SPINBTN