]>
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 | 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 | |
98 | ,SWP_SIZE | SWP_MOVE | |
99 | ); | |
100 | } | |
101 | ::WinSetWindowPos( (HWND)m_hStaticMin | |
102 | ,HWND_TOP | |
103 | ,(LONG)nXOffset - (nMinLen + nCx) | |
104 | ,(LONG)nYOffset | |
105 | ,(LONG)nMinLen | |
106 | ,(LONG)nCyf | |
107 | ,SWP_SIZE | SWP_MOVE | |
108 | ); | |
109 | nXOffset += nWidth + nCx; | |
110 | ||
111 | ::WinSetWindowPos( (HWND)m_hStaticMax | |
112 | ,HWND_TOP | |
113 | ,(LONG)nXOffset | |
114 | ,(LONG)nYOffset | |
115 | ,(LONG)nMaxLen | |
116 | ,(LONG)nCyf | |
117 | ,SWP_ZORDER | SWP_SHOW | |
118 | ); | |
119 | } | |
120 | } | |
121 | else | |
122 | { | |
123 | // | |
124 | // Now deal with a vertical slider | |
125 | // | |
126 | ||
127 | if (m_windowStyle & wxSL_LABELS ) | |
128 | { | |
129 | int nMinLen = 0; | |
130 | int nMaxLen = 0; | |
131 | ||
132 | ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf); | |
133 | GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont()); | |
134 | ||
135 | ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf); | |
136 | GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont()); | |
137 | ||
138 | if (m_hStaticValue) | |
139 | { | |
140 | int nNewWidth = (wxMax(nMinLen, nMaxLen)); | |
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 | |
166 | ); | |
167 | } | |
168 | } | |
169 | } // end of wxSlider::AdjustSubControls | |
170 | ||
171 | void wxSlider::ClearSel() | |
172 | { | |
173 | } // end of wxSlider::ClearSel | |
174 | ||
175 | void wxSlider::ClearTicks() | |
176 | { | |
177 | } // end of wxSlider::ClearTicks | |
178 | ||
179 | void wxSlider::Command ( | |
180 | wxCommandEvent& rEvent | |
181 | ) | |
182 | { | |
183 | SetValue(rEvent.GetInt()); | |
184 | ProcessCommand(rEvent); | |
185 | } // end of wxSlider::Command | |
186 | ||
187 | bool wxSlider::ContainsHWND( | |
188 | WXHWND hWnd | |
189 | ) const | |
190 | { | |
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 | |
206 | , const wxValidator& rValidator | |
207 | , const wxString& rsName | |
208 | ) | |
209 | { | |
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; | |
238 | ||
239 | if (m_windowStyle & wxCLIP_SIBLINGS ) | |
240 | lMsStyle |= WS_CLIPSIBLINGS; | |
241 | ||
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; | |
265 | ||
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; | |
279 | ||
280 | SLDCDATA vSlData; | |
281 | ||
282 | vSlData.cbSize = sizeof(SLDCDATA); | |
283 | if (m_windowStyle & wxSL_VERTICAL) | |
284 | lMsStyle = SLS_VERTICAL | SLS_HOMEBOTTOM | WS_VISIBLE | WS_TABSTOP; | |
285 | else | |
286 | lMsStyle = SLS_HORIZONTAL | SLS_HOMELEFT | WS_VISIBLE | WS_TABSTOP; | |
287 | ||
288 | if (m_windowStyle & wxCLIP_SIBLINGS) | |
289 | lMsStyle |= WS_CLIPSIBLINGS; | |
290 | ||
291 | if (m_windowStyle & wxSL_AUTOTICKS) | |
292 | { | |
293 | vSlData.usScale1Spacing = 0; | |
294 | vSlData.usScale2Spacing = 0; | |
295 | } | |
296 | ||
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; | |
309 | lMsStyle |= SLS_RIBBONSTRIP; | |
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 | |
321 | ,HWND_BOTTOM // initial z position | |
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 | |
334 | ,MPFROM2SHORT(SMA_SETALLTICKS, (USHORT)12) | |
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, ""); | |
349 | ||
350 | SetFont(*wxSMALL_FONT); | |
351 | if (m_windowStyle & wxSL_LABELS) | |
352 | { | |
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; | |
360 | ||
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 | } | |
390 | } | |
391 | ||
392 | SetXComp(0); | |
393 | SetYComp(0); | |
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 | ); | |
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 | ); | |
455 | vColour.Set(wxString("BLUE")); | |
456 | lColor = (LONG)vColour.GetPixel(); | |
457 | ::WinSetPresParam( m_hWnd | |
458 | ,PP_HILITEBACKGROUNDCOLOR | |
459 | ,sizeof(LONG) | |
460 | ,(PVOID)&lColor | |
461 | ); | |
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) | |
498 | { | |
499 | int nOS2ParentHeight = GetOS2ParentHeight(pParent); | |
500 | ||
501 | nYOffset = nOS2ParentHeight - (nYOffset + nOS2Height); | |
502 | if (nY != -1) | |
503 | nY1 = nOS2ParentHeight - (nY1 + nOS2Height); | |
504 | } | |
505 | else | |
506 | { | |
507 | RECTL vRect; | |
508 | ||
509 | ::WinQueryWindowRect(HWND_DESKTOP, &vRect); | |
510 | nYOffset = vRect.yTop - (nYOffset + nOS2Height); | |
511 | if (nY != -1) | |
512 | nY1 = vRect.yTop - (nY1 + nOS2Height); | |
513 | } | |
514 | m_nSizeFlags = nSizeFlags; | |
515 | ||
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) | |
535 | { | |
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 | |
554 | ,(LONG)nYOffset - (LONG)(nCyf * 1.2) | |
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 | |
564 | ,(LONG)nYOffset - (LONG)(nCyf * 1.2) | |
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 | ); | |
591 | ::WinQueryWindowPos(GetHwnd(), GetSwp()); | |
592 | ::WinSendMsg( GetHwnd() | |
593 | ,SLM_SETSLIDERINFO | |
594 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
595 | ,0 | |
596 | ) | |
597 | ,MPFROMLONG((ULONG)(nSliderHeight/2)) | |
598 | ); | |
599 | nXOffset += nSliderLength + nCx; | |
600 | ||
601 | ::WinSetWindowPos( (HWND)m_hStaticMax | |
602 | ,HWND_TOP | |
603 | ,(LONG)nXOffset | |
604 | ,(LONG)nYOffset - (LONG)(nCyf * 1.2) | |
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 | } | |
636 | } | |
637 | ||
638 | // | |
639 | // Now deal with a vertical slider | |
640 | // | |
641 | else | |
642 | { | |
643 | if (m_windowStyle & wxSL_LABELS ) | |
644 | { | |
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 | ||
657 | ::WinSetWindowPos( (HWND)m_hStaticValue | |
658 | ,HWND_TOP | |
659 | ,(LONG)nXOffset | |
660 | ,(LONG)nYOffset + nHeight | |
661 | ,(LONG)nNewWidth | |
662 | ,(LONG)nValueHeight | |
663 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
664 | ); | |
665 | nUsedHeight += nCyf; | |
666 | } | |
667 | ::WinSetWindowPos( (HWND)m_hStaticMin | |
668 | ,HWND_TOP | |
669 | ,(LONG)nXOffset | |
670 | ,(LONG)nYOffset + nHeight - nCyf | |
671 | ,(LONG)nMinLen | |
672 | ,(LONG)nCy | |
673 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
674 | ); | |
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 | ||
689 | ::WinSetWindowPos( GetHwnd() | |
690 | ,HWND_TOP | |
691 | ,(LONG)nXOffset | |
692 | ,(LONG)nYOffset + nCyf | |
693 | ,(LONG)nSliderWidth | |
694 | ,(LONG)nSliderLength | |
695 | ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW | |
696 | ); | |
697 | ::WinQueryWindowPos(GetHwnd(), GetSwp()); | |
698 | ::WinSendMsg( GetHwnd() | |
699 | ,SLM_SETSLIDERINFO | |
700 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
701 | ,0 | |
702 | ) | |
703 | ,MPFROMLONG((ULONG)(nSliderWidth/2)) | |
704 | ); | |
705 | nUsedHeight += nSliderLength; | |
706 | ::WinSetWindowPos( (HWND)m_hStaticMax | |
707 | ,HWND_TOP | |
708 | ,(LONG)nXOffset | |
709 | ,(LONG)nYOffset - nCyf | |
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 | ); | |
740 | } | |
741 | } | |
742 | } // end of void wxSlider::DoSetSize | |
743 | ||
744 | int wxSlider::GetLineSize() const | |
745 | { | |
746 | return 1; | |
747 | } // end of wxSlider::GetLineSize | |
748 | ||
749 | int wxSlider::GetPageSize() const | |
750 | { | |
751 | return m_nPageSize; | |
752 | } // end of wxSlider::GetPageSize | |
753 | ||
754 | void wxSlider::GetPosition( | |
755 | int* pnX | |
756 | , int* pnY | |
757 | ) const | |
758 | { | |
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; | |
795 | ||
796 | ::WinQueryWindowPos((HWND)pParent->GetHWND(), &vSwp); | |
797 | vPoint.x = vSwp.x; | |
798 | vPoint.y = vSwp.y; | |
799 | } | |
800 | ||
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()); | |
809 | ||
810 | vPoint.x -= vPt.x; | |
811 | vPoint.y -= vPt.y; | |
812 | } | |
813 | *pnX = vPoint.x; | |
814 | *pnY = vPoint.y; | |
815 | } // end of wxSlider::GetPosition | |
816 | ||
817 | int wxSlider::GetSelEnd() const | |
818 | { | |
819 | return 0; | |
820 | } // end of wxSlider::GetSelEnd | |
821 | ||
822 | int wxSlider::GetSelStart() const | |
823 | { | |
824 | return 0; | |
825 | } // end of wxSlider::GetSelStart | |
826 | ||
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 | ||
837 | void wxSlider::GetSize( | |
838 | int* pnWidth | |
839 | , int* pnHeight | |
840 | ) const | |
841 | { | |
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 | ); | |
865 | if (pnWidth) | |
866 | *pnWidth = vRect.xRight - vRect.xLeft; | |
867 | if (pnHeight) | |
868 | *pnHeight = vRect.yTop - vRect.yBottom; | |
869 | } // end of wxSlider::GetSize | |
870 | ||
871 | int wxSlider::GetThumbLength() const | |
872 | { | |
873 | return m_nThumbLength; | |
874 | } // end of wxSlider::GetThumbLength | |
875 | ||
876 | int wxSlider::GetValue() const | |
877 | { | |
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 | ) | |
910 | { | |
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 | ) | |
927 | { | |
928 | wxEventType eScrollEvent = wxEVT_NULL; | |
929 | ||
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; | |
938 | ||
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 | ); | |
965 | nNewPos = (int)(nPixelPos/m_dPixelToRange); | |
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 | ) | |
997 | { | |
998 | m_nLineSize = nLineSize; | |
999 | } // end of wxSlider::SetLineSize | |
1000 | ||
1001 | ||
1002 | void wxSlider::SetPageSize( | |
1003 | int nPageSize | |
1004 | ) | |
1005 | { | |
1006 | m_nPageSize = nPageSize; | |
1007 | } // end of wxSlider::SetPageSize | |
1008 | ||
1009 | void wxSlider::SetRange( | |
1010 | int nMinValue | |
1011 | , int nMaxValue | |
1012 | ) | |
1013 | { | |
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 | } | |
1033 | ||
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 | ) | |
1045 | { | |
1046 | } // end of wxSlider::SetSelection | |
1047 | ||
1048 | void wxSlider::SetThumbLength( | |
1049 | int nLen | |
1050 | ) | |
1051 | { | |
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 | { | |
1084 | nTickPos = (int)(nTickPos * m_dPixelToRange); | |
1085 | ::WinSendMsg( GetHwnd() | |
1086 | ,SLM_ADDDETENT | |
1087 | ,MPFROMSHORT(nTickPos) | |
1088 | ,NULL | |
1089 | ); | |
1090 | } // end of wxSlider::SetTick | |
1091 | ||
1092 | // For trackbars only | |
1093 | void wxSlider::SetTickFreq( | |
1094 | int n | |
1095 | , int nPos | |
1096 | ) | |
1097 | { | |
1098 | SLDCDATA vSlData; | |
1099 | WNDPARAMS vWndParams; | |
1100 | int nPixelPos; | |
1101 | int i; | |
1102 | ||
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 | { | |
1122 | nPixelPos = (int)(i * n * m_dPixelToRange); | |
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 | ) | |
1134 | { | |
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 | |
1159 | ||
1160 | bool wxSlider::Show( | |
1161 | bool bShow | |
1162 | ) | |
1163 | { | |
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); | |
1171 | return TRUE; | |
1172 | } // end of wxSlider::Show | |
1173 |