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