]> git.saurik.com Git - wxWidgets.git/blob - src/msw/slider95.cpp
Changed name to wxFIXED_MINSIZE since that is more descriptive of what
[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 if ( m_windowStyle & wxSL_LABELS )
245 {
246 // Finally, create max value static item
247 wxString maxLabel;
248 maxLabel.Printf(wxT("%d"), maxValue);
249 wstyle = STATIC_FLAGS;
250
251 if ( m_windowStyle & wxCLIP_SIBLINGS )
252 msStyle |= WS_CLIPSIBLINGS;
253
254 m_staticMax = (WXHWND) CreateWindowEx
255 (
256 0, wxT("STATIC"), maxLabel,
257 wstyle,
258 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
259 wxGetInstance(), NULL
260 );
261
262
263 if (GetFont().Ok())
264 {
265 if (GetFont().GetResourceHandle())
266 {
267 if ( m_staticMin )
268 ::SendMessage((HWND) m_staticMin, WM_SETFONT,
269 (WPARAM) GetFont().GetResourceHandle(), 0L);
270
271 if ( m_staticMax )
272 ::SendMessage((HWND) m_staticMax, WM_SETFONT,
273 (WPARAM) GetFont().GetResourceHandle(), 0L);
274
275 if (m_staticValue)
276 ::SendMessage((HWND) m_staticValue, WM_SETFONT,
277 (WPARAM) GetFont().GetResourceHandle(), 0L);
278 }
279 }
280 }
281
282 SetSize(x, y, width, height);
283 SetValue(value);
284
285 return TRUE;
286 }
287
288 bool wxSlider95::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
289 WXWORD WXUNUSED(pos), WXHWND control)
290 {
291 wxEventType scrollEvent;
292 switch ( wParam )
293 {
294 case SB_TOP:
295 scrollEvent = wxEVT_SCROLL_TOP;
296 break;
297
298 case SB_BOTTOM:
299 scrollEvent = wxEVT_SCROLL_BOTTOM;
300 break;
301
302 case SB_LINEUP:
303 scrollEvent = wxEVT_SCROLL_LINEUP;
304 break;
305
306 case SB_LINEDOWN:
307 scrollEvent = wxEVT_SCROLL_LINEDOWN;
308 break;
309
310 case SB_PAGEUP:
311 scrollEvent = wxEVT_SCROLL_PAGEUP;
312 break;
313
314 case SB_PAGEDOWN:
315 scrollEvent = wxEVT_SCROLL_PAGEDOWN;
316 break;
317
318 case SB_THUMBTRACK:
319 scrollEvent = wxEVT_SCROLL_THUMBTRACK;
320 break;
321
322 case SB_THUMBPOSITION:
323 scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
324 break;
325
326 case SB_ENDSCROLL:
327 scrollEvent = wxEVT_SCROLL_ENDSCROLL;
328 break;
329
330 default:
331 // unknown scroll event?
332 return FALSE;
333 }
334
335 int newPos = (int) ::SendMessage((HWND) control, TBM_GETPOS, 0, 0);
336 if ( (newPos < GetMin()) || (newPos > GetMax()) )
337 {
338 // out of range - but we did process it
339 return TRUE;
340 }
341
342 SetValue(newPos);
343
344 wxScrollEvent event(scrollEvent, m_windowId);
345 event.SetPosition(newPos);
346 event.SetEventObject( this );
347 GetEventHandler()->ProcessEvent(event);
348
349 wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, GetId() );
350 cevent.SetInt( newPos );
351 cevent.SetEventObject( this );
352
353 return GetEventHandler()->ProcessEvent( cevent );
354 }
355
356 wxSlider95::~wxSlider95()
357 {
358 if (m_staticMin)
359 {
360 ::DestroyWindow((HWND) m_staticMin);
361 m_staticMin = (WXHWND) NULL;
362 }
363
364 if (m_staticMax)
365 {
366 ::DestroyWindow((HWND) m_staticMax);
367 m_staticMax = (WXHWND) NULL;
368 }
369
370 if (m_staticValue)
371 {
372 ::DestroyWindow((HWND) m_staticValue);
373 m_staticValue = (WXHWND) NULL;
374 }
375 }
376
377 int wxSlider95::GetValue() const
378 {
379 return ::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0);
380 }
381
382 void wxSlider95::SetValue(int value)
383 {
384 ::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value);
385
386 if (m_staticValue)
387 {
388 wxString str;
389 str.Printf(wxT("%d"), value);
390 ::SetWindowText((HWND) m_staticValue, str);
391 }
392 }
393
394 void wxSlider95::DoGetSize(int *width, int *height) const
395 {
396 RECT rect;
397 rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
398
399 wxFindMaxSize(GetHWND(), &rect);
400
401 if (m_staticMin)
402 wxFindMaxSize(m_staticMin, &rect);
403
404 if (m_staticMax)
405 wxFindMaxSize(m_staticMax, &rect);
406
407 if (m_staticValue)
408 wxFindMaxSize(m_staticValue, &rect);
409
410 if ( width )
411 *width = rect.right - rect.left;
412 if ( height )
413 *height = rect.bottom - rect.top;
414 }
415
416 void wxSlider95::GetPosition(int *x, int *y) const
417 {
418 wxWindow *parent = GetParent();
419 RECT rect;
420 rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
421
422 wxFindMaxSize(GetHWND(), &rect);
423
424 if (m_staticMin)
425 wxFindMaxSize(m_staticMin, &rect);
426 if (m_staticMax)
427 wxFindMaxSize(m_staticMax, &rect);
428 if (m_staticValue)
429 wxFindMaxSize(m_staticValue, &rect);
430
431 // Since we now have the absolute screen coords,
432 // if there's a parent we must subtract its top left corner
433 POINT point;
434 point.x = rect.left;
435 point.y = rect.top;
436 if (parent)
437 ::ScreenToClient((HWND) parent->GetHWND(), &point);
438
439 // We may be faking the client origin.
440 // So a window that's really at (0, 30) may appear
441 // (to wxWin apps) to be at (0, 0).
442 if (GetParent())
443 {
444 wxPoint pt(GetParent()->GetClientAreaOrigin());
445 point.x -= pt.x;
446 point.y -= pt.y;
447 }
448
449 *x = point.x;
450 *y = point.y;
451 }
452
453 // TODO one day, make sense of all this horros and replace it with a readable
454 // DoGetBestSize()
455 void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
456 {
457 int x1 = x;
458 int y1 = y;
459 int w1 = width;
460 int h1 = height;
461
462 int currentX, currentY;
463 GetPosition(&currentX, &currentY);
464 if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
465 x1 = currentX;
466 if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
467 y1 = currentY;
468
469 AdjustForParentClientOrigin(x1, y1, sizeFlags);
470
471 wxChar buf[300];
472
473 int x_offset = x;
474 int y_offset = y;
475
476 int cx; // slider,min,max sizes
477 int cy;
478 int cyf;
479
480 wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
481
482 if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
483 {
484 if ( m_windowStyle & wxSL_LABELS )
485 {
486 int min_len = 0;
487
488 ::GetWindowText((HWND) m_staticMin, buf, 300);
489 GetTextExtent(buf, &min_len, &cyf,NULL,NULL, & this->GetFont());
490
491 int max_len = 0;
492
493 ::GetWindowText((HWND) m_staticMax, buf, 300);
494 GetTextExtent(buf, &max_len, &cyf,NULL,NULL, & this->GetFont());
495 if (m_staticValue)
496 {
497 int new_width = (int)(wxMax(min_len, max_len));
498 int valueHeight = (int)cyf;
499 #ifdef __WIN32__
500 // For some reason, under Win95, the text edit control has
501 // a lot of space before the first character
502 new_width += 3*cx;
503 #endif
504 // The height needs to be a bit bigger under Win95 if
505 // using native 3D effects.
506 valueHeight = (int) (valueHeight * 1.5) ;
507 ::MoveWindow((HWND) m_staticValue, x_offset, y_offset,
508 new_width, valueHeight, TRUE);
509 x_offset += new_width + cx;
510 }
511
512 MoveWindow((HWND) m_staticMin, x_offset, y_offset,
513 (int) min_len, cy, TRUE);
514 x_offset += (int)(min_len + cx);
515
516 // slider_length = (total width available) - (width used so far)
517 // - (width of max label) - (border)
518 int slider_length = (int)(w1 - (x_offset-x) - max_len - cx);
519
520 int slider_height = h1;
521 if (slider_height < 0 )
522 slider_height = 20;
523
524 // Slider must have a minimum/default length/height
525 if (slider_length < 100)
526 slider_length = 100;
527
528 ::MoveWindow(GetHwnd(), x_offset, y_offset,
529 slider_length, slider_height, TRUE);
530 x_offset += slider_length + cx;
531
532 MoveWindow((HWND) m_staticMax, x_offset, y_offset,
533 (int) max_len, cy, TRUE);
534 }
535 else
536 {
537 // No labels
538 // If we're prepared to use the existing size, then...
539 if
540 (
541 width == -1
542 && height == -1
543 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)
544 )
545 {
546 GetSize(&w1, &h1);
547 }
548
549 if ( w1 < 0 )
550 w1 = 200;
551 if ( h1 < 0 )
552 h1 = 20;
553
554 ::MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE);
555 }
556 }
557 else
558 {
559 if ( m_windowStyle & wxSL_LABELS )
560 {
561 int min_len;
562 ::GetWindowText((HWND) m_staticMin, buf, 300);
563 GetTextExtent(buf, &min_len, &cyf,NULL,NULL, & this->GetFont());
564
565 int max_len;
566 ::GetWindowText((HWND) m_staticMax, buf, 300);
567 GetTextExtent(buf, &max_len, &cyf,NULL,NULL, & this->GetFont());
568
569 if (m_staticValue)
570 {
571 int new_width = (int)(wxMax(min_len, max_len));
572 int valueHeight = (int)cyf;
573 new_width += cx;
574
575 // The height needs to be a bit bigger under Win95 if
576 // using native 3D effects.
577 valueHeight = (int) (valueHeight * 1.5) ;
578
579 ::MoveWindow((HWND) m_staticValue, x_offset, y_offset,
580 new_width, valueHeight, TRUE);
581 y_offset += valueHeight;
582 }
583
584 ::MoveWindow((HWND) m_staticMin, x_offset, y_offset,
585 (int) min_len, cy, TRUE);
586 y_offset += cy;
587
588 // slider_length = (total height available) - (height used so far)
589 // - (height of max label) - (border)
590 int slider_length = (int)(h1 - (y_offset-y) - cy - cy);
591
592 int slider_width = w1;
593 if (slider_width < 0 )
594 slider_width = 20;
595
596 // Slider must have a minimum/default length
597 if (slider_length < 100)
598 slider_length = 100;
599
600 ::MoveWindow(GetHwnd(), x_offset, y_offset,
601 slider_width, slider_length, TRUE);
602 y_offset += slider_length;
603
604 ::MoveWindow((HWND) m_staticMax, x_offset, y_offset,
605 (int)max_len, cy, TRUE);
606 }
607 else
608 {
609 // No labels
610 // If we're prepared to use the existing size, then...
611 if
612 (
613 width == -1 && height == -1
614 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)
615 )
616 {
617 GetSize(&w1, &h1);
618 }
619
620 if ( w1 < 0 )
621 w1 = 20;
622 if ( h1 < 0 )
623 h1 = 200;
624
625 ::MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE);
626 }
627 }
628 }
629
630 void wxSlider95::SetRange(int minValue, int maxValue)
631 {
632 m_rangeMin = minValue;
633 m_rangeMax = maxValue;
634
635 ::SendMessage(GetHwnd(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue));
636
637 wxChar buf[40];
638 if ( m_staticMin )
639 {
640 wxSprintf(buf, wxT("%d"), m_rangeMin);
641 ::SetWindowText((HWND) m_staticMin, buf);
642 }
643
644 if ( m_staticMax )
645 {
646 wxSprintf(buf, wxT("%d"), m_rangeMax);
647 ::SetWindowText((HWND) m_staticMax, buf);
648 }
649 }
650
651 WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
652 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
653 {
654 #ifndef __WXWINCE__
655 if ( nCtlColor == CTLCOLOR_SCROLLBAR )
656 return 0;
657 #else
658 if ( nCtlColor != CTLCOLOR_STATIC )
659 return 0;
660 #endif
661 // Otherwise, it's a static
662 return wxControl::OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
663 }
664
665 // For trackbars only
666 void wxSlider95::SetTickFreq(int n, int pos)
667 {
668 m_tickFreq = n;
669 ::SendMessage( GetHwnd(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos );
670 }
671
672 void wxSlider95::SetPageSize(int pageSize)
673 {
674 ::SendMessage( GetHwnd(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize );
675 m_pageSize = pageSize;
676 }
677
678 int wxSlider95::GetPageSize() const
679 {
680 return m_pageSize;
681 }
682
683 void wxSlider95::ClearSel()
684 {
685 ::SendMessage( GetHwnd(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 );
686 }
687
688 void wxSlider95::ClearTicks()
689 {
690 ::SendMessage( GetHwnd(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 );
691 }
692
693 void wxSlider95::SetLineSize(int lineSize)
694 {
695 m_lineSize = lineSize;
696 ::SendMessage( GetHwnd(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize );
697 }
698
699 int wxSlider95::GetLineSize() const
700 {
701 return (int) ::SendMessage( GetHwnd(), TBM_GETLINESIZE,
702 (WPARAM) 0, (LPARAM) 0 );
703 }
704
705 int wxSlider95::GetSelEnd() const
706 {
707 return (int) ::SendMessage( GetHwnd(), TBM_SETSELEND,
708 (WPARAM) 0, (LPARAM) 0 );
709 }
710
711 int wxSlider95::GetSelStart() const
712 {
713 return (int) ::SendMessage( GetHwnd(), TBM_GETSELSTART,
714 (WPARAM) 0, (LPARAM) 0 );
715 }
716
717 void wxSlider95::SetSelection(int minPos, int maxPos)
718 {
719 ::SendMessage(GetHwnd(), TBM_SETSEL,
720 (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) );
721 }
722
723 void wxSlider95::SetThumbLength(int len)
724 {
725 ::SendMessage( GetHwnd(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 );
726 }
727
728 int wxSlider95::GetThumbLength() const
729 {
730 return (int) ::SendMessage( GetHwnd(), TBM_GETTHUMBLENGTH,
731 (WPARAM) 0, (LPARAM) 0 );
732 }
733
734 void wxSlider95::SetTick(int tickPos)
735 {
736 ::SendMessage( GetHwnd(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos );
737 }
738
739 bool wxSlider95::ContainsHWND(WXHWND hWnd) const
740 {
741 return
742 (
743 hWnd == GetStaticMin()
744 || hWnd == GetStaticMax()
745 || hWnd == GetEditValue()
746 );
747 }
748
749 void wxSlider95::Command (wxCommandEvent & event)
750 {
751 SetValue (event.GetInt());
752 ProcessCommand (event);
753 }
754
755 bool wxSlider95::Show(bool show)
756 {
757 wxWindow::Show(show);
758
759 int cshow;
760 if (show)
761 cshow = SW_SHOW;
762 else
763 cshow = SW_HIDE;
764
765 if(m_staticValue)
766 ShowWindow((HWND) m_staticValue, (BOOL)cshow);
767
768 if(m_staticMin)
769 ShowWindow((HWND) m_staticMin, (BOOL)cshow);
770
771 if(m_staticMax)
772 ShowWindow((HWND) m_staticMax, (BOOL)cshow);
773
774 return TRUE;
775 }
776
777 #endif
778 // __WIN95__
779
780 #endif // wxUSE_SLIDER