1 | /*
|
---|
2 | * Trackbar control
|
---|
3 | *
|
---|
4 | * Copyright 1998, 1999 Eric Kohl <ekohl@abo.rhein-zeitung.de>
|
---|
5 | * Copyright 1998,1999 Alex Priem <alexp@sci.kun.nl>
|
---|
6 | * Copyright 1999 Achim Hasenmueller
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * TODO:
|
---|
10 | * - Some messages.
|
---|
11 | * - more display code.
|
---|
12 | * - handle dragging slider better
|
---|
13 | * - better tic handling.
|
---|
14 | * - more notifications.
|
---|
15 | *
|
---|
16 | */
|
---|
17 |
|
---|
18 | /* known bugs:
|
---|
19 |
|
---|
20 | -TBM_SETRANGEMAX & TBM_SETRANGEMIN should only change the view of the
|
---|
21 | trackbar, not the actual amount of tics in the list.
|
---|
22 | -TBM_GETTIC & TBM_GETTICPOS shouldn't rely on infoPtr->tics being sorted.
|
---|
23 | - Make drawing code exact match of w95 drawing.
|
---|
24 | */
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 | #include "winbase.h"
|
---|
29 | #include "commctrl.h"
|
---|
30 | #include "trackbar.h"
|
---|
31 | #include <stdio.h>
|
---|
32 |
|
---|
33 |
|
---|
34 | #define TRACKBAR_GetInfoPtr(wndPtr) ((TRACKBAR_INFO *)GetWindowLongA (hwnd,0))
|
---|
35 |
|
---|
36 |
|
---|
37 | /* Used by TRACKBAR_Refresh to find out which parts of the control
|
---|
38 | need to be recalculated */
|
---|
39 |
|
---|
40 | #define TB_THUMBPOSCHANGED 1
|
---|
41 | #define TB_THUMBSIZECHANGED 2
|
---|
42 | #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBPOSCHANGED)
|
---|
43 | #define TB_SELECTIONCHANGED 4
|
---|
44 | #define TB_DRAG_MODE 16 /* we're dragging the slider */
|
---|
45 | #define TB_DRAGPOSVALID 32 /* current Position is in dragPos */
|
---|
46 | #define TB_SHOW_TOOLTIP 64 /* tooltip-style enabled and tooltip on */
|
---|
47 |
|
---|
48 | /* helper defines for TRACKBAR_DrawTic */
|
---|
49 | #define TIC_LEFTEDGE 0x20
|
---|
50 | #define TIC_RIGHTEDGE 0x40
|
---|
51 | #define TIC_EDGE (TIC_LEFTEDGE | TIC_RIGHTEDGE)
|
---|
52 | #define TIC_SELECTIONMARKMAX 0x80
|
---|
53 | #define TIC_SELECTIONMARKMIN 0x100
|
---|
54 | #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
|
---|
55 |
|
---|
56 | static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code);
|
---|
57 |
|
---|
58 | void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
|
---|
59 | {
|
---|
60 | int i,tic,nrTics;
|
---|
61 |
|
---|
62 | if (infoPtr->uTicFreq && infoPtr->nRangeMax >= infoPtr->nRangeMin)
|
---|
63 | nrTics=(infoPtr->nRangeMax - infoPtr->nRangeMin)/infoPtr->uTicFreq;
|
---|
64 | else {
|
---|
65 | nrTics=0;
|
---|
66 | COMCTL32_Free (infoPtr->tics);
|
---|
67 | infoPtr->tics=NULL;
|
---|
68 | infoPtr->uNumTics=0;
|
---|
69 | return;
|
---|
70 | }
|
---|
71 |
|
---|
72 | if (nrTics!=infoPtr->uNumTics) {
|
---|
73 | infoPtr->tics=COMCTL32_ReAlloc (infoPtr->tics,
|
---|
74 | (nrTics+1)*sizeof (DWORD));
|
---|
75 | infoPtr->uNumTics=nrTics;
|
---|
76 | }
|
---|
77 | infoPtr->uNumTics=nrTics;
|
---|
78 | tic=infoPtr->nRangeMin+infoPtr->uTicFreq;
|
---|
79 | for (i=0; i<nrTics; i++,tic+=infoPtr->uTicFreq)
|
---|
80 | infoPtr->tics[i]=tic;
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 | /* converts from physical (mouse) position to logical position
|
---|
85 | (in range of trackbar) */
|
---|
86 |
|
---|
87 | static DOUBLE
|
---|
88 | TRACKBAR_ConvertPlaceToPosition (TRACKBAR_INFO *infoPtr, int place,
|
---|
89 | int vertical)
|
---|
90 | {
|
---|
91 | double range,width,pos;
|
---|
92 |
|
---|
93 | range=infoPtr->nRangeMax - infoPtr->nRangeMin;
|
---|
94 | if (vertical) {
|
---|
95 | width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
|
---|
96 | pos=(range*(place - infoPtr->rcChannel.top)) / width;
|
---|
97 | } else {
|
---|
98 | width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
|
---|
99 | pos=(range*(place - infoPtr->rcChannel.left)) / width;
|
---|
100 | }
|
---|
101 |
|
---|
102 | if (pos > infoPtr->nRangeMax)
|
---|
103 | pos = infoPtr->nRangeMax;
|
---|
104 | else if (pos < infoPtr->nRangeMin)
|
---|
105 | pos = infoPtr->nRangeMin;
|
---|
106 |
|
---|
107 | // TRACE (trackbar,"%.2f\n",pos);
|
---|
108 | return pos;
|
---|
109 | }
|
---|
110 |
|
---|
111 |
|
---|
112 | static VOID
|
---|
113 | TRACKBAR_CalcChannel (HWND hwnd, TRACKBAR_INFO *infoPtr)
|
---|
114 | {
|
---|
115 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
116 | INT cyChannel;
|
---|
117 | RECT lpRect,*channel = & infoPtr->rcChannel;
|
---|
118 |
|
---|
119 | GetClientRect (hwnd, &lpRect);
|
---|
120 |
|
---|
121 | if (dwStyle & TBS_ENABLESELRANGE)
|
---|
122 | cyChannel = MAX(infoPtr->uThumbLen - 8, 4);
|
---|
123 | else
|
---|
124 | cyChannel = 4;
|
---|
125 |
|
---|
126 | if (dwStyle & TBS_VERT) {
|
---|
127 | channel->top = lpRect.top + 8;
|
---|
128 | channel->bottom = lpRect.bottom - 8;
|
---|
129 |
|
---|
130 | if (dwStyle & TBS_BOTH) {
|
---|
131 | channel->left = (lpRect.right - cyChannel) / 2;
|
---|
132 | channel->right = (lpRect.right + cyChannel) / 2;
|
---|
133 | }
|
---|
134 | else if (dwStyle & TBS_LEFT) {
|
---|
135 | channel->left = lpRect.left + 10;
|
---|
136 | channel->right = channel->left + cyChannel;
|
---|
137 | }
|
---|
138 | else { /* TBS_RIGHT */
|
---|
139 | channel->right = lpRect.right - 10;
|
---|
140 | channel->left = channel->right - cyChannel;
|
---|
141 | }
|
---|
142 | }
|
---|
143 | else {
|
---|
144 | channel->left = lpRect.left + 8;
|
---|
145 | channel->right = lpRect.right - 8;
|
---|
146 | if (dwStyle & TBS_BOTH) {
|
---|
147 | channel->top = (lpRect.bottom - cyChannel) / 2;
|
---|
148 | channel->bottom = (lpRect.bottom + cyChannel) / 2;
|
---|
149 | }
|
---|
150 | else if (dwStyle & TBS_TOP) {
|
---|
151 | channel->top = lpRect.top + 10;
|
---|
152 | channel->bottom = channel->top + cyChannel;
|
---|
153 | }
|
---|
154 | else { /* TBS_BOTTOM */
|
---|
155 | channel->bottom = lpRect.bottom - 10;
|
---|
156 | channel->top = channel->bottom - cyChannel;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | }
|
---|
160 |
|
---|
161 | static VOID
|
---|
162 | TRACKBAR_CalcThumb (HWND hwnd, TRACKBAR_INFO *infoPtr)
|
---|
163 | {
|
---|
164 | RECT *thumb;
|
---|
165 | int range, width;
|
---|
166 |
|
---|
167 | thumb=&infoPtr->rcThumb;
|
---|
168 | range=infoPtr->nRangeMax - infoPtr->nRangeMin;
|
---|
169 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
|
---|
170 | width=infoPtr->rcChannel.bottom - infoPtr->rcChannel.top;
|
---|
171 | thumb->left = infoPtr->rcChannel.left - 1;
|
---|
172 | thumb->right = infoPtr->rcChannel.left + infoPtr->uThumbLen - 8;
|
---|
173 | thumb->top = infoPtr->rcChannel.top +
|
---|
174 | (width*infoPtr->nPos)/range - 5;
|
---|
175 | thumb->bottom = thumb->top + infoPtr->uThumbLen/3;
|
---|
176 |
|
---|
177 | } else {
|
---|
178 | width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
|
---|
179 | thumb->left = infoPtr->rcChannel.left +
|
---|
180 | (width*infoPtr->nPos)/range - 5;
|
---|
181 | thumb->right = thumb->left + infoPtr->uThumbLen/3;
|
---|
182 | thumb->top = infoPtr->rcChannel.top - 1;
|
---|
183 | thumb->bottom = infoPtr->rcChannel.top + infoPtr->uThumbLen - 8;
|
---|
184 | }
|
---|
185 | }
|
---|
186 |
|
---|
187 | static VOID
|
---|
188 | TRACKBAR_CalcSelection (HWND hwnd, TRACKBAR_INFO *infoPtr)
|
---|
189 | {
|
---|
190 | RECT *selection;
|
---|
191 | int range, width;
|
---|
192 |
|
---|
193 | selection= & infoPtr->rcSelection;
|
---|
194 | range=infoPtr->nRangeMax - infoPtr->nRangeMin;
|
---|
195 | width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
|
---|
196 |
|
---|
197 | if (range <= 0)
|
---|
198 | SetRectEmpty (selection);
|
---|
199 | else
|
---|
200 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) {
|
---|
201 | selection->left = infoPtr->rcChannel.left +
|
---|
202 | (width*infoPtr->nSelMin)/range;
|
---|
203 | selection->right = infoPtr->rcChannel.left +
|
---|
204 | (width*infoPtr->nSelMax)/range;
|
---|
205 | selection->top = infoPtr->rcChannel.top + 2;
|
---|
206 | selection->bottom = infoPtr->rcChannel.bottom - 2;
|
---|
207 | } else {
|
---|
208 | selection->top = infoPtr->rcChannel.top +
|
---|
209 | (width*infoPtr->nSelMin)/range;
|
---|
210 | selection->bottom = infoPtr->rcChannel.top +
|
---|
211 | (width*infoPtr->nSelMax)/range;
|
---|
212 | selection->left = infoPtr->rcChannel.left + 2;
|
---|
213 | selection->right = infoPtr->rcChannel.right - 2;
|
---|
214 | }
|
---|
215 | }
|
---|
216 |
|
---|
217 | /* Trackbar drawing code. I like my spaghetti done milanese. */
|
---|
218 |
|
---|
219 | /* ticPos is in tic-units, not in pixels */
|
---|
220 |
|
---|
221 | static VOID
|
---|
222 | TRACKBAR_DrawHorizTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
|
---|
223 | int flags, COLORREF clrTic)
|
---|
224 | {
|
---|
225 | RECT rcChannel=infoPtr->rcChannel;
|
---|
226 | int x,y,width,range,side;
|
---|
227 |
|
---|
228 | range=infoPtr->nRangeMax - infoPtr->nRangeMin;
|
---|
229 | width=rcChannel.right - rcChannel.left;
|
---|
230 |
|
---|
231 | if (flags & TBS_TOP) {
|
---|
232 | y=rcChannel.top-2;
|
---|
233 | side=-1;
|
---|
234 | } else {
|
---|
235 | y=rcChannel.bottom+2;
|
---|
236 | side=1;
|
---|
237 | }
|
---|
238 |
|
---|
239 | if (flags & TIC_SELECTIONMARK) {
|
---|
240 | if (flags & TIC_SELECTIONMARKMIN)
|
---|
241 | x=rcChannel.left + (width*ticPos)/range - 1;
|
---|
242 | else
|
---|
243 | x=rcChannel.left + (width*ticPos)/range + 1;
|
---|
244 |
|
---|
245 | SetPixel (hdc, x,y+6*side, clrTic);
|
---|
246 | SetPixel (hdc, x,y+7*side, clrTic);
|
---|
247 | return;
|
---|
248 | }
|
---|
249 |
|
---|
250 | if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
|
---|
251 | x=rcChannel.left + (width*ticPos)/range;
|
---|
252 | SetPixel (hdc, x,y+5*side, clrTic);
|
---|
253 | SetPixel (hdc, x,y+6*side, clrTic);
|
---|
254 | SetPixel (hdc, x,y+7*side, clrTic);
|
---|
255 | }
|
---|
256 |
|
---|
257 | if (flags & TIC_EDGE) {
|
---|
258 | if (flags & TIC_LEFTEDGE)
|
---|
259 | x=rcChannel.left;
|
---|
260 | else
|
---|
261 | x=rcChannel.right;
|
---|
262 |
|
---|
263 | SetPixel (hdc, x,y+5*side, clrTic);
|
---|
264 | SetPixel (hdc, x,y+6*side, clrTic);
|
---|
265 | SetPixel (hdc, x,y+7*side, clrTic);
|
---|
266 | SetPixel (hdc, x,y+8*side, clrTic);
|
---|
267 | }
|
---|
268 |
|
---|
269 | }
|
---|
270 |
|
---|
271 | static VOID
|
---|
272 | TRACKBAR_DrawVertTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
|
---|
273 | int flags, COLORREF clrTic)
|
---|
274 | {
|
---|
275 | RECT rcChannel=infoPtr->rcChannel;
|
---|
276 | int x,y,width,range,side;
|
---|
277 |
|
---|
278 | range=infoPtr->nRangeMax - infoPtr->nRangeMin;
|
---|
279 | width=rcChannel.bottom - rcChannel.top;
|
---|
280 |
|
---|
281 | if (flags & TBS_TOP) {
|
---|
282 | x=rcChannel.right-2;
|
---|
283 | side=-1;
|
---|
284 | } else {
|
---|
285 | x=rcChannel.left+2;
|
---|
286 | side=1;
|
---|
287 | }
|
---|
288 |
|
---|
289 |
|
---|
290 | if (flags & TIC_SELECTIONMARK) {
|
---|
291 | if (flags & TIC_SELECTIONMARKMIN)
|
---|
292 | y=rcChannel.top + (width*ticPos)/range - 1;
|
---|
293 | else
|
---|
294 | y=rcChannel.top + (width*ticPos)/range + 1;
|
---|
295 |
|
---|
296 | SetPixel (hdc, x+6*side, y, clrTic);
|
---|
297 | SetPixel (hdc, x+7*side, y, clrTic);
|
---|
298 | return;
|
---|
299 | }
|
---|
300 |
|
---|
301 | if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax)) {
|
---|
302 | y=rcChannel.top + (width*ticPos)/range;
|
---|
303 | SetPixel (hdc, x+5*side, y, clrTic);
|
---|
304 | SetPixel (hdc, x+6*side, y, clrTic);
|
---|
305 | SetPixel (hdc, x+7*side, y, clrTic);
|
---|
306 | }
|
---|
307 |
|
---|
308 | if (flags & TIC_EDGE) {
|
---|
309 | if (flags & TIC_LEFTEDGE)
|
---|
310 | y=rcChannel.top;
|
---|
311 | else
|
---|
312 | y=rcChannel.bottom;
|
---|
313 |
|
---|
314 | SetPixel (hdc, x+5*side, y, clrTic);
|
---|
315 | SetPixel (hdc, x+6*side, y, clrTic);
|
---|
316 | SetPixel (hdc, x+7*side, y, clrTic);
|
---|
317 | SetPixel (hdc, x+8*side, y, clrTic);
|
---|
318 | }
|
---|
319 |
|
---|
320 | }
|
---|
321 |
|
---|
322 |
|
---|
323 | static VOID
|
---|
324 | TRACKBAR_DrawTics (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
|
---|
325 | int flags, COLORREF clrTic)
|
---|
326 | {
|
---|
327 |
|
---|
328 | if (flags & TBS_VERT) {
|
---|
329 | if ((flags & TBS_TOP) || (flags & TBS_BOTH))
|
---|
330 | TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos,
|
---|
331 | flags | TBS_TOP , clrTic);
|
---|
332 | if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
|
---|
333 | TRACKBAR_DrawVertTic (infoPtr, hdc, ticPos, flags, clrTic);
|
---|
334 | return;
|
---|
335 | }
|
---|
336 |
|
---|
337 | if ((flags & TBS_TOP) || (flags & TBS_BOTH))
|
---|
338 | TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags | TBS_TOP , clrTic);
|
---|
339 |
|
---|
340 | if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
|
---|
341 | TRACKBAR_DrawHorizTic (infoPtr, hdc, ticPos, flags, clrTic);
|
---|
342 |
|
---|
343 | }
|
---|
344 |
|
---|
345 |
|
---|
346 | static VOID
|
---|
347 | TRACKBAR_Refresh (HWND hwnd, HDC hdc)
|
---|
348 | {
|
---|
349 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
350 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
351 | RECT rcClient, rcChannel, rcSelection;
|
---|
352 | HBRUSH hBrush = CreateSolidBrush (infoPtr->clrBk);
|
---|
353 | int i;
|
---|
354 |
|
---|
355 | GetClientRect (hwnd, &rcClient);
|
---|
356 | hBrush = CreateSolidBrush (infoPtr->clrBk);
|
---|
357 | FillRect (hdc, &rcClient, hBrush);
|
---|
358 | DeleteObject (hBrush);
|
---|
359 |
|
---|
360 | if (infoPtr->flags & TB_DRAGPOSVALID) {
|
---|
361 | infoPtr->nPos=infoPtr->dragPos;
|
---|
362 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
---|
363 | }
|
---|
364 |
|
---|
365 | if (infoPtr->flags & TB_THUMBCHANGED) {
|
---|
366 | TRACKBAR_CalcThumb (hwnd, infoPtr);
|
---|
367 | if (infoPtr->flags & TB_THUMBSIZECHANGED)
|
---|
368 | TRACKBAR_CalcChannel (hwnd, infoPtr);
|
---|
369 | }
|
---|
370 | if (infoPtr->flags & TB_SELECTIONCHANGED)
|
---|
371 | TRACKBAR_CalcSelection (hwnd, infoPtr);
|
---|
372 | infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED |
|
---|
373 | TB_DRAGPOSVALID);
|
---|
374 |
|
---|
375 | /* draw channel */
|
---|
376 |
|
---|
377 | rcChannel = infoPtr->rcChannel;
|
---|
378 | rcSelection= infoPtr->rcSelection;
|
---|
379 | DrawEdge (hdc, &rcChannel, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
---|
380 |
|
---|
381 | if (dwStyle & TBS_ENABLESELRANGE) { /* fill the channel */
|
---|
382 | HBRUSH hbr = CreateSolidBrush (RGB(255,255,255));
|
---|
383 | FillRect (hdc, &rcChannel, hbr);
|
---|
384 | if (((dwStyle & TBS_VERT) &&
|
---|
385 | (rcSelection.left!=rcSelection.right)) ||
|
---|
386 | ((!(dwStyle & TBS_VERT)) &&
|
---|
387 | (rcSelection.left!=rcSelection.right))) {
|
---|
388 | hbr=CreateSolidBrush (COLOR_HIGHLIGHT);
|
---|
389 | FillRect (hdc, &rcSelection, hbr);
|
---|
390 | }
|
---|
391 | DeleteObject (hbr);
|
---|
392 | }
|
---|
393 |
|
---|
394 |
|
---|
395 | /* draw tics */
|
---|
396 |
|
---|
397 | if (!(dwStyle & TBS_NOTICKS)) {
|
---|
398 | int ticFlags = dwStyle & 0x0f;
|
---|
399 | COLORREF clrTic=GetSysColor (COLOR_3DDKSHADOW);
|
---|
400 |
|
---|
401 | for (i=0; i<infoPtr->uNumTics; i++)
|
---|
402 | TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->tics[i],
|
---|
403 | ticFlags, clrTic);
|
---|
404 |
|
---|
405 | TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_LEFTEDGE, clrTic);
|
---|
406 | TRACKBAR_DrawTics (infoPtr, hdc, 0, ticFlags | TIC_RIGHTEDGE, clrTic);
|
---|
407 |
|
---|
408 | if ((dwStyle & TBS_ENABLESELRANGE) &&
|
---|
409 | (rcSelection.left!=rcSelection.right)) {
|
---|
410 | TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMin,
|
---|
411 | ticFlags | TIC_SELECTIONMARKMIN, clrTic);
|
---|
412 | TRACKBAR_DrawTics (infoPtr, hdc, infoPtr->nSelMax,
|
---|
413 | ticFlags | TIC_SELECTIONMARKMAX, clrTic);
|
---|
414 | }
|
---|
415 | }
|
---|
416 |
|
---|
417 | /* draw thumb */
|
---|
418 |
|
---|
419 | if (!(dwStyle & TBS_NOTHUMB)) {
|
---|
420 |
|
---|
421 | HBRUSH hbr = CreateSolidBrush (COLOR_BACKGROUND);
|
---|
422 | RECT thumb = infoPtr->rcThumb;
|
---|
423 |
|
---|
424 | SelectObject (hdc, hbr);
|
---|
425 |
|
---|
426 | if (dwStyle & TBS_BOTH) {
|
---|
427 | FillRect (hdc, &thumb, hbr);
|
---|
428 | DrawEdge (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
|
---|
429 | } else {
|
---|
430 |
|
---|
431 | POINT points[6];
|
---|
432 |
|
---|
433 | /* first, fill the thumb */
|
---|
434 | /* FIXME: revamp. check for TBS_VERT */
|
---|
435 |
|
---|
436 | SetPolyFillMode (hdc,WINDING);
|
---|
437 | points[0].x=thumb.left;
|
---|
438 | points[0].y=thumb.top;
|
---|
439 | points[1].x=thumb.right - 1;
|
---|
440 | points[1].y=thumb.top;
|
---|
441 | points[2].x=thumb.right - 1;
|
---|
442 | points[2].y=thumb.bottom -2;
|
---|
443 | points[3].x=(thumb.right + thumb.left-1)/2;
|
---|
444 | points[3].y=thumb.bottom+4;
|
---|
445 | points[4].x=thumb.left;
|
---|
446 | points[4].y=thumb.bottom -2;
|
---|
447 | points[5].x=points[0].x;
|
---|
448 | points[5].y=points[0].y;
|
---|
449 | Polygon (hdc, points, 6);
|
---|
450 |
|
---|
451 | if (dwStyle & TBS_VERT) {
|
---|
452 | /* draw edge */
|
---|
453 | } else {
|
---|
454 | RECT triangle; /* for correct shadows of thumb */
|
---|
455 | DrawEdge (hdc, &thumb, EDGE_RAISED, BF_TOPLEFT);
|
---|
456 |
|
---|
457 | /* draw notch */
|
---|
458 |
|
---|
459 | triangle.right = thumb.right+5;
|
---|
460 | triangle.left = points[3].x+5;
|
---|
461 | triangle.top = thumb.bottom +5;
|
---|
462 | triangle.bottom= thumb.bottom +1;
|
---|
463 | DrawEdge (hdc, &triangle, EDGE_SUNKEN,
|
---|
464 | BF_DIAGONAL | BF_TOP | BF_RIGHT);
|
---|
465 | triangle.left = thumb.left+6;
|
---|
466 | triangle.right = points[3].x+6;
|
---|
467 | DrawEdge (hdc, &triangle, EDGE_RAISED,
|
---|
468 | BF_DIAGONAL | BF_TOP | BF_LEFT);
|
---|
469 | }
|
---|
470 | }
|
---|
471 | DeleteObject (hbr);
|
---|
472 | }
|
---|
473 |
|
---|
474 | if (infoPtr->bFocus)
|
---|
475 | DrawFocusRect (hdc, &rcClient);
|
---|
476 | }
|
---|
477 |
|
---|
478 |
|
---|
479 | static VOID
|
---|
480 | TRACKBAR_AlignBuddies (HWND hwnd, TRACKBAR_INFO *infoPtr)
|
---|
481 | {
|
---|
482 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
483 | HWND hwndParent = GetParent (hwnd);
|
---|
484 | RECT rcSelf, rcBuddy;
|
---|
485 | INT x, y;
|
---|
486 |
|
---|
487 | GetWindowRect (hwnd, &rcSelf);
|
---|
488 | MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcSelf, 2);
|
---|
489 |
|
---|
490 | /* align buddy left or above */
|
---|
491 | if (infoPtr->hwndBuddyLA) {
|
---|
492 | GetWindowRect (infoPtr->hwndBuddyLA, &rcBuddy);
|
---|
493 | MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
|
---|
494 |
|
---|
495 | if (dwStyle & TBS_VERT) {
|
---|
496 | x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
|
---|
497 | (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
|
---|
498 | y = rcSelf.top - (rcBuddy.bottom - rcBuddy.top);
|
---|
499 | }
|
---|
500 | else {
|
---|
501 | x = rcSelf.left - (rcBuddy.right - rcBuddy.left);
|
---|
502 | y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
|
---|
503 | (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
|
---|
504 | }
|
---|
505 |
|
---|
506 | SetWindowPos (infoPtr->hwndBuddyLA, 0, x, y, 0, 0,
|
---|
507 | SWP_NOZORDER | SWP_NOSIZE);
|
---|
508 | }
|
---|
509 |
|
---|
510 |
|
---|
511 | /* align buddy right or below */
|
---|
512 | if (infoPtr->hwndBuddyRB) {
|
---|
513 | GetWindowRect (infoPtr->hwndBuddyRB, &rcBuddy);
|
---|
514 | MapWindowPoints (HWND_DESKTOP, hwndParent, (LPPOINT)&rcBuddy, 2);
|
---|
515 |
|
---|
516 | if (dwStyle & TBS_VERT) {
|
---|
517 | x = (infoPtr->rcChannel.right + infoPtr->rcChannel.left) / 2 -
|
---|
518 | (rcBuddy.right - rcBuddy.left) / 2 + rcSelf.left;
|
---|
519 | y = rcSelf.bottom;
|
---|
520 | }
|
---|
521 | else {
|
---|
522 | x = rcSelf.right;
|
---|
523 | y = (infoPtr->rcChannel.bottom + infoPtr->rcChannel.top) / 2 -
|
---|
524 | (rcBuddy.bottom - rcBuddy.top) / 2 + rcSelf.top;
|
---|
525 | }
|
---|
526 | SetWindowPos (infoPtr->hwndBuddyRB, 0, x, y, 0, 0,
|
---|
527 | SWP_NOZORDER | SWP_NOSIZE);
|
---|
528 | }
|
---|
529 | }
|
---|
530 |
|
---|
531 |
|
---|
532 | static LRESULT
|
---|
533 | TRACKBAR_ClearSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
534 | {
|
---|
535 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
536 |
|
---|
537 | infoPtr->nSelMin = 0;
|
---|
538 | infoPtr->nSelMax = 0;
|
---|
539 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
---|
540 |
|
---|
541 | if ((BOOL)wParam)
|
---|
542 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
543 |
|
---|
544 | return 0;
|
---|
545 | }
|
---|
546 |
|
---|
547 |
|
---|
548 | static LRESULT
|
---|
549 | TRACKBAR_ClearTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
550 | {
|
---|
551 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
552 |
|
---|
553 | if (infoPtr->tics) {
|
---|
554 | COMCTL32_Free (infoPtr->tics);
|
---|
555 | infoPtr->tics = NULL;
|
---|
556 | infoPtr->uNumTics = 0;
|
---|
557 | }
|
---|
558 |
|
---|
559 | if (wParam)
|
---|
560 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
561 |
|
---|
562 | return 0;
|
---|
563 | }
|
---|
564 |
|
---|
565 |
|
---|
566 | static LRESULT
|
---|
567 | TRACKBAR_GetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
568 | {
|
---|
569 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
570 |
|
---|
571 | if (wParam) /* buddy is left or above */
|
---|
572 | return (LRESULT)infoPtr->hwndBuddyLA;
|
---|
573 |
|
---|
574 | /* buddy is right or below */
|
---|
575 | return (LRESULT) infoPtr->hwndBuddyRB;
|
---|
576 | }
|
---|
577 |
|
---|
578 |
|
---|
579 | static LRESULT
|
---|
580 | TRACKBAR_GetChannelRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
581 | {
|
---|
582 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
583 | LPRECT lprc = (LPRECT)lParam;
|
---|
584 |
|
---|
585 | if (lprc == NULL)
|
---|
586 | return 0;
|
---|
587 |
|
---|
588 | lprc->left = infoPtr->rcChannel.left;
|
---|
589 | lprc->right = infoPtr->rcChannel.right;
|
---|
590 | lprc->bottom = infoPtr->rcChannel.bottom;
|
---|
591 | lprc->top = infoPtr->rcChannel.top;
|
---|
592 |
|
---|
593 | return 0;
|
---|
594 | }
|
---|
595 |
|
---|
596 |
|
---|
597 | static LRESULT
|
---|
598 | TRACKBAR_GetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
599 | {
|
---|
600 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
601 |
|
---|
602 | return infoPtr->nLineSize;
|
---|
603 | }
|
---|
604 |
|
---|
605 |
|
---|
606 | static LRESULT
|
---|
607 | TRACKBAR_GetNumTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
608 | {
|
---|
609 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
610 |
|
---|
611 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_NOTICKS)
|
---|
612 | return 0;
|
---|
613 |
|
---|
614 | return infoPtr->uNumTics+2;
|
---|
615 | }
|
---|
616 |
|
---|
617 |
|
---|
618 | static LRESULT
|
---|
619 | TRACKBAR_GetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
620 | {
|
---|
621 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
622 |
|
---|
623 | return infoPtr->nPageSize;
|
---|
624 | }
|
---|
625 |
|
---|
626 |
|
---|
627 | static LRESULT
|
---|
628 | TRACKBAR_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
629 | {
|
---|
630 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
631 |
|
---|
632 | return infoPtr->nPos;
|
---|
633 | }
|
---|
634 |
|
---|
635 |
|
---|
636 | static LRESULT
|
---|
637 | TRACKBAR_GetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
638 | {
|
---|
639 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
640 |
|
---|
641 | return infoPtr->nRangeMax;
|
---|
642 | }
|
---|
643 |
|
---|
644 |
|
---|
645 | static LRESULT
|
---|
646 | TRACKBAR_GetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
647 | {
|
---|
648 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
649 |
|
---|
650 | return infoPtr->nRangeMin;
|
---|
651 | }
|
---|
652 |
|
---|
653 |
|
---|
654 | static LRESULT
|
---|
655 | TRACKBAR_GetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
656 | {
|
---|
657 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
658 |
|
---|
659 | return infoPtr->nSelMax;
|
---|
660 | }
|
---|
661 |
|
---|
662 |
|
---|
663 | static LRESULT
|
---|
664 | TRACKBAR_GetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
665 | {
|
---|
666 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
667 |
|
---|
668 | return infoPtr->nSelMin;
|
---|
669 | }
|
---|
670 |
|
---|
671 |
|
---|
672 | static LRESULT
|
---|
673 | TRACKBAR_GetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
674 | {
|
---|
675 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
676 |
|
---|
677 | return infoPtr->uThumbLen;
|
---|
678 | }
|
---|
679 |
|
---|
680 | static LRESULT
|
---|
681 | TRACKBAR_GetPTics (HWND hwnd)
|
---|
682 | {
|
---|
683 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
684 |
|
---|
685 | return (LRESULT) infoPtr->tics;
|
---|
686 | }
|
---|
687 |
|
---|
688 | static LRESULT
|
---|
689 | TRACKBAR_GetThumbRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
690 | {
|
---|
691 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
692 | LPRECT lprc = (LPRECT)lParam;
|
---|
693 |
|
---|
694 | if (lprc == NULL)
|
---|
695 | return 0;
|
---|
696 |
|
---|
697 | lprc->left = infoPtr->rcThumb.left;
|
---|
698 | lprc->right = infoPtr->rcThumb.right;
|
---|
699 | lprc->bottom = infoPtr->rcThumb.bottom;
|
---|
700 | lprc->top = infoPtr->rcThumb.top;
|
---|
701 |
|
---|
702 | return 0;
|
---|
703 | }
|
---|
704 |
|
---|
705 |
|
---|
706 | static LRESULT
|
---|
707 | TRACKBAR_GetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
708 | {
|
---|
709 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
710 | INT iTic;
|
---|
711 |
|
---|
712 | iTic=(INT) wParam;
|
---|
713 | if ((iTic<0) || (iTic>infoPtr->uNumTics))
|
---|
714 | return -1;
|
---|
715 |
|
---|
716 | return (LRESULT) infoPtr->tics[iTic];
|
---|
717 |
|
---|
718 | }
|
---|
719 |
|
---|
720 |
|
---|
721 | static LRESULT
|
---|
722 | TRACKBAR_GetTicPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
723 | {
|
---|
724 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
725 | INT iTic, range, width, pos;
|
---|
726 |
|
---|
727 |
|
---|
728 | iTic=(INT ) wParam;
|
---|
729 | if ((iTic<0) || (iTic>infoPtr->uNumTics))
|
---|
730 | return -1;
|
---|
731 |
|
---|
732 | range=infoPtr->nRangeMax - infoPtr->nRangeMin;
|
---|
733 | width=infoPtr->rcChannel.right - infoPtr->rcChannel.left;
|
---|
734 | pos=infoPtr->rcChannel.left + (width * infoPtr->tics[iTic]) / range;
|
---|
735 |
|
---|
736 |
|
---|
737 | return (LRESULT) pos;
|
---|
738 | }
|
---|
739 |
|
---|
740 |
|
---|
741 | static LRESULT
|
---|
742 | TRACKBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
743 | {
|
---|
744 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
745 |
|
---|
746 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS)
|
---|
747 | return (LRESULT)infoPtr->hwndToolTip;
|
---|
748 | return 0;
|
---|
749 | }
|
---|
750 |
|
---|
751 |
|
---|
752 | /* case TBM_GETUNICODEFORMAT: */
|
---|
753 |
|
---|
754 |
|
---|
755 | static LRESULT
|
---|
756 | TRACKBAR_SetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
757 | {
|
---|
758 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
759 | HWND hwndTemp;
|
---|
760 |
|
---|
761 | if (wParam) {
|
---|
762 | /* buddy is left or above */
|
---|
763 | hwndTemp = infoPtr->hwndBuddyLA;
|
---|
764 | infoPtr->hwndBuddyLA = (HWND)lParam;
|
---|
765 |
|
---|
766 | // FIXME (trackbar, "move buddy!\n");
|
---|
767 | }
|
---|
768 | else {
|
---|
769 | /* buddy is right or below */
|
---|
770 | hwndTemp = infoPtr->hwndBuddyRB;
|
---|
771 | infoPtr->hwndBuddyRB = (HWND)lParam;
|
---|
772 |
|
---|
773 | // FIXME (trackbar, "move buddy!\n");
|
---|
774 | }
|
---|
775 |
|
---|
776 | TRACKBAR_AlignBuddies (hwnd, infoPtr);
|
---|
777 |
|
---|
778 | return (LRESULT)hwndTemp;
|
---|
779 | }
|
---|
780 |
|
---|
781 |
|
---|
782 | static LRESULT
|
---|
783 | TRACKBAR_SetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
784 | {
|
---|
785 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
786 | INT nTemp = infoPtr->nLineSize;
|
---|
787 |
|
---|
788 | infoPtr->nLineSize = (INT)lParam;
|
---|
789 |
|
---|
790 | return nTemp;
|
---|
791 | }
|
---|
792 |
|
---|
793 |
|
---|
794 | static LRESULT
|
---|
795 | TRACKBAR_SetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
796 | {
|
---|
797 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
798 | INT nTemp = infoPtr->nPageSize;
|
---|
799 |
|
---|
800 | infoPtr->nPageSize = (INT)lParam;
|
---|
801 |
|
---|
802 | return nTemp;
|
---|
803 | }
|
---|
804 |
|
---|
805 |
|
---|
806 | static LRESULT
|
---|
807 | TRACKBAR_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
808 | {
|
---|
809 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
810 |
|
---|
811 | infoPtr->nPos = (INT)LOWORD(lParam);
|
---|
812 |
|
---|
813 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
---|
814 | infoPtr->nPos = infoPtr->nRangeMin;
|
---|
815 |
|
---|
816 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
---|
817 | infoPtr->nPos = infoPtr->nRangeMax;
|
---|
818 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
---|
819 |
|
---|
820 | if (wParam)
|
---|
821 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
822 |
|
---|
823 | return 0;
|
---|
824 | }
|
---|
825 |
|
---|
826 |
|
---|
827 | static LRESULT
|
---|
828 | TRACKBAR_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
829 | {
|
---|
830 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
831 | infoPtr->nRangeMin = (INT)LOWORD(lParam);
|
---|
832 | infoPtr->nRangeMax = (INT)HIWORD(lParam);
|
---|
833 |
|
---|
834 | if (infoPtr->nPos < infoPtr->nRangeMin) {
|
---|
835 | infoPtr->nPos = infoPtr->nRangeMin;
|
---|
836 | infoPtr->flags |=TB_THUMBPOSCHANGED;
|
---|
837 | }
|
---|
838 |
|
---|
839 | if (infoPtr->nPos > infoPtr->nRangeMax) {
|
---|
840 | infoPtr->nPos = infoPtr->nRangeMax;
|
---|
841 | infoPtr->flags |=TB_THUMBPOSCHANGED;
|
---|
842 | }
|
---|
843 |
|
---|
844 | infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
|
---|
845 | if (infoPtr->nPageSize == 0)
|
---|
846 | infoPtr->nPageSize = 1;
|
---|
847 | TRACKBAR_RecalculateTics (infoPtr);
|
---|
848 |
|
---|
849 | if (wParam)
|
---|
850 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
851 |
|
---|
852 | return 0;
|
---|
853 | }
|
---|
854 |
|
---|
855 |
|
---|
856 | static LRESULT
|
---|
857 | TRACKBAR_SetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
858 | {
|
---|
859 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
860 |
|
---|
861 | infoPtr->nRangeMax = (INT)lParam;
|
---|
862 | if (infoPtr->nPos > infoPtr->nRangeMax) {
|
---|
863 | infoPtr->nPos = infoPtr->nRangeMax;
|
---|
864 | infoPtr->flags |=TB_THUMBPOSCHANGED;
|
---|
865 | }
|
---|
866 |
|
---|
867 | infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
|
---|
868 | if (infoPtr->nPageSize == 0)
|
---|
869 | infoPtr->nPageSize = 1;
|
---|
870 | TRACKBAR_RecalculateTics (infoPtr);
|
---|
871 |
|
---|
872 | if (wParam)
|
---|
873 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
874 |
|
---|
875 | return 0;
|
---|
876 | }
|
---|
877 |
|
---|
878 |
|
---|
879 | static LRESULT
|
---|
880 | TRACKBAR_SetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
881 | {
|
---|
882 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
883 |
|
---|
884 | infoPtr->nRangeMin = (INT)lParam;
|
---|
885 | if (infoPtr->nPos < infoPtr->nRangeMin) {
|
---|
886 | infoPtr->nPos = infoPtr->nRangeMin;
|
---|
887 | infoPtr->flags |=TB_THUMBPOSCHANGED;
|
---|
888 | }
|
---|
889 |
|
---|
890 | infoPtr->nPageSize=(infoPtr->nRangeMax - infoPtr->nRangeMin)/5;
|
---|
891 | if (infoPtr->nPageSize == 0)
|
---|
892 | infoPtr->nPageSize = 1;
|
---|
893 | TRACKBAR_RecalculateTics (infoPtr);
|
---|
894 |
|
---|
895 | if (wParam)
|
---|
896 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
897 |
|
---|
898 | return 0;
|
---|
899 | }
|
---|
900 |
|
---|
901 |
|
---|
902 | static LRESULT
|
---|
903 | TRACKBAR_SetTicFreq (HWND hwnd, WPARAM wParam)
|
---|
904 | {
|
---|
905 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
906 |
|
---|
907 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_AUTOTICKS)
|
---|
908 | infoPtr->uTicFreq=(UINT) wParam;
|
---|
909 |
|
---|
910 | TRACKBAR_RecalculateTics (infoPtr);
|
---|
911 |
|
---|
912 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
913 |
|
---|
914 | return 0;
|
---|
915 | }
|
---|
916 |
|
---|
917 |
|
---|
918 | static LRESULT
|
---|
919 | TRACKBAR_SetSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
920 | {
|
---|
921 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
922 |
|
---|
923 | infoPtr->nSelMin = (INT)LOWORD(lParam);
|
---|
924 | infoPtr->nSelMax = (INT)HIWORD(lParam);
|
---|
925 | infoPtr->flags |=TB_SELECTIONCHANGED;
|
---|
926 |
|
---|
927 | if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
|
---|
928 | return 0;
|
---|
929 |
|
---|
930 | if (infoPtr->nSelMin < infoPtr->nRangeMin)
|
---|
931 | infoPtr->nSelMin = infoPtr->nRangeMin;
|
---|
932 | if (infoPtr->nSelMax > infoPtr->nRangeMax)
|
---|
933 | infoPtr->nSelMax = infoPtr->nRangeMax;
|
---|
934 |
|
---|
935 | if (wParam)
|
---|
936 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
937 |
|
---|
938 |
|
---|
939 | return 0;
|
---|
940 | }
|
---|
941 |
|
---|
942 |
|
---|
943 | static LRESULT
|
---|
944 | TRACKBAR_SetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
945 | {
|
---|
946 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
947 |
|
---|
948 | if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
|
---|
949 | return 0;
|
---|
950 |
|
---|
951 | infoPtr->nSelMax = (INT)lParam;
|
---|
952 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
---|
953 |
|
---|
954 | if (infoPtr->nSelMax > infoPtr->nRangeMax)
|
---|
955 | infoPtr->nSelMax = infoPtr->nRangeMax;
|
---|
956 |
|
---|
957 | if (wParam)
|
---|
958 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
959 |
|
---|
960 | return 0;
|
---|
961 | }
|
---|
962 |
|
---|
963 |
|
---|
964 | static LRESULT
|
---|
965 | TRACKBAR_SetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
966 | {
|
---|
967 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
968 |
|
---|
969 | if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
|
---|
970 | return 0;
|
---|
971 |
|
---|
972 | infoPtr->nSelMin = (INT)lParam;
|
---|
973 | infoPtr->flags |=TB_SELECTIONCHANGED;
|
---|
974 |
|
---|
975 | if (infoPtr->nSelMin < infoPtr->nRangeMin)
|
---|
976 | infoPtr->nSelMin = infoPtr->nRangeMin;
|
---|
977 |
|
---|
978 | if (wParam)
|
---|
979 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
980 |
|
---|
981 | return 0;
|
---|
982 | }
|
---|
983 |
|
---|
984 |
|
---|
985 | static LRESULT
|
---|
986 | TRACKBAR_SetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
987 | {
|
---|
988 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
989 |
|
---|
990 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_FIXEDLENGTH)
|
---|
991 | infoPtr->uThumbLen = (UINT)wParam;
|
---|
992 |
|
---|
993 | infoPtr->flags |= TB_THUMBSIZECHANGED;
|
---|
994 |
|
---|
995 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
996 |
|
---|
997 | return 0;
|
---|
998 | }
|
---|
999 |
|
---|
1000 |
|
---|
1001 | static LRESULT
|
---|
1002 | TRACKBAR_SetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1003 | {
|
---|
1004 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1005 | INT nPos = (INT)lParam;
|
---|
1006 |
|
---|
1007 | if ((nPos < infoPtr->nRangeMin) || (nPos> infoPtr->nRangeMax))
|
---|
1008 | return FALSE;
|
---|
1009 |
|
---|
1010 | infoPtr->uNumTics++;
|
---|
1011 | infoPtr->tics=COMCTL32_ReAlloc( infoPtr->tics,
|
---|
1012 | (infoPtr->uNumTics)*sizeof (DWORD));
|
---|
1013 | infoPtr->tics[infoPtr->uNumTics-1]=nPos;
|
---|
1014 |
|
---|
1015 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1016 |
|
---|
1017 | return TRUE;
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 |
|
---|
1021 | static LRESULT
|
---|
1022 | TRACKBAR_SetTipSide (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1023 | {
|
---|
1024 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1025 | INT fTemp = infoPtr->fLocation;
|
---|
1026 |
|
---|
1027 | infoPtr->fLocation = (INT)wParam;
|
---|
1028 |
|
---|
1029 | return fTemp;
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 |
|
---|
1033 | static LRESULT
|
---|
1034 | TRACKBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1035 | {
|
---|
1036 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1037 |
|
---|
1038 | infoPtr->hwndToolTip = (HWND)wParam;
|
---|
1039 |
|
---|
1040 | return 0;
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 |
|
---|
1044 | /* case TBM_SETUNICODEFORMAT: */
|
---|
1045 |
|
---|
1046 |
|
---|
1047 | static LRESULT
|
---|
1048 | TRACKBAR_InitializeThumb (HWND hwnd)
|
---|
1049 | {
|
---|
1050 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1051 |
|
---|
1052 | infoPtr->uThumbLen = 23; /* initial thumb length */
|
---|
1053 |
|
---|
1054 | TRACKBAR_CalcChannel (hwnd,infoPtr);
|
---|
1055 | TRACKBAR_CalcThumb (hwnd, infoPtr);
|
---|
1056 | infoPtr->flags &= ~TB_SELECTIONCHANGED;
|
---|
1057 |
|
---|
1058 | return 0;
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 |
|
---|
1062 | static LRESULT
|
---|
1063 | TRACKBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1064 | {
|
---|
1065 | TRACKBAR_INFO *infoPtr;
|
---|
1066 |
|
---|
1067 | infoPtr = (TRACKBAR_INFO *)COMCTL32_Alloc (sizeof(TRACKBAR_INFO));
|
---|
1068 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
1069 |
|
---|
1070 | /* set default values */
|
---|
1071 | infoPtr->nRangeMin = 0;
|
---|
1072 | infoPtr->nRangeMax = 100;
|
---|
1073 | infoPtr->nLineSize = 1;
|
---|
1074 | infoPtr->nPageSize = 20;
|
---|
1075 | infoPtr->nSelMin = 0;
|
---|
1076 | infoPtr->nSelMax = 0;
|
---|
1077 | infoPtr->nPos = 0;
|
---|
1078 |
|
---|
1079 | infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
|
---|
1080 | infoPtr->uTicFreq = 1;
|
---|
1081 | infoPtr->tics = NULL;
|
---|
1082 | infoPtr->clrBk = GetSysColor (COLOR_BACKGROUND);
|
---|
1083 | infoPtr->hwndNotify = GetParent (hwnd);
|
---|
1084 |
|
---|
1085 | TRACKBAR_InitializeThumb (hwnd);
|
---|
1086 |
|
---|
1087 | /* Create tooltip control */
|
---|
1088 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) {
|
---|
1089 | TTTOOLINFOA ti;
|
---|
1090 |
|
---|
1091 | infoPtr->hwndToolTip =
|
---|
1092 | CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
|
---|
1093 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
1094 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
1095 | hwnd, 0, 0, 0);
|
---|
1096 |
|
---|
1097 | /* Send NM_TOOLTIPSCREATED notification */
|
---|
1098 | if (infoPtr->hwndToolTip) {
|
---|
1099 | NMTOOLTIPSCREATED nmttc;
|
---|
1100 |
|
---|
1101 | nmttc.hdr.hwndFrom = hwnd;
|
---|
1102 | nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
|
---|
1103 | nmttc.hdr.code = NM_TOOLTIPSCREATED;
|
---|
1104 | nmttc.hwndToolTips = infoPtr->hwndToolTip;
|
---|
1105 |
|
---|
1106 | SendMessageA (GetParent (hwnd), WM_NOTIFY,
|
---|
1107 | (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | ZeroMemory (&ti, sizeof(TTTOOLINFOA));
|
---|
1111 | ti.cbSize = sizeof(TTTOOLINFOA);
|
---|
1112 | ti.uFlags = TTF_IDISHWND | TTF_TRACK;
|
---|
1113 | ti.hwnd = hwnd;
|
---|
1114 | ti.uId = 0;
|
---|
1115 | ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK */
|
---|
1116 | SetRectEmpty (&ti.rect);
|
---|
1117 |
|
---|
1118 | SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | return 0;
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 |
|
---|
1125 | static LRESULT
|
---|
1126 | TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1127 | {
|
---|
1128 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1129 |
|
---|
1130 | /* delete tooltip control */
|
---|
1131 | if (infoPtr->hwndToolTip)
|
---|
1132 | DestroyWindow (infoPtr->hwndToolTip);
|
---|
1133 |
|
---|
1134 | COMCTL32_Free (infoPtr);
|
---|
1135 | return 0;
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 |
|
---|
1139 | static LRESULT
|
---|
1140 | TRACKBAR_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1141 | {
|
---|
1142 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1143 |
|
---|
1144 | // TRACE (trackbar,"\n");
|
---|
1145 |
|
---|
1146 | infoPtr->bFocus = FALSE;
|
---|
1147 | infoPtr->flags &= ~TB_DRAG_MODE;
|
---|
1148 |
|
---|
1149 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1150 |
|
---|
1151 | return 0;
|
---|
1152 | }
|
---|
1153 |
|
---|
1154 |
|
---|
1155 | static LRESULT
|
---|
1156 | TRACKBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1157 | {
|
---|
1158 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1159 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1160 | int clickPlace,prevPos,vertical;
|
---|
1161 | DOUBLE clickPos;
|
---|
1162 |
|
---|
1163 | SetFocus (hwnd);
|
---|
1164 |
|
---|
1165 | vertical = dwStyle & TBS_VERT;
|
---|
1166 | if (vertical)
|
---|
1167 | clickPlace=(INT)HIWORD(lParam);
|
---|
1168 | else
|
---|
1169 | clickPlace=(INT)LOWORD(lParam);
|
---|
1170 |
|
---|
1171 | if ((vertical &&
|
---|
1172 | (clickPlace>infoPtr->rcThumb.top) &&
|
---|
1173 | (clickPlace<infoPtr->rcThumb.bottom)) ||
|
---|
1174 | (!vertical &&
|
---|
1175 | (clickPlace>infoPtr->rcThumb.left) &&
|
---|
1176 | (clickPlace<infoPtr->rcThumb.right))) {
|
---|
1177 | infoPtr->flags |= TB_DRAG_MODE;
|
---|
1178 | if (dwStyle & TBS_TOOLTIPS) { /* enable tooltip */
|
---|
1179 | TTTOOLINFOA ti;
|
---|
1180 | POINT pt;
|
---|
1181 |
|
---|
1182 | GetCursorPos (&pt);
|
---|
1183 | SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 0,
|
---|
1184 | (LPARAM)MAKELPARAM(pt.x, pt.y));
|
---|
1185 |
|
---|
1186 | ti.cbSize = sizeof(TTTOOLINFOA);
|
---|
1187 | ti.uId = 0;
|
---|
1188 | ti.hwnd = (UINT)hwnd;
|
---|
1189 |
|
---|
1190 | infoPtr->flags |= TB_SHOW_TOOLTIP;
|
---|
1191 | SetCapture (hwnd);
|
---|
1192 | SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
|
---|
1193 | (WPARAM)TRUE, (LPARAM)&ti);
|
---|
1194 | }
|
---|
1195 | return 0;
|
---|
1196 | }
|
---|
1197 |
|
---|
1198 | clickPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace, vertical);
|
---|
1199 | prevPos = infoPtr->nPos;
|
---|
1200 |
|
---|
1201 | if (clickPos > prevPos) { /* similar to VK_NEXT */
|
---|
1202 | infoPtr->nPos += infoPtr->nPageSize;
|
---|
1203 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
---|
1204 | infoPtr->nPos = infoPtr->nRangeMax;
|
---|
1205 | TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
|
---|
1206 | } else {
|
---|
1207 | infoPtr->nPos -= infoPtr->nPageSize; /* similar to VK_PRIOR */
|
---|
1208 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
---|
1209 | infoPtr->nPos = infoPtr->nRangeMin;
|
---|
1210 | TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
|
---|
1211 | }
|
---|
1212 |
|
---|
1213 | if (prevPos!=infoPtr->nPos) {
|
---|
1214 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
---|
1215 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1216 | }
|
---|
1217 |
|
---|
1218 | return 0;
|
---|
1219 | }
|
---|
1220 |
|
---|
1221 |
|
---|
1222 | static LRESULT
|
---|
1223 | TRACKBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1224 | {
|
---|
1225 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1226 |
|
---|
1227 | TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
|
---|
1228 |
|
---|
1229 | if (infoPtr->flags & TB_DRAG_MODE)
|
---|
1230 | {
|
---|
1231 | infoPtr->flags &= ~TB_DRAG_MODE;
|
---|
1232 | ReleaseCapture ();
|
---|
1233 | }
|
---|
1234 |
|
---|
1235 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) { /* disable tooltip */
|
---|
1236 | TTTOOLINFOA ti;
|
---|
1237 |
|
---|
1238 | ti.cbSize = sizeof(TTTOOLINFOA);
|
---|
1239 | ti.uId = 0;
|
---|
1240 | ti.hwnd = (UINT)hwnd;
|
---|
1241 |
|
---|
1242 | infoPtr->flags &= ~TB_SHOW_TOOLTIP;
|
---|
1243 | SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE,
|
---|
1244 | (WPARAM)FALSE, (LPARAM)&ti);
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1248 |
|
---|
1249 | return 0;
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 |
|
---|
1253 | static LRESULT
|
---|
1254 | TRACKBAR_CaptureChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1255 | {
|
---|
1256 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1257 |
|
---|
1258 | if (infoPtr->flags & TB_DRAGPOSVALID) {
|
---|
1259 | infoPtr->nPos=infoPtr->dragPos;
|
---|
1260 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1261 | }
|
---|
1262 |
|
---|
1263 | infoPtr->flags &= ~ TB_DRAGPOSVALID;
|
---|
1264 |
|
---|
1265 | TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
|
---|
1266 | return 0;
|
---|
1267 | }
|
---|
1268 |
|
---|
1269 |
|
---|
1270 | static LRESULT
|
---|
1271 | TRACKBAR_Paint (HWND hwnd, WPARAM wParam)
|
---|
1272 | {
|
---|
1273 | HDC hdc;
|
---|
1274 | PAINTSTRUCT ps;
|
---|
1275 |
|
---|
1276 | hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
|
---|
1277 | TRACKBAR_Refresh (hwnd, hdc);
|
---|
1278 | if(!wParam)
|
---|
1279 | EndPaint (hwnd, &ps);
|
---|
1280 | return 0;
|
---|
1281 | }
|
---|
1282 |
|
---|
1283 |
|
---|
1284 | static LRESULT
|
---|
1285 | TRACKBAR_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1286 | {
|
---|
1287 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1288 |
|
---|
1289 | // TRACE (trackbar,"\n");
|
---|
1290 | infoPtr->bFocus = TRUE;
|
---|
1291 |
|
---|
1292 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1293 |
|
---|
1294 | return 0;
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 |
|
---|
1298 | static LRESULT
|
---|
1299 | TRACKBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1300 | {
|
---|
1301 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1302 |
|
---|
1303 | TRACKBAR_CalcChannel (hwnd, infoPtr);
|
---|
1304 | TRACKBAR_AlignBuddies (hwnd, infoPtr);
|
---|
1305 |
|
---|
1306 | return 0;
|
---|
1307 | }
|
---|
1308 |
|
---|
1309 |
|
---|
1310 | static BOOL
|
---|
1311 | TRACKBAR_SendNotify (HWND hwnd, UINT code)
|
---|
1312 | {
|
---|
1313 | // TRACE (trackbar, "%x\n",code);
|
---|
1314 |
|
---|
1315 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT)
|
---|
1316 | return (BOOL) SendMessageA (GetParent (hwnd),
|
---|
1317 | WM_VSCROLL, (WPARAM)code, (LPARAM)hwnd);
|
---|
1318 |
|
---|
1319 | return (BOOL) SendMessageA (GetParent (hwnd),
|
---|
1320 | WM_HSCROLL, (WPARAM)code, (LPARAM)hwnd);
|
---|
1321 | }
|
---|
1322 |
|
---|
1323 |
|
---|
1324 | static LRESULT
|
---|
1325 | TRACKBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1326 | {
|
---|
1327 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1328 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
---|
1329 | SHORT clickPlace;
|
---|
1330 | DOUBLE dragPos;
|
---|
1331 | char buf[80];
|
---|
1332 |
|
---|
1333 | // TRACE (trackbar, "%x\n",wParam);
|
---|
1334 |
|
---|
1335 | if (dwStyle & TBS_VERT)
|
---|
1336 | clickPlace=(SHORT)HIWORD(lParam);
|
---|
1337 | else
|
---|
1338 | clickPlace=(SHORT)LOWORD(lParam);
|
---|
1339 |
|
---|
1340 | if (!(infoPtr->flags & TB_DRAG_MODE))
|
---|
1341 | return TRUE;
|
---|
1342 |
|
---|
1343 | SetCapture (hwnd);
|
---|
1344 | dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace,
|
---|
1345 | dwStyle & TBS_VERT);
|
---|
1346 | if (dragPos > ((INT)dragPos) + 0.5)
|
---|
1347 | infoPtr->dragPos = dragPos + 1;
|
---|
1348 | else
|
---|
1349 | infoPtr->dragPos = dragPos;
|
---|
1350 |
|
---|
1351 | infoPtr->flags |= TB_DRAGPOSVALID;
|
---|
1352 | TRACKBAR_SendNotify (hwnd, TB_THUMBTRACK | (infoPtr->nPos>>16));
|
---|
1353 |
|
---|
1354 | if (infoPtr->flags & TB_SHOW_TOOLTIP) {
|
---|
1355 | POINT pt;
|
---|
1356 | TTTOOLINFOA ti;
|
---|
1357 |
|
---|
1358 | ti.cbSize = sizeof(TTTOOLINFOA);
|
---|
1359 | ti.hwnd = hwnd;
|
---|
1360 | ti.uId = 0;
|
---|
1361 | ti.hinst=0;
|
---|
1362 | sprintf (buf,"%d",infoPtr->nPos);
|
---|
1363 | ti.lpszText = (LPSTR) buf;
|
---|
1364 | GetCursorPos (&pt);
|
---|
1365 |
|
---|
1366 | if (dwStyle & TBS_VERT) {
|
---|
1367 | SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
|
---|
1368 | 0, (LPARAM)MAKELPARAM(pt.x+5, pt.y+15));
|
---|
1369 | } else {
|
---|
1370 | SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION,
|
---|
1371 | 0, (LPARAM)MAKELPARAM(pt.x+15, pt.y+5));
|
---|
1372 | }
|
---|
1373 | SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
|
---|
1374 | 0, (LPARAM)&ti);
|
---|
1375 | }
|
---|
1376 |
|
---|
1377 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1378 | UpdateWindow (hwnd);
|
---|
1379 |
|
---|
1380 | return TRUE;
|
---|
1381 | }
|
---|
1382 |
|
---|
1383 |
|
---|
1384 | static LRESULT
|
---|
1385 | TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
1386 | {
|
---|
1387 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
---|
1388 | INT pos;
|
---|
1389 |
|
---|
1390 | // TRACE (trackbar, "%x\n",wParam);
|
---|
1391 |
|
---|
1392 | pos=infoPtr->nPos;
|
---|
1393 | switch (wParam) {
|
---|
1394 | case VK_LEFT:
|
---|
1395 | case VK_UP:
|
---|
1396 | if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
|
---|
1397 | infoPtr->nPos -= infoPtr->nLineSize;
|
---|
1398 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
---|
1399 | infoPtr->nPos = infoPtr->nRangeMin;
|
---|
1400 | TRACKBAR_SendNotify (hwnd, TB_LINEUP);
|
---|
1401 | break;
|
---|
1402 | case VK_RIGHT:
|
---|
1403 | case VK_DOWN:
|
---|
1404 | if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
|
---|
1405 | infoPtr->nPos += infoPtr->nLineSize;
|
---|
1406 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
---|
1407 | infoPtr->nPos = infoPtr->nRangeMax;
|
---|
1408 | TRACKBAR_SendNotify (hwnd, TB_LINEDOWN);
|
---|
1409 | break;
|
---|
1410 | case VK_NEXT:
|
---|
1411 | if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
|
---|
1412 | infoPtr->nPos += infoPtr->nPageSize;
|
---|
1413 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
---|
1414 | infoPtr->nPos = infoPtr->nRangeMax;
|
---|
1415 | TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
|
---|
1416 | break;
|
---|
1417 | case VK_PRIOR:
|
---|
1418 | if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
|
---|
1419 | infoPtr->nPos -= infoPtr->nPageSize;
|
---|
1420 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
---|
1421 | infoPtr->nPos = infoPtr->nRangeMin;
|
---|
1422 | TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
|
---|
1423 | break;
|
---|
1424 | case VK_HOME:
|
---|
1425 | if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
|
---|
1426 | infoPtr->nPos = infoPtr->nRangeMin;
|
---|
1427 | TRACKBAR_SendNotify (hwnd, TB_TOP);
|
---|
1428 | break;
|
---|
1429 | case VK_END:
|
---|
1430 | if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
|
---|
1431 | infoPtr->nPos = infoPtr->nRangeMax;
|
---|
1432 | TRACKBAR_SendNotify (hwnd, TB_BOTTOM);
|
---|
1433 | break;
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | if (pos!=infoPtr->nPos) {
|
---|
1437 | infoPtr->flags |=TB_THUMBPOSCHANGED;
|
---|
1438 | InvalidateRect (hwnd, NULL, FALSE);
|
---|
1439 | }
|
---|
1440 |
|
---|
1441 | return TRUE;
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 |
|
---|
1445 | static LRESULT
|
---|
1446 | TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
|
---|
1447 | {
|
---|
1448 | switch (wParam) {
|
---|
1449 | case VK_LEFT:
|
---|
1450 | case VK_UP:
|
---|
1451 | case VK_RIGHT:
|
---|
1452 | case VK_DOWN:
|
---|
1453 | case VK_NEXT:
|
---|
1454 | case VK_PRIOR:
|
---|
1455 | case VK_HOME:
|
---|
1456 | case VK_END:
|
---|
1457 | TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
|
---|
1458 | }
|
---|
1459 | return TRUE;
|
---|
1460 | }
|
---|
1461 |
|
---|
1462 |
|
---|
1463 | LRESULT WINAPI
|
---|
1464 | TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
1465 | {
|
---|
1466 | switch (uMsg)
|
---|
1467 | {
|
---|
1468 | case TBM_CLEARSEL:
|
---|
1469 | return TRACKBAR_ClearSel (hwnd, wParam, lParam);
|
---|
1470 |
|
---|
1471 | case TBM_CLEARTICS:
|
---|
1472 | return TRACKBAR_ClearTics (hwnd, wParam, lParam);
|
---|
1473 |
|
---|
1474 | case TBM_GETBUDDY:
|
---|
1475 | return TRACKBAR_GetBuddy (hwnd, wParam, lParam);
|
---|
1476 |
|
---|
1477 | case TBM_GETCHANNELRECT:
|
---|
1478 | return TRACKBAR_GetChannelRect (hwnd, wParam, lParam);
|
---|
1479 |
|
---|
1480 | case TBM_GETLINESIZE:
|
---|
1481 | return TRACKBAR_GetLineSize (hwnd, wParam, lParam);
|
---|
1482 |
|
---|
1483 | case TBM_GETNUMTICS:
|
---|
1484 | return TRACKBAR_GetNumTics (hwnd, wParam, lParam);
|
---|
1485 |
|
---|
1486 | case TBM_GETPAGESIZE:
|
---|
1487 | return TRACKBAR_GetPageSize (hwnd, wParam, lParam);
|
---|
1488 |
|
---|
1489 | case TBM_GETPOS:
|
---|
1490 | return TRACKBAR_GetPos (hwnd, wParam, lParam);
|
---|
1491 |
|
---|
1492 | case TBM_GETPTICS:
|
---|
1493 | return TRACKBAR_GetPTics (hwnd);
|
---|
1494 |
|
---|
1495 | case TBM_GETRANGEMAX:
|
---|
1496 | return TRACKBAR_GetRangeMax (hwnd, wParam, lParam);
|
---|
1497 |
|
---|
1498 | case TBM_GETRANGEMIN:
|
---|
1499 | return TRACKBAR_GetRangeMin (hwnd, wParam, lParam);
|
---|
1500 |
|
---|
1501 | case TBM_GETSELEND:
|
---|
1502 | return TRACKBAR_GetSelEnd (hwnd, wParam, lParam);
|
---|
1503 |
|
---|
1504 | case TBM_GETSELSTART:
|
---|
1505 | return TRACKBAR_GetSelStart (hwnd, wParam, lParam);
|
---|
1506 |
|
---|
1507 | case TBM_GETTHUMBLENGTH:
|
---|
1508 | return TRACKBAR_GetThumbLength (hwnd, wParam, lParam);
|
---|
1509 |
|
---|
1510 | case TBM_GETTHUMBRECT:
|
---|
1511 | return TRACKBAR_GetThumbRect (hwnd, wParam, lParam);
|
---|
1512 |
|
---|
1513 | case TBM_GETTIC:
|
---|
1514 | return TRACKBAR_GetTic (hwnd, wParam, lParam);
|
---|
1515 |
|
---|
1516 | case TBM_GETTICPOS:
|
---|
1517 | return TRACKBAR_GetTicPos (hwnd, wParam, lParam);
|
---|
1518 |
|
---|
1519 | case TBM_GETTOOLTIPS:
|
---|
1520 | return TRACKBAR_GetToolTips (hwnd, wParam, lParam);
|
---|
1521 |
|
---|
1522 | /* case TBM_GETUNICODEFORMAT: */
|
---|
1523 |
|
---|
1524 | case TBM_SETBUDDY:
|
---|
1525 | return TRACKBAR_SetBuddy (hwnd, wParam, lParam);
|
---|
1526 |
|
---|
1527 | case TBM_SETLINESIZE:
|
---|
1528 | return TRACKBAR_SetLineSize (hwnd, wParam, lParam);
|
---|
1529 |
|
---|
1530 | case TBM_SETPAGESIZE:
|
---|
1531 | return TRACKBAR_SetPageSize (hwnd, wParam, lParam);
|
---|
1532 |
|
---|
1533 | case TBM_SETPOS:
|
---|
1534 | return TRACKBAR_SetPos (hwnd, wParam, lParam);
|
---|
1535 |
|
---|
1536 | case TBM_SETRANGE:
|
---|
1537 | return TRACKBAR_SetRange (hwnd, wParam, lParam);
|
---|
1538 |
|
---|
1539 | case TBM_SETRANGEMAX:
|
---|
1540 | return TRACKBAR_SetRangeMax (hwnd, wParam, lParam);
|
---|
1541 |
|
---|
1542 | case TBM_SETRANGEMIN:
|
---|
1543 | return TRACKBAR_SetRangeMin (hwnd, wParam, lParam);
|
---|
1544 |
|
---|
1545 | case TBM_SETSEL:
|
---|
1546 | return TRACKBAR_SetSel (hwnd, wParam, lParam);
|
---|
1547 |
|
---|
1548 | case TBM_SETSELEND:
|
---|
1549 | return TRACKBAR_SetSelEnd (hwnd, wParam, lParam);
|
---|
1550 |
|
---|
1551 | case TBM_SETSELSTART:
|
---|
1552 | return TRACKBAR_SetSelStart (hwnd, wParam, lParam);
|
---|
1553 |
|
---|
1554 | case TBM_SETTHUMBLENGTH:
|
---|
1555 | return TRACKBAR_SetThumbLength (hwnd, wParam, lParam);
|
---|
1556 |
|
---|
1557 | case TBM_SETTIC:
|
---|
1558 | return TRACKBAR_SetTic (hwnd, wParam, lParam);
|
---|
1559 |
|
---|
1560 | case TBM_SETTICFREQ:
|
---|
1561 | return TRACKBAR_SetTicFreq (hwnd, wParam);
|
---|
1562 |
|
---|
1563 | case TBM_SETTIPSIDE:
|
---|
1564 | return TRACKBAR_SetTipSide (hwnd, wParam, lParam);
|
---|
1565 |
|
---|
1566 | case TBM_SETTOOLTIPS:
|
---|
1567 | return TRACKBAR_SetToolTips (hwnd, wParam, lParam);
|
---|
1568 |
|
---|
1569 | /* case TBM_SETUNICODEFORMAT: */
|
---|
1570 |
|
---|
1571 |
|
---|
1572 | case WM_CAPTURECHANGED:
|
---|
1573 | return TRACKBAR_CaptureChanged (hwnd, wParam, lParam);
|
---|
1574 |
|
---|
1575 | case WM_CREATE:
|
---|
1576 | return TRACKBAR_Create (hwnd, wParam, lParam);
|
---|
1577 |
|
---|
1578 | case WM_DESTROY:
|
---|
1579 | return TRACKBAR_Destroy (hwnd, wParam, lParam);
|
---|
1580 |
|
---|
1581 | /* case WM_ENABLE: */
|
---|
1582 |
|
---|
1583 | /* case WM_ERASEBKGND: */
|
---|
1584 | /* return 0; */
|
---|
1585 |
|
---|
1586 | case WM_GETDLGCODE:
|
---|
1587 | return DLGC_WANTARROWS;
|
---|
1588 |
|
---|
1589 | case WM_KEYDOWN:
|
---|
1590 | return TRACKBAR_KeyDown (hwnd, wParam, lParam);
|
---|
1591 |
|
---|
1592 | case WM_KEYUP:
|
---|
1593 | return TRACKBAR_KeyUp (hwnd, wParam);
|
---|
1594 |
|
---|
1595 | case WM_KILLFOCUS:
|
---|
1596 | return TRACKBAR_KillFocus (hwnd, wParam, lParam);
|
---|
1597 |
|
---|
1598 | case WM_LBUTTONDOWN:
|
---|
1599 | return TRACKBAR_LButtonDown (hwnd, wParam, lParam);
|
---|
1600 |
|
---|
1601 | case WM_LBUTTONUP:
|
---|
1602 | return TRACKBAR_LButtonUp (hwnd, wParam, lParam);
|
---|
1603 |
|
---|
1604 | case WM_MOUSEMOVE:
|
---|
1605 | return TRACKBAR_MouseMove (hwnd, wParam, lParam);
|
---|
1606 |
|
---|
1607 | case WM_PAINT:
|
---|
1608 | return TRACKBAR_Paint (hwnd, wParam);
|
---|
1609 |
|
---|
1610 | case WM_SETFOCUS:
|
---|
1611 | return TRACKBAR_SetFocus (hwnd, wParam, lParam);
|
---|
1612 |
|
---|
1613 | case WM_SIZE:
|
---|
1614 | return TRACKBAR_Size (hwnd, wParam, lParam);
|
---|
1615 |
|
---|
1616 | case WM_WININICHANGE:
|
---|
1617 | return TRACKBAR_InitializeThumb (hwnd);
|
---|
1618 |
|
---|
1619 | default:
|
---|
1620 | if (uMsg >= WM_USER)
|
---|
1621 | // ERR (trackbar, "unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
1622 | // uMsg, wParam, lParam);
|
---|
1623 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
1624 | }
|
---|
1625 | return 0;
|
---|
1626 | }
|
---|
1627 |
|
---|
1628 |
|
---|
1629 | VOID
|
---|
1630 | TRACKBAR_Register (VOID)
|
---|
1631 | {
|
---|
1632 | WNDCLASSA wndClass;
|
---|
1633 |
|
---|
1634 | if (GlobalFindAtomA (TRACKBAR_CLASSA)) return;
|
---|
1635 |
|
---|
1636 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
1637 | wndClass.style = CS_GLOBALCLASS;
|
---|
1638 | wndClass.lpfnWndProc = (WNDPROC)TRACKBAR_WindowProc;
|
---|
1639 | wndClass.cbClsExtra = 0;
|
---|
1640 | wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
|
---|
1641 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
1642 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
---|
1643 | wndClass.lpszClassName = TRACKBAR_CLASSA;
|
---|
1644 |
|
---|
1645 | RegisterClassA (&wndClass);
|
---|
1646 | }
|
---|
1647 |
|
---|
1648 |
|
---|
1649 | VOID
|
---|
1650 | TRACKBAR_Unregister (VOID)
|
---|
1651 | {
|
---|
1652 | if (GlobalFindAtomA (TRACKBAR_CLASSA))
|
---|
1653 | UnregisterClassA (TRACKBAR_CLASSA, (HINSTANCE)NULL);
|
---|
1654 | }
|
---|
1655 |
|
---|