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