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
)
99 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
102 ::WinSetWindowPos( (HWND
)m_hStaticMin
104 ,(LONG
)nXOffset
- (nMinLen
+ nCx
)
108 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
110 nXOffset
+= nWidth
+ nCx
;
112 ::WinSetWindowPos( (HWND
)m_hStaticMax
118 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
123 // Now deal with a vertical slider -- OS/2 doesn't have vertical sliders
125 } // end of wxSlider::AdjustSubControls
127 void wxSlider::ClearSel()
129 } // end of wxSlider::ClearSel
131 void wxSlider::ClearTicks()
133 } // end of wxSlider::ClearTicks
135 void wxSlider::Command (
136 wxCommandEvent
& rEvent
139 SetValue(rEvent
.GetInt());
140 ProcessCommand(rEvent
);
141 } // end of wxSlider::Command
143 bool wxSlider::ContainsHWND(
147 return ( hWnd
== GetStaticMin() ||
148 hWnd
== GetStaticMax() ||
149 hWnd
== GetEditValue()
151 } // end of wxSlider::ContainsHWND
153 bool wxSlider::Create(
159 , const wxPoint
& rPos
160 , const wxSize
& rSize
163 , const wxValidator
& rValidator
165 , const wxString
& rsName
170 int nWidth
= rSize
.x
;
171 int nHeight
= rSize
.y
;
177 SetValidator(rValidator
);
180 pParent
->AddChild(this);
181 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
182 SetForegroundColour(pParent
->GetForegroundColour()) ;
189 m_windowStyle
= lStyle
;
193 m_windowId
= (int)NewControlId();
197 if (m_windowStyle
& wxCLIP_SIBLINGS
)
198 lMsStyle
|= WS_CLIPSIBLINGS
;
200 if (m_windowStyle
& wxSL_LABELS
)
202 lMsStyle
|= WS_VISIBLE
| SS_TEXT
| DT_VCENTER
;
205 // If the parent is a scrolled window the controls must
206 // have this style or they will overlap the scrollbars
209 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
210 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
211 lMsStyle
|= WS_CLIPSIBLINGS
;
213 m_hStaticValue
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
214 ,WC_STATIC
// Window class
215 ,(PSZ
)NULL
// Initial Text
216 ,(ULONG
)lMsStyle
// Style flags
217 ,0L, 0L, 0L, 0L // Origin -- 0 size
218 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
219 ,HWND_TOP
// initial z position
220 ,(ULONG
)NewControlId() // Window identifier
221 ,NULL
// no control data
222 ,NULL
// no Presentation parameters
226 // Now create min static control
228 sprintf(wxBuffer
, "%d", nMinValue
);
229 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
230 if (m_windowStyle
& wxCLIP_SIBLINGS
)
231 lWstyle
|= WS_CLIPSIBLINGS
;
233 // If the parent is a scrolled window the controls must
234 // have this style or they will overlap the scrollbars
237 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
238 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
239 lWstyle
|= WS_CLIPSIBLINGS
;
241 m_hStaticMin
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
242 ,WC_STATIC
// Window class
243 ,(PSZ
)wxBuffer
// Initial Text
244 ,(ULONG
)lWstyle
// Style flags
245 ,0L, 0L, 0L, 0L // Origin -- 0 size
246 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
247 ,HWND_TOP
// initial z position
248 ,(ULONG
)NewControlId() // Window identifier
249 ,NULL
// no control data
250 ,NULL
// no Presentation parameters
257 vSlData
.cbSize
= sizeof(SLDCDATA
);
258 if (m_windowStyle
& wxSL_VERTICAL
)
259 lMsStyle
= SLS_VERTICAL
| WS_VISIBLE
| WS_TABSTOP
;
261 lMsStyle
= SLS_HORIZONTAL
| WS_VISIBLE
| WS_TABSTOP
;
263 if (m_windowStyle
& wxCLIP_SIBLINGS
)
264 lMsStyle
|= WS_CLIPSIBLINGS
;
266 if (m_windowStyle
& wxSL_AUTOTICKS
)
268 vSlData
.usScale1Spacing
= 0;
269 vSlData
.usScale2Spacing
= 0;
272 if (m_windowStyle
& wxSL_LEFT
)
273 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left
274 else if (m_windowStyle
& wxSL_RIGHT
)
275 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right
276 else if (m_windowStyle
& wxSL_TOP
)
277 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top
278 else if (m_windowStyle
& wxSL_BOTTOM
)
279 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom
280 else if ( m_windowStyle
& wxSL_BOTH
)
281 lMsStyle
|= SLS_PRIMARYSCALE1
| SLS_PRIMARYSCALE2
;
283 lMsStyle
|= SLS_PRIMARYSCALE2
;
286 // If the parent is a scrolled window the controls must
287 // have this style or they will overlap the scrollbars
290 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
291 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
292 lMsStyle
|= WS_CLIPSIBLINGS
;
294 m_nPageSize
= ((nMaxValue
- nMinValue
)/10);
295 vSlData
.usScale1Increments
= m_nPageSize
;
296 vSlData
.usScale2Increments
= m_nPageSize
;
298 HWND hScrollBar
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
299 ,WC_SLIDER
// Window class
300 ,(PSZ
)wxBuffer
// Initial Text
301 ,(ULONG
)lMsStyle
// Style flags
302 ,0L, 0L, 0L, 0L // Origin -- 0 size
303 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
304 ,HWND_TOP
// initial z position
305 ,(HMENU
)m_windowId
// Window identifier
306 ,&vSlData
// Slider control data
307 ,NULL
// no Presentation parameters
309 m_nRangeMax
= nMaxValue
;
310 m_nRangeMin
= nMinValue
;
313 // Set the size of the ticks ... default to 6 pixels
315 ::WinSendMsg( hScrollBar
317 ,MPFROM2SHORT(SMA_SETALLTICKS
, 6)
321 // Set the position to the initial value
323 ::WinSendMsg( hScrollBar
325 ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
329 m_hWnd
= (WXHWND
)hScrollBar
;
330 SubclassWin(GetHWND());
331 ::WinSetWindowText((HWND
)m_hWnd
, "");
332 SetFont(*wxSMALL_FONT
);
333 if (m_windowStyle
& wxSL_LABELS
)
336 // Finally, create max value static item
338 sprintf(wxBuffer
, "%d", nMaxValue
);
339 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
340 if (m_windowStyle
& wxCLIP_SIBLINGS
)
341 lMsStyle
|= WS_CLIPSIBLINGS
;
343 // If the parent is a scrolled window the controls must
344 // have this style or they will overlap the scrollbars
347 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
348 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
349 lWstyle
|= WS_CLIPSIBLINGS
;
351 m_hStaticMax
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
352 ,WC_STATIC
// Window class
353 ,(PSZ
)wxBuffer
// Initial Text
354 ,(ULONG
)lWstyle
// Style flags
355 ,0L, 0L, 0L, 0L // Origin -- 0 size
356 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
357 ,HWND_TOP
// initial z position
358 ,(ULONG
)NewControlId() // Window identifier
359 ,NULL
// no control data
360 ,NULL
// no Presentation parameters
364 if (GetFont().GetResourceHandle())
367 wxOS2SetFont( m_hStaticMin
371 wxOS2SetFont( m_hStaticMax
375 wxOS2SetFont( m_hStaticValue
387 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
389 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
394 ) + 4; // for bordersizes
398 vColour
.Set(wxString("BLACK"));
400 LONG lColor
= (LONG
)vColour
.GetPixel();
402 ::WinSetPresParam( m_hStaticMin
407 ::WinSetPresParam( m_hStaticMax
412 ::WinSetPresParam( m_hStaticValue
417 ::WinSetPresParam( m_hWnd
422 lColor
= (LONG
)m_backgroundColour
.GetPixel();
423 ::WinSetPresParam( m_hStaticMin
428 ::WinSetPresParam( m_hStaticMax
433 ::WinSetPresParam( m_hStaticValue
438 ::WinSetPresParam( m_hWnd
445 } // end of wxSlider::Create
447 void wxSlider::DoSetSize(
457 int nWidth1
= nWidth
;
458 int nHeight1
= nHeight
;
461 int nCx
; // slider,min,max sizes
469 // Adjust for OS/2's reverse coordinate system
471 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
473 int nOS2Height
= nHeight
;
480 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
482 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
484 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
490 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
491 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
493 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
495 m_nSizeFlags
= nSizeFlags
;
497 GetPosition( &nCurrentX
500 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
502 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
505 AdjustForParentClientOrigin( nX1
509 wxGetCharSize( GetHWND()
515 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
517 if (m_windowStyle
& wxSL_LABELS
)
522 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
523 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
524 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
525 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
529 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
530 int nValueHeight
= nCyf
;
532 ::WinSetWindowPos( (HWND
)m_hStaticValue
535 ,(LONG
)nYOffset
- (nCyf
* 1.2)
538 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
540 nXOffset
+= nNewWidth
+ nCx
;
542 ::WinSetWindowPos( (HWND
)m_hStaticMin
545 ,(LONG
)nYOffset
- nCyf
548 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
550 nXOffset
+= nMinLen
+ nCx
;
552 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
553 int nSliderHeight
= nHeight1
;
555 if (nSliderHeight
< 0)
559 // Slider must have a minimum/default length/height
561 if (nSliderLength
< 100)
564 ::WinSetWindowPos( GetHwnd()
570 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
572 nXOffset
+= nSliderLength
+ nCx
;
574 ::WinSetWindowPos( (HWND
)m_hStaticMax
577 ,(LONG
)nYOffset
- nCyf
580 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
587 // If we're prepared to use the existing size, then...
589 if (nWidth
== -1 && nHeight
== -1 &&
590 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
600 ::WinSetWindowPos( GetHwnd()
606 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
612 // Now deal with a vertical slider
616 if (m_windowStyle
& wxSL_LABELS
)
621 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
622 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
623 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
624 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
627 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
628 int nValueHeight
= nCyf
;
633 // The height needs to be a bit bigger under Win95 if using native
636 nValueHeight
= (int)(nValueHeight
* 1.5);
637 ::WinSetWindowPos( (HWND
)m_hStaticValue
643 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
645 nYOffset
-= nValueHeight
;
646 nUsedHeight
+= nValueHeight
;
648 ::WinSetWindowPos( (HWND
)m_hStaticMin
654 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
659 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
660 int nSliderWidth
= nWidth1
;
662 if (nSliderWidth
< 0)
666 // Slider must have a minimum/default length
668 if (nSliderLength
< 100)
671 ::WinSetWindowPos( (HWND
)m_hStaticMin
677 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
679 nYOffset
-= nSliderLength
;
680 nUsedHeight
+= nSliderLength
;
681 ::WinSetWindowPos( (HWND
)m_hStaticMax
687 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
694 // If we're prepared to use the existing size, then...
696 if (nWidth
== -1 && nHeight
== -1 &&
697 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
707 ::WinSetWindowPos( GetHwnd()
713 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
717 } // end of void wxSlider::DoSetSize
719 int wxSlider::GetLineSize() const
722 } // end of wxSlider::GetLineSize
724 int wxSlider::GetPageSize() const
727 } // end of wxSlider::GetPageSize
729 void wxSlider::GetPosition(
734 wxWindowOS2
* pParent
= GetParent();
741 wxFindMaxSize( GetHWND()
746 wxFindMaxSize( m_hStaticMin
750 wxFindMaxSize( m_hStaticMax
754 wxFindMaxSize( m_hStaticValue
759 // Since we now have the absolute screen coords,
760 // if there's a parent we must subtract its top left corner
764 vPoint
.x
= vRect
.xLeft
;
765 vPoint
.y
= vRect
.yTop
;
771 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
777 // We may be faking the client origin.
778 // So a window that's really at (0, 30) may appear
779 // (to wxWin apps) to be at (0, 0).
783 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
790 } // end of wxSlider::GetPosition
792 int wxSlider::GetSelEnd() const
795 } // end of wxSlider::GetSelEnd
797 int wxSlider::GetSelStart() const
800 } // end of wxSlider::GetSelStart
802 void wxSlider::GetSize(
814 wxFindMaxSize( GetHWND()
819 wxFindMaxSize( m_hStaticMin
823 wxFindMaxSize( m_hStaticMax
827 wxFindMaxSize( m_hStaticValue
830 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
831 *pnHeight
= vRect
.yBottom
- vRect
.yTop
;
832 } // end of wxSlider::GetSize
834 int wxSlider::GetThumbLength() const
836 return m_nThumbLength
;
837 } // end of wxSlider::GetThumbLength
839 int wxSlider::GetValue() const
841 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
843 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
849 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
851 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
853 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
859 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
860 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
863 } // end of wxSlider::GetValue
865 WXHBRUSH
wxSlider::OnCtlColor(
874 return (wxControl::OnCtlColor( hDC
882 } // end of wxSlider::OnCtlColor
884 bool wxSlider::OS2OnScroll(
885 int WXUNUSED(nOrientation
)
891 wxEventType eScrollEvent
= wxEVT_NULL
;
896 if (m_windowStyle
& wxSL_TOP
)
897 eScrollEvent
= wxEVT_SCROLL_TOP
;
898 else if (m_windowStyle
& wxSL_BOTTOM
)
899 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
902 case SLN_SLIDERTRACK
:
903 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
910 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
912 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
918 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
920 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
922 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
928 nNewPos
= (nPixelPos
/m_dPixelToRange
);
929 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
931 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
934 // Out of range - but we did process it
940 wxScrollEvent
vEvent( eScrollEvent
944 vEvent
.SetPosition(nNewPos
);
945 vEvent
.SetEventObject(this);
946 GetEventHandler()->ProcessEvent(vEvent
);
948 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
952 vCevent
.SetInt(nNewPos
);
953 vCevent
.SetEventObject(this);
954 return (GetEventHandler()->ProcessEvent(vCevent
));
955 } // end of wxSlider::OS2OnScroll
957 void wxSlider::SetLineSize(
961 m_nLineSize
= nLineSize
;
962 } // end of wxSlider::SetLineSize
965 void wxSlider::SetPageSize(
969 m_nPageSize
= nPageSize
;
970 } // end of wxSlider::SetPageSize
972 void wxSlider::SetRange(
979 m_nRangeMin
= nMinValue
;
980 m_nRangeMax
= nMaxValue
;
982 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
984 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
990 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
993 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
994 ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
);
999 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1000 ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
);
1002 } // end of wxSlider::SetRange
1004 void wxSlider::SetSelection(
1005 int WXUNUSED(nMinPos
)
1006 , int WXUNUSED(nMaxPos
)
1009 } // end of wxSlider::SetSelection
1011 void wxSlider::SetThumbLength(
1017 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1018 ,SLM_QUERYSLIDERINFO
1019 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1024 ) + 4; // for bordersizes
1025 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1026 ,SLM_QUERYSLIDERINFO
1027 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1033 ::WinSendMsg( GetHwnd()
1035 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1038 ,MPFROM2SHORT(nLen
, nBreadth
)
1040 m_nThumbLength
= nLen
+ 4; // Borders
1041 } // end of wxSlider::SetThumbLength
1043 void wxSlider::SetTick(
1047 nTickPos
*= m_dPixelToRange
;
1048 ::WinSendMsg( GetHwnd()
1050 ,MPFROMSHORT(nTickPos
)
1053 } // end of wxSlider::SetTick
1055 // For trackbars only
1056 void wxSlider::SetTickFreq(
1062 WNDPARAMS vWndParams
;
1066 vSlData
.cbSize
= sizeof(SLDCDATA
);
1067 if (m_windowStyle
& wxSL_AUTOTICKS
)
1069 vSlData
.usScale1Spacing
= 0;
1070 vSlData
.usScale2Spacing
= 0;
1072 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1073 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1075 vWndParams
.fsStatus
= WPM_CTLDATA
;
1076 vWndParams
.cchText
= 0L;
1077 vWndParams
.pszText
= NULL
;
1078 vWndParams
.cbPresParams
= 0L;
1079 vWndParams
.pPresParams
= NULL
;
1080 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1081 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1082 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1083 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1085 nPixelPos
= i
* n
* m_dPixelToRange
;
1086 ::WinSendMsg( GetHwnd()
1088 ,MPFROMSHORT(nPixelPos
)
1092 } // end of wxSlider::SetTickFreq
1094 void wxSlider::SetValue(
1098 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1099 ,SLM_QUERYSLIDERINFO
1100 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1106 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1107 ,SLM_QUERYSLIDERINFO
1108 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1114 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1115 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1117 ::WinSendMsg( GetHwnd()
1119 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1126 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1127 ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
);
1129 } // end of wxSlider::SetValue
1131 bool wxSlider::Show(
1135 wxWindowOS2::Show(bShow
);
1137 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1139 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1141 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1143 } // end of wxSlider::Show