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
207 , const wxValidator
& rValidator
208 , const wxString
& rsName
213 int nWidth
= rSize
.x
;
214 int nHeight
= rSize
.y
;
220 SetValidator(rValidator
);
223 pParent
->AddChild(this);
224 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
225 SetForegroundColour(pParent
->GetForegroundColour()) ;
232 m_windowStyle
= lStyle
;
236 m_windowId
= (int)NewControlId();
240 if (m_windowStyle
& wxCLIP_SIBLINGS
)
241 lMsStyle
|= WS_CLIPSIBLINGS
;
243 if (m_windowStyle
& wxSL_LABELS
)
245 lMsStyle
|= WS_VISIBLE
| SS_TEXT
| DT_VCENTER
;
247 m_hStaticValue
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
248 ,WC_STATIC
// Window class
249 ,(PSZ
)NULL
// Initial Text
250 ,(ULONG
)lMsStyle
// Style flags
251 ,0L, 0L, 0L, 0L // Origin -- 0 size
252 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
253 ,HWND_TOP
// initial z position
254 ,(ULONG
)NewControlId() // Window identifier
255 ,NULL
// no control data
256 ,NULL
// no Presentation parameters
260 // Now create min static control
262 sprintf(wxBuffer
, "%d", nMinValue
);
263 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
264 if (m_windowStyle
& wxCLIP_SIBLINGS
)
265 lWstyle
|= WS_CLIPSIBLINGS
;
267 m_hStaticMin
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
268 ,WC_STATIC
// Window class
269 ,(PSZ
)wxBuffer
// Initial Text
270 ,(ULONG
)lWstyle
// Style flags
271 ,0L, 0L, 0L, 0L // Origin -- 0 size
272 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
273 ,HWND_TOP
// initial z position
274 ,(ULONG
)NewControlId() // Window identifier
275 ,NULL
// no control data
276 ,NULL
// no Presentation parameters
283 vSlData
.cbSize
= sizeof(SLDCDATA
);
284 if (m_windowStyle
& wxSL_VERTICAL
)
285 lMsStyle
= SLS_VERTICAL
| SLS_HOMEBOTTOM
| WS_VISIBLE
| WS_TABSTOP
;
287 lMsStyle
= SLS_HORIZONTAL
| SLS_HOMELEFT
| WS_VISIBLE
| WS_TABSTOP
;
289 if (m_windowStyle
& wxCLIP_SIBLINGS
)
290 lMsStyle
|= WS_CLIPSIBLINGS
;
292 if (m_windowStyle
& wxSL_AUTOTICKS
)
294 vSlData
.usScale1Spacing
= 0;
295 vSlData
.usScale2Spacing
= 0;
298 if (m_windowStyle
& wxSL_LEFT
)
299 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left
300 else if (m_windowStyle
& wxSL_RIGHT
)
301 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right
302 else if (m_windowStyle
& wxSL_TOP
)
303 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top
304 else if (m_windowStyle
& wxSL_BOTTOM
)
305 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom
306 else if ( m_windowStyle
& wxSL_BOTH
)
307 lMsStyle
|= SLS_PRIMARYSCALE1
| SLS_PRIMARYSCALE2
;
309 lMsStyle
|= SLS_PRIMARYSCALE2
;
310 lMsStyle
|= SLS_RIBBONSTRIP
;
312 m_nPageSize
= ((nMaxValue
- nMinValue
)/10);
313 vSlData
.usScale1Increments
= m_nPageSize
;
314 vSlData
.usScale2Increments
= m_nPageSize
;
316 HWND hScrollBar
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
317 ,WC_SLIDER
// Window class
318 ,(PSZ
)wxBuffer
// Initial Text
319 ,(ULONG
)lMsStyle
// Style flags
320 ,0L, 0L, 0L, 0L // Origin -- 0 size
321 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
322 ,HWND_BOTTOM
// initial z position
323 ,(HMENU
)m_windowId
// Window identifier
324 ,&vSlData
// Slider control data
325 ,NULL
// no Presentation parameters
327 m_nRangeMax
= nMaxValue
;
328 m_nRangeMin
= nMinValue
;
331 // Set the size of the ticks ... default to 6 pixels
333 ::WinSendMsg( hScrollBar
335 ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12)
339 // Set the position to the initial value
341 ::WinSendMsg( hScrollBar
343 ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
347 m_hWnd
= (WXHWND
)hScrollBar
;
348 SubclassWin(GetHWND());
349 ::WinSetWindowText((HWND
)m_hWnd
, "");
351 SetFont(*wxSMALL_FONT
);
352 if (m_windowStyle
& wxSL_LABELS
)
355 // Finally, create max value static item
357 sprintf(wxBuffer
, "%d", nMaxValue
);
358 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
359 if (m_windowStyle
& wxCLIP_SIBLINGS
)
360 lMsStyle
|= WS_CLIPSIBLINGS
;
362 m_hStaticMax
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
363 ,WC_STATIC
// Window class
364 ,(PSZ
)wxBuffer
// Initial Text
365 ,(ULONG
)lWstyle
// Style flags
366 ,0L, 0L, 0L, 0L // Origin -- 0 size
367 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
368 ,HWND_TOP
// initial z position
369 ,(ULONG
)NewControlId() // Window identifier
370 ,NULL
// no control data
371 ,NULL
// no Presentation parameters
375 if (GetFont().GetResourceHandle())
378 wxOS2SetFont( m_hStaticMin
382 wxOS2SetFont( m_hStaticMax
386 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
465 } // end of wxSlider::Create
467 void wxSlider::DoSetSize(
477 int nWidth1
= nWidth
;
478 int nHeight1
= nHeight
;
481 int nCx
; // slider,min,max sizes
489 // Adjust for OS/2's reverse coordinate system
491 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
493 int nOS2Height
= nHeight
;
500 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
502 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
504 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
510 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
511 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
513 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
515 m_nSizeFlags
= nSizeFlags
;
517 GetPosition( &nCurrentX
520 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
522 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
525 AdjustForParentClientOrigin( nX1
529 wxGetCharSize( GetHWND()
535 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
537 if (m_windowStyle
& wxSL_LABELS
)
542 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
543 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
544 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
545 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
549 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
550 int nValueHeight
= nCyf
;
552 ::WinSetWindowPos( (HWND
)m_hStaticValue
555 ,(LONG
)nYOffset
- (nCyf
* 1.2)
558 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
560 nXOffset
+= nNewWidth
+ nCx
;
562 ::WinSetWindowPos( (HWND
)m_hStaticMin
565 ,(LONG
)nYOffset
- (nCyf
* 1.2)
568 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
570 nXOffset
+= nMinLen
+ nCx
;
572 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
573 int nSliderHeight
= nHeight1
;
575 if (nSliderHeight
< 0)
579 // Slider must have a minimum/default length/height
581 if (nSliderLength
< 100)
584 ::WinSetWindowPos( GetHwnd()
590 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
592 ::WinQueryWindowPos(GetHwnd(), GetSwp());
593 ::WinSendMsg( GetHwnd()
595 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
598 ,MPFROMLONG((ULONG
)(nSliderHeight
/2))
600 nXOffset
+= nSliderLength
+ nCx
;
602 ::WinSetWindowPos( (HWND
)m_hStaticMax
605 ,(LONG
)nYOffset
- (nCyf
* 1.2)
608 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
615 // If we're prepared to use the existing size, then...
617 if (nWidth
== -1 && nHeight
== -1 &&
618 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
628 ::WinSetWindowPos( GetHwnd()
634 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
640 // Now deal with a vertical slider
644 if (m_windowStyle
& wxSL_LABELS
)
649 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, zBuf
);
650 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
651 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, zBuf
);
652 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &this->GetFont());
655 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
656 int nValueHeight
= nCyf
;
658 ::WinSetWindowPos( (HWND
)m_hStaticValue
661 ,(LONG
)nYOffset
+ nHeight
664 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
668 ::WinSetWindowPos( (HWND
)m_hStaticMin
671 ,(LONG
)nYOffset
+ nHeight
- nCyf
674 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
678 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
679 int nSliderWidth
= nWidth1
;
681 if (nSliderWidth
< 0)
685 // Slider must have a minimum/default length
687 if (nSliderLength
< 100)
690 ::WinSetWindowPos( GetHwnd()
693 ,(LONG
)nYOffset
+ nCyf
696 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
698 ::WinQueryWindowPos(GetHwnd(), GetSwp());
699 ::WinSendMsg( GetHwnd()
701 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
704 ,MPFROMLONG((ULONG
)(nSliderWidth
/2))
706 nUsedHeight
+= nSliderLength
;
707 ::WinSetWindowPos( (HWND
)m_hStaticMax
710 ,(LONG
)nYOffset
- nCyf
713 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
720 // If we're prepared to use the existing size, then...
722 if (nWidth
== -1 && nHeight
== -1 &&
723 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
733 ::WinSetWindowPos( GetHwnd()
739 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
743 } // end of void wxSlider::DoSetSize
745 int wxSlider::GetLineSize() const
748 } // end of wxSlider::GetLineSize
750 int wxSlider::GetPageSize() const
753 } // end of wxSlider::GetPageSize
755 void wxSlider::GetPosition(
760 wxWindowOS2
* pParent
= GetParent();
767 wxFindMaxSize( GetHWND()
772 wxFindMaxSize( m_hStaticMin
776 wxFindMaxSize( m_hStaticMax
780 wxFindMaxSize( m_hStaticValue
785 // Since we now have the absolute screen coords,
786 // if there's a parent we must subtract its top left corner
790 vPoint
.x
= vRect
.xLeft
;
791 vPoint
.y
= vRect
.yTop
;
797 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
803 // We may be faking the client origin.
804 // So a window that's really at (0, 30) may appear
805 // (to wxWin apps) to be at (0, 0).
809 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
816 } // end of wxSlider::GetPosition
818 int wxSlider::GetSelEnd() const
821 } // end of wxSlider::GetSelEnd
823 int wxSlider::GetSelStart() const
826 } // end of wxSlider::GetSelStart
828 void wxSlider::DoGetSize(
836 } // end of wxSlider::DoGetSize
838 void wxSlider::GetSize(
850 wxFindMaxSize( GetHWND()
855 wxFindMaxSize( m_hStaticMin
859 wxFindMaxSize( m_hStaticMax
863 wxFindMaxSize( m_hStaticValue
866 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
867 *pnHeight
= vRect
.yBottom
- vRect
.yTop
;
868 } // end of wxSlider::GetSize
870 int wxSlider::GetThumbLength() const
872 return m_nThumbLength
;
873 } // end of wxSlider::GetThumbLength
875 int wxSlider::GetValue() const
877 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
879 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
885 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
887 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
889 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
895 nNewPos
= (int)(nPixelPos
/dPixelToRange
);
896 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
899 } // end of wxSlider::GetValue
901 WXHBRUSH
wxSlider::OnCtlColor(
910 return (wxControl::OnCtlColor( hDC
918 } // end of wxSlider::OnCtlColor
920 bool wxSlider::OS2OnScroll(
921 int WXUNUSED(nOrientation
)
927 wxEventType eScrollEvent
= wxEVT_NULL
;
932 if (m_windowStyle
& wxSL_TOP
)
933 eScrollEvent
= wxEVT_SCROLL_TOP
;
934 else if (m_windowStyle
& wxSL_BOTTOM
)
935 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
938 case SLN_SLIDERTRACK
:
939 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
946 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
948 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
954 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
956 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
958 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
964 nNewPos
= (nPixelPos
/m_dPixelToRange
);
965 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
967 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
970 // Out of range - but we did process it
976 wxScrollEvent
vEvent( eScrollEvent
980 vEvent
.SetPosition(nNewPos
);
981 vEvent
.SetEventObject(this);
982 GetEventHandler()->ProcessEvent(vEvent
);
984 wxCommandEvent
vCevent( wxEVT_COMMAND_SLIDER_UPDATED
988 vCevent
.SetInt(nNewPos
);
989 vCevent
.SetEventObject(this);
990 return (GetEventHandler()->ProcessEvent(vCevent
));
991 } // end of wxSlider::OS2OnScroll
993 void wxSlider::SetLineSize(
997 m_nLineSize
= nLineSize
;
998 } // end of wxSlider::SetLineSize
1001 void wxSlider::SetPageSize(
1005 m_nPageSize
= nPageSize
;
1006 } // end of wxSlider::SetPageSize
1008 void wxSlider::SetRange(
1015 m_nRangeMin
= nMinValue
;
1016 m_nRangeMax
= nMaxValue
;
1018 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1019 ,SLM_QUERYSLIDERINFO
1020 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1026 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1029 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1030 ::WinSetWindowText((HWND
)m_hStaticMin
, zBuf
);
1035 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1036 ::WinSetWindowText((HWND
)m_hStaticMax
, zBuf
);
1038 } // end of wxSlider::SetRange
1040 void wxSlider::SetSelection(
1041 int WXUNUSED(nMinPos
)
1042 , int WXUNUSED(nMaxPos
)
1045 } // end of wxSlider::SetSelection
1047 void wxSlider::SetThumbLength(
1053 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1054 ,SLM_QUERYSLIDERINFO
1055 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1060 ) + 4; // for bordersizes
1061 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1062 ,SLM_QUERYSLIDERINFO
1063 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1069 ::WinSendMsg( GetHwnd()
1071 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1074 ,MPFROM2SHORT(nLen
, nBreadth
)
1076 m_nThumbLength
= nLen
+ 4; // Borders
1077 } // end of wxSlider::SetThumbLength
1079 void wxSlider::SetTick(
1083 nTickPos
*= m_dPixelToRange
;
1084 ::WinSendMsg( GetHwnd()
1086 ,MPFROMSHORT(nTickPos
)
1089 } // end of wxSlider::SetTick
1091 // For trackbars only
1092 void wxSlider::SetTickFreq(
1098 WNDPARAMS vWndParams
;
1102 vSlData
.cbSize
= sizeof(SLDCDATA
);
1103 if (m_windowStyle
& wxSL_AUTOTICKS
)
1105 vSlData
.usScale1Spacing
= 0;
1106 vSlData
.usScale2Spacing
= 0;
1108 vSlData
.usScale1Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1109 vSlData
.usScale2Increments
= (m_nRangeMax
- m_nRangeMin
)/n
;
1111 vWndParams
.fsStatus
= WPM_CTLDATA
;
1112 vWndParams
.cchText
= 0L;
1113 vWndParams
.pszText
= NULL
;
1114 vWndParams
.cbPresParams
= 0L;
1115 vWndParams
.pPresParams
= NULL
;
1116 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1117 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1118 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1119 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1121 nPixelPos
= i
* n
* m_dPixelToRange
;
1122 ::WinSendMsg( GetHwnd()
1124 ,MPFROMSHORT(nPixelPos
)
1128 } // end of wxSlider::SetTickFreq
1130 void wxSlider::SetValue(
1134 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1135 ,SLM_QUERYSLIDERINFO
1136 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1142 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1143 ,SLM_QUERYSLIDERINFO
1144 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1150 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1151 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1153 ::WinSendMsg( GetHwnd()
1155 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1162 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1163 ::WinSetWindowText((HWND
)m_hStaticValue
, wxBuffer
);
1165 } // end of wxSlider::SetValue
1167 bool wxSlider::Show(
1171 wxWindowOS2::Show(bShow
);
1173 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1175 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1177 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1179 } // end of wxSlider::Show