1 ///////////////////////////////////////////////////////////////////////////// 
   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> 
  26 #include "wx/slider.h" 
  27 #include "wx/os2/private.h" 
  29 IMPLEMENT_DYNAMIC_CLASS(wxSlider
, wxControl
) 
  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( 
  63     int                             nCx
;     // slider,min,max sizes 
  68     wxGetCharSize( GetHWND() 
  74     if ((m_windowStyle 
& wxSL_VERTICAL
) != wxSL_VERTICAL
) 
  76         if (m_windowStyle 
& wxSL_LABELS 
) 
  81             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
); 
  82             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
  84             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
); 
  85             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
  89                 int                 nNewWidth 
= wxMax(nMinLen
, nMaxLen
); 
  90                 int                 nValueHeight 
= nCyf
; 
  92                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
  94                                   ,(LONG
)nXOffset 
- (nNewWidth 
+ nCx 
+ nMinLen 
+ nCx
) 
 101             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 103                               ,(LONG
)nXOffset 
- (nMinLen 
+ nCx
) 
 109             nXOffset 
+= nWidth 
+ nCx
; 
 111             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 117                               ,SWP_ZORDER 
| SWP_SHOW
 
 124         // Now deal with a vertical slider 
 127         if (m_windowStyle 
& wxSL_LABELS 
) 
 132             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
); 
 133             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
 135             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
); 
 136             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
 140                 int                 nNewWidth 
= (wxMax(nMinLen
, nMaxLen
)); 
 142                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 145                                   ,(LONG
)nYOffset 
+ nHeight 
+ nCyf
 
 151             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 154                               ,(LONG
)nYOffset 
+ nHeight
 
 159             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 162                               ,(LONG
)nYOffset 
- nCyf
 
 169 } // end of wxSlider::AdjustSubControls 
 171 void wxSlider::ClearSel() 
 173 } // end of wxSlider::ClearSel 
 175 void wxSlider::ClearTicks() 
 177 } // end of wxSlider::ClearTicks 
 179 void wxSlider::Command ( 
 180   wxCommandEvent
&                   rEvent
 
 183     SetValue(rEvent
.GetInt()); 
 184     ProcessCommand(rEvent
); 
 185 } // end of wxSlider::Command 
 187 bool wxSlider::ContainsHWND( 
 191     return ( hWnd 
== GetStaticMin() || 
 192              hWnd 
== GetStaticMax() || 
 193              hWnd 
== GetEditValue() 
 195 } // end of wxSlider::ContainsHWND 
 197 bool wxSlider::Create( 
 203 , const wxPoint
&                    rPos
 
 204 , const wxSize
&                     rSize
 
 206 , const wxValidator
&                rValidator
 
 207 , const wxString
&                   rsName
 
 212     int                             nWidth   
= rSize
.x
; 
 213     int                             nHeight  
= rSize
.y
; 
 219     SetValidator(rValidator
); 
 222         pParent
->AddChild(this); 
 223     SetBackgroundColour(pParent
->GetBackgroundColour()) ; 
 224     SetForegroundColour(pParent
->GetForegroundColour()) ; 
 231     m_windowStyle  
= lStyle
; 
 235         m_windowId 
= (int)NewControlId(); 
 239     if (m_windowStyle 
& wxCLIP_SIBLINGS 
) 
 240         lMsStyle 
|= WS_CLIPSIBLINGS
; 
 242     if (m_windowStyle 
& wxSL_LABELS
) 
 244         lMsStyle 
|= WS_VISIBLE 
| SS_TEXT 
| DT_VCENTER
; 
 246         m_hStaticValue 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 247                                                    ,WC_STATIC                
// Window class 
 248                                                    ,(PSZ
)NULL                
// Initial Text 
 249                                                    ,(ULONG
)lMsStyle          
// Style flags 
 250                                                    ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 251                                                    ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 252                                                    ,HWND_TOP                 
// initial z position 
 253                                                    ,(ULONG
)NewControlId()    // Window identifier 
 254                                                    ,NULL                     
// no control data 
 255                                                    ,NULL                     
// no Presentation parameters 
 259         // Now create min static control 
 261         sprintf(wxBuffer
, "%d", nMinValue
); 
 262         lWstyle 
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
; 
 263         if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 264             lWstyle 
|= WS_CLIPSIBLINGS
; 
 266         m_hStaticMin 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 267                                                  ,WC_STATIC                
// Window class 
 268                                                  ,(PSZ
)wxBuffer            
// Initial Text 
 269                                                  ,(ULONG
)lWstyle           
// Style flags 
 270                                                  ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 271                                                  ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 272                                                  ,HWND_TOP                 
// initial z position 
 273                                                  ,(ULONG
)NewControlId()    // Window identifier 
 274                                                  ,NULL                     
// no control data 
 275                                                  ,NULL                     
// no Presentation parameters 
 282     vSlData
.cbSize 
= sizeof(SLDCDATA
); 
 283     if (m_windowStyle 
& wxSL_VERTICAL
) 
 284         lMsStyle 
= SLS_VERTICAL 
| SLS_HOMEBOTTOM 
| WS_VISIBLE 
| WS_TABSTOP
; 
 286         lMsStyle 
= SLS_HORIZONTAL 
| SLS_HOMELEFT 
| WS_VISIBLE 
| WS_TABSTOP
; 
 288     if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 289         lMsStyle 
|= WS_CLIPSIBLINGS
; 
 291     if (m_windowStyle 
& wxSL_AUTOTICKS
) 
 293         vSlData
.usScale1Spacing 
= 0; 
 294         vSlData
.usScale2Spacing 
= 0; 
 297     if (m_windowStyle 
& wxSL_LEFT
) 
 298         lMsStyle 
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left 
 299     else if (m_windowStyle 
& wxSL_RIGHT
) 
 300         lMsStyle 
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right 
 301     else if (m_windowStyle 
& wxSL_TOP
) 
 302         lMsStyle 
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top 
 303     else if (m_windowStyle 
& wxSL_BOTTOM 
) 
 304         lMsStyle 
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom 
 305     else if ( m_windowStyle 
& wxSL_BOTH 
) 
 306         lMsStyle 
|= SLS_PRIMARYSCALE1 
| SLS_PRIMARYSCALE2
; 
 308         lMsStyle 
|= SLS_PRIMARYSCALE2
; 
 309     lMsStyle 
|= SLS_RIBBONSTRIP
; 
 311     m_nPageSize 
= ((nMaxValue 
- nMinValue
)/10); 
 312     vSlData
.usScale1Increments 
= m_nPageSize
; 
 313     vSlData
.usScale2Increments 
= m_nPageSize
; 
 315     HWND                            hScrollBar 
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 316                                                                    ,WC_SLIDER                
// Window class 
 317                                                                    ,(PSZ
)wxBuffer            
// Initial Text 
 318                                                                    ,(ULONG
)lMsStyle          
// Style flags 
 319                                                                    ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 320                                                                    ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 321                                                                    ,HWND_BOTTOM                 
// initial z position 
 322                                                                    ,(HMENU
)m_windowId       
// Window identifier 
 323                                                                    ,&vSlData                 
// Slider control data 
 324                                                                    ,NULL                     
// no Presentation parameters 
 326     m_nRangeMax 
= nMaxValue
; 
 327     m_nRangeMin 
= nMinValue
; 
 330     // Set the size of the ticks ... default to 6 pixels 
 332     ::WinSendMsg( hScrollBar
 
 334                  ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12) 
 338     // Set the position to the initial value 
 340     ::WinSendMsg( hScrollBar
 
 342                  ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
) 
 346     m_hWnd 
= (WXHWND
)hScrollBar
; 
 347     SubclassWin(GetHWND()); 
 348     ::WinSetWindowText((HWND
)m_hWnd
, ""); 
 350     SetFont(*wxSMALL_FONT
); 
 351     if (m_windowStyle 
& wxSL_LABELS
) 
 354         // Finally, create max value static item 
 356         sprintf(wxBuffer
, "%d", nMaxValue
); 
 357         lWstyle 
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
; 
 358         if (m_windowStyle 
& wxCLIP_SIBLINGS
) 
 359             lMsStyle 
|= WS_CLIPSIBLINGS
; 
 361         m_hStaticMax 
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle 
 362                                                  ,WC_STATIC                
// Window class 
 363                                                  ,(PSZ
)wxBuffer            
// Initial Text 
 364                                                  ,(ULONG
)lWstyle           
// Style flags 
 365                                                  ,0L, 0L, 0L, 0L           // Origin -- 0 size 
 366                                                  ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent 
 367                                                  ,HWND_TOP                 
// initial z position 
 368                                                  ,(ULONG
)NewControlId()    // Window identifier 
 369                                                  ,NULL                     
// no control data 
 370                                                  ,NULL                     
// no Presentation parameters 
 374             if (GetFont().GetResourceHandle()) 
 377                     wxOS2SetFont( m_hStaticMin
 
 381                     wxOS2SetFont( m_hStaticMax
 
 385                     wxOS2SetFont( m_hStaticValue
 
 399     m_nThumbLength 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 401                                                ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
 406                                  ) + 4; // for bordersizes 
 410     vColour
.Set(wxString("BLACK")); 
 412     LONG                            lColor 
= (LONG
)vColour
.GetPixel(); 
 414     ::WinSetPresParam( m_hStaticMin
 
 419     ::WinSetPresParam( m_hStaticMax
 
 424     ::WinSetPresParam( m_hStaticValue
 
 429     ::WinSetPresParam( m_hWnd
 
 434     lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 435     ::WinSetPresParam( m_hStaticMin
 
 440     ::WinSetPresParam( m_hStaticMax
 
 445     ::WinSetPresParam( m_hStaticValue
 
 450     ::WinSetPresParam( m_hWnd
 
 455     vColour
.Set(wxString("BLUE")); 
 456     lColor 
= (LONG
)vColour
.GetPixel(); 
 457     ::WinSetPresParam( m_hWnd
 
 458                       ,PP_HILITEBACKGROUNDCOLOR
 
 464 } // end of wxSlider::Create 
 466 void wxSlider::DoSetSize( 
 476     int                             nWidth1  
= nWidth
; 
 477     int                             nHeight1 
= nHeight
; 
 480     int                             nCx
;     // slider,min,max sizes 
 488     // Adjust for OS/2's reverse coordinate system 
 490     wxWindowOS2
*                    pParent 
= (wxWindowOS2
*)GetParent(); 
 492     int                             nOS2Height 
= nHeight
; 
 499         int                         nOS2ParentHeight 
= GetOS2ParentHeight(pParent
); 
 501         nYOffset 
= nOS2ParentHeight 
- (nYOffset 
+ nOS2Height
); 
 503             nY1 
= nOS2ParentHeight 
- (nY1 
+ nOS2Height
); 
 509         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 510         nYOffset 
= vRect
.yTop 
- (nYOffset 
+ nOS2Height
); 
 512             nY1 
= vRect
.yTop 
- (nY1 
+ nOS2Height
); 
 514     m_nSizeFlags 
= nSizeFlags
; 
 516     GetPosition( &nCurrentX
 
 519     if (nX 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 521     if (nY 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 524     AdjustForParentClientOrigin( nX1
 
 528     wxGetCharSize( GetHWND() 
 534     if ((m_windowStyle 
& wxSL_VERTICAL
) != wxSL_VERTICAL
) 
 536         if (m_windowStyle 
& wxSL_LABELS 
) 
 541             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
); 
 542             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
 543             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
); 
 544             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
 548                 int              nNewWidth 
= (wxMax(nMinLen
, nMaxLen
)); 
 549                 int              nValueHeight 
= nCyf
; 
 551                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 554                                   ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 557                                   ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 559                 nXOffset 
+= nNewWidth 
+ nCx
; 
 561             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 564                               ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 567                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 569             nXOffset 
+= nMinLen 
+ nCx
; 
 571             int                  nSliderLength 
= nWidth1 
- nXOffset 
- nMaxLen 
- nCx
; 
 572             int                  nSliderHeight 
= nHeight1
; 
 574             if (nSliderHeight 
< 0) 
 578             // Slider must have a minimum/default length/height 
 580             if (nSliderLength 
< 100) 
 583             ::WinSetWindowPos( GetHwnd() 
 589                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 591             ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 592             ::WinSendMsg( GetHwnd() 
 594                          ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 597                          ,MPFROMLONG((ULONG
)(nSliderHeight
/2)) 
 599             nXOffset 
+= nSliderLength 
+ nCx
; 
 601             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 604                               ,(LONG
)nYOffset 
- (LONG
)(nCyf 
* 1.2) 
 607                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 614             // If we're prepared to use the existing size, then... 
 616             if (nWidth 
== -1 && nHeight 
== -1 && 
 617                 ((nSizeFlags 
& wxSIZE_AUTO
) != wxSIZE_AUTO
)) 
 627             ::WinSetWindowPos( GetHwnd() 
 633                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 639     // Now deal with a vertical slider 
 643         if (m_windowStyle 
& wxSL_LABELS 
) 
 648             ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
); 
 649             GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
 650             ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
); 
 651             GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont()); 
 654                 int              nNewWidth 
= wxMax(nMinLen
, nMaxLen
); 
 655                 int              nValueHeight 
= nCyf
; 
 657                 ::WinSetWindowPos( (HWND
)m_hStaticValue
 
 660                                   ,(LONG
)nYOffset 
+ nHeight
 
 663                                   ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 667             ::WinSetWindowPos( (HWND
)m_hStaticMin
 
 670                               ,(LONG
)nYOffset 
+ nHeight 
- nCyf
 
 673                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 677             int                  nSliderLength 
= nHeight1 
- (nUsedHeight 
+ (2 * nCy
)); 
 678             int                  nSliderWidth  
= nWidth1
; 
 680             if (nSliderWidth 
< 0) 
 684             // Slider must have a minimum/default length 
 686             if (nSliderLength 
< 100) 
 689             ::WinSetWindowPos( GetHwnd() 
 692                               ,(LONG
)nYOffset 
+ nCyf
 
 695                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 697             ::WinQueryWindowPos(GetHwnd(), GetSwp()); 
 698             ::WinSendMsg( GetHwnd() 
 700                          ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 703                          ,MPFROMLONG((ULONG
)(nSliderWidth
/2)) 
 705             nUsedHeight 
+= nSliderLength
; 
 706             ::WinSetWindowPos( (HWND
)m_hStaticMax
 
 709                               ,(LONG
)nYOffset 
- nCyf
 
 712                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 719             // If we're prepared to use the existing size, then... 
 721             if (nWidth 
== -1 && nHeight 
== -1 && 
 722                 ((nSizeFlags 
& wxSIZE_AUTO
) != wxSIZE_AUTO
)) 
 732             ::WinSetWindowPos( GetHwnd() 
 738                               ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 742 } // end of void wxSlider::DoSetSize 
 744 int wxSlider::GetLineSize() const 
 747 } // end of wxSlider::GetLineSize 
 749 int wxSlider::GetPageSize() const 
 752 } // end of wxSlider::GetPageSize 
 754 void wxSlider::GetPosition( 
 759     wxWindowOS2
*                    pParent 
= GetParent(); 
 766     wxFindMaxSize( GetHWND() 
 771         wxFindMaxSize( m_hStaticMin
 
 775         wxFindMaxSize( m_hStaticMax
 
 779         wxFindMaxSize( m_hStaticValue
 
 784     // Since we now have the absolute screen coords, 
 785     // if there's a parent we must subtract its top left corner 
 789     vPoint
.x 
= vRect
.xLeft
; 
 790     vPoint
.y 
= vRect
.yTop
; 
 796         ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
); 
 802     // We may be faking the client origin. 
 803     // So a window that's really at (0, 30) may appear 
 804     // (to wxWin apps) to be at (0, 0). 
 808         wxPoint                     
vPt(GetParent()->GetClientAreaOrigin()); 
 815 } // end of wxSlider::GetPosition 
 817 int wxSlider::GetSelEnd() const 
 820 } // end of wxSlider::GetSelEnd 
 822 int wxSlider::GetSelStart() const 
 825 } // end of wxSlider::GetSelStart 
 827 void wxSlider::DoGetSize( 
 835 } // end of wxSlider::DoGetSize 
 837 void wxSlider::GetSize( 
 849     wxFindMaxSize( GetHWND() 
 854         wxFindMaxSize( m_hStaticMin
 
 858         wxFindMaxSize( m_hStaticMax
 
 862         wxFindMaxSize( m_hStaticValue
 
 866         *pnWidth  
= vRect
.xRight 
- vRect
.xLeft
; 
 868         *pnHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 869 } // end of wxSlider::GetSize 
 871 int wxSlider::GetThumbLength() const 
 873     return m_nThumbLength
; 
 874 } // end of wxSlider::GetThumbLength 
 876 int wxSlider::GetValue() const 
 878     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 880                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 886     double                          dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
 888     int                             nPixelPos 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 890                                                                           ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
 
 896     nNewPos 
= (int)(nPixelPos
/dPixelToRange
); 
 897     if (nNewPos 
> (m_nRangeMax 
- m_nRangeMin
)/2) 
 900 } // end of wxSlider::GetValue 
 902 WXHBRUSH 
wxSlider::OnCtlColor( 
 911     return (wxControl::OnCtlColor( hDC
 
 919 } // end of wxSlider::OnCtlColor 
 921 bool wxSlider::OS2OnScroll( 
 922   int                               WXUNUSED(nOrientation
) 
 928     wxEventType                     eScrollEvent 
= wxEVT_NULL
; 
 933             if (m_windowStyle 
& wxSL_TOP
) 
 934                 eScrollEvent 
= wxEVT_SCROLL_TOP
; 
 935             else if (m_windowStyle 
& wxSL_BOTTOM
) 
 936                 eScrollEvent 
= wxEVT_SCROLL_BOTTOM
; 
 939         case SLN_SLIDERTRACK
: 
 940             eScrollEvent 
= wxEVT_SCROLL_THUMBTRACK
; 
 947     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 949                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
 955     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
 957     int                             nPixelPos 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
 959                                                                           ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
 
 965     nNewPos 
= (int)(nPixelPos
/m_dPixelToRange
); 
 966     if (nNewPos 
> (m_nRangeMax 
- m_nRangeMin
)/2) 
 968     if ((nNewPos 
< GetMin()) || (nNewPos 
> GetMax())) 
 971         // Out of range - but we did process it 
 977     wxScrollEvent                   
vEvent( eScrollEvent
 
 981     vEvent
.SetPosition(nNewPos
); 
 982     vEvent
.SetEventObject(this); 
 983     GetEventHandler()->ProcessEvent(vEvent
); 
 985     wxCommandEvent                  
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
 
 989     vCevent
.SetInt(nNewPos
); 
 990     vCevent
.SetEventObject(this); 
 991     return (GetEventHandler()->ProcessEvent(vCevent
)); 
 992 } // end of wxSlider::OS2OnScroll 
 994 void wxSlider::SetLineSize( 
 998     m_nLineSize 
= nLineSize
; 
 999 } // end of wxSlider::SetLineSize 
1002 void wxSlider::SetPageSize( 
1006     m_nPageSize 
= nPageSize
; 
1007 } // end of wxSlider::SetPageSize 
1009 void wxSlider::SetRange( 
1016     m_nRangeMin 
= nMinValue
; 
1017     m_nRangeMax 
= nMaxValue
; 
1019     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1020                                                                             ,SLM_QUERYSLIDERINFO
 
1021                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
1027     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
1030         wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
); 
1031         ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
); 
1036         wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
); 
1037         ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
); 
1039 } // end of wxSlider::SetRange 
1041 void wxSlider::SetSelection( 
1042   int                               WXUNUSED(nMinPos
) 
1043 , int                               WXUNUSED(nMaxPos
) 
1046 } // end of wxSlider::SetSelection 
1048 void wxSlider::SetThumbLength( 
1054     m_nThumbLength 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1055                                                ,SLM_QUERYSLIDERINFO
 
1056                                                ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1061                                  ) + 4; // for bordersizes 
1062     nBreadth 
= SHORT2FROMMR(::WinSendMsg( GetHwnd() 
1063                                          ,SLM_QUERYSLIDERINFO
 
1064                                          ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1070     ::WinSendMsg( GetHwnd() 
1072                  ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
 
1075                  ,MPFROM2SHORT(nLen
, nBreadth
) 
1077     m_nThumbLength 
= nLen 
+ 4; // Borders 
1078 } // end of wxSlider::SetThumbLength 
1080 void wxSlider::SetTick( 
1084     nTickPos 
= (int)(nTickPos 
* m_dPixelToRange
); 
1085     ::WinSendMsg( GetHwnd() 
1087                  ,MPFROMSHORT(nTickPos
) 
1090 } // end of wxSlider::SetTick 
1092 // For trackbars only 
1093 void wxSlider::SetTickFreq( 
1099     WNDPARAMS                       vWndParams
; 
1103     vSlData
.cbSize 
= sizeof(SLDCDATA
); 
1104     if (m_windowStyle 
& wxSL_AUTOTICKS
) 
1106         vSlData
.usScale1Spacing 
= 0; 
1107         vSlData
.usScale2Spacing 
= 0; 
1109     vSlData
.usScale1Increments 
= (m_nRangeMax 
- m_nRangeMin
)/n
; 
1110     vSlData
.usScale2Increments 
= (m_nRangeMax 
- m_nRangeMin
)/n
; 
1112     vWndParams
.fsStatus 
= WPM_CTLDATA
; 
1113     vWndParams
.cchText  
= 0L; 
1114     vWndParams
.pszText  
= NULL
; 
1115     vWndParams
.cbPresParams 
= 0L; 
1116     vWndParams
.pPresParams 
= NULL
; 
1117     vWndParams
.cbCtlData 
= vSlData
.cbSize
; 
1118     vWndParams
.pCtlData 
= (PVOID
)&vSlData
; 
1119     ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0); 
1120     for (i 
= 1; i 
< (m_nRangeMax 
- m_nRangeMin
)/n
; i
++) 
1122         nPixelPos 
= (int)(i 
* n 
* m_dPixelToRange
); 
1123         ::WinSendMsg( GetHwnd() 
1125                      ,MPFROMSHORT(nPixelPos
) 
1129 } // end of wxSlider::SetTickFreq 
1131 void wxSlider::SetValue( 
1135     int                             nPixelRange 
= SHORT1FROMMR(::WinSendMsg( GetHwnd() 
1136                                                                             ,SLM_QUERYSLIDERINFO
 
1137                                                                             ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
 
1143     m_dPixelToRange 
= (double)(nPixelRange 
- m_nThumbLength
)/(double)(m_nRangeMax 
- m_nRangeMin
); 
1144     int                             nNewPos 
= (int)(nValue 
* m_dPixelToRange
); 
1146     ::WinSendMsg( GetHwnd() 
1148                  ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
 
1155         wxSprintf(wxBuffer
, wxT("%d"), nValue
); 
1156         ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
); 
1158 } // end of wxSlider::SetValue 
1160 bool wxSlider::Show( 
1164     wxWindowOS2::Show(bShow
); 
1166         ::WinShowWindow((HWND
)m_hStaticValue
, bShow
); 
1168         ::WinShowWindow((HWND
)m_hStaticMin
, bShow
); 
1170         ::WinShowWindow((HWND
)m_hStaticMax
, bShow
); 
1172 } // end of wxSlider::Show