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_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 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
;
660 ::WinSetWindowPos( (HWND
)m_hStaticValue
663 ,(LONG
)nYOffset
+ nHeight
666 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
670 ::WinSetWindowPos( (HWND
)m_hStaticMin
673 ,(LONG
)nYOffset
+ nHeight
- nCyf
676 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
680 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
681 int nSliderWidth
= nWidth1
;
683 if (nSliderWidth
< 0)
687 // Slider must have a minimum/default length
689 if (nSliderLength
< 100)
692 ::WinSetWindowPos( GetHwnd()
695 ,(LONG
)nYOffset
+ nCyf
698 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
700 ::WinQueryWindowPos(GetHwnd(), GetSwp());
701 ::WinSendMsg( GetHwnd()
703 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
706 ,MPFROMLONG((ULONG
)(nSliderWidth
/2))
708 nUsedHeight
+= nSliderLength
;
709 ::WinSetWindowPos( (HWND
)m_hStaticMax
712 ,(LONG
)nYOffset
- nCyf
715 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
722 // If we're prepared to use the existing size, then...
724 if (nWidth
== -1 && nHeight
== -1 &&
725 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
735 ::WinSetWindowPos( GetHwnd()
741 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
745 } // end of void wxSlider::DoSetSize
747 int wxSlider::GetLineSize() const
750 } // end of wxSlider::GetLineSize
752 int wxSlider::GetPageSize() const
755 } // end of wxSlider::GetPageSize
757 void wxSlider::GetPosition(
762 wxWindowOS2
* pParent
= GetParent();
769 wxFindMaxSize( GetHWND()
774 wxFindMaxSize( m_hStaticMin
778 wxFindMaxSize( m_hStaticMax
782 wxFindMaxSize( m_hStaticValue
787 // Since we now have the absolute screen coords,
788 // if there's a parent we must subtract its top left corner
792 vPoint
.x
= vRect
.xLeft
;
793 vPoint
.y
= vRect
.yTop
;
799 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
805 // We may be faking the client origin.
806 // So a window that's really at (0, 30) may appear
807 // (to wxWin apps) to be at (0, 0).
811 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
818 } // end of wxSlider::GetPosition
820 int wxSlider::GetSelEnd() const
823 } // end of wxSlider::GetSelEnd
825 int wxSlider::GetSelStart() const
828 } // end of wxSlider::GetSelStart
830 void wxSlider::DoGetSize(
838 } // end of wxSlider::DoGetSize
840 void wxSlider::GetSize(
852 wxFindMaxSize( GetHWND()
857 wxFindMaxSize( m_hStaticMin
861 wxFindMaxSize( m_hStaticMax
865 wxFindMaxSize( m_hStaticValue
868 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
869 *pnHeight
= vRect
.yBottom
- vRect
.yTop
;
870 } // end of wxSlider::GetSize
872 int wxSlider::GetThumbLength() const
874 return m_nThumbLength
;
875 } // end of wxSlider::GetThumbLength
877 int wxSlider::GetValue() const
879 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
881 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
887 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
889 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
891 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
897 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
898 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
901 } // end of wxSlider::GetValue
903 WXHBRUSH
wxSlider::OnCtlColor(
912 return (wxControl::OnCtlColor( hDC
920 } // end of wxSlider::OnCtlColor
922 bool wxSlider::OS2OnScroll(
923 int WXUNUSED(nOrientation
)
929 wxEventType eScrollEvent
= wxEVT_NULL
;
934 if (m_windowStyle
& wxSL_TOP
)
935 eScrollEvent
= wxEVT_SCROLL_TOP
;
936 else if (m_windowStyle
& wxSL_BOTTOM
)
937 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
940 case SLN_SLIDERTRACK
:
941 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
948 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
950 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
956 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
958 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
960 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
966 nNewPos
= (nPixelPos
/m_dPixelToRange
);
967 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
969 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
972 // Out of range - but we did process it
978 wxScrollEvent
vEvent( eScrollEvent
982 vEvent
.SetPosition(nNewPos
);
983 vEvent
.SetEventObject(this);
984 GetEventHandler()->ProcessEvent(vEvent
);
986 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
990 vCevent
.SetInt(nNewPos
);
991 vCevent
.SetEventObject(this);
992 return (GetEventHandler()->ProcessEvent(vCevent
));
993 } // end of wxSlider::OS2OnScroll
995 void wxSlider::SetLineSize(
999 m_nLineSize
= nLineSize
;
1000 } // end of wxSlider::SetLineSize
1003 void wxSlider::SetPageSize(
1007 m_nPageSize
= nPageSize
;
1008 } // end of wxSlider::SetPageSize
1010 void wxSlider::SetRange(
1017 m_nRangeMin
= nMinValue
;
1018 m_nRangeMax
= nMaxValue
;
1020 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1021 ,SLM_QUERYSLIDERINFO
1022 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1028 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1031 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1032 ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
);
1037 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1038 ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
);
1040 } // end of wxSlider::SetRange
1042 void wxSlider::SetSelection(
1043 int WXUNUSED(nMinPos
)
1044 , int WXUNUSED(nMaxPos
)
1047 } // end of wxSlider::SetSelection
1049 void wxSlider::SetThumbLength(
1055 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1056 ,SLM_QUERYSLIDERINFO
1057 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1062 ) + 4; // for bordersizes
1063 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1064 ,SLM_QUERYSLIDERINFO
1065 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1071 ::WinSendMsg( GetHwnd()
1073 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1076 ,MPFROM2SHORT(nLen
, nBreadth
)
1078 m_nThumbLength
= nLen
+ 4; // Borders
1079 } // end of wxSlider::SetThumbLength
1081 void wxSlider::SetTick(
1085 nTickPos
*= m_dPixelToRange
;
1086 ::WinSendMsg( GetHwnd()
1088 ,MPFROMSHORT(nTickPos
)
1091 } // end of wxSlider::SetTick
1093 // For trackbars only
1094 void wxSlider::SetTickFreq(
1100 WNDPARAMS vWndParams
;
1104 vSlData
.cbSize
= sizeof(SLDCDATA
);
1105 if (m_windowStyle
& wxSL_AUTOTICKS
)
1107 vSlData
.usScale1Spacing
= 0;
1108 vSlData
.usScale2Spacing
= 0;
1110 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1111 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1113 vWndParams
.fsStatus
= WPM_CTLDATA
;
1114 vWndParams
.cchText
= 0L;
1115 vWndParams
.pszText
= NULL
;
1116 vWndParams
.cbPresParams
= 0L;
1117 vWndParams
.pPresParams
= NULL
;
1118 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1119 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1120 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1121 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1123 nPixelPos
= i
* n
* m_dPixelToRange
;
1124 ::WinSendMsg( GetHwnd()
1126 ,MPFROMSHORT(nPixelPos
)
1130 } // end of wxSlider::SetTickFreq
1132 void wxSlider::SetValue(
1136 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1137 ,SLM_QUERYSLIDERINFO
1138 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1144 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1145 ,SLM_QUERYSLIDERINFO
1146 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1152 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1153 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1155 ::WinSendMsg( GetHwnd()
1157 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1164 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1165 ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
);
1167 } // end of wxSlider::SetValue
1169 bool wxSlider::Show(
1173 wxWindowOS2::Show(bShow
);
1175 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1177 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1179 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1181 } // end of wxSlider::Show