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