]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/spinbutt.cpp
05af314aa86a4ad33277d90543837633637e4b0a
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/spinbutt.cpp
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();
88 long lSstyle
= WS_VISIBLE
|
90 SPBS_MASTER
| // We use only single field spin buttons
91 SPBS_NUMERICONLY
; // We default to numeric data
93 if (m_windowStyle
& wxCLIP_SIBLINGS
)
94 lSstyle
|= WS_CLIPSIBLINGS
;
96 m_hWnd
= (WXHWND
)::WinCreateWindow( GetWinHwnd(pParent
)
111 SetRange(m_min
, m_max
);
113 pParent
->AddChild((wxSpinButton
*)this);
115 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
117 SetYComp(vSwp
.y
-5); // compensate for the associated TextControl border
119 SetFont(*wxSMALL_FONT
);
121 // For OS/2 we want to hide the text portion so we can substitute an
122 // independent text ctrl in its place.
123 // Therefore we must override any user given width with our best guess.
125 SetSize( nX
- GetXComp()
130 wxAssociateWinWithHandle( m_hWnd
135 // Apparently, this does not work, as it crashes in setvalue/setrange calls
136 // What's it supposed to do anyway?
137 ::WinSetWindowULong(GetHwnd(), QWL_USER
, (LONG
)this);
138 fnWndProcSpinCtrl
= (WXFARPROC
)::WinSubclassWindow(m_hWnd
, (PFNWP
)wxSpinCtrlWndProc
);
141 } // end of wxSpinButton::Create
143 wxSpinButton::~wxSpinButton()
145 } // end of wxSpinButton::~wxSpinButton
147 // ----------------------------------------------------------------------------
149 // ----------------------------------------------------------------------------
151 wxSize
wxSpinButton::DoGetBestSize() const
154 // OS/2 PM does not really have system metrics so we'll just set it to
155 // a square based on its height.
158 ::WinQueryWindowRect(GetHwnd(),&vRect
);
159 return wxSize(vRect
.yTop
,vRect
.yTop
);
160 } // end of wxSpinButton::DoGetBestSize
162 // ----------------------------------------------------------------------------
164 // ----------------------------------------------------------------------------
166 int wxSpinButton::GetValue() const
171 ::WinSendMsg( GetHwnd()
174 ,MPFROM2SHORT( (USHORT
)10
180 } // end of wxSpinButton::GetValue
182 bool wxSpinButton::OS2OnScroll( int WXUNUSED(nOrientation
),
183 WXWORD
WXUNUSED(wParam
),
187 wxCHECK_MSG(hControl
, false, wxT("scrolling what?") );
189 wxSpinEvent
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId
);
190 int nVal
= (int)wPos
; // cast is important for negative values!
192 vEvent
.SetPosition(nVal
);
193 vEvent
.SetEventObject(this);
194 return(HandleWindowEvent(vEvent
));
195 } // end of wxSpinButton::OS2OnScroll
197 bool wxSpinButton::OS2Command( WXUINT
WXUNUSED(uCmd
),
198 WXWORD
WXUNUSED(wId
) )
201 } // end of wxSpinButton::OS2Command
203 void wxSpinButton::SetRange(
211 ::WinSendMsg( GetHwnd()
216 } // end of wxSpinButton::SetRange
218 void wxSpinButton::SetValue(
222 ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0));
223 } // end of wxSpinButton::SetValue
225 #endif //wxUSE_SPINBTN