1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/os2/slider.cpp 
   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" 
  23     #include "wx/scrolwin.h" 
  28 #include "wx/slider.h" 
  29 #include "wx/os2/private.h" 
  31 IMPLEMENT_DYNAMIC_CLASS(wxSlider
, wxControl
) 
  43 } // end of wxSlider::wxSlider 
  48         ::WinDestroyWindow((HWND
)m_hStaticMin
); 
  50         ::WinDestroyWindow((HWND
)m_hStaticMax
); 
  52         ::WinDestroyWindow((HWND
)m_hStaticValue
); 
  53 } // end of wxSlider::~wxSlider 
  55 void wxSlider::AdjustSubControls( int nX
, 
  59                                   int WXUNUSED(nSizeFlags
) ) 
  63     int                             nCx
;     // slider,min,max sizes 
  67     wxFont                          vFont 
= this->GetFont(); 
  69     wxGetCharSize( GetHWND() 
  75     if ((m_windowStyle 
& wxSL_VERTICAL
) != wxSL_VERTICAL
) 
  77         if (m_windowStyle 
& wxSL_LABELS 
) 
  82             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
  83             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
  85             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
  86             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
  90                 int                 nNewWidth 
= wxMax(nMinLen
, nMaxLen
); 
  91                 int                 nValueHeight 
= nCyf
; 
  93                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
  95                                   ,(LONG
)nXOffset 
- (nNewWidth 
+ nCx 
+ nMinLen 
+ nCx
) 
 102             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 104                               ,(LONG
)nXOffset 
- (nMinLen 
+ nCx
) 
 110             nXOffset 
+= nWidth 
+ nCx
; 
 112             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 118                               ,SWP_ZORDER 
| SWP_SHOW
 
 125         // Now deal with a vertical slider 
 128         if (m_windowStyle 
& wxSL_LABELS 
) 
 133             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
 134             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 136             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
 137             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 141                 int                 nNewWidth 
= (wxMax(nMinLen
, nMaxLen
)); 
 143                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 146                                   ,(LONG
)nYOffset 
+ nHeight 
+ nCyf
 
 152             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 155                               ,(LONG
)nYOffset 
+ nHeight
 
 160             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 163                               ,(LONG
)nYOffset 
- nCyf
 
 170 } // end of wxSlider::AdjustSubControls 
 172 void wxSlider::ClearSel() 
 174 } // end of wxSlider::ClearSel 
 176 void wxSlider::ClearTicks() 
 178 } // end of wxSlider::ClearTicks 
 180 void wxSlider::Command ( 
 181   wxCommandEvent
&                   rEvent
 
 184     SetValue(rEvent
.GetInt()); 
 185     ProcessCommand(rEvent
); 
 186 } // end of wxSlider::Command 
 188 bool wxSlider::ContainsHWND( 
 192     return ( hWnd 
== GetStaticMin() || 
 193              hWnd 
== GetStaticMax() || 
 194              hWnd 
== GetEditValue() 
 196 } // end of wxSlider::ContainsHWND 
 198 bool wxSlider::Create( 
 204 , const wxPoint
&                    rPos
 
 205 , const wxSize
&                     rSize
 
 207 , const wxValidator
&                rValidator
 
 208 , const wxString
&                   rsName
 
 213     int                             nWidth   
= rSize
.x
; 
 214     int                             nHeight  
= rSize
.y
; 
 220     SetValidator(rValidator
); 
 223         pParent
->AddChild(this); 
 224     SetBackgroundColour(pParent
->GetBackgroundColour()) ; 
 225     SetForegroundColour(pParent
->GetForegroundColour()) ; 
 232     m_windowStyle  
= lStyle
; 
 236         m_windowId 
= (int)NewControlId(); 
 240     if (m_windowStyle 
& wxCLIP_SIBLINGS 
) 
 241         lMsStyle 
|= WS_CLIPSIBLINGS
; 
 243     if (m_windowStyle 
& wxSL_LABELS
) 
 245         lMsStyle 
|= WS_VISIBLE 
| SS_TEXT 
| DT_VCENTER
; 
 247         m_hStaticValue 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 248                                                    ,WC_STATIC                
// Window class 
 249                                                    ,(PSZ
)NULL                
// Initial Text 
 250                                                    ,(ULONG
)lMsStyle          
// Style flags 
 251                                                    ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 252                                                    ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 253                                                    ,HWND_TOP                 
// initial z position 
 254                                                    ,(ULONG
)NewControlId()    // Window identifier 
 255                                                    ,NULL                     
// no control data 
 256                                                    ,NULL                     
// no Presentation parameters 
 260         // Now create min static control 
 262         wxSprintf(wxBuffer
, wxT("%d"), nMinValue
); 
 263         lWstyle 
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
; 
 264         if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 265             lWstyle 
|= WS_CLIPSIBLINGS
; 
 267         m_hStaticMin 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 268                                                  ,WC_STATIC                
// Window class 
 269                                                  ,(PSZ
)wxBuffer            
// Initial Text 
 270                                                  ,(ULONG
)lWstyle           
// Style flags 
 271                                                  ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 272                                                  ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 273                                                  ,HWND_TOP                 
// initial z position 
 274                                                  ,(ULONG
)NewControlId()    // Window identifier 
 275                                                  ,NULL                     
// no control data 
 276                                                  ,NULL                     
// no Presentation parameters 
 283     vSlData
.cbSize 
= sizeof(SLDCDATA
); 
 284     if (m_windowStyle 
& wxSL_VERTICAL
) 
 285         lMsStyle 
= SLS_VERTICAL 
| SLS_HOMEBOTTOM 
| WS_VISIBLE 
| WS_TABSTOP
; 
 287         lMsStyle 
= SLS_HORIZONTAL 
| SLS_HOMELEFT 
| WS_VISIBLE 
| WS_TABSTOP
; 
 289     if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 290         lMsStyle 
|= WS_CLIPSIBLINGS
; 
 292     if (m_windowStyle 
& wxSL_AUTOTICKS
) 
 294         vSlData
.usScale1Spacing 
= 0; 
 295         vSlData
.usScale2Spacing 
= 0; 
 298     if (m_windowStyle 
& wxSL_LEFT
) 
 299         lMsStyle 
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left 
 300     else if (m_windowStyle 
& wxSL_RIGHT
) 
 301         lMsStyle 
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right 
 302     else if (m_windowStyle 
& wxSL_TOP
) 
 303         lMsStyle 
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top 
 304     else if (m_windowStyle 
& wxSL_BOTTOM 
) 
 305         lMsStyle 
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom 
 306     else if ( m_windowStyle 
& wxSL_BOTH 
) 
 307         lMsStyle 
|= SLS_PRIMARYSCALE1 
| SLS_PRIMARYSCALE2
; 
 309         lMsStyle 
|= SLS_PRIMARYSCALE2
; 
 310     lMsStyle 
|= SLS_RIBBONSTRIP
; 
 312     m_nPageSize 
= ((nMaxValue 
- nMinValue
)/10); 
 313     vSlData
.usScale1Increments 
= (USHORT
)m_nPageSize
; 
 314     vSlData
.usScale2Increments 
= (USHORT
)m_nPageSize
; 
 316     HWND hScrollBar 
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 317                                         ,WC_SLIDER                
// Window class 
 318                                         ,(PSZ
)wxBuffer            
// Initial Text 
 319                                         ,(ULONG
)lMsStyle          
// Style flags 
 320                                         ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 321                                         ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 322                                         ,HWND_BOTTOM                 
// initial z position 
 323                                         ,(HMENU
)m_windowId       
// Window identifier 
 324                                         ,&vSlData                 
// Slider control data 
 325                                         ,NULL                     
// no Presentation parameters 
 327     m_nRangeMax 
= nMaxValue
; 
 328     m_nRangeMin 
= nMinValue
; 
 331     // Set the size of the ticks ... default to 6 pixels 
 333     ::WinSendMsg( hScrollBar
 
 335                  ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12) 
 339     // Set the position to the initial value 
 341     ::WinSendMsg( hScrollBar
 
 343                  ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
) 
 347     m_hWnd 
= (WXHWND
)hScrollBar
; 
 348     SubclassWin(GetHWND()); 
 349     ::WinSetWindowText((HWND
)m_hWnd
, ""); 
 351     SetFont(*wxSMALL_FONT
); 
 352     if (m_windowStyle 
& wxSL_LABELS
) 
 355         // Finally, create max value static item 
 357         wxSprintf(wxBuffer
, wxT("%d"), nMaxValue
); 
 358         lWstyle 
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
; 
 359         if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 360             lMsStyle 
|= WS_CLIPSIBLINGS
; 
 362         m_hStaticMax 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 363                                                  ,WC_STATIC                
// Window class 
 364                                                  ,(PSZ
)wxBuffer            
// Initial Text 
 365                                                  ,(ULONG
)lWstyle           
// Style flags 
 366                                                  ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 367                                                  ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 368                                                  ,HWND_TOP                 
// initial z position 
 369                                                  ,(ULONG
)NewControlId()    // Window identifier 
 370                                                  ,NULL                     
// no control data 
 371                                                  ,NULL                     
// no Presentation parameters 
 375             if (GetFont().GetResourceHandle()) 
 378                     wxOS2SetFont( m_hStaticMin
 
 382                     wxOS2SetFont( m_hStaticMax
 
 386                     wxOS2SetFont( m_hStaticValue
 
 400     m_nThumbLength 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 402                                                ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
 407                                  ) + 4; // for bordersizes 
 409     wxColour 
vColour(*wxBLACK
); 
 411     LONG lColor 
= (LONG
)vColour
.GetPixel(); 
 413     ::WinSetPresParam( m_hStaticMin
 
 418     ::WinSetPresParam( m_hStaticMax
 
 423     ::WinSetPresParam( m_hStaticValue
 
 428     ::WinSetPresParam( m_hWnd
 
 433     lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 434     ::WinSetPresParam( m_hStaticMin
 
 439     ::WinSetPresParam( m_hStaticMax
 
 444     ::WinSetPresParam( m_hStaticValue
 
 449     ::WinSetPresParam( m_hWnd
 
 454     vColour
.Set(wxString(wxT("BLUE"))); 
 455     lColor 
= (LONG
)vColour
.GetPixel(); 
 456     ::WinSetPresParam( m_hWnd
 
 457                       ,PP_HILITEBACKGROUNDCOLOR
 
 463 } // end of wxSlider::Create 
 465 void wxSlider::DoSetSize( int nX
, 
 473     int    nWidth1  
= nWidth
; 
 474     int    nHeight1 
= nHeight
; 
 477     int    nCx
;     // slider,min,max sizes 
 483     wxFont vFont 
= this->GetFont(); 
 486     // Adjust for OS/2's reverse coordinate system 
 488     wxWindowOS2
*                    pParent 
= (wxWindowOS2
*)GetParent(); 
 490     int                             nOS2Height 
= nHeight
; 
 494     CacheBestSize(wxSize(nWidth
,nOS2Height
)); 
 498         int nOS2ParentHeight 
= GetOS2ParentHeight(pParent
); 
 500         nYOffset 
= nOS2ParentHeight 
- (nYOffset 
+ nOS2Height
); 
 501         if (nY 
!= wxDefaultCoord
) 
 502             nY1 
= nOS2ParentHeight 
- (nY1 
+ nOS2Height
); 
 508         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 509         nYOffset 
= vRect
.yTop 
- (nYOffset 
+ nOS2Height
); 
 510         if (nY 
!= wxDefaultCoord
) 
 511             nY1 
= vRect
.yTop 
- (nY1 
+ nOS2Height
); 
 513     m_nSizeFlags 
= nSizeFlags
; 
 515     GetPosition( &nCurrentX
, &nCurrentY 
); 
 516     if (nX 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 518     if (nY 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 521     AdjustForParentClientOrigin( nX1
 
 525     wxGetCharSize( GetHWND() 
 531     if ((m_windowStyle 
& wxSL_VERTICAL
) != wxSL_VERTICAL
) 
 533         if (m_windowStyle 
& wxSL_LABELS 
) 
 538             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
 539             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 540             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
 541             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 545                 int              nNewWidth 
= (wxMax(nMinLen
, nMaxLen
)); 
 546                 int              nValueHeight 
= nCyf
; 
 548                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 551                                   ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 554                                   ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 556                 nXOffset 
+= nNewWidth 
+ nCx
; 
 558             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 561                               ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 564                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 566             nXOffset 
+= nMinLen 
+ nCx
; 
 568             int                  nSliderLength 
= nWidth1 
- nXOffset 
- nMaxLen 
- nCx
; 
 569             int                  nSliderHeight 
= nHeight1
; 
 571             if (nSliderHeight 
< 0) 
 575             // Slider must have a minimum/default length/height 
 577             if (nSliderLength 
< 100) 
 580             ::WinSetWindowPos( GetHwnd() 
 586                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 588             ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 589             ::WinSendMsg( GetHwnd() 
 591                          ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 594                          ,MPFROMLONG((ULONG
)(nSliderHeight
/2)) 
 596             nXOffset 
+= nSliderLength 
+ nCx
; 
 598             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 601                               ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 604                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 611             // If we're prepared to use the existing size, then... 
 613             if (nWidth 
== -1 && nHeight 
== -1 && 
 614                 ((nSizeFlags 
& wxSIZE_AUTO
) != wxSIZE_AUTO
)) 
 624             ::WinSetWindowPos( GetHwnd() 
 630                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 636     // Now deal with a vertical slider 
 640         if (m_windowStyle 
& wxSL_LABELS 
) 
 645             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
 646             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 647             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
 648             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 651                 int              nNewWidth 
= wxMax(nMinLen
, nMaxLen
); 
 652                 int              nValueHeight 
= nCyf
; 
 654                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 657                                   ,(LONG
)nYOffset 
+ nHeight
 
 660                                   ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 664             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 667                               ,(LONG
)nYOffset 
+ nHeight 
- nCyf
 
 670                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 674             int                  nSliderLength 
= nHeight1 
- (nUsedHeight 
+ (2 * nCy
)); 
 675             int                  nSliderWidth  
= nWidth1
; 
 677             if (nSliderWidth 
< 0) 
 681             // Slider must have a minimum/default length 
 683             if (nSliderLength 
< 100) 
 686             ::WinSetWindowPos( GetHwnd() 
 689                               ,(LONG
)nYOffset 
+ nCyf
 
 692                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 694             ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 695             ::WinSendMsg( GetHwnd() 
 697                          ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 700                          ,MPFROMLONG((ULONG
)(nSliderWidth
/2)) 
 702             nUsedHeight 
+= nSliderLength
; 
 703             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 706                               ,(LONG
)nYOffset 
- nCyf
 
 709                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 716             // If we're prepared to use the existing size, then... 
 718             if (nWidth 
== -1 && nHeight 
== -1 && 
 719                 ((nSizeFlags 
& wxSIZE_AUTO
) != wxSIZE_AUTO
)) 
 729             ::WinSetWindowPos( GetHwnd() 
 735                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 739 } // end of void wxSlider::DoSetSize 
 741 int wxSlider::GetLineSize() const 
 744 } // end of wxSlider::GetLineSize 
 746 int wxSlider::GetPageSize() const 
 749 } // end of wxSlider::GetPageSize 
 751 void wxSlider::GetPosition( 
 756     wxWindowOS2
*                    pParent 
= GetParent(); 
 763     wxFindMaxSize( GetHWND() 
 768         wxFindMaxSize( m_hStaticMin
 
 772         wxFindMaxSize( m_hStaticMax
 
 776         wxFindMaxSize( m_hStaticValue
 
 781     // Since we now have the absolute screen coords, 
 782     // if there's a parent we must subtract its top left corner 
 786     vPoint
.x 
= vRect
.xLeft
; 
 787     vPoint
.y 
= vRect
.yTop
; 
 793         ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
); 
 799     // We may be faking the client origin. 
 800     // So a window that's really at (0, 30) may appear 
 801     // (to wxWin apps) to be at (0, 0). 
 805         wxPoint                     
vPt(GetParent()->GetClientAreaOrigin()); 
 814 } // end of wxSlider::GetPosition 
 816 int wxSlider::GetSelEnd() const 
 819 } // end of wxSlider::GetSelEnd 
 821 int wxSlider::GetSelStart() const 
 824 } // end of wxSlider::GetSelStart 
 826 void wxSlider::DoGetSize( 
 834 } // end of wxSlider::DoGetSize 
 836 void wxSlider::GetSize( 
 848     wxFindMaxSize( GetHWND() 
 853         wxFindMaxSize( m_hStaticMin
 
 857         wxFindMaxSize( m_hStaticMax
 
 861         wxFindMaxSize( m_hStaticValue
 
 865         *pnWidth  
= vRect
.xRight 
- vRect
.xLeft
; 
 867         *pnHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 868 } // end of wxSlider::GetSize 
 870 int wxSlider::GetThumbLength() const 
 872     return m_nThumbLength
; 
 873 } // end of wxSlider::GetThumbLength 
 875 int wxSlider::GetValue() const 
 877     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 879                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 885     double                          dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
 887     int                             nPixelPos 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 889                                                                           ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
 
 895     nNewPos 
= (int)(nPixelPos
/dPixelToRange
); 
 896     if (nNewPos 
> (m_nRangeMax 
- m_nRangeMin
)/2) 
 899 } // end of wxSlider::GetValue 
 901 WXHBRUSH 
wxSlider::OnCtlColor( 
 910     return (wxControl::OnCtlColor( hDC
 
 918 } // end of wxSlider::OnCtlColor 
 920 bool wxSlider::OS2OnScroll( int    WXUNUSED(nOrientation
), 
 922                             WXWORD 
WXUNUSED(wPos
), 
 923                             WXHWND 
WXUNUSED(hControl
) ) 
 925     wxEventType eScrollEvent 
= wxEVT_NULL
; 
 930             if (m_windowStyle 
& wxSL_TOP
) 
 931                 eScrollEvent 
= wxEVT_SCROLL_TOP
; 
 932             else if (m_windowStyle 
& wxSL_BOTTOM
) 
 933                 eScrollEvent 
= wxEVT_SCROLL_BOTTOM
; 
 936         case SLN_SLIDERTRACK
: 
 937             eScrollEvent 
= wxEVT_SCROLL_THUMBTRACK
; 
 944     int nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 945                                                , SLM_QUERYSLIDERINFO
 
 946                                                , MPFROM2SHORT( SMA_SHAFTDIMENSIONS
, SMA_RANGEVALUE 
) 
 950     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
 952     int nPixelPos 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 953                                              , SLM_QUERYSLIDERINFO
 
 954                                              , MPFROM2SHORT( SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE 
) 
 959     nNewPos 
= (int)(nPixelPos
/m_dPixelToRange
); 
 960     if (nNewPos 
> (m_nRangeMax 
- m_nRangeMin
)/2) 
 962     if ((nNewPos 
< GetMin()) || (nNewPos 
> GetMax())) 
 965         // Out of range - but we did process it 
 971     wxScrollEvent 
vEvent( eScrollEvent
, m_windowId 
); 
 973     vEvent
.SetPosition(nNewPos
); 
 974     vEvent
.SetEventObject(this); 
 975     GetEventHandler()->ProcessEvent(vEvent
); 
 977     wxCommandEvent 
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
, GetId() ); 
 979     vCevent
.SetInt(nNewPos
); 
 980     vCevent
.SetEventObject(this); 
 981     return (GetEventHandler()->ProcessEvent(vCevent
)); 
 982 } // end of wxSlider::OS2OnScroll 
 984 void wxSlider::SetLineSize( int nLineSize 
) 
 986     m_nLineSize 
= nLineSize
; 
 987 } // end of wxSlider::SetLineSize 
 990 void wxSlider::SetPageSize( int nPageSize 
) 
 992     m_nPageSize 
= nPageSize
; 
 993 } // end of wxSlider::SetPageSize 
 995 void wxSlider::SetRange( 
1002     m_nRangeMin 
= nMinValue
; 
1003     m_nRangeMax 
= nMaxValue
; 
1005     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1006                                                                             ,SLM_QUERYSLIDERINFO
 
1007                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
1013     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
1016         wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
); 
1017         ::WinSetWindowText((HWND
)m_hStaticMin
, (PSZ
)zBuf
); 
1022         wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
); 
1023         ::WinSetWindowText((HWND
)m_hStaticMax
, (PSZ
)zBuf
); 
1025 } // end of wxSlider::SetRange 
1027 void wxSlider::SetSelection( 
1028   int                               WXUNUSED(nMinPos
) 
1029 , int                               WXUNUSED(nMaxPos
) 
1032 } // end of wxSlider::SetSelection 
1034 void wxSlider::SetThumbLength( 
1040     m_nThumbLength 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1041                                                ,SLM_QUERYSLIDERINFO
 
1042                                                ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1047                                  ) + 4; // for bordersizes 
1048     nBreadth 
= SHORT2FROMMR(::WinSendMsg( GetHwnd() 
1049                                          ,SLM_QUERYSLIDERINFO
 
1050                                          ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1056     ::WinSendMsg( GetHwnd() 
1058                  ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1061                  ,MPFROM2SHORT(nLen
, nBreadth
) 
1063     m_nThumbLength 
= nLen 
+ 4; // Borders 
1064 } // end of wxSlider::SetThumbLength 
1066 void wxSlider::SetTick( 
1070     nTickPos 
= (int)(nTickPos 
* m_dPixelToRange
); 
1071     ::WinSendMsg( GetHwnd() 
1073                  ,MPFROMSHORT(nTickPos
) 
1076 } // end of wxSlider::SetTick 
1078 // For trackbars only 
1079 void wxSlider::SetTickFreq( int n
, int WXUNUSED(nPos
) ) 
1082     WNDPARAMS vWndParams
; 
1086     vSlData
.cbSize 
= sizeof(SLDCDATA
); 
1087     if (m_windowStyle 
& wxSL_AUTOTICKS
) 
1089         vSlData
.usScale1Spacing 
= 0; 
1090         vSlData
.usScale2Spacing 
= 0; 
1092     vSlData
.usScale1Increments 
= (USHORT
)((m_nRangeMax 
- m_nRangeMin
)/n
); 
1093     vSlData
.usScale2Increments 
= (USHORT
)((m_nRangeMax 
- m_nRangeMin
)/n
); 
1095     vWndParams
.fsStatus 
= WPM_CTLDATA
; 
1096     vWndParams
.cchText  
= 0L; 
1097     vWndParams
.pszText  
= NULL
; 
1098     vWndParams
.cbPresParams 
= 0L; 
1099     vWndParams
.pPresParams 
= NULL
; 
1100     vWndParams
.cbCtlData 
= vSlData
.cbSize
; 
1101     vWndParams
.pCtlData 
= (PVOID
)&vSlData
; 
1102     ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0); 
1103     for (i 
= 1; i 
< (m_nRangeMax 
- m_nRangeMin
)/n
; i
++) 
1105         nPixelPos 
= (int)(i 
* n 
* m_dPixelToRange
); 
1106         ::WinSendMsg( GetHwnd() 
1108                      ,MPFROMSHORT(nPixelPos
) 
1112 } // end of wxSlider::SetTickFreq 
1114 void wxSlider::SetValue( 
1118     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1119                                                                             ,SLM_QUERYSLIDERINFO
 
1120                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
1126     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
1127     int                             nNewPos 
= (int)(nValue 
* m_dPixelToRange
); 
1129     ::WinSendMsg( GetHwnd() 
1131                  ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
 
1138         wxSprintf(wxBuffer
, wxT("%d"), nValue
); 
1139         ::WinSetWindowText((HWND
)m_hStaticValue
, (PSZ
)wxBuffer
); 
1141 } // end of wxSlider::SetValue 
1143 bool wxSlider::Show( 
1147     wxWindowOS2::Show(bShow
); 
1149         ::WinShowWindow((HWND
)m_hStaticValue
, bShow
); 
1151         ::WinShowWindow((HWND
)m_hStaticMin
, bShow
); 
1153         ::WinShowWindow((HWND
)m_hStaticMax
, bShow
); 
1155 } // end of wxSlider::Show 
1157 #endif // wxUSE_SLIDER