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"
25 #include "wx/slider.h"
26 #include "wx/os2/private.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxSlider
, wxControl
)
40 } // end of wxSlider::wxSlider
45 ::WinDestroyWindow((HWND
)m_hStaticMin
);
47 ::WinDestroyWindow((HWND
)m_hStaticMax
);
49 ::WinDestroyWindow((HWND
)m_hStaticValue
);
50 } // end of wxSlider::~wxSlider
52 void wxSlider::AdjustSubControls(
63 int nCx
; // slider,min,max sizes
68 wxGetCharSize( GetHWND()
74 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
76 if (m_windowStyle
& wxSL_LABELS
)
81 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
82 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
84 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
85 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
89 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
90 int nValueHeight
= nCyf
;
92 ::WinSetWindowPos( (HWND
)m_hStaticValue
94 ,(LONG
)nXOffset
- (nNewWidth
+ nCx
+ nMinLen
+ nCx
)
98 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
101 ::WinSetWindowPos( (HWND
)m_hStaticMin
103 ,(LONG
)nXOffset
- (nMinLen
+ nCx
)
107 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
109 nXOffset
+= nWidth
+ nCx
;
111 ::WinSetWindowPos( (HWND
)m_hStaticMax
117 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
122 // Now deal with a vertical slider -- OS/2 doesn't have vertical sliders
124 } // end of wxSlider::AdjustSubControls
126 void wxSlider::ClearSel()
128 } // end of wxSlider::ClearSel
130 void wxSlider::ClearTicks()
132 } // end of wxSlider::ClearTicks
134 void wxSlider::Command (
135 wxCommandEvent
& rEvent
138 SetValue(rEvent
.GetInt());
139 ProcessCommand(rEvent
);
140 } // end of wxSlider::Command
142 bool wxSlider::ContainsHWND(
146 return ( hWnd
== GetStaticMin() ||
147 hWnd
== GetStaticMax() ||
148 hWnd
== GetEditValue()
150 } // end of wxSlider::ContainsHWND
152 bool wxSlider::Create(
158 , const wxPoint
& rPos
159 , const wxSize
& rSize
162 , const wxValidator
& rValidator
164 , const wxString
& rsName
169 int nWidth
= rSize
.x
;
170 int nHeight
= rSize
.y
;
176 SetValidator(rValidator
);
179 pParent
->AddChild(this);
180 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
181 SetForegroundColour(pParent
->GetForegroundColour()) ;
188 m_windowStyle
= lStyle
;
192 m_windowId
= (int)NewControlId();
196 if (m_windowStyle
& wxCLIP_SIBLINGS
)
197 lMsStyle
|= WS_CLIPSIBLINGS
;
199 if (m_windowStyle
& wxSL_LABELS
)
201 lMsStyle
|= WS_VISIBLE
| SS_TEXT
| DT_VCENTER
;
204 // If the parent is a scrolled window the controls must
205 // have this style or they will overlap the scrollbars
208 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
209 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
210 lMsStyle
|= WS_CLIPSIBLINGS
;
212 m_hStaticValue
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
213 ,WC_STATIC
// Window class
214 ,(PSZ
)NULL
// Initial Text
215 ,(ULONG
)lMsStyle
// Style flags
216 ,0L, 0L, 0L, 0L // Origin -- 0 size
217 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
218 ,HWND_TOP
// initial z position
219 ,(ULONG
)NewControlId() // Window identifier
220 ,NULL
// no control data
221 ,NULL
// no Presentation parameters
225 // Now create min static control
227 sprintf(wxBuffer
, "%d", nMinValue
);
228 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
229 if (m_windowStyle
& wxCLIP_SIBLINGS
)
230 lWstyle
|= WS_CLIPSIBLINGS
;
232 // If the parent is a scrolled window the controls must
233 // have this style or they will overlap the scrollbars
236 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
237 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
238 lWstyle
|= WS_CLIPSIBLINGS
;
240 m_hStaticMin
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
241 ,WC_STATIC
// Window class
242 ,(PSZ
)wxBuffer
// Initial Text
243 ,(ULONG
)lWstyle
// Style flags
244 ,0L, 0L, 0L, 0L // Origin -- 0 size
245 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
246 ,HWND_TOP
// initial z position
247 ,(ULONG
)NewControlId() // Window identifier
248 ,NULL
// no control data
249 ,NULL
// no Presentation parameters
256 vSlData
.cbSize
= sizeof(SLDCDATA
);
257 if (m_windowStyle
& wxSL_VERTICAL
)
258 lMsStyle
= SLS_VERTICAL
| WS_VISIBLE
| WS_TABSTOP
;
260 lMsStyle
= SLS_HORIZONTAL
| WS_VISIBLE
| WS_TABSTOP
;
262 if (m_windowStyle
& wxCLIP_SIBLINGS
)
263 lMsStyle
|= WS_CLIPSIBLINGS
;
265 if (m_windowStyle
& wxSL_AUTOTICKS
)
267 vSlData
.usScale1Spacing
= 0;
268 vSlData
.usScale2Spacing
= 0;
271 if (m_windowStyle
& wxSL_LEFT
)
272 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left
273 else if (m_windowStyle
& wxSL_RIGHT
)
274 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right
275 else if (m_windowStyle
& wxSL_TOP
)
276 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top
277 else if (m_windowStyle
& wxSL_BOTTOM
)
278 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom
279 else if ( m_windowStyle
& wxSL_BOTH
)
280 lMsStyle
|= SLS_PRIMARYSCALE1
| SLS_PRIMARYSCALE2
;
282 lMsStyle
|= SLS_PRIMARYSCALE2
;
285 // If the parent is a scrolled window the controls must
286 // have this style or they will overlap the scrollbars
289 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
290 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
291 lMsStyle
|= WS_CLIPSIBLINGS
;
293 m_nPageSize
= ((nMaxValue
- nMinValue
)/10);
294 vSlData
.usScale1Increments
= m_nPageSize
;
295 vSlData
.usScale2Increments
= m_nPageSize
;
297 HWND hScrollBar
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
298 ,WC_SLIDER
// Window class
299 ,(PSZ
)wxBuffer
// Initial Text
300 ,(ULONG
)lMsStyle
// Style flags
301 ,0L, 0L, 0L, 0L // Origin -- 0 size
302 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
303 ,HWND_TOP
// initial z position
304 ,(HMENU
)m_windowId
// Window identifier
305 ,&vSlData
// Slider control data
306 ,NULL
// no Presentation parameters
308 m_nRangeMax
= nMaxValue
;
309 m_nRangeMin
= nMinValue
;
312 // Set the size of the ticks ... default to 6 pixels
314 ::WinSendMsg( hScrollBar
316 ,MPFROM2SHORT(SMA_SETALLTICKS
, 6)
320 // Set the position to the initial value
322 ::WinSendMsg( hScrollBar
324 ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
328 m_hWnd
= (WXHWND
)hScrollBar
;
329 SubclassWin(GetHWND());
330 ::WinSetWindowText((HWND
)m_hWnd
, "");
331 SetFont(pParent
->GetFont());
332 if (m_windowStyle
& wxSL_LABELS
)
335 // Finally, create max value static item
337 sprintf(wxBuffer
, "%d", nMaxValue
);
338 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
339 if (m_windowStyle
& wxCLIP_SIBLINGS
)
340 lMsStyle
|= WS_CLIPSIBLINGS
;
342 // If the parent is a scrolled window the controls must
343 // have this style or they will overlap the scrollbars
346 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
347 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
348 lWstyle
|= WS_CLIPSIBLINGS
;
350 m_hStaticMax
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
351 ,WC_STATIC
// Window class
352 ,(PSZ
)wxBuffer
// Initial Text
353 ,(ULONG
)lWstyle
// Style flags
354 ,0L, 0L, 0L, 0L // Origin -- 0 size
355 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
356 ,HWND_TOP
// initial z position
357 ,(ULONG
)NewControlId() // Window identifier
358 ,NULL
// no control data
359 ,NULL
// no Presentation parameters
363 if (GetFont().GetResourceHandle())
366 wxOS2SetFont( m_hStaticMin
370 wxOS2SetFont( m_hStaticMax
374 wxOS2SetFont( m_hStaticValue
386 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
388 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
393 ) + 4; // for bordersizes
397 vColour
.Set(wxString("BLACK"));
399 LONG lColor
= (LONG
)vColour
.GetPixel();
401 ::WinSetPresParam( m_hStaticMin
406 ::WinSetPresParam( m_hStaticMax
411 ::WinSetPresParam( m_hStaticValue
416 ::WinSetPresParam( m_hWnd
421 lColor
= (LONG
)m_backgroundColour
.GetPixel();
422 ::WinSetPresParam( m_hStaticMin
427 ::WinSetPresParam( m_hStaticMax
432 ::WinSetPresParam( m_hStaticValue
437 ::WinSetPresParam( m_hWnd
444 } // end of wxSlider::Create
446 void wxSlider::DoSetSize(
456 int nWidth1
= nWidth
;
457 int nHeight1
= nHeight
;
460 int nCx
; // slider,min,max sizes
468 // Adjust for OS/2's reverse coordinate system
470 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
472 int nOS2Height
= nHeight
;
479 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
481 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
483 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
489 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
490 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
492 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
494 m_nSizeFlags
= nSizeFlags
;
496 GetPosition( &nCurrentX
499 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
501 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
504 AdjustForParentClientOrigin( nX1
508 wxGetCharSize( GetHWND()
514 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
516 if (m_windowStyle
& wxSL_LABELS
)
521 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
522 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
523 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
524 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
528 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
529 int nValueHeight
= nCyf
;
531 ::WinSetWindowPos( (HWND
)m_hStaticValue
534 ,(LONG
)nYOffset
- (nCyf
* 1.2)
537 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
539 nXOffset
+= nNewWidth
+ nCx
;
541 ::WinSetWindowPos( (HWND
)m_hStaticMin
544 ,(LONG
)nYOffset
- nCyf
547 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
549 nXOffset
+= nMinLen
+ nCx
;
551 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
552 int nSliderHeight
= nHeight1
;
554 if (nSliderHeight
< 0)
558 // Slider must have a minimum/default length/height
560 if (nSliderLength
< 100)
563 ::WinSetWindowPos( GetHwnd()
569 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
571 nXOffset
+= nSliderLength
+ nCx
;
573 ::WinSetWindowPos( (HWND
)m_hStaticMax
576 ,(LONG
)nYOffset
- nCyf
579 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
586 // If we're prepared to use the existing size, then...
588 if (nWidth
== -1 && nHeight
== -1 &&
589 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
599 ::WinSetWindowPos( GetHwnd()
605 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
611 // Now deal with a vertical slider
615 if (m_windowStyle
& wxSL_LABELS
)
620 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
621 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
622 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
623 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
626 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
627 int nValueHeight
= nCyf
;
632 // The height needs to be a bit bigger under Win95 if using native
635 nValueHeight
= (int)(nValueHeight
* 1.5);
636 ::WinSetWindowPos( (HWND
)m_hStaticValue
642 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
644 nYOffset
-= nValueHeight
;
645 nUsedHeight
+= nValueHeight
;
647 ::WinSetWindowPos( (HWND
)m_hStaticMin
653 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
658 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
659 int nSliderWidth
= nWidth1
;
661 if (nSliderWidth
< 0)
665 // Slider must have a minimum/default length
667 if (nSliderLength
< 100)
670 ::WinSetWindowPos( (HWND
)m_hStaticMin
676 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
678 nYOffset
-= nSliderLength
;
679 nUsedHeight
+= nSliderLength
;
680 ::WinSetWindowPos( (HWND
)m_hStaticMax
686 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
693 // If we're prepared to use the existing size, then...
695 if (nWidth
== -1 && nHeight
== -1 &&
696 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
706 ::WinSetWindowPos( GetHwnd()
712 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
716 } // end of void wxSlider::DoSetSize
718 int wxSlider::GetLineSize() const
721 } // end of wxSlider::GetLineSize
723 int wxSlider::GetPageSize() const
726 } // end of wxSlider::GetPageSize
728 void wxSlider::GetPosition(
733 wxWindowOS2
* pParent
= GetParent();
740 wxFindMaxSize( GetHWND()
745 wxFindMaxSize( m_hStaticMin
749 wxFindMaxSize( m_hStaticMax
753 wxFindMaxSize( m_hStaticValue
758 // Since we now have the absolute screen coords,
759 // if there's a parent we must subtract its top left corner
763 vPoint
.x
= vRect
.xLeft
;
764 vPoint
.y
= vRect
.yTop
;
770 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
776 // We may be faking the client origin.
777 // So a window that's really at (0, 30) may appear
778 // (to wxWin apps) to be at (0, 0).
782 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
789 } // end of wxSlider::GetPosition
791 int wxSlider::GetSelEnd() const
794 } // end of wxSlider::GetSelEnd
796 int wxSlider::GetSelStart() const
799 } // end of wxSlider::GetSelStart
801 void wxSlider::GetSize(
813 wxFindMaxSize( GetHWND()
818 wxFindMaxSize( m_hStaticMin
822 wxFindMaxSize( m_hStaticMax
826 wxFindMaxSize( m_hStaticValue
829 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
830 *pnHeight
= vRect
.yBottom
- vRect
.yTop
;
831 } // end of wxSlider::GetSize
833 int wxSlider::GetThumbLength() const
835 return m_nThumbLength
;
836 } // end of wxSlider::GetThumbLength
838 int wxSlider::GetValue() const
840 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
842 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
848 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
850 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
852 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
858 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
859 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
862 } // end of wxSlider::GetValue
864 WXHBRUSH
wxSlider::OnCtlColor(
873 return (wxControl::OnCtlColor( hDC
881 } // end of wxSlider::OnCtlColor
883 bool wxSlider::OS2OnScroll(
884 int WXUNUSED(nOrientation
)
890 wxEventType eScrollEvent
= wxEVT_NULL
;
895 if (m_windowStyle
& wxSL_TOP
)
896 eScrollEvent
= wxEVT_SCROLL_TOP
;
897 else if (m_windowStyle
& wxSL_BOTTOM
)
898 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
901 case SLN_SLIDERTRACK
:
902 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
909 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
911 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
917 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
919 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
921 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
927 nNewPos
= (nPixelPos
/m_dPixelToRange
);
928 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
930 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
933 // Out of range - but we did process it
939 wxScrollEvent
vEvent( eScrollEvent
943 vEvent
.SetPosition(nNewPos
);
944 vEvent
.SetEventObject(this);
945 GetEventHandler()->ProcessEvent(vEvent
);
947 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
951 vCevent
.SetInt(nNewPos
);
952 vCevent
.SetEventObject(this);
953 return (GetEventHandler()->ProcessEvent(vCevent
));
954 } // end of wxSlider::OS2OnScroll
956 void wxSlider::SetLineSize(
960 m_nLineSize
= nLineSize
;
961 } // end of wxSlider::SetLineSize
964 void wxSlider::SetPageSize(
968 m_nPageSize
= nPageSize
;
969 } // end of wxSlider::SetPageSize
971 void wxSlider::SetRange(
978 m_nRangeMin
= nMinValue
;
979 m_nRangeMax
= nMaxValue
;
981 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
983 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
989 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
992 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
993 ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
);
998 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
999 ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
);
1001 } // end of wxSlider::SetRange
1003 void wxSlider::SetSelection(
1004 int WXUNUSED(nMinPos
)
1005 , int WXUNUSED(nMaxPos
)
1008 } // end of wxSlider::SetSelection
1010 void wxSlider::SetThumbLength(
1016 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1017 ,SLM_QUERYSLIDERINFO
1018 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1023 ) + 4; // for bordersizes
1024 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1025 ,SLM_QUERYSLIDERINFO
1026 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1032 ::WinSendMsg( GetHwnd()
1034 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1037 ,MPFROM2SHORT(nLen
, nBreadth
)
1039 m_nThumbLength
= nLen
+ 4; // Borders
1040 } // end of wxSlider::SetThumbLength
1042 void wxSlider::SetTick(
1046 nTickPos
*= m_dPixelToRange
;
1047 ::WinSendMsg( GetHwnd()
1049 ,MPFROMSHORT(nTickPos
)
1052 } // end of wxSlider::SetTick
1054 // For trackbars only
1055 void wxSlider::SetTickFreq(
1061 WNDPARAMS vWndParams
;
1065 vSlData
.cbSize
= sizeof(SLDCDATA
);
1066 if (m_windowStyle
& wxSL_AUTOTICKS
)
1068 vSlData
.usScale1Spacing
= 0;
1069 vSlData
.usScale2Spacing
= 0;
1071 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1072 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1074 vWndParams
.fsStatus
= WPM_CTLDATA
;
1075 vWndParams
.cchText
= 0L;
1076 vWndParams
.pszText
= NULL
;
1077 vWndParams
.cbPresParams
= 0L;
1078 vWndParams
.pPresParams
= NULL
;
1079 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1080 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1081 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1082 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1084 nPixelPos
= i
* n
* m_dPixelToRange
;
1085 ::WinSendMsg( GetHwnd()
1087 ,MPFROMSHORT(nPixelPos
)
1091 } // end of wxSlider::SetTickFreq
1093 void wxSlider::SetValue(
1097 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1098 ,SLM_QUERYSLIDERINFO
1099 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1105 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1106 ,SLM_QUERYSLIDERINFO
1107 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1113 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1114 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1116 ::WinSendMsg( GetHwnd()
1118 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1125 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1126 ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
);
1128 } // end of wxSlider::SetValue
1130 bool wxSlider::Show(
1134 wxWindowOS2::Show(bShow
);
1136 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1138 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1140 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1142 } // end of wxSlider::Show