]>
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 | ||
81d66cf3 JS |
331 | // We may be faking the client origin. |
332 | // So a window that's really at (0, 30) may appear | |
333 | // (to wxWin apps) to be at (0, 0). | |
334 | if (GetParent()) | |
335 | { | |
336 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
337 | point.x -= pt.x; | |
338 | point.y -= pt.y; | |
339 | } | |
2bda0e17 KB |
340 | *x = point.x; |
341 | *y = point.y; | |
342 | } | |
343 | ||
debe6624 | 344 | void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) |
2bda0e17 KB |
345 | { |
346 | int x1 = x; | |
347 | int y1 = y; | |
348 | int w1 = width; | |
349 | int h1 = height; | |
350 | ||
351 | int currentX, currentY; | |
352 | GetPosition(¤tX, ¤tY); | |
353 | if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
354 | x1 = currentX; | |
355 | if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
356 | y1 = currentY; | |
357 | ||
81d66cf3 JS |
358 | AdjustForParentClientOrigin(x1, y1, sizeFlags); |
359 | ||
2bda0e17 KB |
360 | char buf[300]; |
361 | ||
362 | int x_offset = x; | |
363 | int y_offset = y; | |
364 | ||
365 | int cx; // slider,min,max sizes | |
366 | int cy; | |
debe6624 | 367 | int cyf; |
2bda0e17 KB |
368 | |
369 | wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); | |
370 | ||
371 | if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) | |
372 | { | |
373 | if ( m_windowStyle & wxSL_LABELS ) | |
374 | { | |
debe6624 | 375 | int min_len = 0; |
2bda0e17 KB |
376 | |
377 | GetWindowText((HWND) m_staticMin, buf, 300); | |
378 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL, GetFont()); | |
379 | ||
debe6624 | 380 | int max_len = 0; |
2bda0e17 KB |
381 | |
382 | GetWindowText((HWND) m_staticMax, buf, 300); | |
383 | GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont()); | |
384 | if (m_staticValue) | |
385 | { | |
386 | int new_width = (int)(wxMax(min_len, max_len)); | |
387 | int valueHeight = (int)cyf; | |
388 | #ifdef __WIN32__ | |
389 | // For some reason, under Win95, the text edit control has | |
390 | // a lot of space before the first character | |
391 | new_width += 3*cx; | |
392 | #endif | |
2bda0e17 KB |
393 | // The height needs to be a bit bigger under Win95 if using native |
394 | // 3D effects. | |
395 | valueHeight = (int) (valueHeight * 1.5) ; | |
2bda0e17 KB |
396 | MoveWindow((HWND) m_staticValue, x_offset, y_offset, new_width, valueHeight, TRUE); |
397 | x_offset += new_width + cx; | |
398 | } | |
399 | ||
400 | MoveWindow((HWND) m_staticMin, x_offset, y_offset, (int)min_len, cy, TRUE); | |
401 | x_offset += (int)(min_len + cx); | |
402 | ||
403 | int slider_length = (int)(w1 - x_offset - max_len - cx); | |
404 | ||
2bda0e17 KB |
405 | int slider_height = h1; |
406 | if (slider_height < 0 ) | |
407 | slider_height = 20; | |
2bda0e17 KB |
408 | |
409 | // Slider must have a minimum/default length/height | |
410 | if (slider_length < 100) | |
411 | slider_length = 100; | |
412 | ||
413 | MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_length, slider_height, TRUE); | |
414 | x_offset += slider_length + cx; | |
415 | ||
416 | MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE); | |
417 | } | |
418 | else | |
419 | { | |
420 | // No labels | |
421 | if ( w1 < 0 ) | |
422 | w1 = 200; | |
423 | if ( h1 < 0 ) | |
424 | h1 = 20; | |
425 | MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE); | |
426 | } | |
427 | } | |
428 | else | |
429 | { | |
430 | if ( m_windowStyle & wxSL_LABELS ) | |
431 | { | |
debe6624 | 432 | int min_len; |
2bda0e17 KB |
433 | GetWindowText((HWND) m_staticMin, buf, 300); |
434 | GetTextExtent(buf, &min_len, &cyf,NULL,NULL,GetFont()); | |
435 | ||
debe6624 | 436 | int max_len; |
2bda0e17 KB |
437 | GetWindowText((HWND) m_staticMax, buf, 300); |
438 | GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont()); | |
439 | ||
440 | if (m_staticValue) | |
441 | { | |
442 | int new_width = (int)(wxMax(min_len, max_len)); | |
443 | int valueHeight = (int)cyf; | |
444 | /*** Suggested change by George Tasker - remove this block... | |
445 | #ifdef __WIN32__ | |
446 | // For some reason, under Win95, the text edit control has | |
447 | // a lot of space before the first character | |
448 | new_width += 3*cx; | |
449 | #endif | |
450 | ... and replace with following line: */ | |
451 | new_width += cx; | |
452 | ||
2bda0e17 KB |
453 | // The height needs to be a bit bigger under Win95 if using native |
454 | // 3D effects. | |
455 | valueHeight = (int) (valueHeight * 1.5) ; | |
2bda0e17 KB |
456 | |
457 | MoveWindow((HWND) m_staticValue, x_offset, y_offset, new_width, valueHeight, TRUE); | |
458 | y_offset += valueHeight; | |
459 | } | |
460 | ||
461 | MoveWindow((HWND) m_staticMin, x_offset, y_offset, (int)min_len, cy, TRUE); | |
462 | y_offset += cy; | |
463 | ||
464 | int slider_length = (int)(h1 - y_offset - cy - cy); | |
da87a1ca | 465 | |
2bda0e17 KB |
466 | int slider_width = w1; |
467 | if (slider_width < 0 ) | |
468 | slider_width = 20; | |
2bda0e17 KB |
469 | |
470 | // Slider must have a minimum/default length | |
471 | if (slider_length < 100) | |
472 | slider_length = 100; | |
473 | ||
474 | MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_width, slider_length, TRUE); | |
475 | y_offset += slider_length; | |
476 | ||
477 | MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE); | |
478 | } | |
479 | else | |
480 | { | |
481 | // No labels | |
482 | if ( w1 < 0 ) | |
483 | w1 = 20; | |
484 | if ( h1 < 0 ) | |
485 | h1 = 200; | |
486 | MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE); | |
487 | } | |
488 | } | |
2bda0e17 KB |
489 | } |
490 | ||
debe6624 | 491 | void wxSlider95::SetRange(int minValue, int maxValue) |
2bda0e17 KB |
492 | { |
493 | m_rangeMin = minValue; | |
494 | m_rangeMax = maxValue; | |
495 | ||
2bda0e17 | 496 | ::SendMessage((HWND) GetHWND(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue)); |
da87a1ca | 497 | |
2bda0e17 KB |
498 | char buf[40]; |
499 | if ( m_staticMin ) | |
500 | { | |
501 | sprintf(buf, "%d", m_rangeMin); | |
502 | SetWindowText((HWND) m_staticMin, buf); | |
503 | } | |
504 | ||
505 | if ( m_staticMax ) | |
506 | { | |
507 | sprintf(buf, "%d", m_rangeMax); | |
508 | SetWindowText((HWND) m_staticMax, buf); | |
509 | } | |
510 | } | |
511 | ||
debe6624 | 512 | WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
2bda0e17 KB |
513 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
514 | { | |
515 | if ( nCtlColor == CTLCOLOR_SCROLLBAR ) | |
516 | return 0; | |
517 | ||
518 | // Otherwise, it's a static | |
519 | if (GetParent()->GetTransparentBackground()) | |
520 | SetBkMode((HDC) pDC, TRANSPARENT); | |
521 | else | |
522 | SetBkMode((HDC) pDC, OPAQUE); | |
523 | ||
524 | ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue())); | |
525 | ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue())); | |
526 | ||
527 | wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID); | |
2bda0e17 KB |
528 | return (WXHBRUSH) backgroundBrush->GetResourceHandle(); |
529 | } | |
530 | ||
531 | // For trackbars only | |
debe6624 | 532 | void wxSlider95::SetTickFreq(int n, int pos) |
2bda0e17 | 533 | { |
2bda0e17 KB |
534 | m_tickFreq = n; |
535 | ::SendMessage( (HWND) GetHWND(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos ); | |
2bda0e17 KB |
536 | } |
537 | ||
debe6624 | 538 | void wxSlider95::SetPageSize(int pageSize) |
2bda0e17 | 539 | { |
2bda0e17 | 540 | ::SendMessage( (HWND) GetHWND(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize ); |
2bda0e17 KB |
541 | m_pageSize = pageSize; |
542 | } | |
543 | ||
da87a1ca | 544 | int wxSlider95::GetPageSize(void) const |
2bda0e17 KB |
545 | { |
546 | return m_pageSize; | |
547 | } | |
548 | ||
da87a1ca | 549 | void wxSlider95::ClearSel(void) |
2bda0e17 | 550 | { |
2bda0e17 | 551 | ::SendMessage( (HWND) GetHWND(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 ); |
2bda0e17 KB |
552 | } |
553 | ||
da87a1ca | 554 | void wxSlider95::ClearTicks(void) |
2bda0e17 | 555 | { |
2bda0e17 | 556 | ::SendMessage( (HWND) GetHWND(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 ); |
2bda0e17 KB |
557 | } |
558 | ||
debe6624 | 559 | void wxSlider95::SetLineSize(int lineSize) |
2bda0e17 KB |
560 | { |
561 | m_lineSize = lineSize; | |
2bda0e17 | 562 | ::SendMessage( (HWND) GetHWND(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize ); |
2bda0e17 KB |
563 | } |
564 | ||
da87a1ca | 565 | int wxSlider95::GetLineSize(void) const |
2bda0e17 | 566 | { |
2bda0e17 | 567 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETLINESIZE, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
568 | } |
569 | ||
da87a1ca | 570 | int wxSlider95::GetSelEnd(void) const |
2bda0e17 | 571 | { |
2bda0e17 | 572 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_SETSELEND, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
573 | } |
574 | ||
da87a1ca | 575 | int wxSlider95::GetSelStart(void) const |
2bda0e17 | 576 | { |
2bda0e17 | 577 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
578 | } |
579 | ||
debe6624 | 580 | void wxSlider95::SetSelection(int minPos, int maxPos) |
2bda0e17 | 581 | { |
2bda0e17 | 582 | ::SendMessage( (HWND) GetHWND(), TBM_SETSEL, (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) ); |
2bda0e17 KB |
583 | } |
584 | ||
debe6624 | 585 | void wxSlider95::SetThumbLength(int len) |
2bda0e17 | 586 | { |
2bda0e17 | 587 | ::SendMessage( (HWND) GetHWND(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 ); |
2bda0e17 KB |
588 | } |
589 | ||
da87a1ca | 590 | int wxSlider95::GetThumbLength(void) const |
2bda0e17 | 591 | { |
2bda0e17 | 592 | return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 ); |
2bda0e17 KB |
593 | } |
594 | ||
debe6624 | 595 | void wxSlider95::SetTick(int tickPos) |
2bda0e17 | 596 | { |
2bda0e17 | 597 | ::SendMessage( (HWND) GetHWND(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos ); |
2bda0e17 KB |
598 | } |
599 | ||
da87a1ca | 600 | bool wxSlider95::ContainsHWND(WXHWND hWnd) const |
2bda0e17 KB |
601 | { |
602 | return ( hWnd == GetStaticMin() || hWnd == GetStaticMax() || hWnd == GetEditValue() ); | |
603 | } | |
604 | ||
605 | #if WXWIN_COMPATIBILITY | |
606 | // Backward compatibility | |
da87a1ca | 607 | void wxSlider95::OnScroll(wxScrollEvent& event) |
2bda0e17 | 608 | { |
7798a18e | 609 | wxEventType oldEvent = event.GetEventType(); |
2bda0e17 KB |
610 | event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED ); |
611 | if ( !GetEventHandler()->ProcessEvent(event) ) | |
612 | { | |
613 | event.SetEventType( oldEvent ); | |
614 | if (!GetParent()->GetEventHandler()->ProcessEvent(event)) | |
615 | event.Skip(); | |
616 | } | |
617 | } | |
618 | #endif | |
619 | ||
da87a1ca | 620 | void wxSlider95::Command (wxCommandEvent & event) |
2bda0e17 KB |
621 | { |
622 | SetValue (event.GetInt()); | |
623 | ProcessCommand (event); | |
624 | } | |
625 | ||
debe6624 | 626 | bool wxSlider95::Show(bool show) |
2bda0e17 KB |
627 | { |
628 | wxWindow::Show(show); | |
629 | ||
630 | int cshow; | |
631 | if (show) | |
632 | cshow = SW_SHOW; | |
633 | else | |
634 | cshow = SW_HIDE; | |
635 | ||
636 | if(m_staticValue) | |
637 | ShowWindow((HWND) m_staticValue, (BOOL)cshow); | |
638 | if(m_staticMin) | |
639 | ShowWindow((HWND) m_staticMin, (BOOL)cshow); | |
640 | if(m_staticMax) | |
641 | ShowWindow((HWND) m_staticMax, (BOOL)cshow); | |
642 | return TRUE; | |
643 | } | |
644 | ||
da87a1ca JS |
645 | #endif |
646 | // __WIN95__ | |
2bda0e17 | 647 |