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