]>
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 DW |
8 | // Copyright: (c) David Webster |
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 | ); | |
865 | *pnWidth = vRect.xRight - vRect.xLeft; | |
866 | *pnHeight = vRect.yBottom - vRect.yTop; | |
867 | } // end of wxSlider::GetSize | |
0e320a79 | 868 | |
3c299c3a | 869 | int wxSlider::GetThumbLength() const |
0e320a79 | 870 | { |
3c299c3a DW |
871 | return m_nThumbLength; |
872 | } // end of wxSlider::GetThumbLength | |
0e320a79 | 873 | |
3c299c3a | 874 | int wxSlider::GetValue() const |
0e320a79 | 875 | { |
3c299c3a DW |
876 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() |
877 | ,SLM_QUERYSLIDERINFO | |
878 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
879 | ,SMA_RANGEVALUE | |
880 | ) | |
881 | ,(MPARAM)0 | |
882 | ) | |
883 | ); | |
884 | double dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
885 | int nNewPos = 0; | |
886 | int nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
887 | ,SLM_QUERYSLIDERINFO | |
888 | ,MPFROM2SHORT( SMA_SLIDERARMPOSITION | |
889 | ,SMA_RANGEVALUE | |
890 | ) | |
891 | ,(MPARAM)0 | |
892 | ) | |
893 | ); | |
894 | nNewPos = (int)(nPixelPos/dPixelToRange); | |
895 | if (nNewPos > (m_nRangeMax - m_nRangeMin)/2) | |
896 | nNewPos++; | |
897 | return nNewPos; | |
898 | } // end of wxSlider::GetValue | |
899 | ||
900 | WXHBRUSH wxSlider::OnCtlColor( | |
901 | WXHDC hDC | |
902 | , WXHWND hWnd | |
903 | , WXUINT uCtlColor | |
904 | , WXUINT uMessage | |
905 | , WXWPARAM wParam | |
906 | , WXLPARAM lParam | |
907 | ) | |
0e320a79 | 908 | { |
3c299c3a DW |
909 | return (wxControl::OnCtlColor( hDC |
910 | ,hWnd | |
911 | ,uCtlColor | |
912 | ,uMessage | |
913 | ,wParam | |
914 | ,lParam | |
915 | ) | |
916 | ); | |
917 | } // end of wxSlider::OnCtlColor | |
918 | ||
919 | bool wxSlider::OS2OnScroll( | |
920 | int WXUNUSED(nOrientation) | |
921 | , WXWORD wParam | |
922 | , WXWORD wPos | |
923 | , WXHWND hControl | |
924 | ) | |
0e320a79 | 925 | { |
3c299c3a | 926 | wxEventType eScrollEvent = wxEVT_NULL; |
0e320a79 | 927 | |
3c299c3a DW |
928 | switch (wParam) |
929 | { | |
930 | case SLN_CHANGE: | |
931 | if (m_windowStyle & wxSL_TOP) | |
932 | eScrollEvent = wxEVT_SCROLL_TOP; | |
933 | else if (m_windowStyle & wxSL_BOTTOM) | |
934 | eScrollEvent = wxEVT_SCROLL_BOTTOM; | |
935 | break; | |
0e320a79 | 936 | |
3c299c3a DW |
937 | case SLN_SLIDERTRACK: |
938 | eScrollEvent = wxEVT_SCROLL_THUMBTRACK; | |
939 | break; | |
940 | ||
941 | default: | |
942 | return FALSE; | |
943 | } | |
944 | ||
945 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
946 | ,SLM_QUERYSLIDERINFO | |
947 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
948 | ,SMA_RANGEVALUE | |
949 | ) | |
950 | ,(MPARAM)0 | |
951 | ) | |
952 | ); | |
953 | m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
954 | int nNewPos = 0; | |
955 | int nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
956 | ,SLM_QUERYSLIDERINFO | |
957 | ,MPFROM2SHORT( SMA_SLIDERARMPOSITION | |
958 | ,SMA_RANGEVALUE | |
959 | ) | |
960 | ,(MPARAM)0 | |
961 | ) | |
962 | ); | |
9923c37d | 963 | nNewPos = (int)(nPixelPos/m_dPixelToRange); |
3c299c3a DW |
964 | if (nNewPos > (m_nRangeMax - m_nRangeMin)/2) |
965 | nNewPos++; | |
966 | if ((nNewPos < GetMin()) || (nNewPos > GetMax())) | |
967 | { | |
968 | // | |
969 | // Out of range - but we did process it | |
970 | // | |
971 | return TRUE; | |
972 | } | |
973 | SetValue(nNewPos); | |
974 | ||
975 | wxScrollEvent vEvent( eScrollEvent | |
976 | ,m_windowId | |
977 | ); | |
978 | ||
979 | vEvent.SetPosition(nNewPos); | |
980 | vEvent.SetEventObject(this); | |
981 | GetEventHandler()->ProcessEvent(vEvent); | |
982 | ||
983 | wxCommandEvent vCevent( wxEVT_COMMAND_SLIDER_UPDATED | |
984 | ,GetId() | |
985 | ); | |
986 | ||
987 | vCevent.SetInt(nNewPos); | |
988 | vCevent.SetEventObject(this); | |
989 | return (GetEventHandler()->ProcessEvent(vCevent)); | |
990 | } // end of wxSlider::OS2OnScroll | |
991 | ||
992 | void wxSlider::SetLineSize( | |
993 | int nLineSize | |
994 | ) | |
0e320a79 | 995 | { |
3c299c3a DW |
996 | m_nLineSize = nLineSize; |
997 | } // end of wxSlider::SetLineSize | |
998 | ||
0e320a79 | 999 | |
3c299c3a DW |
1000 | void wxSlider::SetPageSize( |
1001 | int nPageSize | |
1002 | ) | |
0e320a79 | 1003 | { |
3c299c3a DW |
1004 | m_nPageSize = nPageSize; |
1005 | } // end of wxSlider::SetPageSize | |
0e320a79 | 1006 | |
3c299c3a DW |
1007 | void wxSlider::SetRange( |
1008 | int nMinValue | |
1009 | , int nMaxValue | |
1010 | ) | |
0e320a79 | 1011 | { |
3c299c3a DW |
1012 | wxChar zBuf[10]; |
1013 | ||
1014 | m_nRangeMin = nMinValue; | |
1015 | m_nRangeMax = nMaxValue; | |
1016 | ||
1017 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
1018 | ,SLM_QUERYSLIDERINFO | |
1019 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
1020 | ,SMA_RANGEVALUE | |
1021 | ) | |
1022 | ,(MPARAM)0 | |
1023 | ) | |
1024 | ); | |
1025 | m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
1026 | if (m_hStaticMin) | |
1027 | { | |
1028 | wxSprintf(zBuf, wxT("%d"), m_nRangeMin); | |
1029 | ::WinSetWindowText((HWND)m_hStaticMin, zBuf); | |
1030 | } | |
0e320a79 | 1031 | |
3c299c3a DW |
1032 | if (m_hStaticMax) |
1033 | { | |
1034 | wxSprintf(zBuf, wxT("%d"), m_nRangeMax); | |
1035 | ::WinSetWindowText((HWND)m_hStaticMax, zBuf); | |
1036 | } | |
1037 | } // end of wxSlider::SetRange | |
1038 | ||
1039 | void wxSlider::SetSelection( | |
1040 | int WXUNUSED(nMinPos) | |
1041 | , int WXUNUSED(nMaxPos) | |
1042 | ) | |
0e320a79 | 1043 | { |
3c299c3a | 1044 | } // end of wxSlider::SetSelection |
0e320a79 | 1045 | |
3c299c3a DW |
1046 | void wxSlider::SetThumbLength( |
1047 | int nLen | |
1048 | ) | |
0e320a79 | 1049 | { |
3c299c3a DW |
1050 | int nBreadth; |
1051 | ||
1052 | m_nThumbLength = SHORT1FROMMR(::WinSendMsg( GetHwnd() | |
1053 | ,SLM_QUERYSLIDERINFO | |
1054 | ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS | |
1055 | ,SMA_RANGEVALUE | |
1056 | ) | |
1057 | ,(MPARAM)0 | |
1058 | ) | |
1059 | ) + 4; // for bordersizes | |
1060 | nBreadth = SHORT2FROMMR(::WinSendMsg( GetHwnd() | |
1061 | ,SLM_QUERYSLIDERINFO | |
1062 | ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS | |
1063 | ,SMA_RANGEVALUE | |
1064 | ) | |
1065 | ,(MPARAM)0 | |
1066 | ) | |
1067 | ); | |
1068 | ::WinSendMsg( GetHwnd() | |
1069 | ,SLM_SETSLIDERINFO | |
1070 | ,MPFROM2SHORT( SMA_SLIDERARMDIMENSIONS | |
1071 | ,SMA_RANGEVALUE | |
1072 | ) | |
1073 | ,MPFROM2SHORT(nLen, nBreadth) | |
1074 | ); | |
1075 | m_nThumbLength = nLen + 4; // Borders | |
1076 | } // end of wxSlider::SetThumbLength | |
1077 | ||
1078 | void wxSlider::SetTick( | |
1079 | int nTickPos | |
1080 | ) | |
1081 | { | |
9923c37d | 1082 | nTickPos = (int)(nTickPos * m_dPixelToRange); |
3c299c3a DW |
1083 | ::WinSendMsg( GetHwnd() |
1084 | ,SLM_ADDDETENT | |
1085 | ,MPFROMSHORT(nTickPos) | |
1086 | ,NULL | |
1087 | ); | |
1088 | } // end of wxSlider::SetTick | |
0e320a79 | 1089 | |
3c299c3a DW |
1090 | // For trackbars only |
1091 | void wxSlider::SetTickFreq( | |
1092 | int n | |
1093 | , int nPos | |
1094 | ) | |
409c9842 | 1095 | { |
3c299c3a DW |
1096 | SLDCDATA vSlData; |
1097 | WNDPARAMS vWndParams; | |
1098 | int nPixelPos; | |
1099 | int i; | |
409c9842 | 1100 | |
3c299c3a DW |
1101 | vSlData.cbSize = sizeof(SLDCDATA); |
1102 | if (m_windowStyle & wxSL_AUTOTICKS) | |
1103 | { | |
1104 | vSlData.usScale1Spacing = 0; | |
1105 | vSlData.usScale2Spacing = 0; | |
1106 | } | |
1107 | vSlData.usScale1Increments = (m_nRangeMax - m_nRangeMin)/n; | |
1108 | vSlData.usScale2Increments = (m_nRangeMax - m_nRangeMin)/n; | |
1109 | ||
1110 | vWndParams.fsStatus = WPM_CTLDATA; | |
1111 | vWndParams.cchText = 0L; | |
1112 | vWndParams.pszText = NULL; | |
1113 | vWndParams.cbPresParams = 0L; | |
1114 | vWndParams.pPresParams = NULL; | |
1115 | vWndParams.cbCtlData = vSlData.cbSize; | |
1116 | vWndParams.pCtlData = (PVOID)&vSlData; | |
1117 | ::WinSendMsg(GetHwnd(), WM_SETWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)0); | |
1118 | for (i = 1; i < (m_nRangeMax - m_nRangeMin)/n; i++) | |
1119 | { | |
9923c37d | 1120 | nPixelPos = (int)(i * n * m_dPixelToRange); |
3c299c3a DW |
1121 | ::WinSendMsg( GetHwnd() |
1122 | ,SLM_ADDDETENT | |
1123 | ,MPFROMSHORT(nPixelPos) | |
1124 | ,NULL | |
1125 | ); | |
1126 | } | |
1127 | } // end of wxSlider::SetTickFreq | |
1128 | ||
1129 | void wxSlider::SetValue( | |
1130 | int nValue | |
1131 | ) | |
0e320a79 | 1132 | { |
3c299c3a DW |
1133 | int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd() |
1134 | ,SLM_QUERYSLIDERINFO | |
1135 | ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS | |
1136 | ,SMA_RANGEVALUE | |
1137 | ) | |
1138 | ,(MPARAM)0 | |
1139 | ) | |
1140 | ); | |
1141 | m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin); | |
1142 | int nNewPos = (int)(nValue * m_dPixelToRange); | |
1143 | ||
1144 | ::WinSendMsg( GetHwnd() | |
1145 | ,SLM_SETSLIDERINFO | |
1146 | ,MPFROM2SHORT( SMA_SLIDERARMPOSITION | |
1147 | ,SMA_RANGEVALUE | |
1148 | ) | |
1149 | ,(MPARAM)nNewPos | |
1150 | ); | |
1151 | if (m_hStaticValue) | |
1152 | { | |
1153 | wxSprintf(wxBuffer, wxT("%d"), nValue); | |
1154 | ::WinSetWindowText((HWND)m_hStaticValue, wxBuffer); | |
1155 | } | |
1156 | } // end of wxSlider::SetValue | |
0e320a79 | 1157 | |
3c299c3a DW |
1158 | bool wxSlider::Show( |
1159 | bool bShow | |
1160 | ) | |
0e320a79 | 1161 | { |
3c299c3a DW |
1162 | wxWindowOS2::Show(bShow); |
1163 | if(m_hStaticValue) | |
1164 | ::WinShowWindow((HWND)m_hStaticValue, bShow); | |
1165 | if(m_hStaticMin) | |
1166 | ::WinShowWindow((HWND)m_hStaticMin, bShow); | |
1167 | if(m_hStaticMax) | |
1168 | ::WinShowWindow((HWND)m_hStaticMax, bShow); | |
0e320a79 | 1169 | return TRUE; |
3c299c3a | 1170 | } // end of wxSlider::Show |
0e320a79 | 1171 |