]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: slider95.cpp | |
3 | // Purpose: wxSlider95, using the Win95 trackbar control | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
13 | #pragma implementation "slider95.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #if wxUSE_SLIDER | |
24 | ||
25 | #ifndef WX_PRECOMP | |
26 | #include "wx/utils.h" | |
27 | #include "wx/brush.h" | |
28 | #include "wx/slider.h" | |
29 | #endif | |
30 | ||
31 | #ifdef __WIN95__ | |
32 | ||
33 | #include "wx/msw/slider95.h" | |
34 | #include "wx/msw/private.h" | |
35 | ||
36 | #if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)) | |
37 | #include <commctrl.h> | |
38 | #endif | |
39 | ||
40 | IMPLEMENT_DYNAMIC_CLASS(wxSlider95, wxControl) | |
41 | ||
42 | /* | |
43 | TODO PROPERTIES | |
44 | value wxSL_DEFAULT_VALUE | |
45 | min wxSL_DEFAULT_MIN | |
46 | max wxSL_DEFAULT_MAX | |
47 | tickfreq (long , 0 ) | |
48 | pagesize ( long ) | |
49 | linesize (long) | |
50 | thumg (long) | |
51 | tick (long) | |
52 | selmin / selmax (long) | |
53 | */ | |
54 | // Slider | |
55 | wxSlider95::wxSlider95() | |
56 | { | |
57 | m_staticValue = (WXHWND) NULL; | |
58 | m_staticMin = (WXHWND) NULL; | |
59 | m_staticMax = (WXHWND) NULL; | |
60 | m_pageSize = 1; | |
61 | m_lineSize = 1; | |
62 | m_rangeMax = 0; | |
63 | m_rangeMin = 0; | |
64 | m_tickFreq = 0; | |
65 | } | |
66 | ||
67 | bool wxSlider95::Create(wxWindow *parent, wxWindowID id, | |
68 | int value, int minValue, int maxValue, | |
69 | const wxPoint& pos, | |
70 | const wxSize& size, long style, | |
71 | const wxValidator& validator, | |
72 | const wxString& name) | |
73 | { | |
74 | if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) | |
75 | style |= wxBORDER_NONE; | |
76 | ||
77 | SetName(name); | |
78 | #if wxUSE_VALIDATORS | |
79 | SetValidator(validator); | |
80 | #endif // wxUSE_VALIDATORS | |
81 | ||
82 | if (parent) parent->AddChild(this); | |
83 | ||
84 | SetBackgroundColour(parent->GetBackgroundColour()) ; | |
85 | SetForegroundColour(parent->GetForegroundColour()) ; | |
86 | ||
87 | m_staticValue = (WXHWND) NULL;; | |
88 | m_staticMin = (WXHWND) NULL;; | |
89 | m_staticMax = (WXHWND) NULL;; | |
90 | m_pageSize = 1; | |
91 | m_lineSize = 1; | |
92 | m_windowStyle = style; | |
93 | m_tickFreq = 0; | |
94 | ||
95 | if ( id == -1 ) | |
96 | m_windowId = (int)NewControlId(); | |
97 | else | |
98 | m_windowId = id; | |
99 | ||
100 | int x = pos.x; | |
101 | int y = pos.y; | |
102 | int width = size.x; | |
103 | int height = size.y; | |
104 | ||
105 | long msStyle = 0; | |
106 | long wstyle = 0; | |
107 | ||
108 | if ( m_windowStyle & wxSL_LABELS ) | |
109 | { | |
110 | msStyle |= SS_CENTER; | |
111 | ||
112 | WXDWORD exStyle = 0; | |
113 | long valueStyle = m_windowStyle & ~wxBORDER_MASK; | |
114 | valueStyle |= wxBORDER_SUNKEN; | |
115 | msStyle |= MSWGetStyle(valueStyle, & exStyle) ; | |
116 | ||
117 | m_staticValue = (WXHWND) CreateWindowEx | |
118 | ( | |
119 | exStyle, wxT("STATIC"), NULL, | |
120 | msStyle, | |
121 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), | |
122 | wxGetInstance(), NULL | |
123 | ); | |
124 | ||
125 | // Now create min static control | |
126 | wxString minLabel; | |
127 | minLabel.Printf(wxT("%d"), minValue); | |
128 | wstyle = STATIC_FLAGS; | |
129 | if ( m_windowStyle & wxCLIP_SIBLINGS ) | |
130 | msStyle |= WS_CLIPSIBLINGS; | |
131 | m_staticMin = (WXHWND) CreateWindowEx | |
132 | ( | |
133 | 0, wxT("STATIC"), minLabel, | |
134 | wstyle, | |
135 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), | |
136 | wxGetInstance(), NULL | |
137 | ); | |
138 | } | |
139 | ||
140 | WXDWORD exStyle = 0; | |
141 | ||
142 | msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; | |
143 | ||
144 | if (m_windowStyle & wxSL_VERTICAL) | |
145 | msStyle = TBS_VERT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ; | |
146 | else | |
147 | msStyle = TBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP ; | |
148 | ||
149 | if ( m_windowStyle & wxSL_AUTOTICKS ) | |
150 | msStyle |= TBS_AUTOTICKS ; | |
151 | ||
152 | if ( m_windowStyle & wxSL_LEFT ) | |
153 | msStyle |= TBS_LEFT; | |
154 | else if ( m_windowStyle & wxSL_RIGHT ) | |
155 | msStyle |= TBS_RIGHT; | |
156 | else if ( m_windowStyle & wxSL_TOP ) | |
157 | msStyle |= TBS_TOP; | |
158 | else if ( m_windowStyle & wxSL_BOTTOM ) | |
159 | msStyle |= TBS_BOTTOM; | |
160 | else if ( m_windowStyle & wxSL_BOTH ) | |
161 | msStyle |= TBS_BOTH; | |
162 | else if ( ! (m_windowStyle & wxSL_AUTOTICKS) ) | |
163 | msStyle |= TBS_NOTICKS; | |
164 | ||
165 | if ( m_windowStyle & wxSL_SELRANGE ) | |
166 | msStyle |= TBS_ENABLESELRANGE; | |
167 | ||
168 | HWND scroll_bar = CreateWindowEx | |
169 | ( | |
170 | exStyle, TRACKBAR_CLASS, wxEmptyString, | |
171 | msStyle, | |
172 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, | |
173 | wxGetInstance(), NULL | |
174 | ); | |
175 | ||
176 | m_rangeMax = maxValue; | |
177 | m_rangeMin = minValue; | |
178 | ||
179 | m_pageSize = (int)((maxValue-minValue)/10); | |
180 | ||
181 | ::SendMessage(scroll_bar, TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue)); | |
182 | ::SendMessage(scroll_bar, TBM_SETPOS, TRUE, (LPARAM)value); | |
183 | ::SendMessage(scroll_bar, TBM_SETPAGESIZE, 0, (LPARAM)m_pageSize); | |
184 | ||
185 | m_hWnd = (WXHWND)scroll_bar; | |
186 | ||
187 | SubclassWin(GetHWND()); | |
188 | ||
189 | ::SetWindowText((HWND) m_hWnd, wxEmptyString); | |
190 | ||
191 | SetFont(parent->GetFont()); | |
192 | ||
193 | if ( m_windowStyle & wxSL_LABELS ) | |
194 | { | |
195 | // Finally, create max value static item | |
196 | wxString maxLabel; | |
197 | maxLabel.Printf(wxT("%d"), maxValue); | |
198 | wstyle = STATIC_FLAGS; | |
199 | ||
200 | if ( m_windowStyle & wxCLIP_SIBLINGS ) | |
201 | msStyle |= WS_CLIPSIBLINGS; | |
202 | ||
203 | m_staticMax = (WXHWND) CreateWindowEx | |
204 | ( | |
205 | 0, wxT("STATIC"), maxLabel, | |
206 | wstyle, | |
207 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), | |
208 | wxGetInstance(), NULL | |
209 | ); | |
210 | ||
211 | ||
212 | if (GetFont().Ok()) | |
213 | { | |
214 | if (GetFont().GetResourceHandle()) | |
215 | { | |
216 | if ( m_staticMin ) | |
217 | ::SendMessage((HWND) m_staticMin, WM_SETFONT, | |
218 | (WPARAM) GetFont().GetResourceHandle(), 0L); | |
219 | ||
220 | if ( m_staticMax ) | |
221 | ::SendMessage((HWND) m_staticMax, WM_SETFONT, | |
222 | (WPARAM) GetFont().GetResourceHandle(), 0L); | |
223 | ||
224 | if (m_staticValue) | |
225 | ::SendMessage((HWND) m_staticValue, WM_SETFONT, | |
226 | (WPARAM) GetFont().GetResourceHandle(), 0L); | |
227 | } | |
228 | } | |
229 | } | |
230 | ||
231 | SetSize(x, y, width, height); | |
232 | SetValue(value); | |
233 | ||
234 | return TRUE; | |
235 | } | |
236 | ||
237 | bool wxSlider95::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, | |
238 | WXWORD WXUNUSED(pos), WXHWND control) | |
239 | { | |
240 | wxEventType scrollEvent; | |
241 | switch ( wParam ) | |
242 | { | |
243 | case SB_TOP: | |
244 | scrollEvent = wxEVT_SCROLL_TOP; | |
245 | break; | |
246 | ||
247 | case SB_BOTTOM: | |
248 | scrollEvent = wxEVT_SCROLL_BOTTOM; | |
249 | break; | |
250 | ||
251 | case SB_LINEUP: | |
252 | scrollEvent = wxEVT_SCROLL_LINEUP; | |
253 | break; | |
254 | ||
255 | case SB_LINEDOWN: | |
256 | scrollEvent = wxEVT_SCROLL_LINEDOWN; | |
257 | break; | |
258 | ||
259 | case SB_PAGEUP: | |
260 | scrollEvent = wxEVT_SCROLL_PAGEUP; | |
261 | break; | |
262 | ||
263 | case SB_PAGEDOWN: | |
264 | scrollEvent = wxEVT_SCROLL_PAGEDOWN; | |
265 | break; | |
266 | ||
267 | case SB_THUMBTRACK: | |
268 | scrollEvent = wxEVT_SCROLL_THUMBTRACK; | |
269 | break; | |
270 | ||
271 | case SB_THUMBPOSITION: | |
272 | scrollEvent = wxEVT_SCROLL_THUMBRELEASE; | |
273 | break; | |
274 | ||
275 | case SB_ENDSCROLL: | |
276 | scrollEvent = wxEVT_SCROLL_ENDSCROLL; | |
277 | break; | |
278 | ||
279 | default: | |
280 | // unknown scroll event? | |
281 | return FALSE; | |
282 | } | |
283 | ||
284 | int newPos = (int) ::SendMessage((HWND) control, TBM_GETPOS, 0, 0); | |
285 | if ( (newPos < GetMin()) || (newPos > GetMax()) ) | |
286 | { | |
287 | // out of range - but we did process it | |
288 | return TRUE; | |
289 | } | |
290 | ||
291 | SetValue(newPos); | |
292 | ||
293 | wxScrollEvent event(scrollEvent, m_windowId); | |
294 | event.SetPosition(newPos); | |
295 | event.SetEventObject( this ); | |
296 | GetEventHandler()->ProcessEvent(event); | |
297 | ||
298 | wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, GetId() ); | |
299 | cevent.SetInt( newPos ); | |
300 | cevent.SetEventObject( this ); | |
301 | ||
302 | return GetEventHandler()->ProcessEvent( cevent ); | |
303 | } | |
304 | ||
305 | wxSlider95::~wxSlider95() | |
306 | { | |
307 | if (m_staticMin) | |
308 | { | |
309 | ::DestroyWindow((HWND) m_staticMin); | |
310 | m_staticMin = (WXHWND) NULL; | |
311 | } | |
312 | ||
313 | if (m_staticMax) | |
314 | { | |
315 | ::DestroyWindow((HWND) m_staticMax); | |
316 | m_staticMax = (WXHWND) NULL; | |
317 | } | |
318 | ||
319 | if (m_staticValue) | |
320 | { | |
321 | ::DestroyWindow((HWND) m_staticValue); | |
322 | m_staticValue = (WXHWND) NULL; | |
323 | } | |
324 | } | |
325 | ||
326 | int wxSlider95::GetValue() const | |
327 | { | |
328 | return ::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0); | |
329 | } | |
330 | ||
331 | void wxSlider95::SetValue(int value) | |
332 | { | |
333 | ::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value); | |
334 | ||
335 | if (m_staticValue) | |
336 | { | |
337 | wxString str; | |
338 | str.Printf(wxT("%d"), value); | |
339 | ::SetWindowText((HWND) m_staticValue, str); | |
340 | } | |
341 | } | |
342 | ||
343 | void wxSlider95::DoGetSize(int *width, int *height) const | |
344 | { | |
345 | GetSize(width, height); | |
346 | } | |
347 | ||
348 | void wxSlider95::GetSize(int *width, int *height) const | |
349 | { | |
350 | RECT rect; | |
351 | rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1; | |
352 | ||
353 | wxFindMaxSize(GetHWND(), &rect); | |
354 | ||
355 | if (m_staticMin) | |
356 | wxFindMaxSize(m_staticMin, &rect); | |
357 | ||
358 | if (m_staticMax) | |
359 | wxFindMaxSize(m_staticMax, &rect); | |
360 | ||
361 | if (m_staticValue) | |
362 | wxFindMaxSize(m_staticValue, &rect); | |
363 | ||
364 | *width = rect.right - rect.left; | |
365 | *height = rect.bottom - rect.top; | |
366 | } | |
367 | ||
368 | void wxSlider95::GetPosition(int *x, int *y) const | |
369 | { | |
370 | wxWindow *parent = GetParent(); | |
371 | RECT rect; | |
372 | rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1; | |
373 | ||
374 | wxFindMaxSize(GetHWND(), &rect); | |
375 | ||
376 | if (m_staticMin) | |
377 | wxFindMaxSize(m_staticMin, &rect); | |
378 | if (m_staticMax) | |
379 | wxFindMaxSize(m_staticMax, &rect); | |
380 | if (m_staticValue) | |
381 | wxFindMaxSize(m_staticValue, &rect); | |
382 | ||
383 | // Since we now have the absolute screen coords, | |
384 | // if there's a parent we must subtract its top left corner | |
385 | POINT point; | |
386 | point.x = rect.left; | |
387 | point.y = rect.top; | |
388 | if (parent) | |
389 | ::ScreenToClient((HWND) parent->GetHWND(), &point); | |
390 | ||
391 | // We may be faking the client origin. | |
392 | // So a window that's really at (0, 30) may appear | |
393 | // (to wxWin apps) to be at (0, 0). | |
394 | if (GetParent()) | |
395 | { | |
396 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
397 | point.x -= pt.x; | |
398 | point.y -= pt.y; | |
399 | } | |
400 | ||
401 | *x = point.x; | |
402 | *y = point.y; | |
403 | } | |
404 | ||
405 | // TODO one day, make sense of all this horros and replace it with a readable | |
406 | // DoGetBestSize() | |
407 | void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags) | |
408 | { | |
409 | int x1 = x; | |
410 | int y1 = y; | |
411 | int w1 = width; | |
412 | int h1 = height; | |
413 | ||
414 | int currentX, currentY; | |
415 | GetPosition(¤tX, ¤tY); | |
416 | if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
417 | x1 = currentX; | |
418 | if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
419 | y1 = currentY; | |
420 | ||
421 | AdjustForParentClientOrigin(x1, y1, sizeFlags); | |
422 | ||
423 | wxChar buf[300]; | |
424 | ||
425 | int x_offset = x; | |
426 | int y_offset = y; | |
427 | ||
428 | int cx; // slider,min,max sizes | |
429 | int cy; | |
430 | int cyf; | |
431 | ||
432 | wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont()); | |
433 | ||
434 | if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) | |
435 | { | |
436 | if ( m_windowStyle & wxSL_LABELS ) | |
437 | { | |
438 | int min_len = 0; | |
439 | ||
440 | ::GetWindowText((HWND) m_staticMin, buf, 300); | |
441 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL, & this->GetFont()); | |
442 | ||
443 | int max_len = 0; | |
444 | ||
445 | ::GetWindowText((HWND) m_staticMax, buf, 300); | |
446 | GetTextExtent(buf, &max_len, &cyf,NULL,NULL, & this->GetFont()); | |
447 | if (m_staticValue) | |
448 | { | |
449 | int new_width = (int)(wxMax(min_len, max_len)); | |
450 | int valueHeight = (int)cyf; | |
451 | #ifdef __WIN32__ | |
452 | // For some reason, under Win95, the text edit control has | |
453 | // a lot of space before the first character | |
454 | new_width += 3*cx; | |
455 | #endif | |
456 | // The height needs to be a bit bigger under Win95 if | |
457 | // using native 3D effects. | |
458 | valueHeight = (int) (valueHeight * 1.5) ; | |
459 | ::MoveWindow((HWND) m_staticValue, x_offset, y_offset, | |
460 | new_width, valueHeight, TRUE); | |
461 | x_offset += new_width + cx; | |
462 | } | |
463 | ||
464 | MoveWindow((HWND) m_staticMin, x_offset, y_offset, | |
465 | (int) min_len, cy, TRUE); | |
466 | x_offset += (int)(min_len + cx); | |
467 | ||
468 | int slider_length = (int)(w1 - x_offset - max_len - cx); | |
469 | ||
470 | int slider_height = h1; | |
471 | if (slider_height < 0 ) | |
472 | slider_height = 20; | |
473 | ||
474 | // Slider must have a minimum/default length/height | |
475 | if (slider_length < 100) | |
476 | slider_length = 100; | |
477 | ||
478 | ::MoveWindow(GetHwnd(), x_offset, y_offset, | |
479 | slider_length, slider_height, TRUE); | |
480 | x_offset += slider_length + cx; | |
481 | ||
482 | MoveWindow((HWND) m_staticMax, x_offset, y_offset, | |
483 | (int) max_len, cy, TRUE); | |
484 | } | |
485 | else | |
486 | { | |
487 | // No labels | |
488 | // If we're prepared to use the existing size, then... | |
489 | if | |
490 | ( | |
491 | width == -1 | |
492 | && height == -1 | |
493 | && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO) | |
494 | ) | |
495 | { | |
496 | GetSize(&w1, &h1); | |
497 | } | |
498 | ||
499 | if ( w1 < 0 ) | |
500 | w1 = 200; | |
501 | if ( h1 < 0 ) | |
502 | h1 = 20; | |
503 | ||
504 | ::MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE); | |
505 | } | |
506 | } | |
507 | else | |
508 | { | |
509 | if ( m_windowStyle & wxSL_LABELS ) | |
510 | { | |
511 | int min_len; | |
512 | ::GetWindowText((HWND) m_staticMin, buf, 300); | |
513 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL, & this->GetFont()); | |
514 | ||
515 | int max_len; | |
516 | ::GetWindowText((HWND) m_staticMax, buf, 300); | |
517 | GetTextExtent(buf, &max_len, &cyf,NULL,NULL, & this->GetFont()); | |
518 | ||
519 | if (m_staticValue) | |
520 | { | |
521 | int new_width = (int)(wxMax(min_len, max_len)); | |
522 | int valueHeight = (int)cyf; | |
523 | /*** Suggested change by George Tasker - remove this block... | |
524 | #ifdef __WIN32__ | |
525 | // For some reason, under Win95, the text edit control has | |
526 | // a lot of space before the first character | |
527 | new_width += 3*cx; | |
528 | #endif | |
529 | ... and replace with following line: */ | |
530 | new_width += cx; | |
531 | ||
532 | // The height needs to be a bit bigger under Win95 if | |
533 | // using native 3D effects. | |
534 | valueHeight = (int) (valueHeight * 1.5) ; | |
535 | ||
536 | ::MoveWindow((HWND) m_staticValue, x_offset, y_offset, | |
537 | new_width, valueHeight, TRUE); | |
538 | y_offset += valueHeight; | |
539 | } | |
540 | ||
541 | ::MoveWindow((HWND) m_staticMin, x_offset, y_offset, | |
542 | (int) min_len, cy, TRUE); | |
543 | y_offset += cy; | |
544 | ||
545 | int slider_length = (int)(h1 - y_offset - cy - cy); | |
546 | ||
547 | int slider_width = w1; | |
548 | if (slider_width < 0 ) | |
549 | slider_width = 20; | |
550 | ||
551 | // Slider must have a minimum/default length | |
552 | if (slider_length < 100) | |
553 | slider_length = 100; | |
554 | ||
555 | ::MoveWindow(GetHwnd(), x_offset, y_offset, | |
556 | slider_width, slider_length, TRUE); | |
557 | y_offset += slider_length; | |
558 | ||
559 | ::MoveWindow((HWND) m_staticMax, x_offset, y_offset, | |
560 | (int)max_len, cy, TRUE); | |
561 | } | |
562 | else | |
563 | { | |
564 | // No labels | |
565 | // If we're prepared to use the existing size, then... | |
566 | if | |
567 | ( | |
568 | width == -1 && height == -1 | |
569 | && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO) | |
570 | ) | |
571 | { | |
572 | GetSize(&w1, &h1); | |
573 | } | |
574 | ||
575 | if ( w1 < 0 ) | |
576 | w1 = 20; | |
577 | if ( h1 < 0 ) | |
578 | h1 = 200; | |
579 | ||
580 | ::MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE); | |
581 | } | |
582 | } | |
583 | } | |
584 | ||
585 | void wxSlider95::SetRange(int minValue, int maxValue) | |
586 | { | |
587 | m_rangeMin = minValue; | |
588 | m_rangeMax = maxValue; | |
589 | ||
590 | ::SendMessage(GetHwnd(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue)); | |
591 | ||
592 | wxChar buf[40]; | |
593 | if ( m_staticMin ) | |
594 | { | |
595 | wxSprintf(buf, wxT("%d"), m_rangeMin); | |
596 | ::SetWindowText((HWND) m_staticMin, buf); | |
597 | } | |
598 | ||
599 | if ( m_staticMax ) | |
600 | { | |
601 | wxSprintf(buf, wxT("%d"), m_rangeMax); | |
602 | ::SetWindowText((HWND) m_staticMax, buf); | |
603 | } | |
604 | } | |
605 | ||
606 | WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
607 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) | |
608 | { | |
609 | #ifndef __WXWINCE__ | |
610 | if ( nCtlColor == CTLCOLOR_SCROLLBAR ) | |
611 | return 0; | |
612 | #else | |
613 | if ( nCtlColor != CTLCOLOR_STATIC ) | |
614 | return 0; | |
615 | #endif | |
616 | // Otherwise, it's a static | |
617 | return wxControl::OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); | |
618 | } | |
619 | ||
620 | // For trackbars only | |
621 | void wxSlider95::SetTickFreq(int n, int pos) | |
622 | { | |
623 | m_tickFreq = n; | |
624 | ::SendMessage( GetHwnd(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos ); | |
625 | } | |
626 | ||
627 | void wxSlider95::SetPageSize(int pageSize) | |
628 | { | |
629 | ::SendMessage( GetHwnd(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize ); | |
630 | m_pageSize = pageSize; | |
631 | } | |
632 | ||
633 | int wxSlider95::GetPageSize() const | |
634 | { | |
635 | return m_pageSize; | |
636 | } | |
637 | ||
638 | void wxSlider95::ClearSel() | |
639 | { | |
640 | ::SendMessage( GetHwnd(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 ); | |
641 | } | |
642 | ||
643 | void wxSlider95::ClearTicks() | |
644 | { | |
645 | ::SendMessage( GetHwnd(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 ); | |
646 | } | |
647 | ||
648 | void wxSlider95::SetLineSize(int lineSize) | |
649 | { | |
650 | m_lineSize = lineSize; | |
651 | ::SendMessage( GetHwnd(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize ); | |
652 | } | |
653 | ||
654 | int wxSlider95::GetLineSize() const | |
655 | { | |
656 | return (int) ::SendMessage( GetHwnd(), TBM_GETLINESIZE, | |
657 | (WPARAM) 0, (LPARAM) 0 ); | |
658 | } | |
659 | ||
660 | int wxSlider95::GetSelEnd() const | |
661 | { | |
662 | return (int) ::SendMessage( GetHwnd(), TBM_SETSELEND, | |
663 | (WPARAM) 0, (LPARAM) 0 ); | |
664 | } | |
665 | ||
666 | int wxSlider95::GetSelStart() const | |
667 | { | |
668 | return (int) ::SendMessage( GetHwnd(), TBM_GETSELSTART, | |
669 | (WPARAM) 0, (LPARAM) 0 ); | |
670 | } | |
671 | ||
672 | void wxSlider95::SetSelection(int minPos, int maxPos) | |
673 | { | |
674 | ::SendMessage(GetHwnd(), TBM_SETSEL, | |
675 | (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) ); | |
676 | } | |
677 | ||
678 | void wxSlider95::SetThumbLength(int len) | |
679 | { | |
680 | ::SendMessage( GetHwnd(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 ); | |
681 | } | |
682 | ||
683 | int wxSlider95::GetThumbLength() const | |
684 | { | |
685 | return (int) ::SendMessage( GetHwnd(), TBM_GETTHUMBLENGTH, | |
686 | (WPARAM) 0, (LPARAM) 0 ); | |
687 | } | |
688 | ||
689 | void wxSlider95::SetTick(int tickPos) | |
690 | { | |
691 | ::SendMessage( GetHwnd(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos ); | |
692 | } | |
693 | ||
694 | bool wxSlider95::ContainsHWND(WXHWND hWnd) const | |
695 | { | |
696 | return | |
697 | ( | |
698 | hWnd == GetStaticMin() | |
699 | || hWnd == GetStaticMax() | |
700 | || hWnd == GetEditValue() | |
701 | ); | |
702 | } | |
703 | ||
704 | void wxSlider95::Command (wxCommandEvent & event) | |
705 | { | |
706 | SetValue (event.GetInt()); | |
707 | ProcessCommand (event); | |
708 | } | |
709 | ||
710 | bool wxSlider95::Show(bool show) | |
711 | { | |
712 | wxWindow::Show(show); | |
713 | ||
714 | int cshow; | |
715 | if (show) | |
716 | cshow = SW_SHOW; | |
717 | else | |
718 | cshow = SW_HIDE; | |
719 | ||
720 | if(m_staticValue) | |
721 | ShowWindow((HWND) m_staticValue, (BOOL)cshow); | |
722 | ||
723 | if(m_staticMin) | |
724 | ShowWindow((HWND) m_staticMin, (BOOL)cshow); | |
725 | ||
726 | if(m_staticMax) | |
727 | ShowWindow((HWND) m_staticMax, (BOOL)cshow); | |
728 | ||
729 | return TRUE; | |
730 | } | |
731 | ||
732 | #endif | |
733 | // __WIN95__ | |
734 | ||
735 | #endif // wxUSE_SLIDER |