]>
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 ///////////////////////////////////////////////////////////////////////////// 
  13     #pragma implementation "spinbutt.h" 
  14     #pragma implementation "spinbutbase.h" 
  17 // For compilers that support precompilation, includes "wx.h". 
  18 #include "wx/wxprec.h" 
  26 // Can't resolve reference to CreateUpDownControl in 
  27 // TWIN32, but could probably use normal CreateWindow instead. 
  30 #include "wx/spinbutt.h" 
  32 extern void  wxAssociateWinWithHandle( HWND         hWnd
 
  36 IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent
, wxNotifyEvent
) 
  38 #include "wx/os2/private.h" 
  40 // ============================================================================ 
  42 // ============================================================================ 
  44 // ---------------------------------------------------------------------------- 
  46 // ---------------------------------------------------------------------------- 
  48 IMPLEMENT_DYNAMIC_CLASS(wxSpinButton
, wxControl
) 
  50 bool wxSpinButton::Create( 
  56 , const wxString
&                   rsName
 
  62     int                             nHeight 
= rSize
.y
; 
  68         m_windowId 
= NewControlId(); 
  71     m_backgroundColour 
= pParent
->GetBackgroundColour(); 
  72     m_foregroundColour 
= pParent
->GetForegroundColour(); 
  75     m_windowStyle      
= lStyle
; 
  78     // Get the right size for the control 
  80     if (nWidth 
<= 0 || nHeight 
<= 0 ) 
  82         wxSize                      vSize 
= DoGetBestSize(); 
  96     lSstyle 
= WS_VISIBLE      
| 
  98               SPBS_MASTER     
| // We use only single field spin buttons 
  99               SPBS_NUMERICONLY
; // We default to numeric data 
 101     if (m_windowStyle 
& wxCLIP_SIBLINGS 
) 
 102         lSstyle 
|= WS_CLIPSIBLINGS
; 
 104     m_hWnd 
= (WXHWND
)::WinCreateWindow( GetWinHwnd(pParent
) 
 119     SetRange(m_min
, m_max
); 
 121         pParent
->AddChild((wxSpinButton 
*)this); 
 123     ::WinQueryWindowPos(m_hWnd
, &vSwp
); 
 126     wxFont
*                          pTextFont 
= new wxFont( 10 
 133     // For OS/2 we want to hide the text portion so we can substitute an 
 134     // independent text ctrl in its place.  10 device units does this 
 141     wxAssociateWinWithHandle( m_hWnd
 
 146     // Apparently, this does not work, as it crashes in setvalue/setrange calls 
 147     // What's it supposed to do anyway? 
 148     ::WinSetWindowULong(GetHwnd(), QWL_USER
, (LONG
)this); 
 149     fnWndProcSpinCtrl 
= (WXFARPROC
)::WinSubclassWindow(m_hWnd
, (PFNWP
)wxSpinCtrlWndProc
); 
 153 } // end of wxSpinButton::Create 
 155 wxSpinButton::~wxSpinButton() 
 157 } // end of wxSpinButton::~wxSpinButton 
 159 // ---------------------------------------------------------------------------- 
 161 // ---------------------------------------------------------------------------- 
 163 wxSize 
wxSpinButton::DoGetBestSize() const 
 166     // OS/2 PM does not really have system metrics so we'll just set  it to 
 167     // 24x20 which is the size of the buttons and the borders. 
 168     // Also we have no horizontal spin buttons. 
 172 } // end of wxSpinButton::DoGetBestSize 
 174 // ---------------------------------------------------------------------------- 
 176 // ---------------------------------------------------------------------------- 
 178 int wxSpinButton::GetValue() const 
 183     ::WinSendMsg( GetHwnd() 
 186                  ,MPFROM2SHORT( (USHORT
)10 
 192 } // end of wxSpinButton::GetValue 
 194 bool wxSpinButton::OS2OnScroll( int    WXUNUSED(nOrientation
), 
 195                                 WXWORD 
WXUNUSED(wParam
), 
 199     wxCHECK_MSG(hControl
, false, wxT("scrolling what?") ) 
 201     wxSpinEvent 
vEvent( wxEVT_SCROLL_THUMBTRACK
, m_windowId 
); 
 202     int nVal 
= (int)wPos
;    // cast is important for negative values! 
 204     vEvent
.SetPosition(nVal
); 
 205     vEvent
.SetEventObject(this); 
 206     return(GetEventHandler()->ProcessEvent(vEvent
)); 
 207 } // end of wxSpinButton::OS2OnScroll 
 209 bool wxSpinButton::OS2Command( WXUINT 
WXUNUSED(uCmd
), 
 210                                WXWORD 
WXUNUSED(wId
) ) 
 213 } // end of wxSpinButton::OS2Command 
 215 void wxSpinButton::SetRange( 
 223     ::WinSendMsg( GetHwnd() 
 228 } // end of wxSpinButton::SetRange 
 230 void wxSpinButton::SetValue( 
 234     ::WinSendMsg(GetHwnd(), SPBM_SETCURRENTVALUE
, MPFROMLONG(nValue
), MPARAM(0)); 
 235 } // end of wxSpinButton::SetValue 
 237 #endif //wxUSE_SPINBTN