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