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