]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/slider.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/slider.cpp
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
22 #include "wx/scrolwin.h"
27 #include "wx/slider.h"
28 #include "wx/os2/private.h"
40 } // end of wxSlider::wxSlider
45 ::WinDestroyWindow((HWND
)m_hStaticMin
);
47 ::WinDestroyWindow((HWND
)m_hStaticMax
);
49 ::WinDestroyWindow((HWND
)m_hStaticValue
);
50 } // end of wxSlider::~wxSlider
52 void wxSlider::AdjustSubControls( int nX
,
56 int WXUNUSED(nSizeFlags
) )
60 int nCx
; // slider,min,max sizes
64 wxFont vFont
= this->GetFont();
66 wxGetCharSize( GetHWND()
72 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
74 if (m_windowStyle
& wxSL_LABELS
)
79 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
80 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
82 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
83 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
87 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
88 int nValueHeight
= nCyf
;
90 ::WinSetWindowPos( (HWND
)m_hStaticValue
92 ,(LONG
)nXOffset
- (nNewWidth
+ nCx
+ nMinLen
+ nCx
)
99 ::WinSetWindowPos( (HWND
)m_hStaticMin
101 ,(LONG
)nXOffset
- (nMinLen
+ nCx
)
107 nXOffset
+= nWidth
+ nCx
;
109 ::WinSetWindowPos( (HWND
)m_hStaticMax
115 ,SWP_ZORDER
| SWP_SHOW
122 // Now deal with a vertical slider
125 if (m_windowStyle
& wxSL_LABELS
)
130 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
131 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
133 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
134 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
138 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
140 ::WinSetWindowPos( (HWND
)m_hStaticValue
143 ,(LONG
)nYOffset
+ nHeight
+ nCyf
149 ::WinSetWindowPos( (HWND
)m_hStaticMax
152 ,(LONG
)nYOffset
+ nHeight
157 ::WinSetWindowPos( (HWND
)m_hStaticMin
160 ,(LONG
)nYOffset
- nCyf
167 } // end of wxSlider::AdjustSubControls
169 void wxSlider::ClearSel()
171 } // end of wxSlider::ClearSel
173 void wxSlider::ClearTicks()
175 } // end of wxSlider::ClearTicks
177 void wxSlider::Command (
178 wxCommandEvent
& rEvent
181 SetValue(rEvent
.GetInt());
182 ProcessCommand(rEvent
);
183 } // end of wxSlider::Command
185 bool wxSlider::ContainsHWND(
189 return ( hWnd
== GetStaticMin() ||
190 hWnd
== GetStaticMax() ||
191 hWnd
== GetEditValue()
193 } // end of wxSlider::ContainsHWND
195 bool wxSlider::Create(
201 , const wxPoint
& rPos
202 , const wxSize
& rSize
204 , const wxValidator
& rValidator
205 , const wxString
& rsName
210 int nWidth
= rSize
.x
;
211 int nHeight
= rSize
.y
;
217 SetValidator(rValidator
);
220 pParent
->AddChild(this);
221 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
222 SetForegroundColour(pParent
->GetForegroundColour()) ;
229 m_windowStyle
= lStyle
;
233 m_windowId
= (int)NewControlId();
237 if (m_windowStyle
& wxCLIP_SIBLINGS
)
238 lMsStyle
|= WS_CLIPSIBLINGS
;
240 if (m_windowStyle
& wxSL_LABELS
)
242 lMsStyle
|= WS_VISIBLE
| SS_TEXT
| DT_VCENTER
;
244 m_hStaticValue
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
245 ,WC_STATIC
// Window class
246 ,(PSZ
)NULL
// Initial Text
247 ,(ULONG
)lMsStyle
// Style flags
248 ,0L, 0L, 0L, 0L // Origin -- 0 size
249 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
250 ,HWND_TOP
// initial z position
251 ,(ULONG
)NewControlId() // Window identifier
252 ,NULL
// no control data
253 ,NULL
// no Presentation parameters
257 // Now create min static control
259 wxSprintf(wxBuffer
, wxT("%d"), nMinValue
);
260 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
261 if (m_windowStyle
& wxCLIP_SIBLINGS
)
262 lWstyle
|= WS_CLIPSIBLINGS
;
264 m_hStaticMin
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
265 ,WC_STATIC
// Window class
266 ,(PSZ
)wxBuffer
// Initial Text
267 ,(ULONG
)lWstyle
// Style flags
268 ,0L, 0L, 0L, 0L // Origin -- 0 size
269 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
270 ,HWND_TOP
// initial z position
271 ,(ULONG
)NewControlId() // Window identifier
272 ,NULL
// no control data
273 ,NULL
// no Presentation parameters
280 vSlData
.cbSize
= sizeof(SLDCDATA
);
281 if (m_windowStyle
& wxSL_VERTICAL
)
282 lMsStyle
= SLS_VERTICAL
| SLS_HOMEBOTTOM
| WS_VISIBLE
| WS_TABSTOP
;
284 lMsStyle
= SLS_HORIZONTAL
| SLS_HOMELEFT
| WS_VISIBLE
| WS_TABSTOP
;
286 if (m_windowStyle
& wxCLIP_SIBLINGS
)
287 lMsStyle
|= WS_CLIPSIBLINGS
;
289 if (m_windowStyle
& wxSL_AUTOTICKS
)
291 vSlData
.usScale1Spacing
= 0;
292 vSlData
.usScale2Spacing
= 0;
295 if (m_windowStyle
& wxSL_LEFT
)
296 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left
297 else if (m_windowStyle
& wxSL_RIGHT
)
298 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right
299 else if (m_windowStyle
& wxSL_TOP
)
300 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top
301 else if (m_windowStyle
& wxSL_BOTTOM
)
302 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom
303 else if ( m_windowStyle
& wxSL_BOTH
)
304 lMsStyle
|= SLS_PRIMARYSCALE1
| SLS_PRIMARYSCALE2
;
306 lMsStyle
|= SLS_PRIMARYSCALE2
;
307 lMsStyle
|= SLS_RIBBONSTRIP
;
309 m_nPageSize
= ((nMaxValue
- nMinValue
)/10);
310 vSlData
.usScale1Increments
= (USHORT
)m_nPageSize
;
311 vSlData
.usScale2Increments
= (USHORT
)m_nPageSize
;
313 HWND hScrollBar
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
314 ,WC_SLIDER
// Window class
315 ,(PSZ
)wxBuffer
// Initial Text
316 ,(ULONG
)lMsStyle
// Style flags
317 ,0L, 0L, 0L, 0L // Origin -- 0 size
318 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
319 ,HWND_BOTTOM
// initial z position
320 ,(HMENU
)m_windowId
// Window identifier
321 ,&vSlData
// Slider control data
322 ,NULL
// no Presentation parameters
324 m_nRangeMax
= nMaxValue
;
325 m_nRangeMin
= nMinValue
;
328 // Set the size of the ticks ... default to 6 pixels
330 ::WinSendMsg( hScrollBar
332 ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12)
336 // Set the position to the initial value
338 ::WinSendMsg( hScrollBar
340 ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
344 m_hWnd
= (WXHWND
)hScrollBar
;
345 SubclassWin(GetHWND());
346 ::WinSetWindowText((HWND
)m_hWnd
, "");
348 SetFont(*wxSMALL_FONT
);
349 if (m_windowStyle
& wxSL_LABELS
)
352 // Finally, create max value static item
354 wxSprintf(wxBuffer
, wxT("%d"), nMaxValue
);
355 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
356 if (m_windowStyle
& wxCLIP_SIBLINGS
)
357 lMsStyle
|= WS_CLIPSIBLINGS
;
359 m_hStaticMax
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
360 ,WC_STATIC
// Window class
361 ,(PSZ
)wxBuffer
// Initial Text
362 ,(ULONG
)lWstyle
// Style flags
363 ,0L, 0L, 0L, 0L // Origin -- 0 size
364 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
365 ,HWND_TOP
// initial z position
366 ,(ULONG
)NewControlId() // Window identifier
367 ,NULL
// no control data
368 ,NULL
// no Presentation parameters
370 if (GetFont().IsOk())
372 if (GetFont().GetResourceHandle())
375 wxOS2SetFont( m_hStaticMin
379 wxOS2SetFont( m_hStaticMax
383 wxOS2SetFont( m_hStaticValue
397 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
399 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
404 ) + 4; // for bordersizes
406 wxColour
vColour(*wxBLACK
);
408 LONG lColor
= (LONG
)vColour
.GetPixel();
410 ::WinSetPresParam( m_hStaticMin
415 ::WinSetPresParam( m_hStaticMax
420 ::WinSetPresParam( m_hStaticValue
425 ::WinSetPresParam( m_hWnd
430 lColor
= (LONG
)m_backgroundColour
.GetPixel();
431 ::WinSetPresParam( m_hStaticMin
436 ::WinSetPresParam( m_hStaticMax
441 ::WinSetPresParam( m_hStaticValue
446 ::WinSetPresParam( m_hWnd
451 vColour
.Set(wxString(wxT("BLUE")));
452 lColor
= (LONG
)vColour
.GetPixel();
453 ::WinSetPresParam( m_hWnd
454 ,PP_HILITEBACKGROUNDCOLOR
460 } // end of wxSlider::Create
462 void wxSlider::DoSetSize( int nX
,
470 int nWidth1
= nWidth
;
471 int nHeight1
= nHeight
;
474 int nCx
; // slider,min,max sizes
480 wxFont vFont
= this->GetFont();
483 // Adjust for OS/2's reverse coordinate system
485 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
487 int nOS2Height
= nHeight
;
491 CacheBestSize(wxSize(nWidth
,nOS2Height
));
495 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
497 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
498 if (nY
!= wxDefaultCoord
)
499 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
505 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
506 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
507 if (nY
!= wxDefaultCoord
)
508 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
510 m_nSizeFlags
= nSizeFlags
;
512 GetPosition( &nCurrentX
, &nCurrentY
);
513 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
515 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
518 AdjustForParentClientOrigin( nX1
522 wxGetCharSize( GetHWND()
528 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
530 if (m_windowStyle
& wxSL_LABELS
)
535 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
536 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
537 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
538 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
542 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
543 int nValueHeight
= nCyf
;
545 ::WinSetWindowPos( (HWND
)m_hStaticValue
548 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
551 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
553 nXOffset
+= nNewWidth
+ nCx
;
555 ::WinSetWindowPos( (HWND
)m_hStaticMin
558 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
561 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
563 nXOffset
+= nMinLen
+ nCx
;
565 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
566 int nSliderHeight
= nHeight1
;
568 if (nSliderHeight
< 0)
572 // Slider must have a minimum/default length/height
574 if (nSliderLength
< 100)
577 ::WinSetWindowPos( GetHwnd()
583 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
585 ::WinQueryWindowPos(GetHwnd(), GetSwp());
586 ::WinSendMsg( GetHwnd()
588 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
591 ,MPFROMLONG((ULONG
)(nSliderHeight
/2))
593 nXOffset
+= nSliderLength
+ nCx
;
595 ::WinSetWindowPos( (HWND
)m_hStaticMax
598 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
601 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
608 // If we're prepared to use the existing size, then...
610 if (nWidth
== -1 && nHeight
== -1 &&
611 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
621 ::WinSetWindowPos( GetHwnd()
627 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
633 // Now deal with a vertical slider
637 if (m_windowStyle
& wxSL_LABELS
)
642 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
643 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
644 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
645 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
648 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
649 int nValueHeight
= nCyf
;
651 ::WinSetWindowPos( (HWND
)m_hStaticValue
654 ,(LONG
)nYOffset
+ nHeight
657 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
661 ::WinSetWindowPos( (HWND
)m_hStaticMin
664 ,(LONG
)nYOffset
+ nHeight
- nCyf
667 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
671 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
672 int nSliderWidth
= nWidth1
;
674 if (nSliderWidth
< 0)
678 // Slider must have a minimum/default length
680 if (nSliderLength
< 100)
683 ::WinSetWindowPos( GetHwnd()
686 ,(LONG
)nYOffset
+ nCyf
689 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
691 ::WinQueryWindowPos(GetHwnd(), GetSwp());
692 ::WinSendMsg( GetHwnd()
694 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
697 ,MPFROMLONG((ULONG
)(nSliderWidth
/2))
699 nUsedHeight
+= nSliderLength
;
700 ::WinSetWindowPos( (HWND
)m_hStaticMax
703 ,(LONG
)nYOffset
- nCyf
706 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
713 // If we're prepared to use the existing size, then...
715 if (nWidth
== -1 && nHeight
== -1 &&
716 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
726 ::WinSetWindowPos( GetHwnd()
732 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
736 } // end of void wxSlider::DoSetSize
738 int wxSlider::GetLineSize() const
741 } // end of wxSlider::GetLineSize
743 int wxSlider::GetPageSize() const
746 } // end of wxSlider::GetPageSize
748 void wxSlider::GetPosition(
753 wxWindowOS2
* pParent
= GetParent();
760 wxFindMaxSize( GetHWND()
765 wxFindMaxSize( m_hStaticMin
769 wxFindMaxSize( m_hStaticMax
773 wxFindMaxSize( m_hStaticValue
778 // Since we now have the absolute screen coords,
779 // if there's a parent we must subtract its top left corner
783 vPoint
.x
= vRect
.xLeft
;
784 vPoint
.y
= vRect
.yTop
;
790 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
796 // We may be faking the client origin.
797 // So a window that's really at (0, 30) may appear
798 // (to wxWin apps) to be at (0, 0).
802 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
811 } // end of wxSlider::GetPosition
813 int wxSlider::GetSelEnd() const
816 } // end of wxSlider::GetSelEnd
818 int wxSlider::GetSelStart() const
821 } // end of wxSlider::GetSelStart
823 void wxSlider::DoGetSize(
831 } // end of wxSlider::DoGetSize
833 void wxSlider::GetSize(
845 wxFindMaxSize( GetHWND()
850 wxFindMaxSize( m_hStaticMin
854 wxFindMaxSize( m_hStaticMax
858 wxFindMaxSize( m_hStaticValue
862 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
864 *pnHeight
= vRect
.yTop
- vRect
.yBottom
;
865 } // end of wxSlider::GetSize
867 int wxSlider::GetThumbLength() const
869 return m_nThumbLength
;
870 } // end of wxSlider::GetThumbLength
872 int wxSlider::GetValue() const
874 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
876 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
882 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
883 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
885 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
891 int nNewPos
= (int)(nPixelPos
/dPixelToRange
);
892 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
895 } // end of wxSlider::GetValue
897 WXHBRUSH
wxSlider::OnCtlColor(
906 return (wxControl::OnCtlColor( hDC
914 } // end of wxSlider::OnCtlColor
916 bool wxSlider::OS2OnScroll( int WXUNUSED(nOrientation
),
918 WXWORD
WXUNUSED(wPos
),
919 WXHWND
WXUNUSED(hControl
) )
921 wxEventType eScrollEvent
= wxEVT_NULL
;
926 if (m_windowStyle
& wxSL_TOP
)
927 eScrollEvent
= wxEVT_SCROLL_TOP
;
928 else if (m_windowStyle
& wxSL_BOTTOM
)
929 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
932 case SLN_SLIDERTRACK
:
933 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
940 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
941 , SLM_QUERYSLIDERINFO
942 , MPFROM2SHORT( SMA_SHAFTDIMENSIONS
, SMA_RANGEVALUE
)
946 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
948 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
949 , SLM_QUERYSLIDERINFO
950 , MPFROM2SHORT( SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
955 nNewPos
= (int)(nPixelPos
/m_dPixelToRange
);
956 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
958 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
961 // Out of range - but we did process it
967 wxScrollEvent
vEvent( eScrollEvent
, m_windowId
);
969 vEvent
.SetPosition(nNewPos
);
970 vEvent
.SetEventObject(this);
971 HandleWindowEvent(vEvent
);
973 wxCommandEvent
vCevent( wxEVT_SLIDER
, GetId() );
975 vCevent
.SetInt(nNewPos
);
976 vCevent
.SetEventObject(this);
977 return (HandleWindowEvent(vCevent
));
978 } // end of wxSlider::OS2OnScroll
980 void wxSlider::SetLineSize( int nLineSize
)
982 m_nLineSize
= nLineSize
;
983 } // end of wxSlider::SetLineSize
986 void wxSlider::SetPageSize( int nPageSize
)
988 m_nPageSize
= nPageSize
;
989 } // end of wxSlider::SetPageSize
991 void wxSlider::SetRange(
998 m_nRangeMin
= nMinValue
;
999 m_nRangeMax
= nMaxValue
;
1001 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1002 ,SLM_QUERYSLIDERINFO
1003 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1009 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1012 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1013 ::WinSetWindowText((HWND
)m_hStaticMin
, (PSZ
)zBuf
);
1018 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1019 ::WinSetWindowText((HWND
)m_hStaticMax
, (PSZ
)zBuf
);
1021 } // end of wxSlider::SetRange
1023 void wxSlider::SetSelection(
1024 int WXUNUSED(nMinPos
)
1025 , int WXUNUSED(nMaxPos
)
1028 } // end of wxSlider::SetSelection
1030 void wxSlider::SetThumbLength(
1036 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1037 ,SLM_QUERYSLIDERINFO
1038 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1043 ) + 4; // for bordersizes
1044 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1045 ,SLM_QUERYSLIDERINFO
1046 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1052 ::WinSendMsg( GetHwnd()
1054 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1057 ,MPFROM2SHORT(nLen
, nBreadth
)
1059 m_nThumbLength
= nLen
+ 4; // Borders
1060 } // end of wxSlider::SetThumbLength
1062 void wxSlider::SetTick(
1066 nTickPos
= (int)(nTickPos
* m_dPixelToRange
);
1067 ::WinSendMsg( GetHwnd()
1069 ,MPFROMSHORT(nTickPos
)
1072 } // end of wxSlider::SetTick
1074 // For trackbars only
1075 void wxSlider::DoSetTickFreq( int n
)
1078 WNDPARAMS vWndParams
;
1082 vSlData
.cbSize
= sizeof(SLDCDATA
);
1083 if (m_windowStyle
& wxSL_AUTOTICKS
)
1085 vSlData
.usScale1Spacing
= 0;
1086 vSlData
.usScale2Spacing
= 0;
1088 vSlData
.usScale1Increments
= (USHORT
)((m_nRangeMax
- m_nRangeMin
)/n
);
1089 vSlData
.usScale2Increments
= (USHORT
)((m_nRangeMax
- m_nRangeMin
)/n
);
1091 vWndParams
.fsStatus
= WPM_CTLDATA
;
1092 vWndParams
.cchText
= 0L;
1093 vWndParams
.pszText
= NULL
;
1094 vWndParams
.cbPresParams
= 0L;
1095 vWndParams
.pPresParams
= NULL
;
1096 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1097 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1098 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1099 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1101 nPixelPos
= (int)(i
* n
* m_dPixelToRange
);
1102 ::WinSendMsg( GetHwnd()
1104 ,MPFROMSHORT(nPixelPos
)
1108 } // end of wxSlider::SetTickFreq
1110 void wxSlider::SetValue(
1114 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1115 ,SLM_QUERYSLIDERINFO
1116 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1122 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1123 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1125 ::WinSendMsg( GetHwnd()
1127 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1134 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1135 ::WinSetWindowText((HWND
)m_hStaticValue
, (PSZ
)wxBuffer
);
1137 } // end of wxSlider::SetValue
1139 bool wxSlider::Show(
1143 wxWindowOS2::Show(bShow
);
1145 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1147 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1149 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1151 } // end of wxSlider::Show
1153 #endif // wxUSE_SLIDER