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(
64 int nCx
; // slider,min,max sizes
69 wxGetCharSize( GetHWND()
75 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
77 if (m_windowStyle
& wxSL_LABELS
)
82 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
83 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
85 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
86 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
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, zBuf
);
134 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
136 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
137 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
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
208 , const wxValidator
& rValidator
210 , const wxString
& rsName
215 int nWidth
= rSize
.x
;
216 int nHeight
= rSize
.y
;
222 SetValidator(rValidator
);
225 pParent
->AddChild(this);
226 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
227 SetForegroundColour(pParent
->GetForegroundColour()) ;
234 m_windowStyle
= lStyle
;
238 m_windowId
= (int)NewControlId();
242 if (m_windowStyle
& wxCLIP_SIBLINGS
)
243 lMsStyle
|= WS_CLIPSIBLINGS
;
245 if (m_windowStyle
& wxSL_LABELS
)
247 lMsStyle
|= WS_VISIBLE
| SS_TEXT
| DT_VCENTER
;
249 m_hStaticValue
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
250 ,WC_STATIC
// Window class
251 ,(PSZ
)NULL
// Initial Text
252 ,(ULONG
)lMsStyle
// Style flags
253 ,0L, 0L, 0L, 0L // Origin -- 0 size
254 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
255 ,HWND_TOP
// initial z position
256 ,(ULONG
)NewControlId() // Window identifier
257 ,NULL
// no control data
258 ,NULL
// no Presentation parameters
262 // Now create min static control
264 sprintf(wxBuffer
, "%d", nMinValue
);
265 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
266 if (m_windowStyle
& wxCLIP_SIBLINGS
)
267 lWstyle
|= WS_CLIPSIBLINGS
;
269 m_hStaticMin
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
270 ,WC_STATIC
// Window class
271 ,(PSZ
)wxBuffer
// Initial Text
272 ,(ULONG
)lWstyle
// Style flags
273 ,0L, 0L, 0L, 0L // Origin -- 0 size
274 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
275 ,HWND_TOP
// initial z position
276 ,(ULONG
)NewControlId() // Window identifier
277 ,NULL
// no control data
278 ,NULL
// no Presentation parameters
285 vSlData
.cbSize
= sizeof(SLDCDATA
);
286 if (m_windowStyle
& wxSL_VERTICAL
)
287 lMsStyle
= SLS_VERTICAL
| SLS_HOMEBOTTOM
| WS_VISIBLE
| WS_TABSTOP
;
289 lMsStyle
= SLS_HORIZONTAL
| SLS_HOMELEFT
| WS_VISIBLE
| WS_TABSTOP
;
291 if (m_windowStyle
& wxCLIP_SIBLINGS
)
292 lMsStyle
|= WS_CLIPSIBLINGS
;
294 if (m_windowStyle
& wxSL_AUTOTICKS
)
296 vSlData
.usScale1Spacing
= 0;
297 vSlData
.usScale2Spacing
= 0;
300 if (m_windowStyle
& wxSL_LEFT
)
301 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left
302 else if (m_windowStyle
& wxSL_RIGHT
)
303 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right
304 else if (m_windowStyle
& wxSL_TOP
)
305 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top
306 else if (m_windowStyle
& wxSL_BOTTOM
)
307 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom
308 else if ( m_windowStyle
& wxSL_BOTH
)
309 lMsStyle
|= SLS_PRIMARYSCALE1
| SLS_PRIMARYSCALE2
;
311 lMsStyle
|= SLS_PRIMARYSCALE2
;
312 lMsStyle
|= SLS_RIBBONSTRIP
;
314 m_nPageSize
= ((nMaxValue
- nMinValue
)/10);
315 vSlData
.usScale1Increments
= m_nPageSize
;
316 vSlData
.usScale2Increments
= m_nPageSize
;
318 HWND hScrollBar
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
319 ,WC_SLIDER
// Window class
320 ,(PSZ
)wxBuffer
// Initial Text
321 ,(ULONG
)lMsStyle
// Style flags
322 ,0L, 0L, 0L, 0L // Origin -- 0 size
323 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
324 ,HWND_TOP
// initial z position
325 ,(HMENU
)m_windowId
// Window identifier
326 ,&vSlData
// Slider control data
327 ,NULL
// no Presentation parameters
329 m_nRangeMax
= nMaxValue
;
330 m_nRangeMin
= nMinValue
;
333 // Set the size of the ticks ... default to 6 pixels
335 ::WinSendMsg( hScrollBar
337 ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12)
341 // Set the position to the initial value
343 ::WinSendMsg( hScrollBar
345 ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
349 m_hWnd
= (WXHWND
)hScrollBar
;
350 SubclassWin(GetHWND());
351 ::WinSetWindowText((HWND
)m_hWnd
, "");
353 SetFont(*wxSMALL_FONT
);
354 if (m_windowStyle
& wxSL_LABELS
)
357 // Finally, create max value static item
359 sprintf(wxBuffer
, "%d", nMaxValue
);
360 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
361 if (m_windowStyle
& wxCLIP_SIBLINGS
)
362 lMsStyle
|= WS_CLIPSIBLINGS
;
364 m_hStaticMax
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
365 ,WC_STATIC
// Window class
366 ,(PSZ
)wxBuffer
// Initial Text
367 ,(ULONG
)lWstyle
// Style flags
368 ,0L, 0L, 0L, 0L // Origin -- 0 size
369 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
370 ,HWND_TOP
// initial z position
371 ,(ULONG
)NewControlId() // Window identifier
372 ,NULL
// no control data
373 ,NULL
// no Presentation parameters
377 if (GetFont().GetResourceHandle())
380 wxOS2SetFont( m_hStaticMin
384 wxOS2SetFont( m_hStaticMax
388 wxOS2SetFont( m_hStaticValue
402 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
404 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
409 ) + 4; // for bordersizes
413 vColour
.Set(wxString("BLACK"));
415 LONG lColor
= (LONG
)vColour
.GetPixel();
417 ::WinSetPresParam( m_hStaticMin
422 ::WinSetPresParam( m_hStaticMax
427 ::WinSetPresParam( m_hStaticValue
432 ::WinSetPresParam( m_hWnd
437 lColor
= (LONG
)m_backgroundColour
.GetPixel();
438 ::WinSetPresParam( m_hStaticMin
443 ::WinSetPresParam( m_hStaticMax
448 ::WinSetPresParam( m_hStaticValue
453 ::WinSetPresParam( m_hWnd
458 vColour
.Set(wxString("BLUE"));
459 lColor
= (LONG
)vColour
.GetPixel();
460 ::WinSetPresParam( m_hWnd
461 ,PP_HILITEBACKGROUNDCOLOR
467 } // end of wxSlider::Create
469 void wxSlider::DoSetSize(
479 int nWidth1
= nWidth
;
480 int nHeight1
= nHeight
;
483 int nCx
; // slider,min,max sizes
491 // Adjust for OS/2's reverse coordinate system
493 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
495 int nOS2Height
= nHeight
;
502 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
504 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
506 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
512 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
513 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
515 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
517 m_nSizeFlags
= nSizeFlags
;
519 GetPosition( &nCurrentX
522 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
524 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
527 AdjustForParentClientOrigin( nX1
531 wxGetCharSize( GetHWND()
537 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
539 if (m_windowStyle
& wxSL_LABELS
)
544 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
545 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
546 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
547 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
551 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
552 int nValueHeight
= nCyf
;
554 ::WinSetWindowPos( (HWND
)m_hStaticValue
557 ,(LONG
)nYOffset
- (nCyf
* 1.2)
560 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
562 nXOffset
+= nNewWidth
+ nCx
;
564 ::WinSetWindowPos( (HWND
)m_hStaticMin
567 ,(LONG
)nYOffset
- (nCyf
* 1.2)
570 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
572 nXOffset
+= nMinLen
+ nCx
;
574 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
575 int nSliderHeight
= nHeight1
;
577 if (nSliderHeight
< 0)
581 // Slider must have a minimum/default length/height
583 if (nSliderLength
< 100)
586 ::WinSetWindowPos( GetHwnd()
592 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
594 ::WinQueryWindowPos(GetHwnd(), GetSwp());
595 ::WinSendMsg( GetHwnd()
597 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
600 ,MPFROMLONG((ULONG
)(nSliderHeight
/2))
602 nXOffset
+= nSliderLength
+ nCx
;
604 ::WinSetWindowPos( (HWND
)m_hStaticMax
607 ,(LONG
)nYOffset
- (nCyf
* 1.2)
610 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
617 // If we're prepared to use the existing size, then...
619 if (nWidth
== -1 && nHeight
== -1 &&
620 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
630 ::WinSetWindowPos( GetHwnd()
636 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
642 // Now deal with a vertical slider
646 if (m_windowStyle
& wxSL_LABELS
)
651 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
652 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
653 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
654 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
657 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
658 int nValueHeight
= nCyf
;
661 // The height needs to be a bit bigger under Win95 if using native
664 ::WinSetWindowPos( (HWND
)m_hStaticValue
667 ,(LONG
)nYOffset
+ nHeight
670 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
674 ::WinSetWindowPos( (HWND
)m_hStaticMin
677 ,(LONG
)nYOffset
+ nHeight
- nCyf
680 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
684 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
685 int nSliderWidth
= nWidth1
;
687 if (nSliderWidth
< 0)
691 // Slider must have a minimum/default length
693 if (nSliderLength
< 100)
696 ::WinSetWindowPos( GetHwnd()
699 ,(LONG
)nYOffset
+ nCyf
702 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
704 ::WinQueryWindowPos(GetHwnd(), GetSwp());
705 ::WinSendMsg( GetHwnd()
707 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
710 ,MPFROMLONG((ULONG
)(nSliderWidth
/2))
712 nUsedHeight
+= nSliderLength
;
713 ::WinSetWindowPos( (HWND
)m_hStaticMax
716 ,(LONG
)nYOffset
- nCyf
719 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
726 // If we're prepared to use the existing size, then...
728 if (nWidth
== -1 && nHeight
== -1 &&
729 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
739 ::WinSetWindowPos( GetHwnd()
745 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
749 } // end of void wxSlider::DoSetSize
751 int wxSlider::GetLineSize() const
754 } // end of wxSlider::GetLineSize
756 int wxSlider::GetPageSize() const
759 } // end of wxSlider::GetPageSize
761 void wxSlider::GetPosition(
766 wxWindowOS2
* pParent
= GetParent();
773 wxFindMaxSize( GetHWND()
778 wxFindMaxSize( m_hStaticMin
782 wxFindMaxSize( m_hStaticMax
786 wxFindMaxSize( m_hStaticValue
791 // Since we now have the absolute screen coords,
792 // if there's a parent we must subtract its top left corner
796 vPoint
.x
= vRect
.xLeft
;
797 vPoint
.y
= vRect
.yTop
;
803 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
809 // We may be faking the client origin.
810 // So a window that's really at (0, 30) may appear
811 // (to wxWin apps) to be at (0, 0).
815 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
822 } // end of wxSlider::GetPosition
824 int wxSlider::GetSelEnd() const
827 } // end of wxSlider::GetSelEnd
829 int wxSlider::GetSelStart() const
832 } // end of wxSlider::GetSelStart
834 void wxSlider::DoGetSize(
842 } // end of wxSlider::DoGetSize
844 void wxSlider::GetSize(
856 wxFindMaxSize( GetHWND()
861 wxFindMaxSize( m_hStaticMin
865 wxFindMaxSize( m_hStaticMax
869 wxFindMaxSize( m_hStaticValue
872 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
873 *pnHeight
= vRect
.yBottom
- vRect
.yTop
;
874 } // end of wxSlider::GetSize
876 int wxSlider::GetThumbLength() const
878 return m_nThumbLength
;
879 } // end of wxSlider::GetThumbLength
881 int wxSlider::GetValue() const
883 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
885 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
891 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
893 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
895 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
901 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
902 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
905 } // end of wxSlider::GetValue
907 WXHBRUSH
wxSlider::OnCtlColor(
916 return (wxControl::OnCtlColor( hDC
924 } // end of wxSlider::OnCtlColor
926 bool wxSlider::OS2OnScroll(
927 int WXUNUSED(nOrientation
)
933 wxEventType eScrollEvent
= wxEVT_NULL
;
938 if (m_windowStyle
& wxSL_TOP
)
939 eScrollEvent
= wxEVT_SCROLL_TOP
;
940 else if (m_windowStyle
& wxSL_BOTTOM
)
941 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
944 case SLN_SLIDERTRACK
:
945 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
952 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
954 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
960 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
962 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
964 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
970 nNewPos
= (nPixelPos
/m_dPixelToRange
);
971 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
973 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
976 // Out of range - but we did process it
982 wxScrollEvent
vEvent( eScrollEvent
986 vEvent
.SetPosition(nNewPos
);
987 vEvent
.SetEventObject(this);
988 GetEventHandler()->ProcessEvent(vEvent
);
990 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
994 vCevent
.SetInt(nNewPos
);
995 vCevent
.SetEventObject(this);
996 return (GetEventHandler()->ProcessEvent(vCevent
));
997 } // end of wxSlider::OS2OnScroll
999 void wxSlider::SetLineSize(
1003 m_nLineSize
= nLineSize
;
1004 } // end of wxSlider::SetLineSize
1007 void wxSlider::SetPageSize(
1011 m_nPageSize
= nPageSize
;
1012 } // end of wxSlider::SetPageSize
1014 void wxSlider::SetRange(
1021 m_nRangeMin
= nMinValue
;
1022 m_nRangeMax
= nMaxValue
;
1024 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1025 ,SLM_QUERYSLIDERINFO
1026 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1032 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1035 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1036 ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
);
1041 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1042 ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
);
1044 } // end of wxSlider::SetRange
1046 void wxSlider::SetSelection(
1047 int WXUNUSED(nMinPos
)
1048 , int WXUNUSED(nMaxPos
)
1051 } // end of wxSlider::SetSelection
1053 void wxSlider::SetThumbLength(
1059 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1060 ,SLM_QUERYSLIDERINFO
1061 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1066 ) + 4; // for bordersizes
1067 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1068 ,SLM_QUERYSLIDERINFO
1069 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1075 ::WinSendMsg( GetHwnd()
1077 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1080 ,MPFROM2SHORT(nLen
, nBreadth
)
1082 m_nThumbLength
= nLen
+ 4; // Borders
1083 } // end of wxSlider::SetThumbLength
1085 void wxSlider::SetTick(
1089 nTickPos
*= m_dPixelToRange
;
1090 ::WinSendMsg( GetHwnd()
1092 ,MPFROMSHORT(nTickPos
)
1095 } // end of wxSlider::SetTick
1097 // For trackbars only
1098 void wxSlider::SetTickFreq(
1104 WNDPARAMS vWndParams
;
1108 vSlData
.cbSize
= sizeof(SLDCDATA
);
1109 if (m_windowStyle
& wxSL_AUTOTICKS
)
1111 vSlData
.usScale1Spacing
= 0;
1112 vSlData
.usScale2Spacing
= 0;
1114 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1115 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1117 vWndParams
.fsStatus
= WPM_CTLDATA
;
1118 vWndParams
.cchText
= 0L;
1119 vWndParams
.pszText
= NULL
;
1120 vWndParams
.cbPresParams
= 0L;
1121 vWndParams
.pPresParams
= NULL
;
1122 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1123 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1124 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1125 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1127 nPixelPos
= i
* n
* m_dPixelToRange
;
1128 ::WinSendMsg( GetHwnd()
1130 ,MPFROMSHORT(nPixelPos
)
1134 } // end of wxSlider::SetTickFreq
1136 void wxSlider::SetValue(
1140 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1141 ,SLM_QUERYSLIDERINFO
1142 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1148 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1149 ,SLM_QUERYSLIDERINFO
1150 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1156 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1157 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1159 ::WinSendMsg( GetHwnd()
1161 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1168 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1169 ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
);
1171 } // end of wxSlider::SetValue
1173 bool wxSlider::Show(
1177 wxWindowOS2::Show(bShow
);
1179 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1181 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1183 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1185 } // end of wxSlider::Show