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