]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/spinbutt.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/spinbutt.cpp
3 // Purpose: wxSpinButton
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
20 // Can't resolve reference to CreateUpDownControl in
21 // TWIN32, but could probably use normal CreateWindow instead.
24 #include "wx/spinbutt.h"
26 extern void wxAssociateWinWithHandle( HWND hWnd
30 #include "wx/os2/private.h"
32 // ============================================================================
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 bool wxSpinButton::Create(
46 , const wxString
& rsName
52 int nHeight
= rSize
.y
;
58 m_windowId
= NewControlId();
63 m_backgroundColour
= pParent
->GetBackgroundColour();
64 m_foregroundColour
= pParent
->GetForegroundColour();
68 m_windowStyle
= lStyle
;
71 // Get the right size for the control
73 if (nWidth
<= 0 || nHeight
<= 0 )
75 wxSize vSize
= DoGetBestSize();
87 long lSstyle
= WS_VISIBLE
|
89 SPBS_MASTER
| // We use only single field spin buttons
90 SPBS_NUMERICONLY
; // We default to numeric data
92 if (m_windowStyle
& wxCLIP_SIBLINGS
)
93 lSstyle
|= WS_CLIPSIBLINGS
;
95 m_hWnd
= (WXHWND
)::WinCreateWindow( GetWinHwnd(pParent
)
110 SetRange(m_min
, m_max
);
112 pParent
->AddChild((wxSpinButton
*)this);
114 ::WinQueryWindowPos(m_hWnd
, &vSwp
);
116 SetYComp(vSwp
.y
-5); // compensate for the associated TextControl border
118 SetFont(*wxSMALL_FONT
);
120 // For OS/2 we want to hide the text portion so we can substitute an
121 // independent text ctrl in its place.
122 // Therefore we must override any user given width with our best guess.
124 SetSize( nX
- GetXComp()
129 wxAssociateWinWithHandle( m_hWnd
134 // Apparently, this does not work, as it crashes in setvalue/setrange calls
135 // What's it supposed to do anyway?
136 ::WinSetWindowULong(GetHwnd(), QWL_USER
, (LONG
)this);
137 fnWndProcSpinCtrl
= (WXFARPROC
)::WinSubclassWindow(m_hWnd
, (PFNWP
)wxSpinCtrlWndProc
);
140 } // end of wxSpinButton::Create
142 wxSpinButton::~wxSpinButton()
144 } // end of wxSpinButton::~wxSpinButton
146 // ----------------------------------------------------------------------------
148 // ----------------------------------------------------------------------------
150 wxSize
wxSpinButton::DoGetBestSize() const
153 // OS/2 PM does not really have system metrics so we'll just set it to
154 // a square based on its height.
157 ::WinQueryWindowRect(GetHwnd(),&vRect
);
158 return wxSize(vRect
.yTop
,vRect
.yTop
);
159 } // end of wxSpinButton::DoGetBestSize
161 // ----------------------------------------------------------------------------
163 // ----------------------------------------------------------------------------
165 int wxSpinButton::GetValue() const
170 ::WinSendMsg( GetHwnd()
173 ,MPFROM2SHORT( (USHORT
)10
179 } // end of wxSpinButton::GetValue
181 bool wxSpinButton::OS2OnScroll( int WXUNUSED(nOrientation
),
182 WXWORD
WXUNUSED(wParam
),
186 wxCHECK_MSG(hControl
, false, wxT("scrolling what?") );
188 wxSpinEvent
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId
);
189 int nVal
= (int)wPos
; // cast is important for negative values!
191 vEvent
.SetPosition(nVal
);
192 vEvent
.SetEventObject(this);
193 return(HandleWindowEvent(vEvent
));
194 } // end of wxSpinButton::OS2OnScroll
196 bool wxSpinButton::OS2Command( WXUINT
WXUNUSED(uCmd
),
197 WXWORD
WXUNUSED(wId
) )
200 } // end of wxSpinButton::OS2Command
202 void wxSpinButton::SetRange(
210 ::WinSendMsg( GetHwnd()
215 } // end of wxSpinButton::SetRange
217 void wxSpinButton::SetValue(
221 ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0));
222 } // end of wxSpinButton::SetValue
224 #endif //wxUSE_SPINBTN