]>
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
);
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. 10 device units does this
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
);
148 } // end of wxSpinButton::Create
150 wxSpinButton::~wxSpinButton()
152 } // end of wxSpinButton::~wxSpinButton
154 // ----------------------------------------------------------------------------
156 // ----------------------------------------------------------------------------
158 wxSize
wxSpinButton::DoGetBestSize() const
161 // OS/2 PM does not really have system metrics so we'll just set it to
162 // 24x20 which is the size of the buttons and the borders.
163 // Also we have no horizontal spin buttons.
167 } // end of wxSpinButton::DoGetBestSize
169 // ----------------------------------------------------------------------------
171 // ----------------------------------------------------------------------------
173 int wxSpinButton::GetValue() const
178 ::WinSendMsg( GetHwnd()
181 ,MPFROM2SHORT( (USHORT
)10
187 } // end of wxSpinButton::GetValue
189 bool wxSpinButton::OS2OnScroll( int WXUNUSED(nOrientation
),
190 WXWORD
WXUNUSED(wParam
),
194 wxCHECK_MSG(hControl
, false, wxT("scrolling what?") )
196 wxSpinEvent
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId
);
197 int nVal
= (int)wPos
; // cast is important for negative values!
199 vEvent
.SetPosition(nVal
);
200 vEvent
.SetEventObject(this);
201 return(GetEventHandler()->ProcessEvent(vEvent
));
202 } // end of wxSpinButton::OS2OnScroll
204 bool wxSpinButton::OS2Command( WXUINT
WXUNUSED(uCmd
),
205 WXWORD
WXUNUSED(wId
) )
208 } // end of wxSpinButton::OS2Command
210 void wxSpinButton::SetRange(
218 ::WinSendMsg( GetHwnd()
223 } // end of wxSpinButton::SetRange
225 void wxSpinButton::SetValue(
229 ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0));
230 } // end of wxSpinButton::SetValue
232 #endif //wxUSE_SPINBTN