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