]> git.saurik.com Git - wxWidgets.git/blob - src/msw/slider95.cpp
Added some window style metadata
[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 WX_BEGIN_FLAGS( wxSliderStyle )
44 // new style border flags, we put them first to
45 // use them for streaming out
46 WX_FLAGS_MEMBER(wxBORDER_SIMPLE)
47 WX_FLAGS_MEMBER(wxBORDER_SUNKEN)
48 WX_FLAGS_MEMBER(wxBORDER_DOUBLE)
49 WX_FLAGS_MEMBER(wxBORDER_RAISED)
50 WX_FLAGS_MEMBER(wxBORDER_STATIC)
51 WX_FLAGS_MEMBER(wxBORDER_NONE)
52
53 // old style border flags
54 WX_FLAGS_MEMBER(wxSIMPLE_BORDER)
55 WX_FLAGS_MEMBER(wxSUNKEN_BORDER)
56 WX_FLAGS_MEMBER(wxDOUBLE_BORDER)
57 WX_FLAGS_MEMBER(wxRAISED_BORDER)
58 WX_FLAGS_MEMBER(wxSTATIC_BORDER)
59 WX_FLAGS_MEMBER(wxNO_BORDER)
60
61 // standard window styles
62 WX_FLAGS_MEMBER(wxTAB_TRAVERSAL)
63 WX_FLAGS_MEMBER(wxCLIP_CHILDREN)
64 WX_FLAGS_MEMBER(wxTRANSPARENT_WINDOW)
65 WX_FLAGS_MEMBER(wxWANTS_CHARS)
66 WX_FLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE)
67 WX_FLAGS_MEMBER(wxALWAYS_SHOW_SB )
68 WX_FLAGS_MEMBER(wxVSCROLL)
69 WX_FLAGS_MEMBER(wxHSCROLL)
70
71 WX_FLAGS_MEMBER(wxSL_HORIZONTAL)
72 WX_FLAGS_MEMBER(wxSL_VERTICAL)
73 WX_FLAGS_MEMBER(wxSL_AUTOTICKS)
74 WX_FLAGS_MEMBER(wxSL_LABELS)
75 WX_FLAGS_MEMBER(wxSL_LEFT)
76 WX_FLAGS_MEMBER(wxSL_TOP)
77 WX_FLAGS_MEMBER(wxSL_RIGHT)
78 WX_FLAGS_MEMBER(wxSL_BOTTOM)
79 WX_FLAGS_MEMBER(wxSL_BOTH)
80 WX_FLAGS_MEMBER(wxSL_SELRANGE)
81
82 WX_END_FLAGS( wxSliderStyle )
83
84 IMPLEMENT_DYNAMIC_CLASS_XTI(wxSlider95, wxControl,"wx/scrolbar.h")
85
86 WX_BEGIN_PROPERTIES_TABLE(wxSlider95)
87 WX_PROPERTY( Value , int , SetValue, GetValue , 0, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
88 WX_PROPERTY( Minimum , int , SetMin, GetMin, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
89 WX_PROPERTY( Maximum , int , SetMax, GetMax, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
90 WX_PROPERTY( PageSize , int , SetPageSize, GetLineSize, 1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
91 WX_PROPERTY( LineSize , int , SetLineSize, GetLineSize, 1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
92 WX_PROPERTY( ThumbLength , int , SetThumbLength, GetThumbLength, 1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
93 WX_PROPERTY_FLAGS( WindowStyle , wxSliderStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
94 WX_END_PROPERTIES_TABLE()
95
96 WX_BEGIN_HANDLERS_TABLE(wxSlider95)
97 WX_END_HANDLERS_TABLE()
98
99 WX_CONSTRUCTOR_8( wxSlider95 , wxWindow* , Parent , wxWindowID , Id , int , Value , int , Minimum , int , Maximum , wxPoint , Position , wxSize , Size , long , WindowStyle )
100 #else
101 IMPLEMENT_DYNAMIC_CLASS(wxSlider95, wxControl)
102 #endif
103
104 // Slider
105 wxSlider95::wxSlider95()
106 {
107 m_staticValue = (WXHWND) NULL;
108 m_staticMin = (WXHWND) NULL;
109 m_staticMax = (WXHWND) NULL;
110 m_pageSize = 1;
111 m_lineSize = 1;
112 m_rangeMax = 0;
113 m_rangeMin = 0;
114 m_tickFreq = 0;
115 }
116
117 bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
118 int value, int minValue, int maxValue,
119 const wxPoint& pos,
120 const wxSize& size, long style,
121 const wxValidator& validator,
122 const wxString& name)
123 {
124 if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
125 style |= wxBORDER_NONE;
126
127 SetName(name);
128 #if wxUSE_VALIDATORS
129 SetValidator(validator);
130 #endif // wxUSE_VALIDATORS
131
132 if (parent) parent->AddChild(this);
133
134 SetBackgroundColour(parent->GetBackgroundColour()) ;
135 SetForegroundColour(parent->GetForegroundColour()) ;
136
137 m_staticValue = (WXHWND) NULL;;
138 m_staticMin = (WXHWND) NULL;;
139 m_staticMax = (WXHWND) NULL;;
140 m_pageSize = 1;
141 m_lineSize = 1;
142 m_windowStyle = style;
143 m_tickFreq = 0;
144
145 if ( id == -1 )
146 m_windowId = (int)NewControlId();
147 else
148 m_windowId = id;
149
150 int x = pos.x;
151 int y = pos.y;
152 int width = size.x;
153 int height = size.y;
154
155 long msStyle = 0;
156 long wstyle = 0;
157
158 if ( m_windowStyle & wxSL_LABELS )
159 {
160 msStyle |= SS_CENTER;
161
162 WXDWORD exStyle = 0;
163 long valueStyle = m_windowStyle & ~wxBORDER_MASK;
164 valueStyle |= wxBORDER_SUNKEN;
165 msStyle |= MSWGetStyle(valueStyle, & exStyle) ;
166
167 m_staticValue = (WXHWND) CreateWindowEx
168 (
169 exStyle, wxT("STATIC"), NULL,
170 msStyle,
171 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
172 wxGetInstance(), NULL
173 );
174
175 // Now create min static control
176 wxString minLabel;
177 minLabel.Printf(wxT("%d"), minValue);
178 wstyle = STATIC_FLAGS;
179 if ( m_windowStyle & wxCLIP_SIBLINGS )
180 msStyle |= WS_CLIPSIBLINGS;
181 m_staticMin = (WXHWND) CreateWindowEx
182 (
183 0, wxT("STATIC"), minLabel,
184 wstyle,
185 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
186 wxGetInstance(), NULL
187 );
188 }
189
190 WXDWORD exStyle = 0;
191
192 msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
193
194 if (m_windowStyle & wxSL_VERTICAL)
195 msStyle = TBS_VERT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
196 else
197 msStyle = TBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
198
199 if ( m_windowStyle & wxSL_AUTOTICKS )
200 msStyle |= TBS_AUTOTICKS ;
201
202 if ( m_windowStyle & wxSL_LEFT )
203 msStyle |= TBS_LEFT;
204 else if ( m_windowStyle & wxSL_RIGHT )
205 msStyle |= TBS_RIGHT;
206 else if ( m_windowStyle & wxSL_TOP )
207 msStyle |= TBS_TOP;
208 else if ( m_windowStyle & wxSL_BOTTOM )
209 msStyle |= TBS_BOTTOM;
210 else if ( m_windowStyle & wxSL_BOTH )
211 msStyle |= TBS_BOTH;
212 else if ( ! (m_windowStyle & wxSL_AUTOTICKS) )
213 msStyle |= TBS_NOTICKS;
214
215 if ( m_windowStyle & wxSL_SELRANGE )
216 msStyle |= TBS_ENABLESELRANGE;
217
218 HWND scroll_bar = CreateWindowEx
219 (
220 exStyle, TRACKBAR_CLASS, wxEmptyString,
221 msStyle,
222 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
223 wxGetInstance(), NULL
224 );
225
226 m_rangeMax = maxValue;
227 m_rangeMin = minValue;
228
229 m_pageSize = (int)((maxValue-minValue)/10);
230
231 ::SendMessage(scroll_bar, TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue));
232 ::SendMessage(scroll_bar, TBM_SETPOS, TRUE, (LPARAM)value);
233 ::SendMessage(scroll_bar, TBM_SETPAGESIZE, 0, (LPARAM)m_pageSize);
234
235 m_hWnd = (WXHWND)scroll_bar;
236
237 SubclassWin(GetHWND());
238
239 ::SetWindowText((HWND) m_hWnd, wxEmptyString);
240
241 SetFont(parent->GetFont());
242
243 if ( m_windowStyle & wxSL_LABELS )
244 {
245 // Finally, create max value static item
246 wxString maxLabel;
247 maxLabel.Printf(wxT("%d"), maxValue);
248 wstyle = STATIC_FLAGS;
249
250 if ( m_windowStyle & wxCLIP_SIBLINGS )
251 msStyle |= WS_CLIPSIBLINGS;
252
253 m_staticMax = (WXHWND) CreateWindowEx
254 (
255 0, wxT("STATIC"), maxLabel,
256 wstyle,
257 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
258 wxGetInstance(), NULL
259 );
260
261
262 if (GetFont().Ok())
263 {
264 if (GetFont().GetResourceHandle())
265 {
266 if ( m_staticMin )
267 ::SendMessage((HWND) m_staticMin, WM_SETFONT,
268 (WPARAM) GetFont().GetResourceHandle(), 0L);
269
270 if ( m_staticMax )
271 ::SendMessage((HWND) m_staticMax, WM_SETFONT,
272 (WPARAM) GetFont().GetResourceHandle(), 0L);
273
274 if (m_staticValue)
275 ::SendMessage((HWND) m_staticValue, WM_SETFONT,
276 (WPARAM) GetFont().GetResourceHandle(), 0L);
277 }
278 }
279 }
280
281 SetSize(x, y, width, height);
282 SetValue(value);
283
284 return TRUE;
285 }
286
287 bool wxSlider95::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
288 WXWORD WXUNUSED(pos), WXHWND control)
289 {
290 wxEventType scrollEvent;
291 switch ( wParam )
292 {
293 case SB_TOP:
294 scrollEvent = wxEVT_SCROLL_TOP;
295 break;
296
297 case SB_BOTTOM:
298 scrollEvent = wxEVT_SCROLL_BOTTOM;
299 break;
300
301 case SB_LINEUP:
302 scrollEvent = wxEVT_SCROLL_LINEUP;
303 break;
304
305 case SB_LINEDOWN:
306 scrollEvent = wxEVT_SCROLL_LINEDOWN;
307 break;
308
309 case SB_PAGEUP:
310 scrollEvent = wxEVT_SCROLL_PAGEUP;
311 break;
312
313 case SB_PAGEDOWN:
314 scrollEvent = wxEVT_SCROLL_PAGEDOWN;
315 break;
316
317 case SB_THUMBTRACK:
318 scrollEvent = wxEVT_SCROLL_THUMBTRACK;
319 break;
320
321 case SB_THUMBPOSITION:
322 scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
323 break;
324
325 case SB_ENDSCROLL:
326 scrollEvent = wxEVT_SCROLL_ENDSCROLL;
327 break;
328
329 default:
330 // unknown scroll event?
331 return FALSE;
332 }
333
334 int newPos = (int) ::SendMessage((HWND) control, TBM_GETPOS, 0, 0);
335 if ( (newPos < GetMin()) || (newPos > GetMax()) )
336 {
337 // out of range - but we did process it
338 return TRUE;
339 }
340
341 SetValue(newPos);
342
343 wxScrollEvent event(scrollEvent, m_windowId);
344 event.SetPosition(newPos);
345 event.SetEventObject( this );
346 GetEventHandler()->ProcessEvent(event);
347
348 wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, GetId() );
349 cevent.SetInt( newPos );
350 cevent.SetEventObject( this );
351
352 return GetEventHandler()->ProcessEvent( cevent );
353 }
354
355 wxSlider95::~wxSlider95()
356 {
357 if (m_staticMin)
358 {
359 ::DestroyWindow((HWND) m_staticMin);
360 m_staticMin = (WXHWND) NULL;
361 }
362
363 if (m_staticMax)
364 {
365 ::DestroyWindow((HWND) m_staticMax);
366 m_staticMax = (WXHWND) NULL;
367 }
368
369 if (m_staticValue)
370 {
371 ::DestroyWindow((HWND) m_staticValue);
372 m_staticValue = (WXHWND) NULL;
373 }
374 }
375
376 int wxSlider95::GetValue() const
377 {
378 return ::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0);
379 }
380
381 void wxSlider95::SetValue(int value)
382 {
383 ::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value);
384
385 if (m_staticValue)
386 {
387 wxString str;
388 str.Printf(wxT("%d"), value);
389 ::SetWindowText((HWND) m_staticValue, str);
390 }
391 }
392
393 void wxSlider95::DoGetSize(int *width, int *height) const
394 {
395 GetSize(width, height);
396 }
397
398 void wxSlider95::GetSize(int *width, int *height) const
399 {
400 RECT rect;
401 rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
402
403 wxFindMaxSize(GetHWND(), &rect);
404
405 if (m_staticMin)
406 wxFindMaxSize(m_staticMin, &rect);
407
408 if (m_staticMax)
409 wxFindMaxSize(m_staticMax, &rect);
410
411 if (m_staticValue)
412 wxFindMaxSize(m_staticValue, &rect);
413
414 *width = rect.right - rect.left;
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 int slider_length = (int)(w1 - x_offset - 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 /*** Suggested change by George Tasker - remove this block...
574 #ifdef __WIN32__
575 // For some reason, under Win95, the text edit control has
576 // a lot of space before the first character
577 new_width += 3*cx;
578 #endif
579 ... and replace with following line: */
580 new_width += cx;
581
582 // The height needs to be a bit bigger under Win95 if
583 // using native 3D effects.
584 valueHeight = (int) (valueHeight * 1.5) ;
585
586 ::MoveWindow((HWND) m_staticValue, x_offset, y_offset,
587 new_width, valueHeight, TRUE);
588 y_offset += valueHeight;
589 }
590
591 ::MoveWindow((HWND) m_staticMin, x_offset, y_offset,
592 (int) min_len, cy, TRUE);
593 y_offset += cy;
594
595 int slider_length = (int)(h1 - y_offset - cy - cy);
596
597 int slider_width = w1;
598 if (slider_width < 0 )
599 slider_width = 20;
600
601 // Slider must have a minimum/default length
602 if (slider_length < 100)
603 slider_length = 100;
604
605 ::MoveWindow(GetHwnd(), x_offset, y_offset,
606 slider_width, slider_length, TRUE);
607 y_offset += slider_length;
608
609 ::MoveWindow((HWND) m_staticMax, x_offset, y_offset,
610 (int)max_len, cy, TRUE);
611 }
612 else
613 {
614 // No labels
615 // If we're prepared to use the existing size, then...
616 if
617 (
618 width == -1 && height == -1
619 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)
620 )
621 {
622 GetSize(&w1, &h1);
623 }
624
625 if ( w1 < 0 )
626 w1 = 20;
627 if ( h1 < 0 )
628 h1 = 200;
629
630 ::MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE);
631 }
632 }
633 }
634
635 void wxSlider95::SetRange(int minValue, int maxValue)
636 {
637 m_rangeMin = minValue;
638 m_rangeMax = maxValue;
639
640 ::SendMessage(GetHwnd(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue));
641
642 wxChar buf[40];
643 if ( m_staticMin )
644 {
645 wxSprintf(buf, wxT("%d"), m_rangeMin);
646 ::SetWindowText((HWND) m_staticMin, buf);
647 }
648
649 if ( m_staticMax )
650 {
651 wxSprintf(buf, wxT("%d"), m_rangeMax);
652 ::SetWindowText((HWND) m_staticMax, buf);
653 }
654 }
655
656 WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
657 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
658 {
659 #ifndef __WXWINCE__
660 if ( nCtlColor == CTLCOLOR_SCROLLBAR )
661 return 0;
662 #else
663 if ( nCtlColor != CTLCOLOR_STATIC )
664 return 0;
665 #endif
666 // Otherwise, it's a static
667 return wxControl::OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
668 }
669
670 // For trackbars only
671 void wxSlider95::SetTickFreq(int n, int pos)
672 {
673 m_tickFreq = n;
674 ::SendMessage( GetHwnd(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos );
675 }
676
677 void wxSlider95::SetPageSize(int pageSize)
678 {
679 ::SendMessage( GetHwnd(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize );
680 m_pageSize = pageSize;
681 }
682
683 int wxSlider95::GetPageSize() const
684 {
685 return m_pageSize;
686 }
687
688 void wxSlider95::ClearSel()
689 {
690 ::SendMessage( GetHwnd(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 );
691 }
692
693 void wxSlider95::ClearTicks()
694 {
695 ::SendMessage( GetHwnd(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 );
696 }
697
698 void wxSlider95::SetLineSize(int lineSize)
699 {
700 m_lineSize = lineSize;
701 ::SendMessage( GetHwnd(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize );
702 }
703
704 int wxSlider95::GetLineSize() const
705 {
706 return (int) ::SendMessage( GetHwnd(), TBM_GETLINESIZE,
707 (WPARAM) 0, (LPARAM) 0 );
708 }
709
710 int wxSlider95::GetSelEnd() const
711 {
712 return (int) ::SendMessage( GetHwnd(), TBM_SETSELEND,
713 (WPARAM) 0, (LPARAM) 0 );
714 }
715
716 int wxSlider95::GetSelStart() const
717 {
718 return (int) ::SendMessage( GetHwnd(), TBM_GETSELSTART,
719 (WPARAM) 0, (LPARAM) 0 );
720 }
721
722 void wxSlider95::SetSelection(int minPos, int maxPos)
723 {
724 ::SendMessage(GetHwnd(), TBM_SETSEL,
725 (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) );
726 }
727
728 void wxSlider95::SetThumbLength(int len)
729 {
730 ::SendMessage( GetHwnd(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 );
731 }
732
733 int wxSlider95::GetThumbLength() const
734 {
735 return (int) ::SendMessage( GetHwnd(), TBM_GETTHUMBLENGTH,
736 (WPARAM) 0, (LPARAM) 0 );
737 }
738
739 void wxSlider95::SetTick(int tickPos)
740 {
741 ::SendMessage( GetHwnd(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos );
742 }
743
744 bool wxSlider95::ContainsHWND(WXHWND hWnd) const
745 {
746 return
747 (
748 hWnd == GetStaticMin()
749 || hWnd == GetStaticMax()
750 || hWnd == GetEditValue()
751 );
752 }
753
754 void wxSlider95::Command (wxCommandEvent & event)
755 {
756 SetValue (event.GetInt());
757 ProcessCommand (event);
758 }
759
760 bool wxSlider95::Show(bool show)
761 {
762 wxWindow::Show(show);
763
764 int cshow;
765 if (show)
766 cshow = SW_SHOW;
767 else
768 cshow = SW_HIDE;
769
770 if(m_staticValue)
771 ShowWindow((HWND) m_staticValue, (BOOL)cshow);
772
773 if(m_staticMin)
774 ShowWindow((HWND) m_staticMin, (BOOL)cshow);
775
776 if(m_staticMax)
777 ShowWindow((HWND) m_staticMax, (BOOL)cshow);
778
779 return TRUE;
780 }
781
782 #endif
783 // __WIN95__
784
785 #endif // wxUSE_SLIDER