]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: slider.cpp | |
3 | // Purpose: wxSlider | |
409c9842 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
409c9842 | 6 | // Created: 10/15/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
409c9842 | 8 | // Copyright: (c) David Webster |
65571936 | 9 | // Licence: wxWindows licence |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
409c9842 DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include <stdio.h> | |
21 | #include <wx/utils.h> | |
22 | #include <wx/brush.h> | |
a4a16252 | 23 | #include <wx/scrolwin.h> |
0e320a79 DW |
24 | #endif |
25 | ||
26 | #include "wx/slider.h" | |
409c9842 | 27 | #include "wx/os2/private.h" |
0e320a79 | 28 | |
0e320a79 DW |
29 | IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl) |
30 | ||
0e320a79 DW |
31 | wxSlider::wxSlider() |
32 | { | |
3c299c3a DW |
33 | m_hStaticValue = 0L; |
34 | m_hStaticMin = 0L; | |
35 | m_hStaticMax = 0L; | |
36 | m_nPageSize = 1; | |
37 | m_nLineSize = 1; | |
38 | m_nRangeMax = 0; | |
39 | m_nRangeMin = 0; | |
40 | m_nTickFreq = 0; | |
41 | } // end of wxSlider::wxSlider | |
409c9842 | 42 | |
0e320a79 DW |
43 | wxSlider::~wxSlider() |
44 | { | |
3c299c3a DW |
45 | if (m_hStaticMin) |
46 | ::WinDestroyWindow((HWND)m_hStaticMin); | |
47 | if (m_hStaticMax) | |
48 | ::WinDestroyWindow((HWND)m_hStaticMax); | |
49 | if (m_hStaticValue) | |
50 | ::WinDestroyWindow((HWND)m_hStaticValue); | |
51 | } // end of wxSlider::~wxSlider | |
0e320a79 | 52 | |
d8a3f66c DW |
53 | void wxSlider::AdjustSubControls( |
54 | int nX | |
55 | , int nY | |
56 | , int nWidth | |
57 | , int nHeight | |
58 | , int nSizeFlags | |
59 | ) | |
60 | { | |
d8a3f66c DW |
61 | int nXOffset = nX; |
62 | int nYOffset = nY; | |
63 | int nCx; // slider,min,max sizes | |
64 | int nCy; | |
65 | int nCyf; | |
66 | char zBuf[300]; | |
67 | ||
68 | wxGetCharSize( GetHWND() | |
69 | ,&nCx | |
70 | ,&nCy | |
71 | ,&this->GetFont() | |
72 | ); | |
73 | ||
74 | if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) | |
75 | { | |
76 | if (m_windowStyle & wxSL_LABELS ) | |
77 | { | |
78 | int nMinLen = 0; | |
79 | int nMaxLen = 0; | |
80 | ||
81 | ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf); | |
82 | GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont()); | |
83 | ||
84 | ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf); | |
85 | GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont()); | |
86 | ||
87 | if (m_hStaticValue) | |
88 | { | |
89 | int nNewWidth = wxMax(nMinLen, nMaxLen); | |
90 | int nValueHeight = nCyf; | |
91 | ||
92 | ::WinSetWindowPos( (HWND)m_hStaticValue | |
93 | ,HWND_TOP | |
94 | ,(LONG)nXOffset - (nNewWidth + nCx + nMinLen + nCx) | |
95 | ,(LONG)nYOffset | |
96 | ,(LONG)nNewWidth | |
97 | ,(LONG)nValueHeight | |
b3260bce | 98 | ,SWP_SIZE | SWP_MOVE |
d8a3f66c DW |
99 | ); |
100 | } | |
101 | ::WinSetWindowPos( (HWND)m_hStaticMin | |
102 | ,HWND_TOP | |
103 | ,(LONG)nXOffset - (nMinLen + nCx) | |
104 | ,(LONG)nYOffset | |
105 | ,(LONG)nMinLen | |
31833fd7 | 106 | ,(LONG)nCyf |
b3260bce | 107 | ,SWP_SIZE | SWP_MOVE |
d8a3f66c DW |
108 | ); |
109 | nXOffset += nWidth + nCx; | |
110 | ||
111 | ::WinSetWindowPos( (HWND)m_hStaticMax | |
112 | ,HWND_TOP | |
113 | ,(LONG)nXOffset | |
114 | ,(LONG)nYOffset | |
115 | ,(LONG)nMaxLen | |
31833fd7 | 116 | ,(LONG)nCyf |
70a2c656 DW |
117 | ,SWP_ZORDER | SWP_SHOW |
118 | ); | |
119 | } | |
120 | } | |
121 | else | |
122 | { | |
123 | // | |
124 | // Now deal with a vertical slider | |
125 | // | |
126 | ||
31833fd7 | 127 | if (m_windowStyle & wxSL_LABELS ) |
70a2c656 DW |
128 | { |
129 | int nMinLen = 0; | |
130 | int nMaxLen = 0; | |
131 | ||
132 | ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf); | |
31833fd7 | 133 | GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont()); |
70a2c656 DW |
134 | |
135 | ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf); | |
31833fd7 | 136 | GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont()); |
70a2c656 DW |
137 | |
138 | if (m_hStaticValue) | |
139 | { | |
31833fd7 | 140 | int nNewWidth = (wxMax(nMinLen, nMaxLen)); |
70a2c656 DW |
141 | |
142 | ::WinSetWindowPos( (HWND)m_hStaticValue | |
143 | ,HWND_TOP | |
144 | ,(LONG)nXOffset | |
145 | ,(LONG)nYOffset + nHeight + nCyf | |
146 | ,(LONG)nNewWidth | |
147 | ,(LONG)nCyf | |
148 | ,SWP_SIZE | SWP_MOVE | |
149 | ); | |
150 | } | |
151 | ::WinSetWindowPos( (HWND)m_hStaticMax | |
152 | ,HWND_TOP | |
153 | ,(LONG)nXOffset | |
154 | ,(LONG)nYOffset + nHeight | |
155 | ,(LONG)nMaxLen | |
156 | ,(LONG)nCyf | |
157 | ,SWP_SIZE | SWP_MOVE | |
158 | ); | |
159 | ::WinSetWindowPos( (HWND)m_hStaticMin | |
160 | ,HWND_TOP | |
161 | ,(LONG)nXOffset | |
162 | ,(LONG)nYOffset - nCyf | |
163 | ,(LONG)nMinLen | |
164 | ,(LONG)nCyf | |
165 | ,SWP_SIZE | SWP_MOVE | |
d8a3f66c DW |
166 | ); |
167 | } | |
168 | } | |
d8a3f66c DW |
169 | } // end of wxSlider::AdjustSubControls |
170 | ||
3c299c3a | 171 | void wxSlider::ClearSel() |
0e320a79 | 172 | { |
3c299c3a | 173 | } // end of wxSlider::ClearSel |
0e320a79 | 174 | |
3c299c3a | 175 | void wxSlider::ClearTicks() |
0e320a79 | 176 | { |
3c299c3a | 177 | } // end of wxSlider::ClearTicks |
0e320a79 | 178 | |
3c299c3a DW |
179 | void wxSlider::Command ( |
180 | wxCommandEvent& rEvent | |
181 | ) | |
0e320a79 | 182 | { |
3c299c3a DW |
183 | SetValue(rEvent.GetInt()); |
184 | ProcessCommand(rEvent); | |
185 | } // end of wxSlider::Command | |
0e320a79 | 186 | |
3c299c3a DW |
187 | bool wxSlider::ContainsHWND( |
188 | WXHWND hWnd | |
189 | ) const | |
0e320a79 | 190 | { |
3c299c3a DW |
191 | return ( hWnd == GetStaticMin() || |
192 | hWnd == GetStaticMax() || | |
193 | hWnd == GetEditValue() | |
194 | ); | |
195 | } // end of wxSlider::ContainsHWND | |
196 | ||
197 | bool wxSlider::Create( | |
198 | wxWindow* pParent | |
199 | , wxWindowID vId | |
200 | , int nValue | |
201 | , int nMinValue | |
202 | , int nMaxValue | |
203 | , const wxPoint& rPos | |
204 | , const wxSize& rSize | |
205 | , long lStyle | |
3c299c3a | 206 | , const wxValidator& rValidator |
3c299c3a DW |
207 | , const wxString& rsName |
208 | ) | |
0e320a79 | 209 | { |
3c299c3a DW |
210 | int nX = rPos.x; |
211 | int nY = rPos.y; | |
212 | int nWidth = rSize.x; | |
213 | int nHeight = rSize.y; | |
214 | long lMsStyle = 0L; | |
215 | long lWstyle = 0L; | |
216 | ||
217 | SetName(rsName); | |
218 | #if wxUSE_VALIDATORS | |
219 | SetValidator(rValidator); | |
220 | #endif | |
221 | if (pParent) | |
222 | pParent->AddChild(this); | |
223 | SetBackgroundColour(pParent->GetBackgroundColour()) ; | |
224 | SetForegroundColour(pParent->GetForegroundColour()) ; | |
225 | ||
226 | m_hStaticValue = 0L; | |
227 | m_hStaticMin = 0L; | |
228 | m_hStaticMax = 0L; | |
229 | m_nPageSize = 1; | |
230 | m_nLineSize = 1; | |
231 | m_windowStyle = lStyle; | |
232 | m_nTickFreq = 0; | |
233 | ||
234 | if (vId == -1) | |
235 | m_windowId = (int)NewControlId(); | |
236 | else | |
237 | m_windowId = vId; | |
409c9842 | 238 | |
3c299c3a DW |
239 | if (m_windowStyle & wxCLIP_SIBLINGS ) |
240 | lMsStyle |= WS_CLIPSIBLINGS; | |
409c9842 | 241 | |
3c299c3a DW |
242 | if (m_windowStyle & wxSL_LABELS) |
243 | { | |
244 | lMsStyle |= WS_VISIBLE | SS_TEXT | DT_VCENTER; | |
245 | ||
246 | m_hStaticValue = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle | |
247 | ,WC_STATIC // Window class | |
248 | ,(PSZ)NULL // Initial Text | |
249 | ,(ULONG)lMsStyle // Style flags | |
250 | ,0L, 0L, 0L, 0L // Origin -- 0 size | |
251 | ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent | |
252 | ,HWND_TOP // initial z position | |
253 | ,(ULONG)NewControlId() // Window identifier | |
254 | ,NULL // no control data | |
255 | ,NULL // no Presentation parameters | |
256 | ); | |
257 | ||
258 | // | |
259 | // Now create min static control | |
260 | // | |
261 | sprintf(wxBuffer, "%d", nMinValue); | |
262 | lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE; | |
263 | if (m_windowStyle & wxCLIP_SIBLINGS) | |
264 | lWstyle |= WS_CLIPSIBLINGS; | |
5d44b24e | 265 | |
3c299c3a DW |
266 | m_hStaticMin = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle |
267 | ,WC_STATIC // Window class | |
268 | ,(PSZ)wxBuffer // Initial Text | |
269 | ,(ULONG)lWstyle // Style flags | |
270 | ,0L, 0L, 0L, 0L // Origin -- 0 size | |
271 | ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent | |
272 | ,HWND_TOP // initial z position | |
273 | ,(ULONG)NewControlId() // Window identifier | |
274 | ,NULL // no control data | |
275 | ,NULL // no Presentation parameters | |
276 | ); | |
277 | } | |
278 | lMsStyle = 0; | |
409c9842 | 279 | |
3c299c3a | 280 | SLDCDATA vSlData; |
409c9842 | 281 | |
3c299c3a DW |
282 | vSlData.cbSize = sizeof(SLDCDATA); |
283 | if (m_windowStyle & wxSL_VERTICAL) | |
70a2c656 | 284 | lMsStyle = SLS_VERTICAL | SLS_HOMEBOTTOM | WS_VISIBLE | WS_TABSTOP; |
3c299c3a | 285 | else |
9e25f509 | 286 | lMsStyle = SLS_HORIZONTAL | SLS_HOMELEFT | WS_VISIBLE | WS_TABSTOP; |
409c9842 | 287 | |
3c299c3a DW |
288 | if (m_windowStyle & wxCLIP_SIBLINGS) |
289 | lMsStyle |= WS_CLIPSIBLINGS; | |
409c9842 | 290 | |
3c299c3a | 291 | if (m_windowStyle & wxSL_AUTOTICKS) |
409c9842 | 292 | { |
3c299c3a DW |
293 | vSlData.usScale1Spacing = 0; |
294 | vSlData.usScale2Spacing = 0; | |
295 | } | |
409c9842 | 296 | |
3c299c3a DW |
297 | if (m_windowStyle & wxSL_LEFT) |
298 | lMsStyle |= SLS_PRIMARYSCALE2; // if SLS_VERTICAL then SCALE2 is to the left | |
299 | else if (m_windowStyle & wxSL_RIGHT) | |
300 | lMsStyle |= SLS_PRIMARYSCALE1; // if SLS_VERTICAL then SCALE2 is to the right | |
301 | else if (m_windowStyle & wxSL_TOP) | |
302 | lMsStyle |= SLS_PRIMARYSCALE1; // if SLS_HORIZONTAL then SCALE1 is to the top | |
303 | else if (m_windowStyle & wxSL_BOTTOM ) | |
304 | lMsStyle |= SLS_PRIMARYSCALE2; // if SLS_HORIZONTAL then SCALE1 is to the bottom | |
305 | else if ( m_windowStyle & wxSL_BOTH ) | |
306 | lMsStyle |= SLS_PRIMARYSCALE1 | SLS_PRIMARYSCALE2; | |
307 | else | |
308 | lMsStyle |= SLS_PRIMARYSCALE2; | |
70a2c656 | 309 | lMsStyle |= SLS_RIBBONSTRIP; |
3c299c3a DW |
310 | |
311 | m_nPageSize = ((nMaxValue - nMinValue)/10); | |
312 | vSlData.usScale1Increments = m_nPageSize; | |
313 | vSlData.usScale2Increments = m_nPageSize; | |
314 | ||
315 | HWND hScrollBar = ::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle | |
316 | ,WC_SLIDER // Window class | |
317 | ,(PSZ)wxBuffer // Initial Text | |
318 | ,(ULONG)lMsStyle // Style flags | |
319 | ,0L, 0L, 0L, 0L // Origin -- 0 size | |
320 | ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent | |
757cc9de | 321 | ,HWND_BOTTOM // initial z position |
3c299c3a DW |
322 | ,(HMENU)m_windowId // Window identifier |
323 | ,&vSlData // Slider control data | |
324 | ,NULL // no Presentation parameters | |
325 | ); | |
326 | m_nRangeMax = nMaxValue; | |
327 | m_nRangeMin = nMinValue; | |
328 | ||
329 | // | |
330 | // Set the size of the ticks ... default to 6 pixels | |
331 | // | |
332 | ::WinSendMsg( hScrollBar | |
333 | ,SLM_SETTICKSIZE | |
70a2c656 | 334 | ,MPFROM2SHORT(SMA_SETALLTICKS, (USHORT)12) |
3c299c3a DW |
335 | ,NULL |
336 | ); | |
337 | // | |
338 | // Set the position to the initial value | |
339 | // | |
340 | ::WinSendMsg( hScrollBar | |
341 | ,SLM_SETSLIDERINFO | |
342 | ,MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE) | |
343 | ,(MPARAM)nValue | |
344 | ); | |
345 | ||
346 | m_hWnd = (WXHWND)hScrollBar; | |
347 | SubclassWin(GetHWND()); | |
348 | ::WinSetWindowText((HWND)m_hWnd, ""); | |
b3260bce | 349 | |
70a2c656 | 350 | SetFont(*wxSMALL_FONT); |
3c299c3a | 351 | if (m_windowStyle & wxSL_LABELS) |
409c9842 | 352 | { |
3c299c3a DW |
353 | // |
354 | // Finally, create max value static item | |
355 | // | |
356 | sprintf(wxBuffer, "%d", nMaxValue); | |
357 | lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE; | |
358 | if (m_windowStyle & wxCLIP_SIBLINGS) | |
359 | lMsStyle |= WS_CLIPSIBLINGS; | |
5d44b24e | 360 | |
3c299c3a DW |
361 | m_hStaticMax = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle |
362 | ,WC_STATIC // Window class | |
363 | ,(PSZ)wxBuffer // Initial Text | |
364 | ,(ULONG)lWstyle // Style flags | |
365 | ,0L, 0L, 0L, 0L // Origin -- 0 size | |
366 | ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent | |
367 | ,HWND_TOP // initial z position | |
368 | ,(ULONG)NewControlId() // Window identifier | |
369 | ,NULL // no control data | |
370 | ,NULL // no Presentation parameters | |
371 | ); | |
372 | if (GetFont().Ok()) | |
373 | { | |
374 | if (GetFont().GetResourceHandle()) | |
375 | { | |
376 | if (m_hStaticMin) | |
377 | wxOS2SetFont( m_hStaticMin | |
378 | ,GetFont() | |
379 | ); | |
380 | if (m_hStaticMax) | |
381 | wxOS2SetFont( m_hStaticMax | |
382 | ,GetFont() | |
383 | ); | |
384 | if (m_hStaticValue) | |
385 | wxOS2SetFont( m_hStaticValue | |
386 | ,GetFont() | |
387 | ); | |
388 | } | |
389 | } | |
409c9842 DW |
390 | } |
391 | ||
31833fd7 DW |
392 | SetXComp(0); |
393 | SetYComp(0); | |
3c299c3a DW |
394 | SetSize( nX |
395 | ,nY | |
396 | ,nWidth | |
397 | ,nHeight | |
398 | ); | |
399 | m_nThumbLength = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
400 | ,SLM_QUERYSLIDERINFO | |
401 | ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS | |
402 | ,SMA_RANGEVALUE | |
403 | ) | |
404 | ,(MPARAM)0 | |
405 | ) | |
406 | ) + 4; // for bordersizes | |
407 | ||
408 | wxColour vColour; | |
409 | ||
410 | vColour.Set(wxString("BLACK")); | |
411 | ||
412 | LONG lColor = (LONG)vColour.GetPixel(); | |
413 | ||
414 | ::WinSetPresParam( m_hStaticMin | |
415 | ,PP_FOREGROUNDCOLOR | |
416 | ,sizeof(LONG) | |
417 | ,(PVOID)&lColor | |
418 | ); | |
419 | ::WinSetPresParam( m_hStaticMax | |
420 | ,PP_FOREGROUNDCOLOR | |
421 | ,sizeof(LONG) | |
422 | ,(PVOID)&lColor | |
423 | ); | |
424 | ::WinSetPresParam( m_hStaticValue | |
425 | ,PP_FOREGROUNDCOLOR | |
426 | ,sizeof(LONG) | |
427 | ,(PVOID)&lColor | |
428 | ); | |
429 | ::WinSetPresParam( m_hWnd | |
430 | ,PP_FOREGROUNDCOLOR | |
431 | ,sizeof(LONG) | |
432 | ,(PVOID)&lColor | |
433 | ); | |
7993e67c DW |
434 | lColor = (LONG)m_backgroundColour.GetPixel(); |
435 | ::WinSetPresParam( m_hStaticMin | |
436 | ,PP_BACKGROUNDCOLOR | |
437 | ,sizeof(LONG) | |
438 | ,(PVOID)&lColor | |
439 | ); | |
440 | ::WinSetPresParam( m_hStaticMax | |
441 | ,PP_BACKGROUNDCOLOR | |
442 | ,sizeof(LONG) | |
443 | ,(PVOID)&lColor | |
444 | ); | |
445 | ::WinSetPresParam( m_hStaticValue | |
446 | ,PP_BACKGROUNDCOLOR | |
447 | ,sizeof(LONG) | |
448 | ,(PVOID)&lColor | |
449 | ); | |
450 | ::WinSetPresParam( m_hWnd | |
451 | ,PP_BACKGROUNDCOLOR | |
452 | ,sizeof(LONG) | |
453 | ,(PVOID)&lColor | |
454 | ); | |
70a2c656 DW |
455 | vColour.Set(wxString("BLUE")); |
456 | lColor = (LONG)vColour.GetPixel(); | |
457 | ::WinSetPresParam( m_hWnd | |
458 | ,PP_HILITEBACKGROUNDCOLOR | |
459 | ,sizeof(LONG) | |
460 | ,(PVOID)&lColor | |
461 | ); | |
3c299c3a DW |
462 | SetValue(nValue); |
463 | return TRUE; | |
464 | } // end of wxSlider::Create | |
465 | ||
466 | void wxSlider::DoSetSize( | |
467 | int nX | |
468 | , int nY | |
469 | , int nWidth | |
470 | , int nHeight | |
471 | , int nSizeFlags | |
472 | ) | |
473 | { | |
474 | int nX1 = nX; | |
475 | int nY1 = nY; | |
476 | int nWidth1 = nWidth; | |
477 | int nHeight1 = nHeight; | |
478 | int nXOffset = nX; | |
479 | int nYOffset = nY; | |
480 | int nCx; // slider,min,max sizes | |
481 | int nCy; | |
482 | int nCyf; | |
483 | int nCurrentX; | |
484 | int nCurrentY; | |
485 | char zBuf[300]; | |
486 | ||
487 | // | |
488 | // Adjust for OS/2's reverse coordinate system | |
489 | // | |
490 | wxWindowOS2* pParent = (wxWindowOS2*)GetParent(); | |
491 | int nUsedHeight = 0; | |
492 | int nOS2Height = nHeight; | |
493 | ||
494 | if (nOS2Height < 0) | |
495 | nOS2Height = 20; | |
496 | ||
497 | if (pParent) | |
409c9842 | 498 | { |
d8a3f66c DW |
499 | int nOS2ParentHeight = GetOS2ParentHeight(pParent); |
500 | ||
501 | nYOffset = nOS2ParentHeight - (nYOffset + nOS2Height); | |
502 | if (nY != -1) | |
503 | nY1 = nOS2ParentHeight - (nY1 + nOS2Height); | |
409c9842 | 504 | } |
3c299c3a | 505 | else |
409c9842 | 506 | { |
3c299c3a | 507 | RECTL vRect; |
409c9842 | 508 | |
3c299c3a DW |
509 | ::WinQueryWindowRect(HWND_DESKTOP, &vRect); |
510 | nYOffset = vRect.yTop - (nYOffset + nOS2Height); | |
511 | if (nY != -1) | |
512 | nY1 = vRect.yTop - (nY1 + nOS2Height); | |
513 | } | |
d8a3f66c | 514 | m_nSizeFlags = nSizeFlags; |
409c9842 | 515 | |
3c299c3a DW |
516 | GetPosition( &nCurrentX |
517 | ,&nCurrentY | |
518 | ); | |
519 | if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
520 | nX1 = nCurrentX; | |
521 | if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
522 | nY1 = nCurrentY; | |
523 | ||
524 | AdjustForParentClientOrigin( nX1 | |
525 | ,nY1 | |
526 | ,nSizeFlags | |
527 | ); | |
528 | wxGetCharSize( GetHWND() | |
529 | ,&nCx | |
530 | ,&nCy | |
531 | ,&this->GetFont() | |
532 | ); | |
533 | ||
534 | if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) | |
409c9842 | 535 | { |
3c299c3a DW |
536 | if (m_windowStyle & wxSL_LABELS ) |
537 | { | |
538 | int nMinLen = 0; | |
539 | int nMaxLen = 0; | |
540 | ||
541 | ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf); | |
542 | GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont()); | |
543 | ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf); | |
544 | GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont()); | |
545 | ||
546 | if (m_hStaticValue) | |
547 | { | |
548 | int nNewWidth = (wxMax(nMinLen, nMaxLen)); | |
549 | int nValueHeight = nCyf; | |
550 | ||
551 | ::WinSetWindowPos( (HWND)m_hStaticValue | |
552 | ,HWND_TOP | |
553 | ,(LONG)nXOffset | |
9923c37d | 554 | ,(LONG)nYOffset - (LONG)(nCyf * 1.2) |
3c299c3a DW |
555 | ,(LONG)nNewWidth |
556 | ,(LONG)nValueHeight | |
557 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
558 | ); | |
559 | nXOffset += nNewWidth + nCx; | |
560 | } | |
561 | ::WinSetWindowPos( (HWND)m_hStaticMin | |
562 | ,HWND_TOP | |
563 | ,(LONG)nXOffset | |
9923c37d | 564 | ,(LONG)nYOffset - (LONG)(nCyf * 1.2) |
3c299c3a DW |
565 | ,(LONG)nMinLen |
566 | ,(LONG)nCy | |
567 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
568 | ); | |
569 | nXOffset += nMinLen + nCx; | |
570 | ||
571 | int nSliderLength = nWidth1 - nXOffset - nMaxLen - nCx; | |
572 | int nSliderHeight = nHeight1; | |
573 | ||
574 | if (nSliderHeight < 0) | |
575 | nSliderHeight = 20; | |
576 | ||
577 | // | |
578 | // Slider must have a minimum/default length/height | |
579 | // | |
580 | if (nSliderLength < 100) | |
581 | nSliderLength = 100; | |
582 | ||
583 | ::WinSetWindowPos( GetHwnd() | |
584 | ,HWND_TOP | |
585 | ,(LONG)nXOffset | |
586 | ,(LONG)nYOffset | |
587 | ,(LONG)nSliderLength | |
588 | ,(LONG)nSliderHeight | |
589 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
590 | ); | |
31833fd7 DW |
591 | ::WinQueryWindowPos(GetHwnd(), GetSwp()); |
592 | ::WinSendMsg( GetHwnd() | |
593 | ,SLM_SETSLIDERINFO | |
594 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
595 | ,0 | |
596 | ) | |
597 | ,MPFROMLONG((ULONG)(nSliderHeight/2)) | |
598 | ); | |
3c299c3a DW |
599 | nXOffset += nSliderLength + nCx; |
600 | ||
601 | ::WinSetWindowPos( (HWND)m_hStaticMax | |
602 | ,HWND_TOP | |
603 | ,(LONG)nXOffset | |
9923c37d | 604 | ,(LONG)nYOffset - (LONG)(nCyf * 1.2) |
3c299c3a DW |
605 | ,(LONG)nMaxLen |
606 | ,(LONG)nCy | |
607 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
608 | ); | |
609 | } | |
610 | else | |
611 | { | |
612 | // | |
613 | // No labels | |
614 | // If we're prepared to use the existing size, then... | |
615 | // | |
616 | if (nWidth == -1 && nHeight == -1 && | |
617 | ((nSizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)) | |
618 | { | |
619 | GetSize( &nWidth1 | |
620 | ,&nHeight1 | |
621 | ); | |
622 | } | |
623 | if (nWidth1 < 0) | |
624 | nWidth1 = 200; | |
625 | if (nHeight1 < 0) | |
626 | nHeight1 = 20; | |
627 | ::WinSetWindowPos( GetHwnd() | |
628 | ,HWND_TOP | |
629 | ,(LONG)nX1 | |
630 | ,(LONG)nY1 | |
631 | ,(LONG)nWidth1 | |
632 | ,(LONG)nHeight1 | |
633 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
634 | ); | |
635 | } | |
409c9842 DW |
636 | } |
637 | ||
3c299c3a DW |
638 | // |
639 | // Now deal with a vertical slider | |
640 | // | |
409c9842 DW |
641 | else |
642 | { | |
3c299c3a | 643 | if (m_windowStyle & wxSL_LABELS ) |
409c9842 | 644 | { |
3c299c3a DW |
645 | int nMinLen; |
646 | int nMaxLen; | |
647 | ||
648 | ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf); | |
649 | GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont()); | |
650 | ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf); | |
651 | GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont()); | |
652 | if (m_hStaticValue) | |
653 | { | |
654 | int nNewWidth = wxMax(nMinLen, nMaxLen); | |
655 | int nValueHeight = nCyf; | |
656 | ||
3c299c3a DW |
657 | ::WinSetWindowPos( (HWND)m_hStaticValue |
658 | ,HWND_TOP | |
659 | ,(LONG)nXOffset | |
31833fd7 | 660 | ,(LONG)nYOffset + nHeight |
3c299c3a DW |
661 | ,(LONG)nNewWidth |
662 | ,(LONG)nValueHeight | |
663 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
664 | ); | |
31833fd7 | 665 | nUsedHeight += nCyf; |
3c299c3a DW |
666 | } |
667 | ::WinSetWindowPos( (HWND)m_hStaticMin | |
668 | ,HWND_TOP | |
669 | ,(LONG)nXOffset | |
31833fd7 | 670 | ,(LONG)nYOffset + nHeight - nCyf |
3c299c3a DW |
671 | ,(LONG)nMinLen |
672 | ,(LONG)nCy | |
673 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
674 | ); | |
3c299c3a DW |
675 | nUsedHeight += nCy; |
676 | ||
677 | int nSliderLength = nHeight1 - (nUsedHeight + (2 * nCy)); | |
678 | int nSliderWidth = nWidth1; | |
679 | ||
680 | if (nSliderWidth < 0) | |
681 | nSliderWidth = 20; | |
682 | ||
683 | // | |
684 | // Slider must have a minimum/default length | |
685 | // | |
686 | if (nSliderLength < 100) | |
687 | nSliderLength = 100; | |
688 | ||
70a2c656 | 689 | ::WinSetWindowPos( GetHwnd() |
3c299c3a DW |
690 | ,HWND_TOP |
691 | ,(LONG)nXOffset | |
31833fd7 | 692 | ,(LONG)nYOffset + nCyf |
3c299c3a DW |
693 | ,(LONG)nSliderWidth |
694 | ,(LONG)nSliderLength | |
695 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
696 | ); | |
31833fd7 DW |
697 | ::WinQueryWindowPos(GetHwnd(), GetSwp()); |
698 | ::WinSendMsg( GetHwnd() | |
699 | ,SLM_SETSLIDERINFO | |
700 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
701 | ,0 | |
702 | ) | |
703 | ,MPFROMLONG((ULONG)(nSliderWidth/2)) | |
704 | ); | |
3c299c3a DW |
705 | nUsedHeight += nSliderLength; |
706 | ::WinSetWindowPos( (HWND)m_hStaticMax | |
707 | ,HWND_TOP | |
708 | ,(LONG)nXOffset | |
31833fd7 | 709 | ,(LONG)nYOffset - nCyf |
3c299c3a DW |
710 | ,(LONG)nMaxLen |
711 | ,(LONG)nCy | |
712 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
713 | ); | |
714 | } | |
715 | else | |
716 | { | |
717 | // | |
718 | // No labels | |
719 | // If we're prepared to use the existing size, then... | |
720 | // | |
721 | if (nWidth == -1 && nHeight == -1 && | |
722 | ((nSizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)) | |
723 | { | |
724 | GetSize( &nWidth1 | |
725 | ,&nHeight1 | |
726 | ); | |
727 | } | |
728 | if (nWidth1 < 0) | |
729 | nWidth1 = 20; | |
730 | if (nHeight1 < 0) | |
731 | nHeight1 = 200; | |
732 | ::WinSetWindowPos( GetHwnd() | |
733 | ,HWND_TOP | |
734 | ,(LONG)nX1 | |
735 | ,(LONG)nY1 | |
736 | ,(LONG)nWidth1 | |
737 | ,(LONG)nHeight1 | |
738 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
739 | ); | |
409c9842 | 740 | } |
409c9842 | 741 | } |
3c299c3a | 742 | } // end of void wxSlider::DoSetSize |
0e320a79 | 743 | |
3c299c3a | 744 | int wxSlider::GetLineSize() const |
0e320a79 | 745 | { |
3c299c3a DW |
746 | return 1; |
747 | } // end of wxSlider::GetLineSize | |
0e320a79 | 748 | |
3c299c3a DW |
749 | int wxSlider::GetPageSize() const |
750 | { | |
751 | return m_nPageSize; | |
752 | } // end of wxSlider::GetPageSize | |
0e320a79 | 753 | |
3c299c3a DW |
754 | void wxSlider::GetPosition( |
755 | int* pnX | |
756 | , int* pnY | |
757 | ) const | |
409c9842 | 758 | { |
3c299c3a DW |
759 | wxWindowOS2* pParent = GetParent(); |
760 | RECTL vRect; | |
761 | ||
762 | vRect.xLeft = -1; | |
763 | vRect.xRight = -1; | |
764 | vRect.yTop = -1; | |
765 | vRect.yBottom = -1; | |
766 | wxFindMaxSize( GetHWND() | |
767 | ,&vRect | |
768 | ); | |
769 | ||
770 | if (m_hStaticMin) | |
771 | wxFindMaxSize( m_hStaticMin | |
772 | ,&vRect | |
773 | ); | |
774 | if (m_hStaticMax) | |
775 | wxFindMaxSize( m_hStaticMax | |
776 | ,&vRect | |
777 | ); | |
778 | if (m_hStaticValue) | |
779 | wxFindMaxSize( m_hStaticValue | |
780 | ,&vRect | |
781 | ); | |
782 | ||
783 | // | |
784 | // Since we now have the absolute screen coords, | |
785 | // if there's a parent we must subtract its top left corner | |
786 | // | |
787 | POINTL vPoint; | |
788 | ||
789 | vPoint.x = vRect.xLeft; | |
790 | vPoint.y = vRect.yTop; | |
791 | ||
792 | if (pParent) | |
793 | { | |
794 | SWP vSwp; | |
409c9842 | 795 | |
3c299c3a DW |
796 | ::WinQueryWindowPos((HWND)pParent->GetHWND(), &vSwp); |
797 | vPoint.x = vSwp.x; | |
798 | vPoint.y = vSwp.y; | |
799 | } | |
409c9842 | 800 | |
3c299c3a DW |
801 | // |
802 | // We may be faking the client origin. | |
803 | // So a window that's really at (0, 30) may appear | |
804 | // (to wxWin apps) to be at (0, 0). | |
805 | // | |
806 | if (GetParent()) | |
807 | { | |
808 | wxPoint vPt(GetParent()->GetClientAreaOrigin()); | |
409c9842 | 809 | |
3c299c3a DW |
810 | vPoint.x -= vPt.x; |
811 | vPoint.y -= vPt.y; | |
812 | } | |
813 | *pnX = vPoint.x; | |
814 | *pnY = vPoint.y; | |
815 | } // end of wxSlider::GetPosition | |
409c9842 | 816 | |
3c299c3a | 817 | int wxSlider::GetSelEnd() const |
0e320a79 | 818 | { |
3c299c3a DW |
819 | return 0; |
820 | } // end of wxSlider::GetSelEnd | |
0e320a79 | 821 | |
3c299c3a | 822 | int wxSlider::GetSelStart() const |
0e320a79 | 823 | { |
3c299c3a DW |
824 | return 0; |
825 | } // end of wxSlider::GetSelStart | |
0e320a79 | 826 | |
1cee3f60 DW |
827 | void wxSlider::DoGetSize( |
828 | int* pnWidth | |
829 | , int* pnHeight | |
830 | ) const | |
831 | { | |
832 | GetSize( pnWidth | |
833 | ,pnHeight | |
834 | ); | |
835 | } // end of wxSlider::DoGetSize | |
836 | ||
3c299c3a DW |
837 | void wxSlider::GetSize( |
838 | int* pnWidth | |
839 | , int* pnHeight | |
840 | ) const | |
0e320a79 | 841 | { |
3c299c3a DW |
842 | RECTL vRect; |
843 | ||
844 | vRect.xLeft = -1; | |
845 | vRect.xRight = -1; | |
846 | vRect.yTop = -1; | |
847 | vRect.yBottom = -1; | |
848 | ||
849 | wxFindMaxSize( GetHWND() | |
850 | ,&vRect | |
851 | ); | |
852 | ||
853 | if (m_hStaticMin) | |
854 | wxFindMaxSize( m_hStaticMin | |
855 | ,&vRect | |
856 | ); | |
857 | if (m_hStaticMax) | |
858 | wxFindMaxSize( m_hStaticMax | |
859 | ,&vRect | |
860 | ); | |
861 | if (m_hStaticValue) | |
862 | wxFindMaxSize( m_hStaticValue | |
863 | ,&vRect | |
864 | ); | |
2da36bfe SN |
865 | if (pnWidth) |
866 | *pnWidth = vRect.xRight - vRect.xLeft; | |
867 | if (pnHeight) | |
868 | *pnHeight = vRect.yTop - vRect.yBottom; | |
3c299c3a | 869 | } // end of wxSlider::GetSize |
0e320a79 | 870 | |
3c299c3a | 871 | int wxSlider::GetThumbLength() const |
0e320a79 | 872 | { |
3c299c3a DW |
873 | return m_nThumbLength; |
874 | } // end of wxSlider::GetThumbLength | |
0e320a79 | 875 | |
3c299c3a | 876 | int wxSlider::GetValue() const |
0e320a79 | 877 | { |
3c299c3a DW |
878 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() |
879 | ,SLM_QUERYSLIDERINFO | |
880 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
881 | ,SMA_RANGEVALUE | |
882 | ) | |
883 | ,(MPARAM)0 | |
884 | ) | |
885 | ); | |
886 | double dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
887 | int nNewPos = 0; | |
888 | int nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
889 | ,SLM_QUERYSLIDERINFO | |
890 | ,MPFROM2SHORT( SMA_SLIDERARMPOSITION | |
891 | ,SMA_RANGEVALUE | |
892 | ) | |
893 | ,(MPARAM)0 | |
894 | ) | |
895 | ); | |
896 | nNewPos = (int)(nPixelPos/dPixelToRange); | |
897 | if (nNewPos > (m_nRangeMax - m_nRangeMin)/2) | |
898 | nNewPos++; | |
899 | return nNewPos; | |
900 | } // end of wxSlider::GetValue | |
901 | ||
902 | WXHBRUSH wxSlider::OnCtlColor( | |
903 | WXHDC hDC | |
904 | , WXHWND hWnd | |
905 | , WXUINT uCtlColor | |
906 | , WXUINT uMessage | |
907 | , WXWPARAM wParam | |
908 | , WXLPARAM lParam | |
909 | ) | |
0e320a79 | 910 | { |
3c299c3a DW |
911 | return (wxControl::OnCtlColor( hDC |
912 | ,hWnd | |
913 | ,uCtlColor | |
914 | ,uMessage | |
915 | ,wParam | |
916 | ,lParam | |
917 | ) | |
918 | ); | |
919 | } // end of wxSlider::OnCtlColor | |
920 | ||
921 | bool wxSlider::OS2OnScroll( | |
922 | int WXUNUSED(nOrientation) | |
923 | , WXWORD wParam | |
924 | , WXWORD wPos | |
925 | , WXHWND hControl | |
926 | ) | |
0e320a79 | 927 | { |
3c299c3a | 928 | wxEventType eScrollEvent = wxEVT_NULL; |
0e320a79 | 929 | |
3c299c3a DW |
930 | switch (wParam) |
931 | { | |
932 | case SLN_CHANGE: | |
933 | if (m_windowStyle & wxSL_TOP) | |
934 | eScrollEvent = wxEVT_SCROLL_TOP; | |
935 | else if (m_windowStyle & wxSL_BOTTOM) | |
936 | eScrollEvent = wxEVT_SCROLL_BOTTOM; | |
937 | break; | |
0e320a79 | 938 | |
3c299c3a DW |
939 | case SLN_SLIDERTRACK: |
940 | eScrollEvent = wxEVT_SCROLL_THUMBTRACK; | |
941 | break; | |
942 | ||
943 | default: | |
944 | return FALSE; | |
945 | } | |
946 | ||
947 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
948 | ,SLM_QUERYSLIDERINFO | |
949 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
950 | ,SMA_RANGEVALUE | |
951 | ) | |
952 | ,(MPARAM)0 | |
953 | ) | |
954 | ); | |
955 | m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
956 | int nNewPos = 0; | |
957 | int nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
958 | ,SLM_QUERYSLIDERINFO | |
959 | ,MPFROM2SHORT( SMA_SLIDERARMPOSITION | |
960 | ,SMA_RANGEVALUE | |
961 | ) | |
962 | ,(MPARAM)0 | |
963 | ) | |
964 | ); | |
9923c37d | 965 | nNewPos = (int)(nPixelPos/m_dPixelToRange); |
3c299c3a DW |
966 | if (nNewPos > (m_nRangeMax - m_nRangeMin)/2) |
967 | nNewPos++; | |
968 | if ((nNewPos < GetMin()) || (nNewPos > GetMax())) | |
969 | { | |
970 | // | |
971 | // Out of range - but we did process it | |
972 | // | |
973 | return TRUE; | |
974 | } | |
975 | SetValue(nNewPos); | |
976 | ||
977 | wxScrollEvent vEvent( eScrollEvent | |
978 | ,m_windowId | |
979 | ); | |
980 | ||
981 | vEvent.SetPosition(nNewPos); | |
982 | vEvent.SetEventObject(this); | |
983 | GetEventHandler()->ProcessEvent(vEvent); | |
984 | ||
985 | wxCommandEvent vCevent( wxEVT_COMMAND_SLIDER_UPDATED | |
986 | ,GetId() | |
987 | ); | |
988 | ||
989 | vCevent.SetInt(nNewPos); | |
990 | vCevent.SetEventObject(this); | |
991 | return (GetEventHandler()->ProcessEvent(vCevent)); | |
992 | } // end of wxSlider::OS2OnScroll | |
993 | ||
994 | void wxSlider::SetLineSize( | |
995 | int nLineSize | |
996 | ) | |
0e320a79 | 997 | { |
3c299c3a DW |
998 | m_nLineSize = nLineSize; |
999 | } // end of wxSlider::SetLineSize | |
1000 | ||
0e320a79 | 1001 | |
3c299c3a DW |
1002 | void wxSlider::SetPageSize( |
1003 | int nPageSize | |
1004 | ) | |
0e320a79 | 1005 | { |
3c299c3a DW |
1006 | m_nPageSize = nPageSize; |
1007 | } // end of wxSlider::SetPageSize | |
0e320a79 | 1008 | |
3c299c3a DW |
1009 | void wxSlider::SetRange( |
1010 | int nMinValue | |
1011 | , int nMaxValue | |
1012 | ) | |
0e320a79 | 1013 | { |
3c299c3a DW |
1014 | wxChar zBuf[10]; |
1015 | ||
1016 | m_nRangeMin = nMinValue; | |
1017 | m_nRangeMax = nMaxValue; | |
1018 | ||
1019 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
1020 | ,SLM_QUERYSLIDERINFO | |
1021 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
1022 | ,SMA_RANGEVALUE | |
1023 | ) | |
1024 | ,(MPARAM)0 | |
1025 | ) | |
1026 | ); | |
1027 | m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
1028 | if (m_hStaticMin) | |
1029 | { | |
1030 | wxSprintf(zBuf, wxT("%d"), m_nRangeMin); | |
1031 | ::WinSetWindowText((HWND)m_hStaticMin, zBuf); | |
1032 | } | |
0e320a79 | 1033 | |
3c299c3a DW |
1034 | if (m_hStaticMax) |
1035 | { | |
1036 | wxSprintf(zBuf, wxT("%d"), m_nRangeMax); | |
1037 | ::WinSetWindowText((HWND)m_hStaticMax, zBuf); | |
1038 | } | |
1039 | } // end of wxSlider::SetRange | |
1040 | ||
1041 | void wxSlider::SetSelection( | |
1042 | int WXUNUSED(nMinPos) | |
1043 | , int WXUNUSED(nMaxPos) | |
1044 | ) | |
0e320a79 | 1045 | { |
3c299c3a | 1046 | } // end of wxSlider::SetSelection |
0e320a79 | 1047 | |
3c299c3a DW |
1048 | void wxSlider::SetThumbLength( |
1049 | int nLen | |
1050 | ) | |
0e320a79 | 1051 | { |
3c299c3a DW |
1052 | int nBreadth; |
1053 | ||
1054 | m_nThumbLength = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
1055 | ,SLM_QUERYSLIDERINFO | |
1056 | ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS | |
1057 | ,SMA_RANGEVALUE | |
1058 | ) | |
1059 | ,(MPARAM)0 | |
1060 | ) | |
1061 | ) + 4; // for bordersizes | |
1062 | nBreadth = SHORT2FROMMR(::WinSendMsg( GetHwnd() | |
1063 | ,SLM_QUERYSLIDERINFO | |
1064 | ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS | |
1065 | ,SMA_RANGEVALUE | |
1066 | ) | |
1067 | ,(MPARAM)0 | |
1068 | ) | |
1069 | ); | |
1070 | ::WinSendMsg( GetHwnd() | |
1071 | ,SLM_SETSLIDERINFO | |
1072 | ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS | |
1073 | ,SMA_RANGEVALUE | |
1074 | ) | |
1075 | ,MPFROM2SHORT(nLen, nBreadth) | |
1076 | ); | |
1077 | m_nThumbLength = nLen + 4; // Borders | |
1078 | } // end of wxSlider::SetThumbLength | |
1079 | ||
1080 | void wxSlider::SetTick( | |
1081 | int nTickPos | |
1082 | ) | |
1083 | { | |
9923c37d | 1084 | nTickPos = (int)(nTickPos * m_dPixelToRange); |
3c299c3a DW |
1085 | ::WinSendMsg( GetHwnd() |
1086 | ,SLM_ADDDETENT | |
1087 | ,MPFROMSHORT(nTickPos) | |
1088 | ,NULL | |
1089 | ); | |
1090 | } // end of wxSlider::SetTick | |
0e320a79 | 1091 | |
3c299c3a DW |
1092 | // For trackbars only |
1093 | void wxSlider::SetTickFreq( | |
1094 | int n | |
1095 | , int nPos | |
1096 | ) | |
409c9842 | 1097 | { |
3c299c3a DW |
1098 | SLDCDATA vSlData; |
1099 | WNDPARAMS vWndParams; | |
1100 | int nPixelPos; | |
1101 | int i; | |
409c9842 | 1102 | |
3c299c3a DW |
1103 | vSlData.cbSize = sizeof(SLDCDATA); |
1104 | if (m_windowStyle & wxSL_AUTOTICKS) | |
1105 | { | |
1106 | vSlData.usScale1Spacing = 0; | |
1107 | vSlData.usScale2Spacing = 0; | |
1108 | } | |
1109 | vSlData.usScale1Increments = (m_nRangeMax - m_nRangeMin)/n; | |
1110 | vSlData.usScale2Increments = (m_nRangeMax - m_nRangeMin)/n; | |
1111 | ||
1112 | vWndParams.fsStatus = WPM_CTLDATA; | |
1113 | vWndParams.cchText = 0L; | |
1114 | vWndParams.pszText = NULL; | |
1115 | vWndParams.cbPresParams = 0L; | |
1116 | vWndParams.pPresParams = NULL; | |
1117 | vWndParams.cbCtlData = vSlData.cbSize; | |
1118 | vWndParams.pCtlData = (PVOID)&vSlData; | |
1119 | ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)0); | |
1120 | for (i = 1; i < (m_nRangeMax - m_nRangeMin)/n; i++) | |
1121 | { | |
9923c37d | 1122 | nPixelPos = (int)(i * n * m_dPixelToRange); |
3c299c3a DW |
1123 | ::WinSendMsg( GetHwnd() |
1124 | ,SLM_ADDDETENT | |
1125 | ,MPFROMSHORT(nPixelPos) | |
1126 | ,NULL | |
1127 | ); | |
1128 | } | |
1129 | } // end of wxSlider::SetTickFreq | |
1130 | ||
1131 | void wxSlider::SetValue( | |
1132 | int nValue | |
1133 | ) | |
0e320a79 | 1134 | { |
3c299c3a DW |
1135 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() |
1136 | ,SLM_QUERYSLIDERINFO | |
1137 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
1138 | ,SMA_RANGEVALUE | |
1139 | ) | |
1140 | ,(MPARAM)0 | |
1141 | ) | |
1142 | ); | |
1143 | m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
1144 | int nNewPos = (int)(nValue * m_dPixelToRange); | |
1145 | ||
1146 | ::WinSendMsg( GetHwnd() | |
1147 | ,SLM_SETSLIDERINFO | |
1148 | ,MPFROM2SHORT( SMA_SLIDERARMPOSITION | |
1149 | ,SMA_RANGEVALUE | |
1150 | ) | |
1151 | ,(MPARAM)nNewPos | |
1152 | ); | |
1153 | if (m_hStaticValue) | |
1154 | { | |
1155 | wxSprintf(wxBuffer, wxT("%d"), nValue); | |
1156 | ::WinSetWindowText((HWND)m_hStaticValue, wxBuffer); | |
1157 | } | |
1158 | } // end of wxSlider::SetValue | |
0e320a79 | 1159 | |
3c299c3a DW |
1160 | bool wxSlider::Show( |
1161 | bool bShow | |
1162 | ) | |
0e320a79 | 1163 | { |
3c299c3a DW |
1164 | wxWindowOS2::Show(bShow); |
1165 | if(m_hStaticValue) | |
1166 | ::WinShowWindow((HWND)m_hStaticValue, bShow); | |
1167 | if(m_hStaticMin) | |
1168 | ::WinShowWindow((HWND)m_hStaticMin, bShow); | |
1169 | if(m_hStaticMax) | |
1170 | ::WinShowWindow((HWND)m_hStaticMax, bShow); | |
0e320a79 | 1171 | return TRUE; |
3c299c3a | 1172 | } // end of wxSlider::Show |
0e320a79 | 1173 |