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
69 wxFont vFont
= this->GetFont();
71 wxGetCharSize( GetHWND()
77 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
79 if (m_windowStyle
& wxSL_LABELS
)
84 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
85 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
87 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
88 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
92 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
93 int nValueHeight
= nCyf
;
95 ::WinSetWindowPos( (HWND
)m_hStaticValue
97 ,(LONG
)nXOffset
- (nNewWidth
+ nCx
+ nMinLen
+ nCx
)
104 ::WinSetWindowPos( (HWND
)m_hStaticMin
106 ,(LONG
)nXOffset
- (nMinLen
+ nCx
)
112 nXOffset
+= nWidth
+ nCx
;
114 ::WinSetWindowPos( (HWND
)m_hStaticMax
120 ,SWP_ZORDER
| SWP_SHOW
127 // Now deal with a vertical slider
130 if (m_windowStyle
& wxSL_LABELS
)
135 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
136 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
138 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
139 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
143 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
145 ::WinSetWindowPos( (HWND
)m_hStaticValue
148 ,(LONG
)nYOffset
+ nHeight
+ nCyf
154 ::WinSetWindowPos( (HWND
)m_hStaticMax
157 ,(LONG
)nYOffset
+ nHeight
162 ::WinSetWindowPos( (HWND
)m_hStaticMin
165 ,(LONG
)nYOffset
- nCyf
172 } // end of wxSlider::AdjustSubControls
174 void wxSlider::ClearSel()
176 } // end of wxSlider::ClearSel
178 void wxSlider::ClearTicks()
180 } // end of wxSlider::ClearTicks
182 void wxSlider::Command (
183 wxCommandEvent
& rEvent
186 SetValue(rEvent
.GetInt());
187 ProcessCommand(rEvent
);
188 } // end of wxSlider::Command
190 bool wxSlider::ContainsHWND(
194 return ( hWnd
== GetStaticMin() ||
195 hWnd
== GetStaticMax() ||
196 hWnd
== GetEditValue()
198 } // end of wxSlider::ContainsHWND
200 bool wxSlider::Create(
206 , const wxPoint
& rPos
207 , const wxSize
& rSize
209 , 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 wxSprintf(wxBuffer
, wxT("%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_BOTTOM
// 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 wxSprintf(wxBuffer
, wxT("%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(wxT("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(wxT("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
489 wxFont vFont
= this->GetFont();
492 // Adjust for OS/2's reverse coordinate system
494 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
496 int nOS2Height
= nHeight
;
503 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
505 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
507 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
513 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
514 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
516 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
518 m_nSizeFlags
= nSizeFlags
;
520 GetPosition( &nCurrentX
523 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
525 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
528 AdjustForParentClientOrigin( nX1
532 wxGetCharSize( GetHWND()
538 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
540 if (m_windowStyle
& wxSL_LABELS
)
545 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
546 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
547 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
548 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
552 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
553 int nValueHeight
= nCyf
;
555 ::WinSetWindowPos( (HWND
)m_hStaticValue
558 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
561 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
563 nXOffset
+= nNewWidth
+ nCx
;
565 ::WinSetWindowPos( (HWND
)m_hStaticMin
568 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
571 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
573 nXOffset
+= nMinLen
+ nCx
;
575 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
576 int nSliderHeight
= nHeight1
;
578 if (nSliderHeight
< 0)
582 // Slider must have a minimum/default length/height
584 if (nSliderLength
< 100)
587 ::WinSetWindowPos( GetHwnd()
593 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
595 ::WinQueryWindowPos(GetHwnd(), GetSwp());
596 ::WinSendMsg( GetHwnd()
598 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
601 ,MPFROMLONG((ULONG
)(nSliderHeight
/2))
603 nXOffset
+= nSliderLength
+ nCx
;
605 ::WinSetWindowPos( (HWND
)m_hStaticMax
608 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
611 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
618 // If we're prepared to use the existing size, then...
620 if (nWidth
== -1 && nHeight
== -1 &&
621 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
631 ::WinSetWindowPos( GetHwnd()
637 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
643 // Now deal with a vertical slider
647 if (m_windowStyle
& wxSL_LABELS
)
652 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
653 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
654 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
655 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
658 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
659 int nValueHeight
= nCyf
;
661 ::WinSetWindowPos( (HWND
)m_hStaticValue
664 ,(LONG
)nYOffset
+ nHeight
667 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
671 ::WinSetWindowPos( (HWND
)m_hStaticMin
674 ,(LONG
)nYOffset
+ nHeight
- nCyf
677 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
681 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
682 int nSliderWidth
= nWidth1
;
684 if (nSliderWidth
< 0)
688 // Slider must have a minimum/default length
690 if (nSliderLength
< 100)
693 ::WinSetWindowPos( GetHwnd()
696 ,(LONG
)nYOffset
+ nCyf
699 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
701 ::WinQueryWindowPos(GetHwnd(), GetSwp());
702 ::WinSendMsg( GetHwnd()
704 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
707 ,MPFROMLONG((ULONG
)(nSliderWidth
/2))
709 nUsedHeight
+= nSliderLength
;
710 ::WinSetWindowPos( (HWND
)m_hStaticMax
713 ,(LONG
)nYOffset
- nCyf
716 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
723 // If we're prepared to use the existing size, then...
725 if (nWidth
== -1 && nHeight
== -1 &&
726 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
736 ::WinSetWindowPos( GetHwnd()
742 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
746 } // end of void wxSlider::DoSetSize
748 int wxSlider::GetLineSize() const
751 } // end of wxSlider::GetLineSize
753 int wxSlider::GetPageSize() const
756 } // end of wxSlider::GetPageSize
758 void wxSlider::GetPosition(
763 wxWindowOS2
* pParent
= GetParent();
770 wxFindMaxSize( GetHWND()
775 wxFindMaxSize( m_hStaticMin
779 wxFindMaxSize( m_hStaticMax
783 wxFindMaxSize( m_hStaticValue
788 // Since we now have the absolute screen coords,
789 // if there's a parent we must subtract its top left corner
793 vPoint
.x
= vRect
.xLeft
;
794 vPoint
.y
= vRect
.yTop
;
800 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
806 // We may be faking the client origin.
807 // So a window that's really at (0, 30) may appear
808 // (to wxWin apps) to be at (0, 0).
812 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
819 } // end of wxSlider::GetPosition
821 int wxSlider::GetSelEnd() const
824 } // end of wxSlider::GetSelEnd
826 int wxSlider::GetSelStart() const
829 } // end of wxSlider::GetSelStart
831 void wxSlider::DoGetSize(
839 } // end of wxSlider::DoGetSize
841 void wxSlider::GetSize(
853 wxFindMaxSize( GetHWND()
858 wxFindMaxSize( m_hStaticMin
862 wxFindMaxSize( m_hStaticMax
866 wxFindMaxSize( m_hStaticValue
870 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
872 *pnHeight
= vRect
.yTop
- vRect
.yBottom
;
873 } // end of wxSlider::GetSize
875 int wxSlider::GetThumbLength() const
877 return m_nThumbLength
;
878 } // end of wxSlider::GetThumbLength
880 int wxSlider::GetValue() const
882 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
884 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
890 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
892 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
894 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
900 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
901 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
904 } // end of wxSlider::GetValue
906 WXHBRUSH
wxSlider::OnCtlColor(
915 return (wxControl::OnCtlColor( hDC
923 } // end of wxSlider::OnCtlColor
925 bool wxSlider::OS2OnScroll(
926 int WXUNUSED(nOrientation
)
932 wxEventType eScrollEvent
= wxEVT_NULL
;
937 if (m_windowStyle
& wxSL_TOP
)
938 eScrollEvent
= wxEVT_SCROLL_TOP
;
939 else if (m_windowStyle
& wxSL_BOTTOM
)
940 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
943 case SLN_SLIDERTRACK
:
944 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
951 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
953 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
959 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
961 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
963 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
969 nNewPos
= (int)(nPixelPos
/m_dPixelToRange
);
970 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
972 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
975 // Out of range - but we did process it
981 wxScrollEvent
vEvent( eScrollEvent
985 vEvent
.SetPosition(nNewPos
);
986 vEvent
.SetEventObject(this);
987 GetEventHandler()->ProcessEvent(vEvent
);
989 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
993 vCevent
.SetInt(nNewPos
);
994 vCevent
.SetEventObject(this);
995 return (GetEventHandler()->ProcessEvent(vCevent
));
996 } // end of wxSlider::OS2OnScroll
998 void wxSlider::SetLineSize(
1002 m_nLineSize
= nLineSize
;
1003 } // end of wxSlider::SetLineSize
1006 void wxSlider::SetPageSize(
1010 m_nPageSize
= nPageSize
;
1011 } // end of wxSlider::SetPageSize
1013 void wxSlider::SetRange(
1020 m_nRangeMin
= nMinValue
;
1021 m_nRangeMax
= nMaxValue
;
1023 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1024 ,SLM_QUERYSLIDERINFO
1025 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1031 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1034 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1035 ::WinSetWindowText((HWND
)m_hStaticMin
, (PSZ
)zBuf
);
1040 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1041 ::WinSetWindowText((HWND
)m_hStaticMax
, (PSZ
)zBuf
);
1043 } // end of wxSlider::SetRange
1045 void wxSlider::SetSelection(
1046 int WXUNUSED(nMinPos
)
1047 , int WXUNUSED(nMaxPos
)
1050 } // end of wxSlider::SetSelection
1052 void wxSlider::SetThumbLength(
1058 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1059 ,SLM_QUERYSLIDERINFO
1060 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1065 ) + 4; // for bordersizes
1066 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1067 ,SLM_QUERYSLIDERINFO
1068 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1074 ::WinSendMsg( GetHwnd()
1076 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1079 ,MPFROM2SHORT(nLen
, nBreadth
)
1081 m_nThumbLength
= nLen
+ 4; // Borders
1082 } // end of wxSlider::SetThumbLength
1084 void wxSlider::SetTick(
1088 nTickPos
= (int)(nTickPos
* m_dPixelToRange
);
1089 ::WinSendMsg( GetHwnd()
1091 ,MPFROMSHORT(nTickPos
)
1094 } // end of wxSlider::SetTick
1096 // For trackbars only
1097 void wxSlider::SetTickFreq(
1103 WNDPARAMS vWndParams
;
1107 vSlData
.cbSize
= sizeof(SLDCDATA
);
1108 if (m_windowStyle
& wxSL_AUTOTICKS
)
1110 vSlData
.usScale1Spacing
= 0;
1111 vSlData
.usScale2Spacing
= 0;
1113 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1114 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1116 vWndParams
.fsStatus
= WPM_CTLDATA
;
1117 vWndParams
.cchText
= 0L;
1118 vWndParams
.pszText
= NULL
;
1119 vWndParams
.cbPresParams
= 0L;
1120 vWndParams
.pPresParams
= NULL
;
1121 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1122 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1123 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1124 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1126 nPixelPos
= (int)(i
* n
* m_dPixelToRange
);
1127 ::WinSendMsg( GetHwnd()
1129 ,MPFROMSHORT(nPixelPos
)
1133 } // end of wxSlider::SetTickFreq
1135 void wxSlider::SetValue(
1139 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1140 ,SLM_QUERYSLIDERINFO
1141 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1147 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1148 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1150 ::WinSendMsg( GetHwnd()
1152 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1159 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1160 ::WinSetWindowText((HWND
)m_hStaticValue
, (PSZ
)wxBuffer
);
1162 } // end of wxSlider::SetValue
1164 bool wxSlider::Show(
1168 wxWindowOS2::Show(bShow
);
1170 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1172 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1174 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1176 } // end of wxSlider::Show
1178 #endif // wxUSE_SLIDER