]>
Commit | Line | Data |
---|---|---|
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 and Markus Holzem | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
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 | #ifndef WX_PRECOMP | |
24 | #include <stdio.h> | |
25 | #endif | |
26 | ||
27 | #ifdef __WIN95__ | |
28 | ||
29 | #include "wx/msw/slider95.h" | |
30 | #include "wx/msw/private.h" | |
31 | ||
32 | #if defined(__WIN95__) && !defined(__GNUWIN32__) | |
33 | #include <commctrl.h> | |
34 | #endif | |
35 | ||
36 | #if !USE_SHARED_LIBRARY | |
37 | IMPLEMENT_DYNAMIC_CLASS(wxSlider95, wxControl) | |
38 | ||
39 | #if WXWIN_COMPATIBILITY | |
40 | BEGIN_EVENT_TABLE(wxSlider95, wxControl) | |
41 | EVT_SCROLL(wxSlider95::OnScroll) | |
42 | END_EVENT_TABLE() | |
43 | #endif | |
44 | ||
45 | #endif | |
46 | ||
47 | // Slider | |
48 | wxSlider95::wxSlider95(void) | |
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 | ||
60 | bool wxSlider95::Create(wxWindow *parent, wxWindowID id, | |
61 | int value, int minValue, int maxValue, | |
62 | const wxPoint& pos, | |
63 | const wxSize& size, long style, | |
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 | ||
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 | ||
166 | SetFont(parent->GetFont()); | |
167 | ||
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 | } | |
185 | ||
186 | SetSize(x, y, width, height); | |
187 | SetValue(value); | |
188 | ||
189 | return TRUE; | |
190 | } | |
191 | ||
192 | void wxSlider95::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control) | |
193 | { | |
194 | int position = 0; // Dummy - not used in this mode | |
195 | ||
196 | int nScrollInc; | |
197 | wxEventType scrollEvent = wxEVT_NULL; | |
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 | ||
245 | { | |
246 | ||
247 | int newPos = (int)::SendMessage((HWND) control, TBM_GETPOS, 0, 0); | |
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 | ||
260 | void wxSlider95::MSWOnHScroll(WXWORD wParam, WXWORD pos, WXHWND control) | |
261 | { | |
262 | MSWOnVScroll(wParam, pos, control); | |
263 | } | |
264 | ||
265 | wxSlider95::~wxSlider95(void) | |
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 | ||
275 | int wxSlider95::GetValue(void) const | |
276 | { | |
277 | return ::SendMessage((HWND) GetHWND(), TBM_GETPOS, 0, 0); | |
278 | } | |
279 | ||
280 | void wxSlider95::SetValue(int value) | |
281 | { | |
282 | ::SendMessage((HWND) GetHWND(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value); | |
283 | if (m_staticValue) | |
284 | { | |
285 | sprintf(wxBuffer, "%d", value); | |
286 | SetWindowText((HWND) m_staticValue, wxBuffer); | |
287 | } | |
288 | } | |
289 | ||
290 | void wxSlider95::GetSize(int *width, int *height) const | |
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 | ||
308 | void wxSlider95::GetPosition(int *x, int *y) const | |
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 | ||
335 | void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) | |
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; | |
356 | int cyf; | |
357 | ||
358 | wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); | |
359 | ||
360 | if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) | |
361 | { | |
362 | if ( m_windowStyle & wxSL_LABELS ) | |
363 | { | |
364 | int min_len = 0; | |
365 | ||
366 | GetWindowText((HWND) m_staticMin, buf, 300); | |
367 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL, GetFont()); | |
368 | ||
369 | int max_len = 0; | |
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 | |
382 | // The height needs to be a bit bigger under Win95 if using native | |
383 | // 3D effects. | |
384 | valueHeight = (int) (valueHeight * 1.5) ; | |
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 | ||
394 | int slider_height = h1; | |
395 | if (slider_height < 0 ) | |
396 | slider_height = 20; | |
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 | { | |
421 | int min_len; | |
422 | GetWindowText((HWND) m_staticMin, buf, 300); | |
423 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL,GetFont()); | |
424 | ||
425 | int max_len; | |
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 | ||
442 | // The height needs to be a bit bigger under Win95 if using native | |
443 | // 3D effects. | |
444 | valueHeight = (int) (valueHeight * 1.5) ; | |
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); | |
454 | ||
455 | int slider_width = w1; | |
456 | if (slider_width < 0 ) | |
457 | slider_width = 20; | |
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 | } | |
478 | } | |
479 | ||
480 | void wxSlider95::SetRange(int minValue, int maxValue) | |
481 | { | |
482 | m_rangeMin = minValue; | |
483 | m_rangeMax = maxValue; | |
484 | ||
485 | ::SendMessage((HWND) GetHWND(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue)); | |
486 | ||
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 | ||
501 | WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, | |
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); | |
517 | return (WXHBRUSH) backgroundBrush->GetResourceHandle(); | |
518 | } | |
519 | ||
520 | // For trackbars only | |
521 | void wxSlider95::SetTickFreq(int n, int pos) | |
522 | { | |
523 | m_tickFreq = n; | |
524 | ::SendMessage( (HWND) GetHWND(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos ); | |
525 | } | |
526 | ||
527 | void wxSlider95::SetPageSize(int pageSize) | |
528 | { | |
529 | ::SendMessage( (HWND) GetHWND(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize ); | |
530 | m_pageSize = pageSize; | |
531 | } | |
532 | ||
533 | int wxSlider95::GetPageSize(void) const | |
534 | { | |
535 | return m_pageSize; | |
536 | } | |
537 | ||
538 | void wxSlider95::ClearSel(void) | |
539 | { | |
540 | ::SendMessage( (HWND) GetHWND(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 ); | |
541 | } | |
542 | ||
543 | void wxSlider95::ClearTicks(void) | |
544 | { | |
545 | ::SendMessage( (HWND) GetHWND(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 ); | |
546 | } | |
547 | ||
548 | void wxSlider95::SetLineSize(int lineSize) | |
549 | { | |
550 | m_lineSize = lineSize; | |
551 | ::SendMessage( (HWND) GetHWND(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize ); | |
552 | } | |
553 | ||
554 | int wxSlider95::GetLineSize(void) const | |
555 | { | |
556 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETLINESIZE, (WPARAM) 0, (LPARAM) 0 ); | |
557 | } | |
558 | ||
559 | int wxSlider95::GetSelEnd(void) const | |
560 | { | |
561 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_SETSELEND, (WPARAM) 0, (LPARAM) 0 ); | |
562 | } | |
563 | ||
564 | int wxSlider95::GetSelStart(void) const | |
565 | { | |
566 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 ); | |
567 | } | |
568 | ||
569 | void wxSlider95::SetSelection(int minPos, int maxPos) | |
570 | { | |
571 | ::SendMessage( (HWND) GetHWND(), TBM_SETSEL, (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) ); | |
572 | } | |
573 | ||
574 | void wxSlider95::SetThumbLength(int len) | |
575 | { | |
576 | ::SendMessage( (HWND) GetHWND(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 ); | |
577 | } | |
578 | ||
579 | int wxSlider95::GetThumbLength(void) const | |
580 | { | |
581 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 ); | |
582 | } | |
583 | ||
584 | void wxSlider95::SetTick(int tickPos) | |
585 | { | |
586 | ::SendMessage( (HWND) GetHWND(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos ); | |
587 | } | |
588 | ||
589 | bool wxSlider95::ContainsHWND(WXHWND hWnd) const | |
590 | { | |
591 | return ( hWnd == GetStaticMin() || hWnd == GetStaticMax() || hWnd == GetEditValue() ); | |
592 | } | |
593 | ||
594 | #if WXWIN_COMPATIBILITY | |
595 | // Backward compatibility | |
596 | void wxSlider95::OnScroll(wxScrollEvent& event) | |
597 | { | |
598 | wxEventType oldEvent = event.GetEventType(); | |
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 | ||
609 | void wxSlider95::Command (wxCommandEvent & event) | |
610 | { | |
611 | SetValue (event.GetInt()); | |
612 | ProcessCommand (event); | |
613 | } | |
614 | ||
615 | bool wxSlider95::Show(bool show) | |
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 | ||
634 | #endif | |
635 | // __WIN95__ | |
636 |