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_lWindowStyle
& winSL_LABELS
)
133 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
134 GetTextExtent(zBuf
, &lMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
136 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
137 GetTextExtent(zBuf
, &lMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
141 int nNewWidth
= (DAWUTL_MAX(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
400 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
402 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
407 ) + 4; // for bordersizes
411 vColour
.Set(wxString("BLACK"));
413 LONG lColor
= (LONG
)vColour
.GetPixel();
415 ::WinSetPresParam( m_hStaticMin
420 ::WinSetPresParam( m_hStaticMax
425 ::WinSetPresParam( m_hStaticValue
430 ::WinSetPresParam( m_hWnd
435 lColor
= (LONG
)m_backgroundColour
.GetPixel();
436 ::WinSetPresParam( m_hStaticMin
441 ::WinSetPresParam( m_hStaticMax
446 ::WinSetPresParam( m_hStaticValue
451 ::WinSetPresParam( m_hWnd
456 vColour
.Set(wxString("BLUE"));
457 lColor
= (LONG
)vColour
.GetPixel();
458 ::WinSetPresParam( m_hWnd
459 ,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
- (nCyf
* 1.2)
559 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
561 nXOffset
+= nNewWidth
+ nCx
;
563 ::WinSetWindowPos( (HWND
)m_hStaticMin
566 ,(LONG
)nYOffset
- (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 nXOffset
+= nSliderLength
+ nCx
;
595 ::WinSetWindowPos( (HWND
)m_hStaticMax
598 ,(LONG
)nYOffset
- (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, zBuf
);
643 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
644 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
645 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
648 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
649 int nValueHeight
= nCyf
;
654 // The height needs to be a bit bigger under Win95 if using native
657 ::WinSetWindowPos( (HWND
)m_hStaticValue
660 ,(LONG
)nYOffset
+ lHeight
663 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
667 ::WinSetWindowPos( (HWND
)m_hStaticMin
670 ,(LONG
)nYOffset
+ lHeight
-lCyf
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()
695 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
697 nUsedHeight
+= nSliderLength
;
698 ::WinSetWindowPos( (HWND
)m_hStaticMax
704 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
711 // If we're prepared to use the existing size, then...
713 if (nWidth
== -1 && nHeight
== -1 &&
714 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
724 ::WinSetWindowPos( GetHwnd()
730 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
734 } // end of void wxSlider::DoSetSize
736 int wxSlider::GetLineSize() const
739 } // end of wxSlider::GetLineSize
741 int wxSlider::GetPageSize() const
744 } // end of wxSlider::GetPageSize
746 void wxSlider::GetPosition(
751 wxWindowOS2
* pParent
= GetParent();
758 wxFindMaxSize( GetHWND()
763 wxFindMaxSize( m_hStaticMin
767 wxFindMaxSize( m_hStaticMax
771 wxFindMaxSize( m_hStaticValue
776 // Since we now have the absolute screen coords,
777 // if there's a parent we must subtract its top left corner
781 vPoint
.x
= vRect
.xLeft
;
782 vPoint
.y
= vRect
.yTop
;
788 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
794 // We may be faking the client origin.
795 // So a window that's really at (0, 30) may appear
796 // (to wxWin apps) to be at (0, 0).
800 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
807 } // end of wxSlider::GetPosition
809 int wxSlider::GetSelEnd() const
812 } // end of wxSlider::GetSelEnd
814 int wxSlider::GetSelStart() const
817 } // end of wxSlider::GetSelStart
819 void wxSlider::DoGetSize(
827 } // end of wxSlider::DoGetSize
829 void wxSlider::GetSize(
841 wxFindMaxSize( GetHWND()
846 wxFindMaxSize( m_hStaticMin
850 wxFindMaxSize( m_hStaticMax
854 wxFindMaxSize( m_hStaticValue
857 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
858 *pnHeight
= vRect
.yBottom
- vRect
.yTop
;
859 } // end of wxSlider::GetSize
861 int wxSlider::GetThumbLength() const
863 return m_nThumbLength
;
864 } // end of wxSlider::GetThumbLength
866 int wxSlider::GetValue() const
868 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
870 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
876 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
878 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
880 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
886 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
887 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
890 } // end of wxSlider::GetValue
892 WXHBRUSH
wxSlider::OnCtlColor(
901 return (wxControl::OnCtlColor( hDC
909 } // end of wxSlider::OnCtlColor
911 bool wxSlider::OS2OnScroll(
912 int WXUNUSED(nOrientation
)
918 wxEventType eScrollEvent
= wxEVT_NULL
;
923 if (m_windowStyle
& wxSL_TOP
)
924 eScrollEvent
= wxEVT_SCROLL_TOP
;
925 else if (m_windowStyle
& wxSL_BOTTOM
)
926 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
929 case SLN_SLIDERTRACK
:
930 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
937 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
939 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
945 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
947 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
949 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
955 nNewPos
= (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
971 vEvent
.SetPosition(nNewPos
);
972 vEvent
.SetEventObject(this);
973 GetEventHandler()->ProcessEvent(vEvent
);
975 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
979 vCevent
.SetInt(nNewPos
);
980 vCevent
.SetEventObject(this);
981 return (GetEventHandler()->ProcessEvent(vCevent
));
982 } // end of wxSlider::OS2OnScroll
984 void wxSlider::SetLineSize(
988 m_nLineSize
= nLineSize
;
989 } // end of wxSlider::SetLineSize
992 void wxSlider::SetPageSize(
996 m_nPageSize
= nPageSize
;
997 } // end of wxSlider::SetPageSize
999 void wxSlider::SetRange(
1006 m_nRangeMin
= nMinValue
;
1007 m_nRangeMax
= nMaxValue
;
1009 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1010 ,SLM_QUERYSLIDERINFO
1011 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1017 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1020 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1021 ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
);
1026 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1027 ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
);
1029 } // end of wxSlider::SetRange
1031 void wxSlider::SetSelection(
1032 int WXUNUSED(nMinPos
)
1033 , int WXUNUSED(nMaxPos
)
1036 } // end of wxSlider::SetSelection
1038 void wxSlider::SetThumbLength(
1044 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1045 ,SLM_QUERYSLIDERINFO
1046 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1051 ) + 4; // for bordersizes
1052 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1053 ,SLM_QUERYSLIDERINFO
1054 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1060 ::WinSendMsg( GetHwnd()
1062 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1065 ,MPFROM2SHORT(nLen
, nBreadth
)
1067 m_nThumbLength
= nLen
+ 4; // Borders
1068 } // end of wxSlider::SetThumbLength
1070 void wxSlider::SetTick(
1074 nTickPos
*= m_dPixelToRange
;
1075 ::WinSendMsg( GetHwnd()
1077 ,MPFROMSHORT(nTickPos
)
1080 } // end of wxSlider::SetTick
1082 // For trackbars only
1083 void wxSlider::SetTickFreq(
1089 WNDPARAMS vWndParams
;
1093 vSlData
.cbSize
= sizeof(SLDCDATA
);
1094 if (m_windowStyle
& wxSL_AUTOTICKS
)
1096 vSlData
.usScale1Spacing
= 0;
1097 vSlData
.usScale2Spacing
= 0;
1099 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1100 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1102 vWndParams
.fsStatus
= WPM_CTLDATA
;
1103 vWndParams
.cchText
= 0L;
1104 vWndParams
.pszText
= NULL
;
1105 vWndParams
.cbPresParams
= 0L;
1106 vWndParams
.pPresParams
= NULL
;
1107 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1108 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1109 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1110 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1112 nPixelPos
= i
* n
* m_dPixelToRange
;
1113 ::WinSendMsg( GetHwnd()
1115 ,MPFROMSHORT(nPixelPos
)
1119 } // end of wxSlider::SetTickFreq
1121 void wxSlider::SetValue(
1125 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1126 ,SLM_QUERYSLIDERINFO
1127 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1133 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1134 ,SLM_QUERYSLIDERINFO
1135 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1141 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1142 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1144 ::WinSendMsg( GetHwnd()
1146 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1153 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1154 ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
);
1156 } // end of wxSlider::SetValue
1158 bool wxSlider::Show(
1162 wxWindowOS2::Show(bShow
);
1164 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1166 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1168 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1170 } // end of wxSlider::Show