]>
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
); 
 120     SetYComp(vSwp
.y
-5); // compensate for the associated TextControl border 
 122     SetFont(*wxSMALL_FONT
); 
 124     // For OS/2 we want to hide the text portion so we can substitute an 
 125     // independent text ctrl in its place. 
 126     // Therefore we must override any user given width with our best guess. 
 128     SetSize( nX 
- GetXComp() 
 133     wxAssociateWinWithHandle( m_hWnd
 
 138     // Apparently, this does not work, as it crashes in setvalue/setrange calls 
 139     // What's it supposed to do anyway? 
 140     ::WinSetWindowULong(GetHwnd(), QWL_USER
, (LONG
)this); 
 141     fnWndProcSpinCtrl 
= (WXFARPROC
)::WinSubclassWindow(m_hWnd
, (PFNWP
)wxSpinCtrlWndProc
); 
 144 } // end of wxSpinButton::Create 
 146 wxSpinButton::~wxSpinButton() 
 148 } // end of wxSpinButton::~wxSpinButton 
 150 // ---------------------------------------------------------------------------- 
 152 // ---------------------------------------------------------------------------- 
 154 wxSize 
wxSpinButton::DoGetBestSize() const 
 157     // OS/2 PM does not really have system metrics so we'll just set it to 
 158     // a square based on its height. 
 161     ::WinQueryWindowRect(GetHwnd(),&vRect
); 
 162     return wxSize(vRect
.yTop
,vRect
.yTop
); 
 163 } // end of wxSpinButton::DoGetBestSize 
 165 // ---------------------------------------------------------------------------- 
 167 // ---------------------------------------------------------------------------- 
 169 int wxSpinButton::GetValue() const 
 174     ::WinSendMsg( GetHwnd() 
 177                  ,MPFROM2SHORT( (USHORT
)10 
 183 } // end of wxSpinButton::GetValue 
 185 bool wxSpinButton::OS2OnScroll( int    WXUNUSED(nOrientation
), 
 186                                 WXWORD 
WXUNUSED(wParam
), 
 190     wxCHECK_MSG(hControl
, false, wxT("scrolling what?") ); 
 192     wxSpinEvent 
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId 
); 
 193     int nVal 
= (int)wPos
;    // cast is important for negative values! 
 195     vEvent
.SetPosition(nVal
); 
 196     vEvent
.SetEventObject(this); 
 197     return(HandleWindowEvent(vEvent
)); 
 198 } // end of wxSpinButton::OS2OnScroll 
 200 bool wxSpinButton::OS2Command( WXUINT 
WXUNUSED(uCmd
), 
 201                                WXWORD 
WXUNUSED(wId
) ) 
 204 } // end of wxSpinButton::OS2Command 
 206 void wxSpinButton::SetRange( 
 214     ::WinSendMsg( GetHwnd() 
 219 } // end of wxSpinButton::SetRange 
 221 void wxSpinButton::SetValue( 
 225     ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0)); 
 226 } // end of wxSpinButton::SetValue 
 228 #endif //wxUSE_SPINBTN