]>
Commit | Line | Data |
---|---|---|
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 | |
9 | // Licence: wxWindows license | |
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 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include <stdio.h> | |
2bda0e17 KB |
25 | #endif |
26 | ||
da87a1ca | 27 | #ifdef __WIN95__ |
2bda0e17 | 28 | |
da87a1ca JS |
29 | #include "wx/msw/slider95.h" |
30 | #include "wx/msw/private.h" | |
2bda0e17 KB |
31 | |
32 | #if defined(__WIN95__) && !defined(__GNUWIN32__) | |
33 | #include <commctrl.h> | |
34 | #endif | |
35 | ||
36 | #if !USE_SHARED_LIBRARY | |
da87a1ca | 37 | IMPLEMENT_DYNAMIC_CLASS(wxSlider95, wxControl) |
2bda0e17 KB |
38 | |
39 | #if WXWIN_COMPATIBILITY | |
da87a1ca JS |
40 | BEGIN_EVENT_TABLE(wxSlider95, wxControl) |
41 | EVT_SCROLL(wxSlider95::OnScroll) | |
2bda0e17 KB |
42 | END_EVENT_TABLE() |
43 | #endif | |
44 | ||
45 | #endif | |
46 | ||
47 | // Slider | |
da87a1ca | 48 | wxSlider95::wxSlider95(void) |
2bda0e17 KB |
49 | { |
50 | m_staticValue = 0; | |
51 | m_staticMin = 0; | |
52 | m_staticMax = 0; | |
53 | m_pageSize = 1; | |
54 | m_lineSize = 1; | |
55 | m_rangeMax = 0; | |
56 | m_rangeMin = 0; | |
57 | m_tickFreq = 0; | |
58 | } | |
59 | ||
debe6624 JS |
60 | bool wxSlider95::Create(wxWindow *parent, wxWindowID id, |
61 | int value, int minValue, int maxValue, | |
2bda0e17 | 62 | const wxPoint& pos, |
debe6624 | 63 | const wxSize& size, long style, |
2bda0e17 KB |
64 | const wxValidator& validator, |
65 | const wxString& name) | |
66 | { | |
67 | SetName(name); | |
68 | SetValidator(validator); | |
69 | ||
70 | if (parent) parent->AddChild(this); | |
71 | SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; | |
72 | SetForegroundColour(parent->GetDefaultForegroundColour()) ; | |
73 | ||
74 | m_staticValue = 0; | |
75 | m_staticMin = 0; | |
76 | m_staticMax = 0; | |
77 | m_pageSize = 1; | |
78 | m_lineSize = 1; | |
79 | m_windowStyle = style; | |
80 | m_tickFreq = 0; | |
81 | ||
82 | if ( id == -1 ) | |
83 | m_windowId = (int)NewControlId(); | |
84 | else | |
85 | m_windowId = id; | |
86 | ||
87 | int x = pos.x; | |
88 | int y = pos.y; | |
89 | int width = size.x; | |
90 | int height = size.y; | |
91 | ||
2bda0e17 KB |
92 | long msStyle ; |
93 | ||
94 | if ( m_windowStyle & wxSL_LABELS ) | |
95 | { | |
96 | msStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER; | |
97 | ||
98 | bool want3D; | |
99 | WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; | |
100 | ||
101 | m_staticValue = (WXHWND) CreateWindowEx(exStyle, "STATIC", NULL, | |
102 | msStyle, | |
103 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), | |
104 | wxGetInstance(), NULL); | |
105 | ||
106 | // Now create min static control | |
107 | sprintf(wxBuffer, "%d", minValue); | |
108 | m_staticMin = (WXHWND) CreateWindowEx(0, "STATIC", wxBuffer, | |
109 | STATIC_FLAGS, | |
110 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), | |
111 | wxGetInstance(), NULL); | |
112 | } | |
113 | ||
114 | msStyle = 0; | |
115 | if (m_windowStyle & wxSL_VERTICAL) | |
116 | msStyle = TBS_VERT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ; | |
117 | else | |
118 | msStyle = TBS_HORZ | WS_CHILD | WS_VISIBLE | WS_TABSTOP ; | |
119 | ||
120 | if ( m_windowStyle & wxSL_AUTOTICKS ) | |
121 | msStyle |= TBS_AUTOTICKS ; | |
122 | ||
123 | if ( m_windowStyle & wxSL_LEFT ) | |
124 | msStyle |= TBS_LEFT; | |
125 | else if ( m_windowStyle & wxSL_RIGHT ) | |
126 | msStyle |= TBS_RIGHT; | |
127 | else if ( m_windowStyle & wxSL_TOP ) | |
128 | msStyle |= TBS_TOP; | |
129 | else if ( m_windowStyle & wxSL_BOTTOM ) | |
130 | msStyle |= TBS_BOTTOM; | |
131 | else if ( m_windowStyle & wxSL_BOTH ) | |
132 | msStyle |= TBS_BOTH; | |
133 | else if ( ! (m_windowStyle & wxSL_AUTOTICKS) ) | |
134 | msStyle |= TBS_NOTICKS; | |
135 | ||
136 | if ( m_windowStyle & wxSL_SELRANGE ) | |
137 | msStyle |= TBS_ENABLESELRANGE ; | |
138 | ||
139 | HWND scroll_bar = CreateWindowEx(MakeExtendedStyle(m_windowStyle), TRACKBAR_CLASS, wxBuffer, | |
140 | msStyle, | |
141 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, | |
142 | wxGetInstance(), NULL); | |
143 | ||
144 | m_rangeMax = maxValue; | |
145 | m_rangeMin = minValue; | |
146 | ||
147 | m_pageSize = (int)((maxValue-minValue)/10); | |
148 | ||
149 | ::SendMessage(scroll_bar, TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue)); | |
150 | ::SendMessage(scroll_bar, TBM_SETPOS, TRUE, (LPARAM)value); | |
151 | ::SendMessage(scroll_bar, TBM_SETPAGESIZE, 0, (LPARAM)m_pageSize); | |
152 | ||
153 | m_hWnd = (WXHWND)scroll_bar; | |
154 | ||
155 | SubclassWin(GetHWND()); | |
156 | ||
157 | if ( m_windowStyle & wxSL_LABELS ) | |
158 | { | |
159 | // Finally, create max value static item | |
160 | sprintf(wxBuffer, "%d", maxValue); | |
161 | m_staticMax = (WXHWND) CreateWindowEx(0, "STATIC", wxBuffer, | |
162 | STATIC_FLAGS, | |
163 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), | |
164 | wxGetInstance(), NULL); | |
165 | ||
da87a1ca JS |
166 | SetFont(parent->GetFont()); |
167 | ||
2bda0e17 KB |
168 | if (GetFont()) |
169 | { | |
170 | // GetFont()->RealizeResource(); | |
171 | if (GetFont()->GetResourceHandle()) | |
172 | { | |
173 | if ( m_staticMin ) | |
174 | SendMessage((HWND)m_staticMin,WM_SETFONT, | |
175 | (WPARAM)GetFont()->GetResourceHandle(),0L); | |
176 | if ( m_staticMax ) | |
177 | SendMessage((HWND)m_staticMax,WM_SETFONT, | |
178 | (WPARAM)GetFont()->GetResourceHandle(),0L); | |
179 | if (m_staticValue) | |
180 | SendMessage((HWND)m_staticValue,WM_SETFONT, | |
181 | (WPARAM)GetFont()->GetResourceHandle(),0L); | |
182 | } | |
183 | } | |
184 | } | |
2bda0e17 KB |
185 | |
186 | SetSize(x, y, width, height); | |
187 | SetValue(value); | |
188 | ||
189 | return TRUE; | |
190 | } | |
191 | ||
debe6624 | 192 | void wxSlider95::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control) |
2bda0e17 | 193 | { |
2bda0e17 | 194 | int position = 0; // Dummy - not used in this mode |
2bda0e17 KB |
195 | |
196 | int nScrollInc; | |
7798a18e | 197 | wxEventType scrollEvent = wxEVT_NULL; |
2bda0e17 KB |
198 | switch ( wParam ) |
199 | { | |
200 | case SB_TOP: | |
201 | nScrollInc = m_rangeMax - position; | |
202 | scrollEvent = wxEVT_SCROLL_TOP; | |
203 | break; | |
204 | ||
205 | case SB_BOTTOM: | |
206 | nScrollInc = - position; | |
207 | scrollEvent = wxEVT_SCROLL_BOTTOM; | |
208 | break; | |
209 | ||
210 | case SB_LINEUP: | |
211 | nScrollInc = - GetLineSize(); | |
212 | scrollEvent = wxEVT_SCROLL_LINEUP; | |
213 | break; | |
214 | ||
215 | case SB_LINEDOWN: | |
216 | nScrollInc = GetLineSize(); | |
217 | scrollEvent = wxEVT_SCROLL_LINEDOWN; | |
218 | break; | |
219 | ||
220 | case SB_PAGEUP: | |
221 | nScrollInc = -GetPageSize(); | |
222 | scrollEvent = wxEVT_SCROLL_PAGEUP; | |
223 | break; | |
224 | ||
225 | case SB_PAGEDOWN: | |
226 | nScrollInc = GetPageSize(); | |
227 | scrollEvent = wxEVT_SCROLL_PAGEDOWN; | |
228 | break; | |
229 | ||
230 | case SB_THUMBTRACK: | |
231 | case SB_THUMBPOSITION: | |
232 | #ifdef __WIN32__ | |
233 | nScrollInc = (signed short)pos - position; | |
234 | #else | |
235 | nScrollInc = pos - position; | |
236 | #endif | |
237 | scrollEvent = wxEVT_SCROLL_THUMBTRACK; | |
238 | break; | |
239 | ||
240 | default: | |
241 | nScrollInc = 0; | |
242 | return; | |
243 | } | |
244 | ||
2bda0e17 KB |
245 | { |
246 | ||
2bda0e17 | 247 | int newPos = (int)::SendMessage((HWND) control, TBM_GETPOS, 0, 0); |
2bda0e17 KB |
248 | if (!(newPos < GetMin() || newPos > GetMax())) |
249 | { | |
250 | SetValue(newPos); | |
251 | ||
252 | wxScrollEvent event(scrollEvent, m_windowId); | |
253 | event.SetPosition(newPos); | |
254 | event.SetEventObject( this ); | |
255 | GetEventHandler()->ProcessEvent(event); | |
256 | } | |
257 | } | |
258 | } | |
259 | ||
debe6624 | 260 | void wxSlider95::MSWOnHScroll(WXWORD wParam, WXWORD pos, WXHWND control) |
2bda0e17 KB |
261 | { |
262 | MSWOnVScroll(wParam, pos, control); | |
263 | } | |
264 | ||
da87a1ca | 265 | wxSlider95::~wxSlider95(void) |
2bda0e17 KB |
266 | { |
267 | if (m_staticMin) | |
268 | DestroyWindow((HWND) m_staticMin); | |
269 | if (m_staticMax) | |
270 | DestroyWindow((HWND) m_staticMax); | |
271 | if (m_staticValue) | |
272 | DestroyWindow((HWND) m_staticValue); | |
273 | } | |
274 | ||
da87a1ca | 275 | int wxSlider95::GetValue(void) const |
2bda0e17 | 276 | { |
2bda0e17 | 277 | return ::SendMessage((HWND) GetHWND(), TBM_GETPOS, 0, 0); |
2bda0e17 KB |
278 | } |
279 | ||
debe6624 | 280 | void wxSlider95::SetValue(int value) |
2bda0e17 | 281 | { |
2bda0e17 | 282 | ::SendMessage((HWND) GetHWND(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value); |
2bda0e17 KB |
283 | if (m_staticValue) |
284 | { | |
285 | sprintf(wxBuffer, "%d", value); | |
286 | SetWindowText((HWND) m_staticValue, wxBuffer); | |
287 | } | |
288 | } | |
289 | ||
da87a1ca | 290 | void wxSlider95::GetSize(int *width, int *height) const |
2bda0e17 KB |
291 | { |
292 | RECT rect; | |
293 | rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1; | |
294 | ||
295 | wxFindMaxSize(GetHWND(), &rect); | |
296 | ||
297 | if (m_staticMin) | |
298 | wxFindMaxSize(m_staticMin, &rect); | |
299 | if (m_staticMax) | |
300 | wxFindMaxSize(m_staticMax, &rect); | |
301 | if (m_staticValue) | |
302 | wxFindMaxSize(m_staticValue, &rect); | |
303 | ||
304 | *width = rect.right - rect.left; | |
305 | *height = rect.bottom - rect.top; | |
306 | } | |
307 | ||
da87a1ca | 308 | void wxSlider95::GetPosition(int *x, int *y) const |
2bda0e17 KB |
309 | { |
310 | wxWindow *parent = GetParent(); | |
311 | RECT rect; | |
312 | rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1; | |
313 | ||
314 | wxFindMaxSize(GetHWND(), &rect); | |
315 | ||
316 | if (m_staticMin) | |
317 | wxFindMaxSize(m_staticMin, &rect); | |
318 | if (m_staticMax) | |
319 | wxFindMaxSize(m_staticMax, &rect); | |
320 | if (m_staticValue) | |
321 | wxFindMaxSize(m_staticValue, &rect); | |
322 | ||
323 | // Since we now have the absolute screen coords, | |
324 | // if there's a parent we must subtract its top left corner | |
325 | POINT point; | |
326 | point.x = rect.left; | |
327 | point.y = rect.top; | |
328 | if (parent) | |
329 | ::ScreenToClient((HWND) parent->GetHWND(), &point); | |
330 | ||
331 | *x = point.x; | |
332 | *y = point.y; | |
333 | } | |
334 | ||
debe6624 | 335 | void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) |
2bda0e17 KB |
336 | { |
337 | int x1 = x; | |
338 | int y1 = y; | |
339 | int w1 = width; | |
340 | int h1 = height; | |
341 | ||
342 | int currentX, currentY; | |
343 | GetPosition(¤tX, ¤tY); | |
344 | if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
345 | x1 = currentX; | |
346 | if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
347 | y1 = currentY; | |
348 | ||
349 | char buf[300]; | |
350 | ||
351 | int x_offset = x; | |
352 | int y_offset = y; | |
353 | ||
354 | int cx; // slider,min,max sizes | |
355 | int cy; | |
debe6624 | 356 | int cyf; |
2bda0e17 KB |
357 | |
358 | wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); | |
359 | ||
360 | if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) | |
361 | { | |
362 | if ( m_windowStyle & wxSL_LABELS ) | |
363 | { | |
debe6624 | 364 | int min_len = 0; |
2bda0e17 KB |
365 | |
366 | GetWindowText((HWND) m_staticMin, buf, 300); | |
367 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL, GetFont()); | |
368 | ||
debe6624 | 369 | int max_len = 0; |
2bda0e17 KB |
370 | |
371 | GetWindowText((HWND) m_staticMax, buf, 300); | |
372 | GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont()); | |
373 | if (m_staticValue) | |
374 | { | |
375 | int new_width = (int)(wxMax(min_len, max_len)); | |
376 | int valueHeight = (int)cyf; | |
377 | #ifdef __WIN32__ | |
378 | // For some reason, under Win95, the text edit control has | |
379 | // a lot of space before the first character | |
380 | new_width += 3*cx; | |
381 | #endif | |
2bda0e17 KB |
382 | // The height needs to be a bit bigger under Win95 if using native |
383 | // 3D effects. | |
384 | valueHeight = (int) (valueHeight * 1.5) ; | |
2bda0e17 KB |
385 | MoveWindow((HWND) m_staticValue, x_offset, y_offset, new_width, valueHeight, TRUE); |
386 | x_offset += new_width + cx; | |
387 | } | |
388 | ||
389 | MoveWindow((HWND) m_staticMin, x_offset, y_offset, (int)min_len, cy, TRUE); | |
390 | x_offset += (int)(min_len + cx); | |
391 | ||
392 | int slider_length = (int)(w1 - x_offset - max_len - cx); | |
393 | ||
2bda0e17 KB |
394 | int slider_height = h1; |
395 | if (slider_height < 0 ) | |
396 | slider_height = 20; | |
2bda0e17 KB |
397 | |
398 | // Slider must have a minimum/default length/height | |
399 | if (slider_length < 100) | |
400 | slider_length = 100; | |
401 | ||
402 | MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_length, slider_height, TRUE); | |
403 | x_offset += slider_length + cx; | |
404 | ||
405 | MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE); | |
406 | } | |
407 | else | |
408 | { | |
409 | // No labels | |
410 | if ( w1 < 0 ) | |
411 | w1 = 200; | |
412 | if ( h1 < 0 ) | |
413 | h1 = 20; | |
414 | MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE); | |
415 | } | |
416 | } | |
417 | else | |
418 | { | |
419 | if ( m_windowStyle & wxSL_LABELS ) | |
420 | { | |
debe6624 | 421 | int min_len; |
2bda0e17 KB |
422 | GetWindowText((HWND) m_staticMin, buf, 300); |
423 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL,GetFont()); | |
424 | ||
debe6624 | 425 | int max_len; |
2bda0e17 KB |
426 | GetWindowText((HWND) m_staticMax, buf, 300); |
427 | GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont()); | |
428 | ||
429 | if (m_staticValue) | |
430 | { | |
431 | int new_width = (int)(wxMax(min_len, max_len)); | |
432 | int valueHeight = (int)cyf; | |
433 | /*** Suggested change by George Tasker - remove this block... | |
434 | #ifdef __WIN32__ | |
435 | // For some reason, under Win95, the text edit control has | |
436 | // a lot of space before the first character | |
437 | new_width += 3*cx; | |
438 | #endif | |
439 | ... and replace with following line: */ | |
440 | new_width += cx; | |
441 | ||
2bda0e17 KB |
442 | // The height needs to be a bit bigger under Win95 if using native |
443 | // 3D effects. | |
444 | valueHeight = (int) (valueHeight * 1.5) ; | |
2bda0e17 KB |
445 | |
446 | MoveWindow((HWND) m_staticValue, x_offset, y_offset, new_width, valueHeight, TRUE); | |
447 | y_offset += valueHeight; | |
448 | } | |
449 | ||
450 | MoveWindow((HWND) m_staticMin, x_offset, y_offset, (int)min_len, cy, TRUE); | |
451 | y_offset += cy; | |
452 | ||
453 | int slider_length = (int)(h1 - y_offset - cy - cy); | |
da87a1ca | 454 | |
2bda0e17 KB |
455 | int slider_width = w1; |
456 | if (slider_width < 0 ) | |
457 | slider_width = 20; | |
2bda0e17 KB |
458 | |
459 | // Slider must have a minimum/default length | |
460 | if (slider_length < 100) | |
461 | slider_length = 100; | |
462 | ||
463 | MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_width, slider_length, TRUE); | |
464 | y_offset += slider_length; | |
465 | ||
466 | MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE); | |
467 | } | |
468 | else | |
469 | { | |
470 | // No labels | |
471 | if ( w1 < 0 ) | |
472 | w1 = 20; | |
473 | if ( h1 < 0 ) | |
474 | h1 = 200; | |
475 | MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE); | |
476 | } | |
477 | } | |
2bda0e17 KB |
478 | } |
479 | ||
debe6624 | 480 | void wxSlider95::SetRange(int minValue, int maxValue) |
2bda0e17 KB |
481 | { |
482 | m_rangeMin = minValue; | |
483 | m_rangeMax = maxValue; | |
484 | ||
2bda0e17 | 485 | ::SendMessage((HWND) GetHWND(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue)); |
da87a1ca | 486 | |
2bda0e17 KB |
487 | char buf[40]; |
488 | if ( m_staticMin ) | |
489 | { | |
490 | sprintf(buf, "%d", m_rangeMin); | |
491 | SetWindowText((HWND) m_staticMin, buf); | |
492 | } | |
493 | ||
494 | if ( m_staticMax ) | |
495 | { | |
496 | sprintf(buf, "%d", m_rangeMax); | |
497 | SetWindowText((HWND) m_staticMax, buf); | |
498 | } | |
499 | } | |
500 | ||
debe6624 | 501 | WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
2bda0e17 KB |
502 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
503 | { | |
504 | if ( nCtlColor == CTLCOLOR_SCROLLBAR ) | |
505 | return 0; | |
506 | ||
507 | // Otherwise, it's a static | |
508 | if (GetParent()->GetTransparentBackground()) | |
509 | SetBkMode((HDC) pDC, TRANSPARENT); | |
510 | else | |
511 | SetBkMode((HDC) pDC, OPAQUE); | |
512 | ||
513 | ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue())); | |
514 | ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue())); | |
515 | ||
516 | wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID); | |
2bda0e17 KB |
517 | return (WXHBRUSH) backgroundBrush->GetResourceHandle(); |
518 | } | |
519 | ||
520 | // For trackbars only | |
debe6624 | 521 | void wxSlider95::SetTickFreq(int n, int pos) |
2bda0e17 | 522 | { |
2bda0e17 KB |
523 | m_tickFreq = n; |
524 | ::SendMessage( (HWND) GetHWND(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos ); | |
2bda0e17 KB |
525 | } |
526 | ||
debe6624 | 527 | void wxSlider95::SetPageSize(int pageSize) |
2bda0e17 | 528 | { |
2bda0e17 | 529 | ::SendMessage( (HWND) GetHWND(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize ); |
2bda0e17 KB |
530 | m_pageSize = pageSize; |
531 | } | |
532 | ||
da87a1ca | 533 | int wxSlider95::GetPageSize(void) const |
2bda0e17 KB |
534 | { |
535 | return m_pageSize; | |
536 | } | |
537 | ||
da87a1ca | 538 | void wxSlider95::ClearSel(void) |
2bda0e17 | 539 | { |
2bda0e17 | 540 | ::SendMessage( (HWND) GetHWND(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 ); |
2bda0e17 KB |
541 | } |
542 | ||
da87a1ca | 543 | void wxSlider95::ClearTicks(void) |
2bda0e17 | 544 | { |
2bda0e17 | 545 | ::SendMessage( (HWND) GetHWND(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 ); |
2bda0e17 KB |
546 | } |
547 | ||
debe6624 | 548 | void wxSlider95::SetLineSize(int lineSize) |
2bda0e17 KB |
549 | { |
550 | m_lineSize = lineSize; | |
2bda0e17 | 551 | ::SendMessage( (HWND) GetHWND(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize ); |
2bda0e17 KB |
552 | } |
553 | ||
da87a1ca | 554 | int wxSlider95::GetLineSize(void) const |
2bda0e17 | 555 | { |
2bda0e17 | 556 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETLINESIZE, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
557 | } |
558 | ||
da87a1ca | 559 | int wxSlider95::GetSelEnd(void) const |
2bda0e17 | 560 | { |
2bda0e17 | 561 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_SETSELEND, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
562 | } |
563 | ||
da87a1ca | 564 | int wxSlider95::GetSelStart(void) const |
2bda0e17 | 565 | { |
2bda0e17 | 566 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
567 | } |
568 | ||
debe6624 | 569 | void wxSlider95::SetSelection(int minPos, int maxPos) |
2bda0e17 | 570 | { |
2bda0e17 | 571 | ::SendMessage( (HWND) GetHWND(), TBM_SETSEL, (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) ); |
2bda0e17 KB |
572 | } |
573 | ||
debe6624 | 574 | void wxSlider95::SetThumbLength(int len) |
2bda0e17 | 575 | { |
2bda0e17 | 576 | ::SendMessage( (HWND) GetHWND(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 ); |
2bda0e17 KB |
577 | } |
578 | ||
da87a1ca | 579 | int wxSlider95::GetThumbLength(void) const |
2bda0e17 | 580 | { |
2bda0e17 | 581 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
582 | } |
583 | ||
debe6624 | 584 | void wxSlider95::SetTick(int tickPos) |
2bda0e17 | 585 | { |
2bda0e17 | 586 | ::SendMessage( (HWND) GetHWND(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos ); |
2bda0e17 KB |
587 | } |
588 | ||
da87a1ca | 589 | bool wxSlider95::ContainsHWND(WXHWND hWnd) const |
2bda0e17 KB |
590 | { |
591 | return ( hWnd == GetStaticMin() || hWnd == GetStaticMax() || hWnd == GetEditValue() ); | |
592 | } | |
593 | ||
594 | #if WXWIN_COMPATIBILITY | |
595 | // Backward compatibility | |
da87a1ca | 596 | void wxSlider95::OnScroll(wxScrollEvent& event) |
2bda0e17 | 597 | { |
7798a18e | 598 | wxEventType oldEvent = event.GetEventType(); |
2bda0e17 KB |
599 | event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED ); |
600 | if ( !GetEventHandler()->ProcessEvent(event) ) | |
601 | { | |
602 | event.SetEventType( oldEvent ); | |
603 | if (!GetParent()->GetEventHandler()->ProcessEvent(event)) | |
604 | event.Skip(); | |
605 | } | |
606 | } | |
607 | #endif | |
608 | ||
da87a1ca | 609 | void wxSlider95::Command (wxCommandEvent & event) |
2bda0e17 KB |
610 | { |
611 | SetValue (event.GetInt()); | |
612 | ProcessCommand (event); | |
613 | } | |
614 | ||
debe6624 | 615 | bool wxSlider95::Show(bool show) |
2bda0e17 KB |
616 | { |
617 | wxWindow::Show(show); | |
618 | ||
619 | int cshow; | |
620 | if (show) | |
621 | cshow = SW_SHOW; | |
622 | else | |
623 | cshow = SW_HIDE; | |
624 | ||
625 | if(m_staticValue) | |
626 | ShowWindow((HWND) m_staticValue, (BOOL)cshow); | |
627 | if(m_staticMin) | |
628 | ShowWindow((HWND) m_staticMin, (BOOL)cshow); | |
629 | if(m_staticMax) | |
630 | ShowWindow((HWND) m_staticMax, (BOOL)cshow); | |
631 | return TRUE; | |
632 | } | |
633 | ||
da87a1ca JS |
634 | #endif |
635 | // __WIN95__ | |
2bda0e17 | 636 |