]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/slider.cpp
e74e38ac5edf7920f1ce1ab3dbcc10e41edecaa8
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/slider.cpp
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"
28 #include "wx/slider.h"
29 #include "wx/os2/private.h"
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( int nX
,
57 int WXUNUSED(nSizeFlags
) )
61 int nCx
; // slider,min,max sizes
65 wxFont vFont
= this->GetFont();
67 wxGetCharSize( GetHWND()
73 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
75 if (m_windowStyle
& wxSL_LABELS
)
80 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
81 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
83 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
84 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
88 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
89 int nValueHeight
= nCyf
;
91 ::WinSetWindowPos( (HWND
)m_hStaticValue
93 ,(LONG
)nXOffset
- (nNewWidth
+ nCx
+ nMinLen
+ nCx
)
100 ::WinSetWindowPos( (HWND
)m_hStaticMin
102 ,(LONG
)nXOffset
- (nMinLen
+ nCx
)
108 nXOffset
+= nWidth
+ nCx
;
110 ::WinSetWindowPos( (HWND
)m_hStaticMax
116 ,SWP_ZORDER
| SWP_SHOW
123 // Now deal with a vertical slider
126 if (m_windowStyle
& wxSL_LABELS
)
131 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
132 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
134 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
135 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
139 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
141 ::WinSetWindowPos( (HWND
)m_hStaticValue
144 ,(LONG
)nYOffset
+ nHeight
+ nCyf
150 ::WinSetWindowPos( (HWND
)m_hStaticMax
153 ,(LONG
)nYOffset
+ nHeight
158 ::WinSetWindowPos( (HWND
)m_hStaticMin
161 ,(LONG
)nYOffset
- nCyf
168 } // end of wxSlider::AdjustSubControls
170 void wxSlider::ClearSel()
172 } // end of wxSlider::ClearSel
174 void wxSlider::ClearTicks()
176 } // end of wxSlider::ClearTicks
178 void wxSlider::Command (
179 wxCommandEvent
& rEvent
182 SetValue(rEvent
.GetInt());
183 ProcessCommand(rEvent
);
184 } // end of wxSlider::Command
186 bool wxSlider::ContainsHWND(
190 return ( hWnd
== GetStaticMin() ||
191 hWnd
== GetStaticMax() ||
192 hWnd
== GetEditValue()
194 } // end of wxSlider::ContainsHWND
196 bool wxSlider::Create(
202 , const wxPoint
& rPos
203 , const wxSize
& rSize
205 , const wxValidator
& rValidator
206 , const wxString
& rsName
211 int nWidth
= rSize
.x
;
212 int nHeight
= rSize
.y
;
218 SetValidator(rValidator
);
221 pParent
->AddChild(this);
222 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
223 SetForegroundColour(pParent
->GetForegroundColour()) ;
230 m_windowStyle
= lStyle
;
234 m_windowId
= (int)NewControlId();
238 if (m_windowStyle
& wxCLIP_SIBLINGS
)
239 lMsStyle
|= WS_CLIPSIBLINGS
;
241 if (m_windowStyle
& wxSL_LABELS
)
243 lMsStyle
|= WS_VISIBLE
| SS_TEXT
| DT_VCENTER
;
245 m_hStaticValue
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
246 ,WC_STATIC
// Window class
247 ,(PSZ
)NULL
// Initial Text
248 ,(ULONG
)lMsStyle
// Style flags
249 ,0L, 0L, 0L, 0L // Origin -- 0 size
250 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
251 ,HWND_TOP
// initial z position
252 ,(ULONG
)NewControlId() // Window identifier
253 ,NULL
// no control data
254 ,NULL
// no Presentation parameters
258 // Now create min static control
260 wxSprintf(wxBuffer
, wxT("%d"), nMinValue
);
261 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
262 if (m_windowStyle
& wxCLIP_SIBLINGS
)
263 lWstyle
|= WS_CLIPSIBLINGS
;
265 m_hStaticMin
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
266 ,WC_STATIC
// Window class
267 ,(PSZ
)wxBuffer
// Initial Text
268 ,(ULONG
)lWstyle
// Style flags
269 ,0L, 0L, 0L, 0L // Origin -- 0 size
270 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
271 ,HWND_TOP
// initial z position
272 ,(ULONG
)NewControlId() // Window identifier
273 ,NULL
// no control data
274 ,NULL
// no Presentation parameters
281 vSlData
.cbSize
= sizeof(SLDCDATA
);
282 if (m_windowStyle
& wxSL_VERTICAL
)
283 lMsStyle
= SLS_VERTICAL
| SLS_HOMEBOTTOM
| WS_VISIBLE
| WS_TABSTOP
;
285 lMsStyle
= SLS_HORIZONTAL
| SLS_HOMELEFT
| WS_VISIBLE
| WS_TABSTOP
;
287 if (m_windowStyle
& wxCLIP_SIBLINGS
)
288 lMsStyle
|= WS_CLIPSIBLINGS
;
290 if (m_windowStyle
& wxSL_AUTOTICKS
)
292 vSlData
.usScale1Spacing
= 0;
293 vSlData
.usScale2Spacing
= 0;
296 if (m_windowStyle
& wxSL_LEFT
)
297 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_VERTICAL then SCALE2 is to the left
298 else if (m_windowStyle
& wxSL_RIGHT
)
299 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_VERTICAL then SCALE2 is to the right
300 else if (m_windowStyle
& wxSL_TOP
)
301 lMsStyle
|= SLS_PRIMARYSCALE1
; // if SLS_HORIZONTAL then SCALE1 is to the top
302 else if (m_windowStyle
& wxSL_BOTTOM
)
303 lMsStyle
|= SLS_PRIMARYSCALE2
; // if SLS_HORIZONTAL then SCALE1 is to the bottom
304 else if ( m_windowStyle
& wxSL_BOTH
)
305 lMsStyle
|= SLS_PRIMARYSCALE1
| SLS_PRIMARYSCALE2
;
307 lMsStyle
|= SLS_PRIMARYSCALE2
;
308 lMsStyle
|= SLS_RIBBONSTRIP
;
310 m_nPageSize
= ((nMaxValue
- nMinValue
)/10);
311 vSlData
.usScale1Increments
= (USHORT
)m_nPageSize
;
312 vSlData
.usScale2Increments
= (USHORT
)m_nPageSize
;
314 HWND hScrollBar
= ::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
315 ,WC_SLIDER
// Window class
316 ,(PSZ
)wxBuffer
// Initial Text
317 ,(ULONG
)lMsStyle
// Style flags
318 ,0L, 0L, 0L, 0L // Origin -- 0 size
319 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
320 ,HWND_BOTTOM
// initial z position
321 ,(HMENU
)m_windowId
// Window identifier
322 ,&vSlData
// Slider control data
323 ,NULL
// no Presentation parameters
325 m_nRangeMax
= nMaxValue
;
326 m_nRangeMin
= nMinValue
;
329 // Set the size of the ticks ... default to 6 pixels
331 ::WinSendMsg( hScrollBar
333 ,MPFROM2SHORT(SMA_SETALLTICKS
, (USHORT
)12)
337 // Set the position to the initial value
339 ::WinSendMsg( hScrollBar
341 ,MPFROM2SHORT(SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
345 m_hWnd
= (WXHWND
)hScrollBar
;
346 SubclassWin(GetHWND());
347 ::WinSetWindowText((HWND
)m_hWnd
, "");
349 SetFont(*wxSMALL_FONT
);
350 if (m_windowStyle
& wxSL_LABELS
)
353 // Finally, create max value static item
355 wxSprintf(wxBuffer
, wxT("%d"), nMaxValue
);
356 lWstyle
= SS_TEXT
|DT_LEFT
|WS_VISIBLE
;
357 if (m_windowStyle
& wxCLIP_SIBLINGS
)
358 lMsStyle
|= WS_CLIPSIBLINGS
;
360 m_hStaticMax
= (WXHWND
)::WinCreateWindow( (HWND
)GetHwndOf(pParent
) // Parent window handle
361 ,WC_STATIC
// Window class
362 ,(PSZ
)wxBuffer
// Initial Text
363 ,(ULONG
)lWstyle
// Style flags
364 ,0L, 0L, 0L, 0L // Origin -- 0 size
365 ,(HWND
)GetHwndOf(pParent
) // owner window handle (same as parent
366 ,HWND_TOP
// initial z position
367 ,(ULONG
)NewControlId() // Window identifier
368 ,NULL
// no control data
369 ,NULL
// no Presentation parameters
371 if (GetFont().IsOk())
373 if (GetFont().GetResourceHandle())
376 wxOS2SetFont( m_hStaticMin
380 wxOS2SetFont( m_hStaticMax
384 wxOS2SetFont( m_hStaticValue
398 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
400 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
405 ) + 4; // for bordersizes
407 wxColour
vColour(*wxBLACK
);
409 LONG lColor
= (LONG
)vColour
.GetPixel();
411 ::WinSetPresParam( m_hStaticMin
416 ::WinSetPresParam( m_hStaticMax
421 ::WinSetPresParam( m_hStaticValue
426 ::WinSetPresParam( m_hWnd
431 lColor
= (LONG
)m_backgroundColour
.GetPixel();
432 ::WinSetPresParam( m_hStaticMin
437 ::WinSetPresParam( m_hStaticMax
442 ::WinSetPresParam( m_hStaticValue
447 ::WinSetPresParam( m_hWnd
452 vColour
.Set(wxString(wxT("BLUE")));
453 lColor
= (LONG
)vColour
.GetPixel();
454 ::WinSetPresParam( m_hWnd
455 ,PP_HILITEBACKGROUNDCOLOR
461 } // end of wxSlider::Create
463 void wxSlider::DoSetSize( int nX
,
471 int nWidth1
= nWidth
;
472 int nHeight1
= nHeight
;
475 int nCx
; // slider,min,max sizes
481 wxFont vFont
= this->GetFont();
484 // Adjust for OS/2's reverse coordinate system
486 wxWindowOS2
* pParent
= (wxWindowOS2
*)GetParent();
488 int nOS2Height
= nHeight
;
492 CacheBestSize(wxSize(nWidth
,nOS2Height
));
496 int nOS2ParentHeight
= GetOS2ParentHeight(pParent
);
498 nYOffset
= nOS2ParentHeight
- (nYOffset
+ nOS2Height
);
499 if (nY
!= wxDefaultCoord
)
500 nY1
= nOS2ParentHeight
- (nY1
+ nOS2Height
);
506 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
507 nYOffset
= vRect
.yTop
- (nYOffset
+ nOS2Height
);
508 if (nY
!= wxDefaultCoord
)
509 nY1
= vRect
.yTop
- (nY1
+ nOS2Height
);
511 m_nSizeFlags
= nSizeFlags
;
513 GetPosition( &nCurrentX
, &nCurrentY
);
514 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
516 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
519 AdjustForParentClientOrigin( nX1
523 wxGetCharSize( GetHWND()
529 if ((m_windowStyle
& wxSL_VERTICAL
) != wxSL_VERTICAL
)
531 if (m_windowStyle
& wxSL_LABELS
)
536 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
537 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
538 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
539 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
543 int nNewWidth
= (wxMax(nMinLen
, nMaxLen
));
544 int nValueHeight
= nCyf
;
546 ::WinSetWindowPos( (HWND
)m_hStaticValue
549 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
552 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
554 nXOffset
+= nNewWidth
+ nCx
;
556 ::WinSetWindowPos( (HWND
)m_hStaticMin
559 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
562 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
564 nXOffset
+= nMinLen
+ nCx
;
566 int nSliderLength
= nWidth1
- nXOffset
- nMaxLen
- nCx
;
567 int nSliderHeight
= nHeight1
;
569 if (nSliderHeight
< 0)
573 // Slider must have a minimum/default length/height
575 if (nSliderLength
< 100)
578 ::WinSetWindowPos( GetHwnd()
584 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
586 ::WinQueryWindowPos(GetHwnd(), GetSwp());
587 ::WinSendMsg( GetHwnd()
589 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
592 ,MPFROMLONG((ULONG
)(nSliderHeight
/2))
594 nXOffset
+= nSliderLength
+ nCx
;
596 ::WinSetWindowPos( (HWND
)m_hStaticMax
599 ,(LONG
)nYOffset
- (LONG
)(nCyf
* 1.2)
602 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
609 // If we're prepared to use the existing size, then...
611 if (nWidth
== -1 && nHeight
== -1 &&
612 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
622 ::WinSetWindowPos( GetHwnd()
628 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
634 // Now deal with a vertical slider
638 if (m_windowStyle
& wxSL_LABELS
)
643 ::WinQueryWindowText((HWND
)m_hStaticMin
, 300, (PSZ
)zBuf
);
644 GetTextExtent(zBuf
, &nMinLen
, &nCyf
, NULL
, NULL
, &vFont
);
645 ::WinQueryWindowText((HWND
)m_hStaticMax
, 300, (PSZ
)zBuf
);
646 GetTextExtent(zBuf
, &nMaxLen
, &nCyf
, NULL
, NULL
, &vFont
);
649 int nNewWidth
= wxMax(nMinLen
, nMaxLen
);
650 int nValueHeight
= nCyf
;
652 ::WinSetWindowPos( (HWND
)m_hStaticValue
655 ,(LONG
)nYOffset
+ nHeight
658 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
662 ::WinSetWindowPos( (HWND
)m_hStaticMin
665 ,(LONG
)nYOffset
+ nHeight
- nCyf
668 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
672 int nSliderLength
= nHeight1
- (nUsedHeight
+ (2 * nCy
));
673 int nSliderWidth
= nWidth1
;
675 if (nSliderWidth
< 0)
679 // Slider must have a minimum/default length
681 if (nSliderLength
< 100)
684 ::WinSetWindowPos( GetHwnd()
687 ,(LONG
)nYOffset
+ nCyf
690 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
692 ::WinQueryWindowPos(GetHwnd(), GetSwp());
693 ::WinSendMsg( GetHwnd()
695 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
698 ,MPFROMLONG((ULONG
)(nSliderWidth
/2))
700 nUsedHeight
+= nSliderLength
;
701 ::WinSetWindowPos( (HWND
)m_hStaticMax
704 ,(LONG
)nYOffset
- nCyf
707 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
714 // If we're prepared to use the existing size, then...
716 if (nWidth
== -1 && nHeight
== -1 &&
717 ((nSizeFlags
& wxSIZE_AUTO
) != wxSIZE_AUTO
))
727 ::WinSetWindowPos( GetHwnd()
733 ,SWP_ZORDER
| SWP_SIZE
| SWP_MOVE
| SWP_SHOW
737 } // end of void wxSlider::DoSetSize
739 int wxSlider::GetLineSize() const
742 } // end of wxSlider::GetLineSize
744 int wxSlider::GetPageSize() const
747 } // end of wxSlider::GetPageSize
749 void wxSlider::GetPosition(
754 wxWindowOS2
* pParent
= GetParent();
761 wxFindMaxSize( GetHWND()
766 wxFindMaxSize( m_hStaticMin
770 wxFindMaxSize( m_hStaticMax
774 wxFindMaxSize( m_hStaticValue
779 // Since we now have the absolute screen coords,
780 // if there's a parent we must subtract its top left corner
784 vPoint
.x
= vRect
.xLeft
;
785 vPoint
.y
= vRect
.yTop
;
791 ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
);
797 // We may be faking the client origin.
798 // So a window that's really at (0, 30) may appear
799 // (to wxWin apps) to be at (0, 0).
803 wxPoint
vPt(GetParent()->GetClientAreaOrigin());
812 } // end of wxSlider::GetPosition
814 int wxSlider::GetSelEnd() const
817 } // end of wxSlider::GetSelEnd
819 int wxSlider::GetSelStart() const
822 } // end of wxSlider::GetSelStart
824 void wxSlider::DoGetSize(
832 } // end of wxSlider::DoGetSize
834 void wxSlider::GetSize(
846 wxFindMaxSize( GetHWND()
851 wxFindMaxSize( m_hStaticMin
855 wxFindMaxSize( m_hStaticMax
859 wxFindMaxSize( m_hStaticValue
863 *pnWidth
= vRect
.xRight
- vRect
.xLeft
;
865 *pnHeight
= vRect
.yTop
- vRect
.yBottom
;
866 } // end of wxSlider::GetSize
868 int wxSlider::GetThumbLength() const
870 return m_nThumbLength
;
871 } // end of wxSlider::GetThumbLength
873 int wxSlider::GetValue() const
875 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
877 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
883 double dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
884 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
886 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
892 int nNewPos
= (int)(nPixelPos
/dPixelToRange
);
893 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
896 } // end of wxSlider::GetValue
898 WXHBRUSH
wxSlider::OnCtlColor(
907 return (wxControl::OnCtlColor( hDC
915 } // end of wxSlider::OnCtlColor
917 bool wxSlider::OS2OnScroll( int WXUNUSED(nOrientation
),
919 WXWORD
WXUNUSED(wPos
),
920 WXHWND
WXUNUSED(hControl
) )
922 wxEventType eScrollEvent
= wxEVT_NULL
;
927 if (m_windowStyle
& wxSL_TOP
)
928 eScrollEvent
= wxEVT_SCROLL_TOP
;
929 else if (m_windowStyle
& wxSL_BOTTOM
)
930 eScrollEvent
= wxEVT_SCROLL_BOTTOM
;
933 case SLN_SLIDERTRACK
:
934 eScrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
941 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
942 , SLM_QUERYSLIDERINFO
943 , MPFROM2SHORT( SMA_SHAFTDIMENSIONS
, SMA_RANGEVALUE
)
947 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
949 int nPixelPos
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
950 , SLM_QUERYSLIDERINFO
951 , MPFROM2SHORT( SMA_SLIDERARMPOSITION
, SMA_RANGEVALUE
)
956 nNewPos
= (int)(nPixelPos
/m_dPixelToRange
);
957 if (nNewPos
> (m_nRangeMax
- m_nRangeMin
)/2)
959 if ((nNewPos
< GetMin()) || (nNewPos
> GetMax()))
962 // Out of range - but we did process it
968 wxScrollEvent
vEvent( eScrollEvent
, m_windowId
);
970 vEvent
.SetPosition(nNewPos
);
971 vEvent
.SetEventObject(this);
972 HandleWindowEvent(vEvent
);
974 wxCommandEvent
vCevent( wxEVT_SLIDER
, GetId() );
976 vCevent
.SetInt(nNewPos
);
977 vCevent
.SetEventObject(this);
978 return (HandleWindowEvent(vCevent
));
979 } // end of wxSlider::OS2OnScroll
981 void wxSlider::SetLineSize( int nLineSize
)
983 m_nLineSize
= nLineSize
;
984 } // end of wxSlider::SetLineSize
987 void wxSlider::SetPageSize( int nPageSize
)
989 m_nPageSize
= nPageSize
;
990 } // end of wxSlider::SetPageSize
992 void wxSlider::SetRange(
999 m_nRangeMin
= nMinValue
;
1000 m_nRangeMax
= nMaxValue
;
1002 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1003 ,SLM_QUERYSLIDERINFO
1004 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1010 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1013 wxSprintf(zBuf
, wxT("%d"), m_nRangeMin
);
1014 ::WinSetWindowText((HWND
)m_hStaticMin
, (PSZ
)zBuf
);
1019 wxSprintf(zBuf
, wxT("%d"), m_nRangeMax
);
1020 ::WinSetWindowText((HWND
)m_hStaticMax
, (PSZ
)zBuf
);
1022 } // end of wxSlider::SetRange
1024 void wxSlider::SetSelection(
1025 int WXUNUSED(nMinPos
)
1026 , int WXUNUSED(nMaxPos
)
1029 } // end of wxSlider::SetSelection
1031 void wxSlider::SetThumbLength(
1037 m_nThumbLength
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1038 ,SLM_QUERYSLIDERINFO
1039 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1044 ) + 4; // for bordersizes
1045 nBreadth
= SHORT2FROMMR(::WinSendMsg( GetHwnd()
1046 ,SLM_QUERYSLIDERINFO
1047 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1053 ::WinSendMsg( GetHwnd()
1055 ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS
1058 ,MPFROM2SHORT(nLen
, nBreadth
)
1060 m_nThumbLength
= nLen
+ 4; // Borders
1061 } // end of wxSlider::SetThumbLength
1063 void wxSlider::SetTick(
1067 nTickPos
= (int)(nTickPos
* m_dPixelToRange
);
1068 ::WinSendMsg( GetHwnd()
1070 ,MPFROMSHORT(nTickPos
)
1073 } // end of wxSlider::SetTick
1075 // For trackbars only
1076 void wxSlider::DoSetTickFreq( int n
)
1079 WNDPARAMS vWndParams
;
1083 vSlData
.cbSize
= sizeof(SLDCDATA
);
1084 if (m_windowStyle
& wxSL_AUTOTICKS
)
1086 vSlData
.usScale1Spacing
= 0;
1087 vSlData
.usScale2Spacing
= 0;
1089 vSlData
.usScale1Increments
= (USHORT
)((m_nRangeMax
- m_nRangeMin
)/n
);
1090 vSlData
.usScale2Increments
= (USHORT
)((m_nRangeMax
- m_nRangeMin
)/n
);
1092 vWndParams
.fsStatus
= WPM_CTLDATA
;
1093 vWndParams
.cchText
= 0L;
1094 vWndParams
.pszText
= NULL
;
1095 vWndParams
.cbPresParams
= 0L;
1096 vWndParams
.pPresParams
= NULL
;
1097 vWndParams
.cbCtlData
= vSlData
.cbSize
;
1098 vWndParams
.pCtlData
= (PVOID
)&vSlData
;
1099 ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)0);
1100 for (i
= 1; i
< (m_nRangeMax
- m_nRangeMin
)/n
; i
++)
1102 nPixelPos
= (int)(i
* n
* m_dPixelToRange
);
1103 ::WinSendMsg( GetHwnd()
1105 ,MPFROMSHORT(nPixelPos
)
1109 } // end of wxSlider::SetTickFreq
1111 void wxSlider::SetValue(
1115 int nPixelRange
= SHORT1FROMMR(::WinSendMsg( GetHwnd()
1116 ,SLM_QUERYSLIDERINFO
1117 ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
1123 m_dPixelToRange
= (double)(nPixelRange
- m_nThumbLength
)/(double)(m_nRangeMax
- m_nRangeMin
);
1124 int nNewPos
= (int)(nValue
* m_dPixelToRange
);
1126 ::WinSendMsg( GetHwnd()
1128 ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
1135 wxSprintf(wxBuffer
, wxT("%d"), nValue
);
1136 ::WinSetWindowText((HWND
)m_hStaticValue
, (PSZ
)wxBuffer
);
1138 } // end of wxSlider::SetValue
1140 bool wxSlider::Show(
1144 wxWindowOS2::Show(bShow
);
1146 ::WinShowWindow((HWND
)m_hStaticValue
, bShow
);
1148 ::WinShowWindow((HWND
)m_hStaticMin
, bShow
);
1150 ::WinShowWindow((HWND
)m_hStaticMax
, bShow
);
1152 } // end of wxSlider::Show
1154 #endif // wxUSE_SLIDER