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" 
  41 } // end of wxSlider::wxSlider 
  46         ::WinDestroyWindow((HWND
)m_hStaticMin
); 
  48         ::WinDestroyWindow((HWND
)m_hStaticMax
); 
  50         ::WinDestroyWindow((HWND
)m_hStaticValue
); 
  51 } // end of wxSlider::~wxSlider 
  53 void wxSlider::AdjustSubControls( int nX
, 
  57                                   int WXUNUSED(nSizeFlags
) ) 
  61     int                             nCx
;     // slider,min,max sizes 
  65     wxFont                          vFont 
= this->GetFont(); 
  67     wxGetCharSize( GetHWND() 
  73     if ((m_windowStyle 
& wxSL_VERTICAL
) != wxSL_VERTICAL
) 
  75         if (m_windowStyle 
& wxSL_LABELS 
) 
  80             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
  81             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
  83             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
  84             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
  88                 int                 nNewWidth 
= wxMax(nMinLen
, nMaxLen
); 
  89                 int                 nValueHeight 
= nCyf
; 
  91                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
  93                                   ,(LONG
)nXOffset 
- (nNewWidth 
+ nCx 
+ nMinLen 
+ nCx
) 
 100             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 102                               ,(LONG
)nXOffset 
- (nMinLen 
+ nCx
) 
 108             nXOffset 
+= nWidth 
+ nCx
; 
 110             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 116                               ,SWP_ZORDER 
| SWP_SHOW
 
 123         // Now deal with a vertical slider 
 126         if (m_windowStyle 
& wxSL_LABELS 
) 
 131             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
 132             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 134             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
 135             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 139                 int                 nNewWidth 
= (wxMax(nMinLen
, nMaxLen
)); 
 141                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 144                                   ,(LONG
)nYOffset 
+ nHeight 
+ nCyf
 
 150             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 153                               ,(LONG
)nYOffset 
+ nHeight
 
 158             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 161                               ,(LONG
)nYOffset 
- nCyf
 
 168 } // end of wxSlider::AdjustSubControls 
 170 void wxSlider::ClearSel() 
 172 } // end of wxSlider::ClearSel 
 174 void wxSlider::ClearTicks() 
 176 } // end of wxSlider::ClearTicks 
 178 void wxSlider::Command ( 
 179   wxCommandEvent
&                   rEvent
 
 182     SetValue(rEvent
.GetInt()); 
 183     ProcessCommand(rEvent
); 
 184 } // end of wxSlider::Command 
 186 bool wxSlider::ContainsHWND( 
 190     return ( hWnd 
== GetStaticMin() || 
 191              hWnd 
== GetStaticMax() || 
 192              hWnd 
== GetEditValue() 
 194 } // end of wxSlider::ContainsHWND 
 196 bool wxSlider::Create( 
 202 , const wxPoint
&                    rPos
 
 203 , const wxSize
&                     rSize
 
 205 , const wxValidator
&                rValidator
 
 206 , const wxString
&                   rsName
 
 211     int                             nWidth   
= rSize
.x
; 
 212     int                             nHeight  
= rSize
.y
; 
 218     SetValidator(rValidator
); 
 221         pParent
->AddChild(this); 
 222     SetBackgroundColour(pParent
->GetBackgroundColour()) ; 
 223     SetForegroundColour(pParent
->GetForegroundColour()) ; 
 230     m_windowStyle  
= lStyle
; 
 234         m_windowId 
= (int)NewControlId(); 
 238     if (m_windowStyle 
& wxCLIP_SIBLINGS 
) 
 239         lMsStyle 
|= WS_CLIPSIBLINGS
; 
 241     if (m_windowStyle 
& wxSL_LABELS
) 
 243         lMsStyle 
|= WS_VISIBLE 
| SS_TEXT 
| DT_VCENTER
; 
 245         m_hStaticValue 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 246                                                    ,WC_STATIC                
// Window class 
 247                                                    ,(PSZ
)NULL                
// Initial Text 
 248                                                    ,(ULONG
)lMsStyle          
// Style flags 
 249                                                    ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 250                                                    ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 251                                                    ,HWND_TOP                 
// initial z position 
 252                                                    ,(ULONG
)NewControlId()    // Window identifier 
 253                                                    ,NULL                     
// no control data 
 254                                                    ,NULL                     
// no Presentation parameters 
 258         // Now create min static control 
 260         wxSprintf(wxBuffer
, wxT("%d"), nMinValue
); 
 261         lWstyle 
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
; 
 262         if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 263             lWstyle 
|= WS_CLIPSIBLINGS
; 
 265         m_hStaticMin 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 266                                                  ,WC_STATIC                
// Window class 
 267                                                  ,(PSZ
)wxBuffer            
// Initial Text 
 268                                                  ,(ULONG
)lWstyle           
// Style flags 
 269                                                  ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 270                                                  ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 271                                                  ,HWND_TOP                 
// initial z position 
 272                                                  ,(ULONG
)NewControlId()    // Window identifier 
 273                                                  ,NULL                     
// no control data 
 274                                                  ,NULL                     
// no Presentation parameters 
 281     vSlData
.cbSize 
= sizeof(SLDCDATA
); 
 282     if (m_windowStyle 
& wxSL_VERTICAL
) 
 283         lMsStyle 
= SLS_VERTICAL 
| SLS_HOMEBOTTOM 
| WS_VISIBLE 
| WS_TABSTOP
; 
 285         lMsStyle 
= SLS_HORIZONTAL 
| SLS_HOMELEFT 
| WS_VISIBLE 
| WS_TABSTOP
; 
 287     if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 288         lMsStyle 
|= WS_CLIPSIBLINGS
; 
 290     if (m_windowStyle 
& wxSL_AUTOTICKS
) 
 292         vSlData
.usScale1Spacing 
= 0; 
 293         vSlData
.usScale2Spacing 
= 0; 
 296     if (m_windowStyle 
& wxSL_LEFT
) 
 297         lMsStyle 
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left 
 298     else if (m_windowStyle 
& wxSL_RIGHT
) 
 299         lMsStyle 
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right 
 300     else if (m_windowStyle 
& wxSL_TOP
) 
 301         lMsStyle 
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top 
 302     else if (m_windowStyle 
& wxSL_BOTTOM 
) 
 303         lMsStyle 
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom 
 304     else if ( m_windowStyle 
& wxSL_BOTH 
) 
 305         lMsStyle 
|= SLS_PRIMARYSCALE1 
| SLS_PRIMARYSCALE2
; 
 307         lMsStyle 
|= SLS_PRIMARYSCALE2
; 
 308     lMsStyle 
|= SLS_RIBBONSTRIP
; 
 310     m_nPageSize 
= ((nMaxValue 
- nMinValue
)/10); 
 311     vSlData
.usScale1Increments 
= (USHORT
)m_nPageSize
; 
 312     vSlData
.usScale2Increments 
= (USHORT
)m_nPageSize
; 
 314     HWND hScrollBar 
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 315                                         ,WC_SLIDER                
// Window class 
 316                                         ,(PSZ
)wxBuffer            
// Initial Text 
 317                                         ,(ULONG
)lMsStyle          
// Style flags 
 318                                         ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 319                                         ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 320                                         ,HWND_BOTTOM                 
// initial z position 
 321                                         ,(HMENU
)m_windowId       
// Window identifier 
 322                                         ,&vSlData                 
// Slider control data 
 323                                         ,NULL                     
// no Presentation parameters 
 325     m_nRangeMax 
= nMaxValue
; 
 326     m_nRangeMin 
= nMinValue
; 
 329     // Set the size of the ticks ... default to 6 pixels 
 331     ::WinSendMsg( hScrollBar
 
 333                  ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12) 
 337     // Set the position to the initial value 
 339     ::WinSendMsg( hScrollBar
 
 341                  ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
) 
 345     m_hWnd 
= (WXHWND
)hScrollBar
; 
 346     SubclassWin(GetHWND()); 
 347     ::WinSetWindowText((HWND
)m_hWnd
, ""); 
 349     SetFont(*wxSMALL_FONT
); 
 350     if (m_windowStyle 
& wxSL_LABELS
) 
 353         // Finally, create max value static item 
 355         wxSprintf(wxBuffer
, wxT("%d"), nMaxValue
); 
 356         lWstyle 
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
; 
 357         if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 358             lMsStyle 
|= WS_CLIPSIBLINGS
; 
 360         m_hStaticMax 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 361                                                  ,WC_STATIC                
// Window class 
 362                                                  ,(PSZ
)wxBuffer            
// Initial Text 
 363                                                  ,(ULONG
)lWstyle           
// Style flags 
 364                                                  ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 365                                                  ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 366                                                  ,HWND_TOP                 
// initial z position 
 367                                                  ,(ULONG
)NewControlId()    // Window identifier 
 368                                                  ,NULL                     
// no control data 
 369                                                  ,NULL                     
// no Presentation parameters 
 371         if (GetFont().IsOk()) 
 373             if (GetFont().GetResourceHandle()) 
 376                     wxOS2SetFont( m_hStaticMin
 
 380                     wxOS2SetFont( m_hStaticMax
 
 384                     wxOS2SetFont( m_hStaticValue
 
 398     m_nThumbLength 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 400                                                ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
 405                                  ) + 4; // for bordersizes 
 407     wxColour 
vColour(*wxBLACK
); 
 409     LONG lColor 
= (LONG
)vColour
.GetPixel(); 
 411     ::WinSetPresParam( m_hStaticMin
 
 416     ::WinSetPresParam( m_hStaticMax
 
 421     ::WinSetPresParam( m_hStaticValue
 
 426     ::WinSetPresParam( m_hWnd
 
 431     lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 432     ::WinSetPresParam( m_hStaticMin
 
 437     ::WinSetPresParam( m_hStaticMax
 
 442     ::WinSetPresParam( m_hStaticValue
 
 447     ::WinSetPresParam( m_hWnd
 
 452     vColour
.Set(wxString(wxT("BLUE"))); 
 453     lColor 
= (LONG
)vColour
.GetPixel(); 
 454     ::WinSetPresParam( m_hWnd
 
 455                       ,PP_HILITEBACKGROUNDCOLOR
 
 461 } // end of wxSlider::Create 
 463 void wxSlider::DoSetSize( int nX
, 
 471     int    nWidth1  
= nWidth
; 
 472     int    nHeight1 
= nHeight
; 
 475     int    nCx
;     // slider,min,max sizes 
 481     wxFont vFont 
= this->GetFont(); 
 484     // Adjust for OS/2's reverse coordinate system 
 486     wxWindowOS2
*                    pParent 
= (wxWindowOS2
*)GetParent(); 
 488     int                             nOS2Height 
= nHeight
; 
 492     CacheBestSize(wxSize(nWidth
,nOS2Height
)); 
 496         int nOS2ParentHeight 
= GetOS2ParentHeight(pParent
); 
 498         nYOffset 
= nOS2ParentHeight 
- (nYOffset 
+ nOS2Height
); 
 499         if (nY 
!= wxDefaultCoord
) 
 500             nY1 
= nOS2ParentHeight 
- (nY1 
+ nOS2Height
); 
 506         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 507         nYOffset 
= vRect
.yTop 
- (nYOffset 
+ nOS2Height
); 
 508         if (nY 
!= wxDefaultCoord
) 
 509             nY1 
= vRect
.yTop 
- (nY1 
+ nOS2Height
); 
 511     m_nSizeFlags 
= nSizeFlags
; 
 513     GetPosition( &nCurrentX
, &nCurrentY 
); 
 514     if (nX 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 516     if (nY 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 519     AdjustForParentClientOrigin( nX1
 
 523     wxGetCharSize( GetHWND() 
 529     if ((m_windowStyle 
& wxSL_VERTICAL
) != wxSL_VERTICAL
) 
 531         if (m_windowStyle 
& wxSL_LABELS 
) 
 536             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
 537             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 538             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
 539             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 543                 int              nNewWidth 
= (wxMax(nMinLen
, nMaxLen
)); 
 544                 int              nValueHeight 
= nCyf
; 
 546                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 549                                   ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 552                                   ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 554                 nXOffset 
+= nNewWidth 
+ nCx
; 
 556             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 559                               ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 562                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 564             nXOffset 
+= nMinLen 
+ nCx
; 
 566             int                  nSliderLength 
= nWidth1 
- nXOffset 
- nMaxLen 
- nCx
; 
 567             int                  nSliderHeight 
= nHeight1
; 
 569             if (nSliderHeight 
< 0) 
 573             // Slider must have a minimum/default length/height 
 575             if (nSliderLength 
< 100) 
 578             ::WinSetWindowPos( GetHwnd() 
 584                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 586             ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 587             ::WinSendMsg( GetHwnd() 
 589                          ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 592                          ,MPFROMLONG((ULONG
)(nSliderHeight
/2)) 
 594             nXOffset 
+= nSliderLength 
+ nCx
; 
 596             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 599                               ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 602                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 609             // If we're prepared to use the existing size, then... 
 611             if (nWidth 
== -1 && nHeight 
== -1 && 
 612                 ((nSizeFlags 
& wxSIZE_AUTO
) != wxSIZE_AUTO
)) 
 622             ::WinSetWindowPos( GetHwnd() 
 628                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 634     // Now deal with a vertical slider 
 638         if (m_windowStyle 
& wxSL_LABELS 
) 
 643             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
); 
 644             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 645             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
); 
 646             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
); 
 649                 int              nNewWidth 
= wxMax(nMinLen
, nMaxLen
); 
 650                 int              nValueHeight 
= nCyf
; 
 652                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 655                                   ,(LONG
)nYOffset 
+ nHeight
 
 658                                   ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 662             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 665                               ,(LONG
)nYOffset 
+ nHeight 
- nCyf
 
 668                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 672             int                  nSliderLength 
= nHeight1 
- (nUsedHeight 
+ (2 * nCy
)); 
 673             int                  nSliderWidth  
= nWidth1
; 
 675             if (nSliderWidth 
< 0) 
 679             // Slider must have a minimum/default length 
 681             if (nSliderLength 
< 100) 
 684             ::WinSetWindowPos( GetHwnd() 
 687                               ,(LONG
)nYOffset 
+ nCyf
 
 690                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 692             ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 693             ::WinSendMsg( GetHwnd() 
 695                          ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 698                          ,MPFROMLONG((ULONG
)(nSliderWidth
/2)) 
 700             nUsedHeight 
+= nSliderLength
; 
 701             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 704                               ,(LONG
)nYOffset 
- nCyf
 
 707                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 714             // If we're prepared to use the existing size, then... 
 716             if (nWidth 
== -1 && nHeight 
== -1 && 
 717                 ((nSizeFlags 
& wxSIZE_AUTO
) != wxSIZE_AUTO
)) 
 727             ::WinSetWindowPos( GetHwnd() 
 733                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 737 } // end of void wxSlider::DoSetSize 
 739 int wxSlider::GetLineSize() const 
 742 } // end of wxSlider::GetLineSize 
 744 int wxSlider::GetPageSize() const 
 747 } // end of wxSlider::GetPageSize 
 749 void wxSlider::GetPosition( 
 754     wxWindowOS2
*                    pParent 
= GetParent(); 
 761     wxFindMaxSize( GetHWND() 
 766         wxFindMaxSize( m_hStaticMin
 
 770         wxFindMaxSize( m_hStaticMax
 
 774         wxFindMaxSize( m_hStaticValue
 
 779     // Since we now have the absolute screen coords, 
 780     // if there's a parent we must subtract its top left corner 
 784     vPoint
.x 
= vRect
.xLeft
; 
 785     vPoint
.y 
= vRect
.yTop
; 
 791         ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
); 
 797     // We may be faking the client origin. 
 798     // So a window that's really at (0, 30) may appear 
 799     // (to wxWin apps) to be at (0, 0). 
 803         wxPoint                     
vPt(GetParent()->GetClientAreaOrigin()); 
 812 } // end of wxSlider::GetPosition 
 814 int wxSlider::GetSelEnd() const 
 817 } // end of wxSlider::GetSelEnd 
 819 int wxSlider::GetSelStart() const 
 822 } // end of wxSlider::GetSelStart 
 824 void wxSlider::DoGetSize( 
 832 } // end of wxSlider::DoGetSize 
 834 void wxSlider::GetSize( 
 846     wxFindMaxSize( GetHWND() 
 851         wxFindMaxSize( m_hStaticMin
 
 855         wxFindMaxSize( m_hStaticMax
 
 859         wxFindMaxSize( m_hStaticValue
 
 863         *pnWidth  
= vRect
.xRight 
- vRect
.xLeft
; 
 865         *pnHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 866 } // end of wxSlider::GetSize 
 868 int wxSlider::GetThumbLength() const 
 870     return m_nThumbLength
; 
 871 } // end of wxSlider::GetThumbLength 
 873 int wxSlider::GetValue() const 
 875     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 877                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 883     double                          dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
 885     int                             nPixelPos 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 887                                                                           ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
 
 893     nNewPos 
= (int)(nPixelPos
/dPixelToRange
); 
 894     if (nNewPos 
> (m_nRangeMax 
- m_nRangeMin
)/2) 
 897 } // end of wxSlider::GetValue 
 899 WXHBRUSH 
wxSlider::OnCtlColor( 
 908     return (wxControl::OnCtlColor( hDC
 
 916 } // end of wxSlider::OnCtlColor 
 918 bool wxSlider::OS2OnScroll( int    WXUNUSED(nOrientation
), 
 920                             WXWORD 
WXUNUSED(wPos
), 
 921                             WXHWND 
WXUNUSED(hControl
) ) 
 923     wxEventType eScrollEvent 
= wxEVT_NULL
; 
 928             if (m_windowStyle 
& wxSL_TOP
) 
 929                 eScrollEvent 
= wxEVT_SCROLL_TOP
; 
 930             else if (m_windowStyle 
& wxSL_BOTTOM
) 
 931                 eScrollEvent 
= wxEVT_SCROLL_BOTTOM
; 
 934         case SLN_SLIDERTRACK
: 
 935             eScrollEvent 
= wxEVT_SCROLL_THUMBTRACK
; 
 942     int nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 943                                                , SLM_QUERYSLIDERINFO
 
 944                                                , MPFROM2SHORT( SMA_SHAFTDIMENSIONS
, SMA_RANGEVALUE 
) 
 948     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
 950     int nPixelPos 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 951                                              , SLM_QUERYSLIDERINFO
 
 952                                              , MPFROM2SHORT( SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE 
) 
 957     nNewPos 
= (int)(nPixelPos
/m_dPixelToRange
); 
 958     if (nNewPos 
> (m_nRangeMax 
- m_nRangeMin
)/2) 
 960     if ((nNewPos 
< GetMin()) || (nNewPos 
> GetMax())) 
 963         // Out of range - but we did process it 
 969     wxScrollEvent 
vEvent( eScrollEvent
, m_windowId 
); 
 971     vEvent
.SetPosition(nNewPos
); 
 972     vEvent
.SetEventObject(this); 
 973     HandleWindowEvent(vEvent
); 
 975     wxCommandEvent 
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
, GetId() ); 
 977     vCevent
.SetInt(nNewPos
); 
 978     vCevent
.SetEventObject(this); 
 979     return (HandleWindowEvent(vCevent
)); 
 980 } // end of wxSlider::OS2OnScroll 
 982 void wxSlider::SetLineSize( int nLineSize 
) 
 984     m_nLineSize 
= nLineSize
; 
 985 } // end of wxSlider::SetLineSize 
 988 void wxSlider::SetPageSize( int nPageSize 
) 
 990     m_nPageSize 
= nPageSize
; 
 991 } // end of wxSlider::SetPageSize 
 993 void wxSlider::SetRange( 
1000     m_nRangeMin 
= nMinValue
; 
1001     m_nRangeMax 
= nMaxValue
; 
1003     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1004                                                                             ,SLM_QUERYSLIDERINFO
 
1005                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
1011     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
1014         wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
); 
1015         ::WinSetWindowText((HWND
)m_hStaticMin
, (PSZ
)zBuf
); 
1020         wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
); 
1021         ::WinSetWindowText((HWND
)m_hStaticMax
, (PSZ
)zBuf
); 
1023 } // end of wxSlider::SetRange 
1025 void wxSlider::SetSelection( 
1026   int                               WXUNUSED(nMinPos
) 
1027 , int                               WXUNUSED(nMaxPos
) 
1030 } // end of wxSlider::SetSelection 
1032 void wxSlider::SetThumbLength( 
1038     m_nThumbLength 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1039                                                ,SLM_QUERYSLIDERINFO
 
1040                                                ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1045                                  ) + 4; // for bordersizes 
1046     nBreadth 
= SHORT2FROMMR(::WinSendMsg( GetHwnd() 
1047                                          ,SLM_QUERYSLIDERINFO
 
1048                                          ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1054     ::WinSendMsg( GetHwnd() 
1056                  ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1059                  ,MPFROM2SHORT(nLen
, nBreadth
) 
1061     m_nThumbLength 
= nLen 
+ 4; // Borders 
1062 } // end of wxSlider::SetThumbLength 
1064 void wxSlider::SetTick( 
1068     nTickPos 
= (int)(nTickPos 
* m_dPixelToRange
); 
1069     ::WinSendMsg( GetHwnd() 
1071                  ,MPFROMSHORT(nTickPos
) 
1074 } // end of wxSlider::SetTick 
1076 // For trackbars only 
1077 void wxSlider::DoSetTickFreq( int n 
) 
1080     WNDPARAMS vWndParams
; 
1084     vSlData
.cbSize 
= sizeof(SLDCDATA
); 
1085     if (m_windowStyle 
& wxSL_AUTOTICKS
) 
1087         vSlData
.usScale1Spacing 
= 0; 
1088         vSlData
.usScale2Spacing 
= 0; 
1090     vSlData
.usScale1Increments 
= (USHORT
)((m_nRangeMax 
- m_nRangeMin
)/n
); 
1091     vSlData
.usScale2Increments 
= (USHORT
)((m_nRangeMax 
- m_nRangeMin
)/n
); 
1093     vWndParams
.fsStatus 
= WPM_CTLDATA
; 
1094     vWndParams
.cchText  
= 0L; 
1095     vWndParams
.pszText  
= NULL
; 
1096     vWndParams
.cbPresParams 
= 0L; 
1097     vWndParams
.pPresParams 
= NULL
; 
1098     vWndParams
.cbCtlData 
= vSlData
.cbSize
; 
1099     vWndParams
.pCtlData 
= (PVOID
)&vSlData
; 
1100     ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0); 
1101     for (i 
= 1; i 
< (m_nRangeMax 
- m_nRangeMin
)/n
; i
++) 
1103         nPixelPos 
= (int)(i 
* n 
* m_dPixelToRange
); 
1104         ::WinSendMsg( GetHwnd() 
1106                      ,MPFROMSHORT(nPixelPos
) 
1110 } // end of wxSlider::SetTickFreq 
1112 void wxSlider::SetValue( 
1116     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1117                                                                             ,SLM_QUERYSLIDERINFO
 
1118                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
1124     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
1125     int                             nNewPos 
= (int)(nValue 
* m_dPixelToRange
); 
1127     ::WinSendMsg( GetHwnd() 
1129                  ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
 
1136         wxSprintf(wxBuffer
, wxT("%d"), nValue
); 
1137         ::WinSetWindowText((HWND
)m_hStaticValue
, (PSZ
)wxBuffer
); 
1139 } // end of wxSlider::SetValue 
1141 bool wxSlider::Show( 
1145     wxWindowOS2::Show(bShow
); 
1147         ::WinShowWindow((HWND
)m_hStaticValue
, bShow
); 
1149         ::WinShowWindow((HWND
)m_hStaticMin
, bShow
); 
1151         ::WinShowWindow((HWND
)m_hStaticMax
, bShow
); 
1153 } // end of wxSlider::Show 
1155 #endif // wxUSE_SLIDER