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>
28 #include "wx/slider.h"
29 #include "wx/os2/private.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxSlider
, wxControl
)
43 } // end of wxSlider::wxSlider
48 ::WinDestroyWindow((HWND
)m_hStaticMin
);
50 ::WinDestroyWindow((HWND
)m_hStaticMax
);
52 ::WinDestroyWindow((HWND
)m_hStaticValue
);
53 } // end of wxSlider::~wxSlider
55 void wxSlider::AdjustSubControls(
65 int nCx
; // slider,min,max sizes
70 wxGetCharSize( GetHWND()
76 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
78 if (m_windowStyle
& wxSL_LABELS
)
83 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
84 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
86 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
87 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
91 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
92 int nValueHeight
= nCyf
;
94 ::WinSetWindowPos( (HWND
)m_hStaticValue
96 ,(LONG
)nXOffset
- (nNewWidth
+ nCx
+ nMinLen
+ nCx
)
103 ::WinSetWindowPos( (HWND
)m_hStaticMin
105 ,(LONG
)nXOffset
- (nMinLen
+ nCx
)
111 nXOffset
+= nWidth
+ nCx
;
113 ::WinSetWindowPos( (HWND
)m_hStaticMax
119 ,SWP_ZORDER
| SWP_SHOW
126 // Now deal with a vertical slider
129 if (m_windowStyle
& wxSL_LABELS
)
134 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
135 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
137 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
138 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
142 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
144 ::WinSetWindowPos( (HWND
)m_hStaticValue
147 ,(LONG
)nYOffset
+ nHeight
+ nCyf
153 ::WinSetWindowPos( (HWND
)m_hStaticMax
156 ,(LONG
)nYOffset
+ nHeight
161 ::WinSetWindowPos( (HWND
)m_hStaticMin
164 ,(LONG
)nYOffset
- nCyf
171 } // end of wxSlider::AdjustSubControls
173 void wxSlider::ClearSel()
175 } // end of wxSlider::ClearSel
177 void wxSlider::ClearTicks()
179 } // end of wxSlider::ClearTicks
181 void wxSlider::Command (
182 wxCommandEvent
& rEvent
185 SetValue(rEvent
.GetInt());
186 ProcessCommand(rEvent
);
187 } // end of wxSlider::Command
189 bool wxSlider::ContainsHWND(
193 return ( hWnd
== GetStaticMin() ||
194 hWnd
== GetStaticMax() ||
195 hWnd
== GetEditValue()
197 } // end of wxSlider::ContainsHWND
199 bool wxSlider::Create(
205 , const wxPoint
& rPos
206 , const wxSize
& rSize
208 , const wxValidator
& rValidator
209 , const wxString
& rsName
214 int nWidth
= rSize
.x
;
215 int nHeight
= rSize
.y
;
221 SetValidator(rValidator
);
224 pParent
->AddChild(this);
225 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
226 SetForegroundColour(pParent
->GetForegroundColour()) ;
233 m_windowStyle
= lStyle
;
237 m_windowId
= (int)NewControlId();
241 if (m_windowStyle
& wxCLIP_SIBLINGS
)
242 lMsStyle
|= WS_CLIPSIBLINGS
;
244 if (m_windowStyle
& wxSL_LABELS
)
246 lMsStyle
|= WS_VISIBLE
| SS_TEXT
| DT_VCENTER
;
248 m_hStaticValue
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
249 ,WC_STATIC
// Window class
250 ,(PSZ
)NULL
// Initial Text
251 ,(ULONG
)lMsStyle
// Style flags
252 ,0L, 0L, 0L, 0L // Origin -- 0 size
253 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
254 ,HWND_TOP
// initial z position
255 ,(ULONG
)NewControlId() // Window identifier
256 ,NULL
// no control data
257 ,NULL
// no Presentation parameters
261 // Now create min static control
263 sprintf(wxBuffer
, "%d", nMinValue
);
264 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
265 if (m_windowStyle
& wxCLIP_SIBLINGS
)
266 lWstyle
|= WS_CLIPSIBLINGS
;
268 m_hStaticMin
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
269 ,WC_STATIC
// Window class
270 ,(PSZ
)wxBuffer
// Initial Text
271 ,(ULONG
)lWstyle
// Style flags
272 ,0L, 0L, 0L, 0L // Origin -- 0 size
273 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
274 ,HWND_TOP
// initial z position
275 ,(ULONG
)NewControlId() // Window identifier
276 ,NULL
// no control data
277 ,NULL
// no Presentation parameters
284 vSlData
.cbSize
= sizeof(SLDCDATA
);
285 if (m_windowStyle
& wxSL_VERTICAL
)
286 lMsStyle
= SLS_VERTICAL
| SLS_HOMEBOTTOM
| WS_VISIBLE
| WS_TABSTOP
;
288 lMsStyle
= SLS_HORIZONTAL
| SLS_HOMELEFT
| WS_VISIBLE
| WS_TABSTOP
;
290 if (m_windowStyle
& wxCLIP_SIBLINGS
)
291 lMsStyle
|= WS_CLIPSIBLINGS
;
293 if (m_windowStyle
& wxSL_AUTOTICKS
)
295 vSlData
.usScale1Spacing
= 0;
296 vSlData
.usScale2Spacing
= 0;
299 if (m_windowStyle
& wxSL_LEFT
)
300 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left
301 else if (m_windowStyle
& wxSL_RIGHT
)
302 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right
303 else if (m_windowStyle
& wxSL_TOP
)
304 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top
305 else if (m_windowStyle
& wxSL_BOTTOM
)
306 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom
307 else if ( m_windowStyle
& wxSL_BOTH
)
308 lMsStyle
|= SLS_PRIMARYSCALE1
| SLS_PRIMARYSCALE2
;
310 lMsStyle
|= SLS_PRIMARYSCALE2
;
311 lMsStyle
|= SLS_RIBBONSTRIP
;
313 m_nPageSize
= ((nMaxValue
- nMinValue
)/10);
314 vSlData
.usScale1Increments
= m_nPageSize
;
315 vSlData
.usScale2Increments
= m_nPageSize
;
317 HWND hScrollBar
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
318 ,WC_SLIDER
// Window class
319 ,(PSZ
)wxBuffer
// Initial Text
320 ,(ULONG
)lMsStyle
// Style flags
321 ,0L, 0L, 0L, 0L // Origin -- 0 size
322 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
323 ,HWND_BOTTOM
// initial z position
324 ,(HMENU
)m_windowId
// Window identifier
325 ,&vSlData
// Slider control data
326 ,NULL
// no Presentation parameters
328 m_nRangeMax
= nMaxValue
;
329 m_nRangeMin
= nMinValue
;
332 // Set the size of the ticks ... default to 6 pixels
334 ::WinSendMsg( hScrollBar
336 ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12)
340 // Set the position to the initial value
342 ::WinSendMsg( hScrollBar
344 ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
348 m_hWnd
= (WXHWND
)hScrollBar
;
349 SubclassWin(GetHWND());
350 ::WinSetWindowText((HWND
)m_hWnd
, "");
352 SetFont(*wxSMALL_FONT
);
353 if (m_windowStyle
& wxSL_LABELS
)
356 // Finally, create max value static item
358 sprintf(wxBuffer
, "%d", nMaxValue
);
359 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
360 if (m_windowStyle
& wxCLIP_SIBLINGS
)
361 lMsStyle
|= WS_CLIPSIBLINGS
;
363 m_hStaticMax
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
364 ,WC_STATIC
// Window class
365 ,(PSZ
)wxBuffer
// Initial Text
366 ,(ULONG
)lWstyle
// Style flags
367 ,0L, 0L, 0L, 0L // Origin -- 0 size
368 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
369 ,HWND_TOP
// initial z position
370 ,(ULONG
)NewControlId() // Window identifier
371 ,NULL
// no control data
372 ,NULL
// no Presentation parameters
376 if (GetFont().GetResourceHandle())
379 wxOS2SetFont( m_hStaticMin
383 wxOS2SetFont( m_hStaticMax
387 wxOS2SetFont( m_hStaticValue
401 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
403 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
408 ) + 4; // for bordersizes
412 vColour
.Set(wxString("BLACK"));
414 LONG lColor
= (LONG
)vColour
.GetPixel();
416 ::WinSetPresParam( m_hStaticMin
421 ::WinSetPresParam( m_hStaticMax
426 ::WinSetPresParam( m_hStaticValue
431 ::WinSetPresParam( m_hWnd
436 lColor
= (LONG
)m_backgroundColour
.GetPixel();
437 ::WinSetPresParam( m_hStaticMin
442 ::WinSetPresParam( m_hStaticMax
447 ::WinSetPresParam( m_hStaticValue
452 ::WinSetPresParam( m_hWnd
457 vColour
.Set(wxString("BLUE"));
458 lColor
= (LONG
)vColour
.GetPixel();
459 ::WinSetPresParam( m_hWnd
460 ,PP_HILITEBACKGROUNDCOLOR
466 } // end of wxSlider::Create
468 void wxSlider::DoSetSize(
478 int nWidth1
= nWidth
;
479 int nHeight1
= nHeight
;
482 int nCx
; // slider,min,max sizes
490 // Adjust for OS/2's reverse coordinate system
492 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
494 int nOS2Height
= nHeight
;
501 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
503 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
505 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
511 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
512 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
514 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
516 m_nSizeFlags
= nSizeFlags
;
518 GetPosition( &nCurrentX
521 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
523 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
526 AdjustForParentClientOrigin( nX1
530 wxGetCharSize( GetHWND()
536 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
538 if (m_windowStyle
& wxSL_LABELS
)
543 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
544 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
545 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
546 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
550 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
551 int nValueHeight
= nCyf
;
553 ::WinSetWindowPos( (HWND
)m_hStaticValue
556 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
559 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
561 nXOffset
+= nNewWidth
+ nCx
;
563 ::WinSetWindowPos( (HWND
)m_hStaticMin
566 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
569 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
571 nXOffset
+= nMinLen
+ nCx
;
573 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
574 int nSliderHeight
= nHeight1
;
576 if (nSliderHeight
< 0)
580 // Slider must have a minimum/default length/height
582 if (nSliderLength
< 100)
585 ::WinSetWindowPos( GetHwnd()
591 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
593 ::WinQueryWindowPos(GetHwnd(), GetSwp());
594 ::WinSendMsg( GetHwnd()
596 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
599 ,MPFROMLONG((ULONG
)(nSliderHeight
/2))
601 nXOffset
+= nSliderLength
+ nCx
;
603 ::WinSetWindowPos( (HWND
)m_hStaticMax
606 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
609 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
616 // If we're prepared to use the existing size, then...
618 if (nWidth
== -1 && nHeight
== -1 &&
619 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
629 ::WinSetWindowPos( GetHwnd()
635 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
641 // Now deal with a vertical slider
645 if (m_windowStyle
& wxSL_LABELS
)
650 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
651 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
652 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
653 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
656 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
657 int nValueHeight
= nCyf
;
659 ::WinSetWindowPos( (HWND
)m_hStaticValue
662 ,(LONG
)nYOffset
+ nHeight
665 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
669 ::WinSetWindowPos( (HWND
)m_hStaticMin
672 ,(LONG
)nYOffset
+ nHeight
- nCyf
675 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
679 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
680 int nSliderWidth
= nWidth1
;
682 if (nSliderWidth
< 0)
686 // Slider must have a minimum/default length
688 if (nSliderLength
< 100)
691 ::WinSetWindowPos( GetHwnd()
694 ,(LONG
)nYOffset
+ nCyf
697 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
699 ::WinQueryWindowPos(GetHwnd(), GetSwp());
700 ::WinSendMsg( GetHwnd()
702 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
705 ,MPFROMLONG((ULONG
)(nSliderWidth
/2))
707 nUsedHeight
+= nSliderLength
;
708 ::WinSetWindowPos( (HWND
)m_hStaticMax
711 ,(LONG
)nYOffset
- nCyf
714 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
721 // If we're prepared to use the existing size, then...
723 if (nWidth
== -1 && nHeight
== -1 &&
724 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
734 ::WinSetWindowPos( GetHwnd()
740 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
744 } // end of void wxSlider::DoSetSize
746 int wxSlider::GetLineSize() const
749 } // end of wxSlider::GetLineSize
751 int wxSlider::GetPageSize() const
754 } // end of wxSlider::GetPageSize
756 void wxSlider::GetPosition(
761 wxWindowOS2
* pParent
= GetParent();
768 wxFindMaxSize( GetHWND()
773 wxFindMaxSize( m_hStaticMin
777 wxFindMaxSize( m_hStaticMax
781 wxFindMaxSize( m_hStaticValue
786 // Since we now have the absolute screen coords,
787 // if there's a parent we must subtract its top left corner
791 vPoint
.x
= vRect
.xLeft
;
792 vPoint
.y
= vRect
.yTop
;
798 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
804 // We may be faking the client origin.
805 // So a window that's really at (0, 30) may appear
806 // (to wxWin apps) to be at (0, 0).
810 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
817 } // end of wxSlider::GetPosition
819 int wxSlider::GetSelEnd() const
822 } // end of wxSlider::GetSelEnd
824 int wxSlider::GetSelStart() const
827 } // end of wxSlider::GetSelStart
829 void wxSlider::DoGetSize(
837 } // end of wxSlider::DoGetSize
839 void wxSlider::GetSize(
851 wxFindMaxSize( GetHWND()
856 wxFindMaxSize( m_hStaticMin
860 wxFindMaxSize( m_hStaticMax
864 wxFindMaxSize( m_hStaticValue
868 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
870 *pnHeight
= vRect
.yTop
- vRect
.yBottom
;
871 } // end of wxSlider::GetSize
873 int wxSlider::GetThumbLength() const
875 return m_nThumbLength
;
876 } // end of wxSlider::GetThumbLength
878 int wxSlider::GetValue() const
880 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
882 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
888 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
890 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
892 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
898 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
899 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
902 } // end of wxSlider::GetValue
904 WXHBRUSH
wxSlider::OnCtlColor(
913 return (wxControl::OnCtlColor( hDC
921 } // end of wxSlider::OnCtlColor
923 bool wxSlider::OS2OnScroll(
924 int WXUNUSED(nOrientation
)
930 wxEventType eScrollEvent
= wxEVT_NULL
;
935 if (m_windowStyle
& wxSL_TOP
)
936 eScrollEvent
= wxEVT_SCROLL_TOP
;
937 else if (m_windowStyle
& wxSL_BOTTOM
)
938 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
941 case SLN_SLIDERTRACK
:
942 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
949 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
951 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
957 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
959 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
961 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
967 nNewPos
= (int)(nPixelPos
/m_dPixelToRange
);
968 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
970 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
973 // Out of range - but we did process it
979 wxScrollEvent
vEvent( eScrollEvent
983 vEvent
.SetPosition(nNewPos
);
984 vEvent
.SetEventObject(this);
985 GetEventHandler()->ProcessEvent(vEvent
);
987 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
991 vCevent
.SetInt(nNewPos
);
992 vCevent
.SetEventObject(this);
993 return (GetEventHandler()->ProcessEvent(vCevent
));
994 } // end of wxSlider::OS2OnScroll
996 void wxSlider::SetLineSize(
1000 m_nLineSize
= nLineSize
;
1001 } // end of wxSlider::SetLineSize
1004 void wxSlider::SetPageSize(
1008 m_nPageSize
= nPageSize
;
1009 } // end of wxSlider::SetPageSize
1011 void wxSlider::SetRange(
1018 m_nRangeMin
= nMinValue
;
1019 m_nRangeMax
= nMaxValue
;
1021 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1022 ,SLM_QUERYSLIDERINFO
1023 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1029 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1032 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1033 ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
);
1038 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1039 ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
);
1041 } // end of wxSlider::SetRange
1043 void wxSlider::SetSelection(
1044 int WXUNUSED(nMinPos
)
1045 , int WXUNUSED(nMaxPos
)
1048 } // end of wxSlider::SetSelection
1050 void wxSlider::SetThumbLength(
1056 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1057 ,SLM_QUERYSLIDERINFO
1058 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1063 ) + 4; // for bordersizes
1064 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1065 ,SLM_QUERYSLIDERINFO
1066 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1072 ::WinSendMsg( GetHwnd()
1074 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1077 ,MPFROM2SHORT(nLen
, nBreadth
)
1079 m_nThumbLength
= nLen
+ 4; // Borders
1080 } // end of wxSlider::SetThumbLength
1082 void wxSlider::SetTick(
1086 nTickPos
= (int)(nTickPos
* m_dPixelToRange
);
1087 ::WinSendMsg( GetHwnd()
1089 ,MPFROMSHORT(nTickPos
)
1092 } // end of wxSlider::SetTick
1094 // For trackbars only
1095 void wxSlider::SetTickFreq(
1101 WNDPARAMS vWndParams
;
1105 vSlData
.cbSize
= sizeof(SLDCDATA
);
1106 if (m_windowStyle
& wxSL_AUTOTICKS
)
1108 vSlData
.usScale1Spacing
= 0;
1109 vSlData
.usScale2Spacing
= 0;
1111 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1112 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1114 vWndParams
.fsStatus
= WPM_CTLDATA
;
1115 vWndParams
.cchText
= 0L;
1116 vWndParams
.pszText
= NULL
;
1117 vWndParams
.cbPresParams
= 0L;
1118 vWndParams
.pPresParams
= NULL
;
1119 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1120 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1121 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1122 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1124 nPixelPos
= (int)(i
* n
* m_dPixelToRange
);
1125 ::WinSendMsg( GetHwnd()
1127 ,MPFROMSHORT(nPixelPos
)
1131 } // end of wxSlider::SetTickFreq
1133 void wxSlider::SetValue(
1137 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1138 ,SLM_QUERYSLIDERINFO
1139 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1145 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1146 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1148 ::WinSendMsg( GetHwnd()
1150 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1157 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1158 ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
);
1160 } // end of wxSlider::SetValue
1162 bool wxSlider::Show(
1166 wxWindowOS2::Show(bShow
);
1168 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1170 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1172 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1174 } // end of wxSlider::Show
1176 #endif // wxUSE_SLIDER