| 1 | /* $Id: trackbar.cpp,v 1.3 2000-03-18 16:17:33 cbratschi Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Trackbar control
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998, 1999 Eric Kohl <ekohl@abo.rhein-zeitung.de>
|
|---|
| 6 | * Copyright 1998,1999 Alex Priem <alexp@sci.kun.nl>
|
|---|
| 7 | * Copyright 1999 Achim Hasenmueller
|
|---|
| 8 | * Copyright 1999 Christoph Bratschi <cbratschi@datacomm.ch>
|
|---|
| 9 | *
|
|---|
| 10 | *
|
|---|
| 11 | * Status: complete
|
|---|
| 12 | * Version: 5.80
|
|---|
| 13 | *
|
|---|
| 14 | * Note: TBM_SETTHUMBLENGTH implemented, COMCTL32 5.00 ignores it
|
|---|
| 15 | * Microsoft(TM) should fix this bug :)
|
|---|
| 16 | */
|
|---|
| 17 |
|
|---|
| 18 | #include "winbase.h"
|
|---|
| 19 | #include "commctrl.h"
|
|---|
| 20 | #include "ccbase.h"
|
|---|
| 21 | #include "trackbar.h"
|
|---|
| 22 | #include <stdio.h>
|
|---|
| 23 |
|
|---|
| 24 | #define TRACKBAR_GetInfoPtr(hwnd) ((TRACKBAR_INFO*)getInfoPtr(hwnd))
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | /* Used by TRACKBAR_Draw to find out which parts of the control
|
|---|
| 28 | need to be recalculated */
|
|---|
| 29 |
|
|---|
| 30 | #define TB_THUMBPOSCHANGED 1
|
|---|
| 31 | #define TB_THUMBSIZECHANGED 2
|
|---|
| 32 | #define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBPOSCHANGED)
|
|---|
| 33 | #define TB_SELECTIONCHANGED 4
|
|---|
| 34 | #define TB_DRAG_MODE 16 /* we're dragging the slider */
|
|---|
| 35 | #define TB_DRAGPOSVALID 32 /* current Position is in dragPos */
|
|---|
| 36 | #define TB_SCROLL_MODE 64 /* WM_TIMER scroll mode */
|
|---|
| 37 | #define TB_SHOW_TOOLTIP 128 /* tooltip-style enabled and tooltip on */
|
|---|
| 38 |
|
|---|
| 39 | /* helper defines for TRACKBAR_DrawTic */
|
|---|
| 40 | #define TIC_LEFTEDGE 0x20
|
|---|
| 41 | #define TIC_RIGHTEDGE 0x40
|
|---|
| 42 | #define TIC_EDGE (TIC_LEFTEDGE | TIC_RIGHTEDGE)
|
|---|
| 43 | #define TIC_SELECTIONMARKMAX 0x80
|
|---|
| 44 | #define TIC_SELECTIONMARKMIN 0x100
|
|---|
| 45 | #define TIC_SELECTIONMARK (TIC_SELECTIONMARKMAX | TIC_SELECTIONMARKMIN)
|
|---|
| 46 |
|
|---|
| 47 | /* size calculation */
|
|---|
| 48 |
|
|---|
| 49 | #define BORDER_SIZE 2
|
|---|
| 50 |
|
|---|
| 51 | #define SCALE_SIZE 4
|
|---|
| 52 | #define SCALE_SPACE 1
|
|---|
| 53 |
|
|---|
| 54 | #define THUMB_LEN 23
|
|---|
| 55 | #define THUMB_MINLEN 4
|
|---|
| 56 |
|
|---|
| 57 | #define CHANNEL_NOSEL_HEIGHT 4 //min no sel height
|
|---|
| 58 | #define CHANNEL_MIN_HEIGHT 6 //min sel height
|
|---|
| 59 | #define CHANNEL_THUMB_DIFF 8 //sel thumb, channel difference
|
|---|
| 60 | #define CHANNEL_SPACE 8
|
|---|
| 61 | #define CHANNEL_SCALE_SPACE SCALE_SIZE+SCALE_SPACE+BORDER_SIZE
|
|---|
| 62 | #define CHANNEL_THUMB_SPACE BORDER_SIZE
|
|---|
| 63 |
|
|---|
| 64 | #define TOOLTIP_SPACE 5
|
|---|
| 65 |
|
|---|
| 66 | /* scroll mode */
|
|---|
| 67 |
|
|---|
| 68 | #define SCROLL_TIME 500 //ms
|
|---|
| 69 | #define SCROLL_TIMER_ID 1
|
|---|
| 70 |
|
|---|
| 71 | /* Tooltips */
|
|---|
| 72 |
|
|---|
| 73 | #define TOOLTIP_XSPACE 5
|
|---|
| 74 | #define TOOLTIP_YSPACE 5
|
|---|
| 75 |
|
|---|
| 76 | static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code);
|
|---|
| 77 |
|
|---|
| 78 | static void TRACKBAR_RecalculateTics (HWND hwnd,TRACKBAR_INFO *infoPtr,BOOL restoreOld)
|
|---|
| 79 | {
|
|---|
| 80 | INT i,tic,nrTics;
|
|---|
| 81 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 82 |
|
|---|
| 83 | if (dwStyle & TBS_NOTICKS) //no ticks
|
|---|
| 84 | {
|
|---|
| 85 | COMCTL32_Free(infoPtr->tics);
|
|---|
| 86 | infoPtr->tics = NULL;
|
|---|
| 87 |
|
|---|
| 88 | infoPtr->uNumTics = 0;
|
|---|
| 89 | return;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | if (restoreOld && !(dwStyle & TBS_AUTOTICKS) && infoPtr->tics != NULL)
|
|---|
| 93 | { //check old ticks
|
|---|
| 94 | LPLONG oldTics = (LONG*)COMCTL32_Alloc(infoPtr->uNumTics*sizeof(DWORD));
|
|---|
| 95 | INT count = 0;
|
|---|
| 96 |
|
|---|
| 97 | for (i = 0;i < infoPtr->uNumTics;i++)
|
|---|
| 98 | {
|
|---|
| 99 | if ((infoPtr->tics[i] >= infoPtr->nRangeMin) && (infoPtr->tics[i] <= infoPtr->nRangeMax))
|
|---|
| 100 | {
|
|---|
| 101 | oldTics[count] = infoPtr->tics[i];
|
|---|
| 102 | count++;
|
|---|
| 103 | }
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | COMCTL32_Free(infoPtr->tics);
|
|---|
| 107 | infoPtr->tics = (LONG*)COMCTL32_ReAlloc(oldTics,count*sizeof(DWORD));
|
|---|
| 108 | infoPtr->uNumTics = count;
|
|---|
| 109 |
|
|---|
| 110 | return;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | if (infoPtr->uTicFreq && (infoPtr->nRangeMax > infoPtr->nRangeMin) && (dwStyle & TBS_AUTOTICKS))
|
|---|
| 114 | {
|
|---|
| 115 | //Tics without start and end tic
|
|---|
| 116 | nrTics = (infoPtr->nRangeMax-infoPtr->nRangeMin)/infoPtr->uTicFreq-1;
|
|---|
| 117 | if (nrTics <= 0)
|
|---|
| 118 | {
|
|---|
| 119 | COMCTL32_Free(infoPtr->tics);
|
|---|
| 120 | infoPtr->tics = NULL;
|
|---|
| 121 | infoPtr->uNumTics = 0;
|
|---|
| 122 | return;
|
|---|
| 123 | }
|
|---|
| 124 | } else
|
|---|
| 125 | {
|
|---|
| 126 | COMCTL32_Free(infoPtr->tics);
|
|---|
| 127 | infoPtr->tics = NULL;
|
|---|
| 128 | infoPtr->uNumTics = 0;
|
|---|
| 129 | return;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | if (nrTics != infoPtr->uNumTics)
|
|---|
| 133 | {
|
|---|
| 134 | COMCTL32_Free(infoPtr->tics);
|
|---|
| 135 | infoPtr->tics = (LONG*)COMCTL32_Alloc(nrTics*sizeof(DWORD));
|
|---|
| 136 | infoPtr->uNumTics = nrTics;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | tic = infoPtr->nRangeMin+infoPtr->uTicFreq; //start not included
|
|---|
| 140 | for (i = 0;i < nrTics;i++)
|
|---|
| 141 | {
|
|---|
| 142 | infoPtr->tics[i] = tic;
|
|---|
| 143 | tic += infoPtr->uTicFreq;
|
|---|
| 144 | }
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 | /* converts from physical (mouse) position to logical position
|
|---|
| 149 | (in range of trackbar) */
|
|---|
| 150 |
|
|---|
| 151 | static DOUBLE
|
|---|
| 152 | TRACKBAR_ConvertPlaceToPosition(TRACKBAR_INFO *infoPtr,int place,int vertical)
|
|---|
| 153 | {
|
|---|
| 154 | double range,width,pos;
|
|---|
| 155 |
|
|---|
| 156 | range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 157 | if (vertical)
|
|---|
| 158 | {
|
|---|
| 159 | width = infoPtr->rcChannel.bottom-infoPtr->rcChannel.top;
|
|---|
| 160 | pos = infoPtr->nRangeMin+(range*(place-infoPtr->rcChannel.top))/width;
|
|---|
| 161 | } else
|
|---|
| 162 | {
|
|---|
| 163 | width = infoPtr->rcChannel.right-infoPtr->rcChannel.left;
|
|---|
| 164 | pos = infoPtr->nRangeMin+(range*(place-infoPtr->rcChannel.left))/width;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | if (pos > infoPtr->nRangeMax) pos = infoPtr->nRangeMax;
|
|---|
| 168 | else if (pos < infoPtr->nRangeMin) pos = infoPtr->nRangeMin;
|
|---|
| 169 |
|
|---|
| 170 | // TRACE (trackbar,"%.2f\n",pos);
|
|---|
| 171 | return pos;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 | static VOID
|
|---|
| 176 | TRACKBAR_CalcChannel (HWND hwnd,TRACKBAR_INFO *infoPtr)
|
|---|
| 177 | {
|
|---|
| 178 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 179 | INT channelSize;
|
|---|
| 180 | RECT lpRect,*channel = &infoPtr->rcChannel;
|
|---|
| 181 | INT thumbDiff;
|
|---|
| 182 |
|
|---|
| 183 | GetClientRect(hwnd,&lpRect);
|
|---|
| 184 |
|
|---|
| 185 | if (dwStyle & TBS_ENABLESELRANGE) channelSize = MAX(infoPtr->uThumbLen-CHANNEL_THUMB_DIFF,CHANNEL_MIN_HEIGHT);
|
|---|
| 186 | else channelSize = CHANNEL_NOSEL_HEIGHT;
|
|---|
| 187 |
|
|---|
| 188 | thumbDiff = (infoPtr->uThumbLen-channelSize)/2;
|
|---|
| 189 |
|
|---|
| 190 | if (dwStyle & TBS_VERT)
|
|---|
| 191 | {
|
|---|
| 192 | channel->top = lpRect.top+CHANNEL_SPACE;
|
|---|
| 193 | channel->bottom = lpRect.bottom-CHANNEL_SPACE;
|
|---|
| 194 |
|
|---|
| 195 | if ((dwStyle & TBS_BOTH) || (dwStyle & TBS_NOTICKS))
|
|---|
| 196 | { //center
|
|---|
| 197 | channel->left = (lpRect.right-channelSize)/2;
|
|---|
| 198 | channel->right = (lpRect.right+channelSize)/2;
|
|---|
| 199 | } else if (dwStyle & TBS_LEFT)
|
|---|
| 200 | {
|
|---|
| 201 | channel->left = lpRect.left+thumbDiff+CHANNEL_SCALE_SPACE;
|
|---|
| 202 | channel->right = channel->left+channelSize;
|
|---|
| 203 | } else
|
|---|
| 204 | { //Right, align left
|
|---|
| 205 | channel->left = lpRect.left+thumbDiff+CHANNEL_THUMB_SPACE;
|
|---|
| 206 | channel->right = channel->left+channelSize;
|
|---|
| 207 | }
|
|---|
| 208 | } else
|
|---|
| 209 | {
|
|---|
| 210 | channel->left = lpRect.left+CHANNEL_SPACE;
|
|---|
| 211 | channel->right = lpRect.right-CHANNEL_SPACE;
|
|---|
| 212 | if ((dwStyle & TBS_BOTH) || (dwStyle & TBS_NOTICKS))
|
|---|
| 213 | { //center
|
|---|
| 214 | channel->top = (lpRect.bottom-channelSize)/2;
|
|---|
| 215 | channel->bottom = (lpRect.bottom+channelSize)/2;
|
|---|
| 216 | } else if (dwStyle & TBS_TOP)
|
|---|
| 217 | {
|
|---|
| 218 | channel->top = lpRect.top+thumbDiff+CHANNEL_SCALE_SPACE;
|
|---|
| 219 | channel->bottom = channel->top+channelSize;
|
|---|
| 220 | } else
|
|---|
| 221 | { //Bottom, align top
|
|---|
| 222 | channel->top = lpRect.top+thumbDiff+CHANNEL_THUMB_SPACE;
|
|---|
| 223 | channel->bottom = channel->top+channelSize;
|
|---|
| 224 | }
|
|---|
| 225 | }
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | //Calculate thumb size
|
|---|
| 229 |
|
|---|
| 230 | static VOID
|
|---|
| 231 | TRACKBAR_CalcThumb(HWND hwnd,TRACKBAR_INFO *infoPtr)
|
|---|
| 232 | {
|
|---|
| 233 | RECT *thumb;
|
|---|
| 234 | RECT *fullThumb;
|
|---|
| 235 | int range, width;
|
|---|
| 236 | int x,y;
|
|---|
| 237 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 238 | int thumbFactor = 2;
|
|---|
| 239 |
|
|---|
| 240 | thumb = &infoPtr->rcThumb;
|
|---|
| 241 | fullThumb = &infoPtr->rcFullThumb;
|
|---|
| 242 | range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 243 | if (dwStyle & TBS_VERT)
|
|---|
| 244 | {
|
|---|
| 245 | width = infoPtr->rcChannel.bottom-infoPtr->rcChannel.top;
|
|---|
| 246 | y = infoPtr->uThumbLen/thumbFactor; //thumb height
|
|---|
| 247 | if (y%2 == 1) y++; //for real arrow
|
|---|
| 248 | thumb->top = infoPtr->rcChannel.top+(width*(infoPtr->nPos-infoPtr->nRangeMin))/range-y/2; //centered
|
|---|
| 249 | thumb->bottom = thumb->top+y;
|
|---|
| 250 | //centered, no arrows
|
|---|
| 251 | thumb->left = infoPtr->rcChannel.left-(infoPtr->uThumbLen-(infoPtr->rcChannel.right-infoPtr->rcChannel.left))/2;
|
|---|
| 252 | thumb->right = thumb->left+infoPtr->uThumbLen;
|
|---|
| 253 | CopyRect(fullThumb,thumb);
|
|---|
| 254 | if (dwStyle & TBS_BOTH) return;
|
|---|
| 255 | x = y/2; //arrow width
|
|---|
| 256 | if (dwStyle & TBS_LEFT) thumb->left += x; else thumb->right -= x;
|
|---|
| 257 | } else
|
|---|
| 258 | {
|
|---|
| 259 | width = infoPtr->rcChannel.right-infoPtr->rcChannel.left;
|
|---|
| 260 | x = infoPtr->uThumbLen/thumbFactor; //thumb width
|
|---|
| 261 | if (x%2 == 1) x++; //for real arrow
|
|---|
| 262 | thumb->left = infoPtr->rcChannel.left+(width*(infoPtr->nPos-infoPtr->nRangeMin))/range-x/2; //centered
|
|---|
| 263 | thumb->right = thumb->left+x;
|
|---|
| 264 | //centered, no arrows
|
|---|
| 265 | thumb->top = infoPtr->rcChannel.top-(infoPtr->uThumbLen-(infoPtr->rcChannel.bottom-infoPtr->rcChannel.top))/2;
|
|---|
| 266 | thumb->bottom = thumb->top+infoPtr->uThumbLen;
|
|---|
| 267 | CopyRect(fullThumb,thumb);
|
|---|
| 268 | if (dwStyle & TBS_BOTH) return;
|
|---|
| 269 | y = x/2; //arrow height
|
|---|
| 270 | if (dwStyle & TBS_TOP) thumb->top += y; else thumb->bottom -= y;
|
|---|
| 271 | }
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | static VOID
|
|---|
| 275 | TRACKBAR_CalcSelection (HWND hwnd, TRACKBAR_INFO *infoPtr)
|
|---|
| 276 | {
|
|---|
| 277 | RECT *selection;
|
|---|
| 278 | int range,width,height;
|
|---|
| 279 | int selMin = infoPtr->nSelMin-infoPtr->nRangeMin; //relative to nRangeMin
|
|---|
| 280 | int selMax = infoPtr->nSelMax-infoPtr->nRangeMin; //dito
|
|---|
| 281 |
|
|---|
| 282 | selection = &infoPtr->rcSelection;
|
|---|
| 283 | range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 284 |
|
|---|
| 285 | if ((range <= 0) || (selMin == selMax)) SetRectEmpty(selection);
|
|---|
| 286 | else
|
|---|
| 287 | if (!(GetWindowLongA(hwnd, GWL_STYLE) & TBS_VERT))
|
|---|
| 288 | { //Horizontal
|
|---|
| 289 | width = infoPtr->rcChannel.right-infoPtr->rcChannel.left;
|
|---|
| 290 | selection->left = infoPtr->rcChannel.left+(width*selMin)/range;
|
|---|
| 291 | selection->right = infoPtr->rcChannel.left+(width*selMax)/range;
|
|---|
| 292 | selection->top = infoPtr->rcChannel.top+2;
|
|---|
| 293 | selection->bottom = infoPtr->rcChannel.bottom-2;
|
|---|
| 294 | } else
|
|---|
| 295 | { //Vertical
|
|---|
| 296 | height = infoPtr->rcChannel.bottom-infoPtr->rcChannel.top;
|
|---|
| 297 | selection->top = infoPtr->rcChannel.top+(height*selMin)/range;
|
|---|
| 298 | selection->bottom = infoPtr->rcChannel.top+(height*selMax)/range;
|
|---|
| 299 | selection->left = infoPtr->rcChannel.left+2;
|
|---|
| 300 | selection->right = infoPtr->rcChannel.right-2;
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | /* Trackbar drawing code */
|
|---|
| 305 |
|
|---|
| 306 | /* ticPos is in tic-units, not in pixels */
|
|---|
| 307 |
|
|---|
| 308 | static VOID
|
|---|
| 309 | TRACKBAR_DrawHorizTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
|
|---|
| 310 | int flags, COLORREF clrTic)
|
|---|
| 311 | {
|
|---|
| 312 | RECT rcChannel = infoPtr->rcChannel;
|
|---|
| 313 | int x,y,width,range,side;
|
|---|
| 314 |
|
|---|
| 315 | range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 316 | width = rcChannel.right-rcChannel.left;
|
|---|
| 317 |
|
|---|
| 318 | if (flags & TBS_TOP)
|
|---|
| 319 | {
|
|---|
| 320 | y = infoPtr->rcFullThumb.top-SCALE_SPACE-1;
|
|---|
| 321 | side = -1;
|
|---|
| 322 | } else
|
|---|
| 323 | {
|
|---|
| 324 | y = infoPtr->rcFullThumb.bottom+SCALE_SPACE+1;
|
|---|
| 325 | side = 1;
|
|---|
| 326 | }
|
|---|
| 327 | if (flags & TIC_SELECTIONMARK)
|
|---|
| 328 | {
|
|---|
| 329 | ticPos -= infoPtr->nRangeMin; //relative to nRangeMin
|
|---|
| 330 | if (flags & TIC_SELECTIONMARKMIN) x = rcChannel.left+(width*ticPos)/range - 1;
|
|---|
| 331 | else x = rcChannel.left+(width*ticPos)/range+1;
|
|---|
| 332 |
|
|---|
| 333 | //first line
|
|---|
| 334 | SetPixel(hdc,x,y+1*side,clrTic);
|
|---|
| 335 | SetPixel(hdc,x,y+2*side,clrTic);
|
|---|
| 336 | //point
|
|---|
| 337 | if (flags & TIC_SELECTIONMARKMIN) x--; else x++;
|
|---|
| 338 | SetPixel(hdc,x,y+2*side,clrTic);
|
|---|
| 339 |
|
|---|
| 340 | return;
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | if ((ticPos > infoPtr->nRangeMin) && (ticPos < infoPtr->nRangeMax))
|
|---|
| 344 | {
|
|---|
| 345 | ticPos -= infoPtr->nRangeMin; //relative to nRangeMin
|
|---|
| 346 | x = rcChannel.left+(width*ticPos)/range;
|
|---|
| 347 | SetPixel(hdc,x,y,clrTic); //base
|
|---|
| 348 | SetPixel(hdc,x,y+1*side,clrTic);
|
|---|
| 349 | SetPixel(hdc,x,y+2*side,clrTic);
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | if (flags & TIC_EDGE)
|
|---|
| 353 | {
|
|---|
| 354 | if (flags & TIC_LEFTEDGE) x = rcChannel.left;
|
|---|
| 355 | else x = rcChannel.right;
|
|---|
| 356 |
|
|---|
| 357 | SetPixel(hdc,x,y,clrTic); //base
|
|---|
| 358 | SetPixel(hdc,x,y+1*side,clrTic);
|
|---|
| 359 | SetPixel(hdc,x,y+2*side,clrTic);
|
|---|
| 360 | SetPixel(hdc,x,y+3*side,clrTic);
|
|---|
| 361 | }
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | static VOID TRACKBAR_FillHorzTics(TRACKBAR_INFO *infoPtr,HDC hdc,int flags,COLORREF clrTic)
|
|---|
| 365 | {
|
|---|
| 366 | RECT rect;
|
|---|
| 367 | INT range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 368 | INT width = infoPtr->rcChannel.right-infoPtr->rcChannel.left;
|
|---|
| 369 | HBRUSH hbr = CreateSolidBrush(clrTic);
|
|---|
| 370 |
|
|---|
| 371 | if (flags & TBS_TOP)
|
|---|
| 372 | {
|
|---|
| 373 | rect.bottom = infoPtr->rcFullThumb.top-SCALE_SPACE-1+1;
|
|---|
| 374 | rect.top = rect.bottom-3;
|
|---|
| 375 | } else
|
|---|
| 376 | {
|
|---|
| 377 | rect.top = infoPtr->rcFullThumb.bottom+SCALE_SPACE+1;
|
|---|
| 378 | rect.bottom = rect.top+3;
|
|---|
| 379 | }
|
|---|
| 380 | rect.left = infoPtr->rcChannel.left+(width*(infoPtr->tics[0]-infoPtr->nRangeMin))/range;
|
|---|
| 381 | rect.right = infoPtr->rcChannel.left+(width*(infoPtr->tics[infoPtr->uNumTics-1]-infoPtr->nRangeMin))/range+1;
|
|---|
| 382 |
|
|---|
| 383 | FillRect(hdc,&rect,hbr);
|
|---|
| 384 | DeleteObject(hbr);
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | static VOID
|
|---|
| 388 | TRACKBAR_DrawVertTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
|
|---|
| 389 | int flags, COLORREF clrTic)
|
|---|
| 390 | {
|
|---|
| 391 | RECT rcChannel = infoPtr->rcChannel;
|
|---|
| 392 | int x,y,width,range,side;
|
|---|
| 393 |
|
|---|
| 394 | range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 395 | width = rcChannel.bottom-rcChannel.top;
|
|---|
| 396 |
|
|---|
| 397 | if (flags & TBS_LEFT)
|
|---|
| 398 | {
|
|---|
| 399 | x = infoPtr->rcFullThumb.left-SCALE_SPACE-1;
|
|---|
| 400 | side = -1;
|
|---|
| 401 | } else
|
|---|
| 402 | {
|
|---|
| 403 | x = infoPtr->rcFullThumb.right+SCALE_SPACE+1;
|
|---|
| 404 | side = 1;
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 | if (flags & TIC_SELECTIONMARK)
|
|---|
| 409 | {
|
|---|
| 410 | ticPos -= infoPtr->nRangeMin;
|
|---|
| 411 | if (flags & TIC_SELECTIONMARKMIN) y = rcChannel.top+(width*ticPos)/range-1;
|
|---|
| 412 | else y = rcChannel.top+(width*ticPos)/range+1;
|
|---|
| 413 |
|
|---|
| 414 | //first line
|
|---|
| 415 | SetPixel(hdc,x+1*side,y,clrTic);
|
|---|
| 416 | SetPixel(hdc,x+2*side,y,clrTic);
|
|---|
| 417 | //point
|
|---|
| 418 | if (flags & TIC_SELECTIONMARKMIN) y--; else y++;
|
|---|
| 419 | SetPixel(hdc,x+2*side,y,clrTic);
|
|---|
| 420 |
|
|---|
| 421 | return;
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | if ((ticPos>infoPtr->nRangeMin) && (ticPos<infoPtr->nRangeMax))
|
|---|
| 425 | {
|
|---|
| 426 | ticPos -= infoPtr->nRangeMin;
|
|---|
| 427 | y = rcChannel.top+(width*ticPos)/range;
|
|---|
| 428 | SetPixel (hdc,x, y,clrTic); //base
|
|---|
| 429 | SetPixel (hdc,x+1*side,y,clrTic);
|
|---|
| 430 | SetPixel (hdc,x+2*side,y,clrTic);
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | if (flags & TIC_EDGE)
|
|---|
| 434 | {
|
|---|
| 435 | if (flags & TIC_LEFTEDGE) y = rcChannel.top;
|
|---|
| 436 | else y = rcChannel.bottom;
|
|---|
| 437 |
|
|---|
| 438 | SetPixel (hdc,x,y,clrTic); //base
|
|---|
| 439 | SetPixel (hdc,x+1*side,y,clrTic);
|
|---|
| 440 | SetPixel (hdc,x+2*side,y,clrTic);
|
|---|
| 441 | SetPixel (hdc,x+3*side,y,clrTic);
|
|---|
| 442 | }
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | static VOID TRACKBAR_FillVertTics(TRACKBAR_INFO *infoPtr,HDC hdc,int flags,COLORREF clrTic)
|
|---|
| 446 | {
|
|---|
| 447 | RECT rect;
|
|---|
| 448 | INT range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 449 | INT width = infoPtr->rcChannel.bottom-infoPtr->rcChannel.top;
|
|---|
| 450 | HBRUSH hbr = CreateSolidBrush(clrTic);
|
|---|
| 451 |
|
|---|
| 452 | if (flags & TBS_TOP)
|
|---|
| 453 | {
|
|---|
| 454 | rect.right = infoPtr->rcFullThumb.left-SCALE_SPACE-1+1;
|
|---|
| 455 | rect.left = rect.right-3;
|
|---|
| 456 | } else
|
|---|
| 457 | {
|
|---|
| 458 | rect.left = infoPtr->rcFullThumb.right+SCALE_SPACE+1;
|
|---|
| 459 | rect.right = rect.left+3;
|
|---|
| 460 | }
|
|---|
| 461 | rect.top = infoPtr->rcChannel.top+(width*(infoPtr->tics[0]-infoPtr->nRangeMin))/range;
|
|---|
| 462 | rect.bottom = infoPtr->rcChannel.top+(width*(infoPtr->tics[infoPtr->uNumTics-1]-infoPtr->nRangeMin))/range+1;
|
|---|
| 463 |
|
|---|
| 464 | FillRect(hdc,&rect,hbr);
|
|---|
| 465 | DeleteObject(hbr);
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | static VOID
|
|---|
| 469 | TRACKBAR_DrawTics (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos,
|
|---|
| 470 | int flags, COLORREF clrTic)
|
|---|
| 471 | {
|
|---|
| 472 | if (flags & TBS_VERT)
|
|---|
| 473 | {
|
|---|
| 474 | if ((flags & TBS_LEFT) || (flags & TBS_BOTH))
|
|---|
| 475 | TRACKBAR_DrawVertTic (infoPtr,hdc,ticPos,flags | TBS_LEFT ,clrTic);
|
|---|
| 476 | //TBS_RIGHT == default
|
|---|
| 477 | if (!(flags & TBS_LEFT) || (flags & TBS_BOTH))
|
|---|
| 478 | TRACKBAR_DrawVertTic(infoPtr,hdc,ticPos,flags & ~TBS_LEFT,clrTic);
|
|---|
| 479 | } else
|
|---|
| 480 | {
|
|---|
| 481 | if ((flags & TBS_TOP) || (flags & TBS_BOTH))
|
|---|
| 482 | TRACKBAR_DrawHorizTic(infoPtr,hdc,ticPos,flags | TBS_TOP,clrTic);
|
|---|
| 483 | //TBS_BOTTOM == default
|
|---|
| 484 | if (!(flags & TBS_TOP) || (flags & TBS_BOTH))
|
|---|
| 485 | TRACKBAR_DrawHorizTic(infoPtr,hdc,ticPos,flags & ~TBS_TOP,clrTic);
|
|---|
| 486 | }
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 | //draw thumb, call only from draw!
|
|---|
| 490 |
|
|---|
| 491 | static VOID TRACKBAR_DrawThumb(TRACKBAR_INFO *infoPtr,HWND hwnd,HDC hdc,DWORD dwStyle)
|
|---|
| 492 | {
|
|---|
| 493 | if (!(dwStyle & TBS_NOTHUMB))
|
|---|
| 494 | {
|
|---|
| 495 | HBRUSH hbr,hbrOld;
|
|---|
| 496 | RECT thumb = infoPtr->rcThumb;
|
|---|
| 497 |
|
|---|
| 498 | if ((infoPtr->flags & TB_DRAG_MODE) || !IsWindowEnabled(hwnd)) hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));
|
|---|
| 499 | else hbr = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
|
|---|
| 500 | hbrOld = SelectObject(hdc,hbr);
|
|---|
| 501 |
|
|---|
| 502 | if (dwStyle & TBS_BOTH)
|
|---|
| 503 | {
|
|---|
| 504 | DrawEdge(hdc,&thumb,EDGE_RAISED,BF_RECT | BF_ADJUST);
|
|---|
| 505 | FillRect(hdc,&thumb,hbr);
|
|---|
| 506 | } else
|
|---|
| 507 | {
|
|---|
| 508 | POINT points[6];
|
|---|
| 509 | RECT triangle; /* for correct shadows of thumb */
|
|---|
| 510 |
|
|---|
| 511 | if (dwStyle & TBS_VERT)
|
|---|
| 512 | { //Vertical
|
|---|
| 513 |
|
|---|
| 514 | if (dwStyle & TBS_LEFT)
|
|---|
| 515 | {
|
|---|
| 516 | HPEN oldPen,pen;
|
|---|
| 517 |
|
|---|
| 518 | //Outline
|
|---|
| 519 |
|
|---|
| 520 | SetPolyFillMode(hdc,WINDING);
|
|---|
| 521 | points[0].x = thumb.left;
|
|---|
| 522 | points[0].y = thumb.top;
|
|---|
| 523 | points[1].x = thumb.left-(thumb.bottom-thumb.top)/2;
|
|---|
| 524 | points[1].y = thumb.top+(thumb.bottom-thumb.top)/2;
|
|---|
| 525 | points[2].x = thumb.left;
|
|---|
| 526 | points[2].y = thumb.bottom;
|
|---|
| 527 | points[3].x = thumb.right;
|
|---|
| 528 | points[3].y = thumb.bottom;
|
|---|
| 529 | points[4].x = thumb.right;
|
|---|
| 530 | points[4].y = thumb.top;
|
|---|
| 531 | points[5].x = points[0].x;
|
|---|
| 532 | points[5].y = points[0].y;
|
|---|
| 533 | Polygon(hdc,points,6);
|
|---|
| 534 |
|
|---|
| 535 | //Edge
|
|---|
| 536 |
|
|---|
| 537 | thumb.bottom++;
|
|---|
| 538 | thumb.right++;
|
|---|
| 539 | DrawEdge(hdc,&thumb,EDGE_RAISED,BF_BOTTOM | BF_TOP | BF_RIGHT);
|
|---|
| 540 |
|
|---|
| 541 | //Draw notch
|
|---|
| 542 |
|
|---|
| 543 | triangle.right = points[0].x;
|
|---|
| 544 | triangle.top = points[0].y;
|
|---|
| 545 | triangle.left = points[1].x;
|
|---|
| 546 | triangle.bottom = points[1].y;
|
|---|
| 547 | DrawEdge(hdc,&triangle,EDGE_RAISED,BF_DIAGONAL | BF_DIAGONAL_ENDTOPRIGHT);
|
|---|
| 548 |
|
|---|
| 549 | //draw this line direct, DrawEdge not useful
|
|---|
| 550 | pen = GetSysColorPen(COLOR_3DDKSHADOW);
|
|---|
| 551 | oldPen = SelectObject(hdc,pen);
|
|---|
| 552 | MoveToEx(hdc,points[1].x,points[1].y,NULL);
|
|---|
| 553 | LineTo(hdc,points[2].x-1,points[2].y-1);
|
|---|
| 554 | pen = GetSysColorPen(COLOR_BTNSHADOW);
|
|---|
| 555 | SelectObject(hdc,pen);
|
|---|
| 556 | MoveToEx(hdc,points[1].x+1,points[1].y,NULL);
|
|---|
| 557 | LineTo(hdc,points[2].x,points[2].y-1);
|
|---|
| 558 | SelectObject(hdc,oldPen);
|
|---|
| 559 |
|
|---|
| 560 | } else //Right
|
|---|
| 561 | {
|
|---|
| 562 | HPEN oldPen,pen;
|
|---|
| 563 |
|
|---|
| 564 | //Outline
|
|---|
| 565 |
|
|---|
| 566 | SetPolyFillMode(hdc,WINDING);
|
|---|
| 567 | points[0].x = thumb.left;
|
|---|
| 568 | points[0].y = thumb.top;
|
|---|
| 569 | points[1].x = thumb.left;
|
|---|
| 570 | points[1].y = thumb.bottom;
|
|---|
| 571 | points[2].x = thumb.right;
|
|---|
| 572 | points[2].y = thumb.bottom;
|
|---|
| 573 | points[3].x = thumb.right+(thumb.bottom-thumb.top)/2;
|
|---|
| 574 | points[3].y = thumb.bottom-(thumb.bottom-thumb.top)/2;
|
|---|
| 575 | points[4].x = thumb.right;
|
|---|
| 576 | points[4].y = thumb.top;
|
|---|
| 577 | points[5].x = points[0].x;
|
|---|
| 578 | points[5].y = points[0].y;
|
|---|
| 579 | Polygon(hdc,points,6);
|
|---|
| 580 |
|
|---|
| 581 | //Edge
|
|---|
| 582 |
|
|---|
| 583 | thumb.bottom++;
|
|---|
| 584 | DrawEdge(hdc,&thumb,EDGE_RAISED,BF_BOTTOM | BF_TOP | BF_LEFT);
|
|---|
| 585 |
|
|---|
| 586 | //Draw notch
|
|---|
| 587 |
|
|---|
| 588 | //draw this line direct, DrawEdge not useful
|
|---|
| 589 | pen = GetSysColorPen(COLOR_3DLIGHT);
|
|---|
| 590 | oldPen = SelectObject(hdc,pen);
|
|---|
| 591 | MoveToEx(hdc,points[4].x,points[4].y,NULL);
|
|---|
| 592 | LineTo(hdc,points[3].x,points[3].y);
|
|---|
| 593 | pen = GetSysColorPen(COLOR_BTNHIGHLIGHT);
|
|---|
| 594 | SelectObject(hdc,pen);
|
|---|
| 595 | MoveToEx(hdc,points[4].x,points[4].y+1,NULL);
|
|---|
| 596 | LineTo(hdc,points[3].x-1,points[3].y);
|
|---|
| 597 | SelectObject(hdc,oldPen);
|
|---|
| 598 |
|
|---|
| 599 | triangle.right = points[3].x;
|
|---|
| 600 | triangle.top = points[3].y;
|
|---|
| 601 | triangle.left = points[2].x;
|
|---|
| 602 | triangle.bottom = points[2].y;
|
|---|
| 603 | DrawEdge(hdc,&triangle,EDGE_RAISED,BF_DIAGONAL | BF_DIAGONAL_ENDBOTTOMLEFT);
|
|---|
| 604 | }
|
|---|
| 605 | } else
|
|---|
| 606 | { //Horizontal
|
|---|
| 607 |
|
|---|
| 608 | if (dwStyle & TBS_TOP)
|
|---|
| 609 | {
|
|---|
| 610 | //Outline
|
|---|
| 611 |
|
|---|
| 612 | SetPolyFillMode(hdc,WINDING);
|
|---|
| 613 | points[0].x = thumb.left;
|
|---|
| 614 | points[0].y = thumb.top;
|
|---|
| 615 | points[1].x = thumb.left+(thumb.right-thumb.left)/2;
|
|---|
| 616 | points[1].y = thumb.top-(thumb.right-thumb.left)/2;
|
|---|
| 617 | points[2].x = thumb.right;
|
|---|
| 618 | points[2].y = thumb.top;
|
|---|
| 619 | points[3].x = thumb.right;
|
|---|
| 620 | points[3].y = thumb.bottom;
|
|---|
| 621 | points[4].x = thumb.left;
|
|---|
| 622 | points[4].y = thumb.bottom;
|
|---|
| 623 | points[5].x = points[0].x;
|
|---|
| 624 | points[5].y = points[0].y;
|
|---|
| 625 | Polygon(hdc,points,6);
|
|---|
| 626 |
|
|---|
| 627 | //Edge
|
|---|
| 628 |
|
|---|
| 629 | thumb.right++;
|
|---|
| 630 | thumb.bottom++;
|
|---|
| 631 | DrawEdge(hdc,&thumb,EDGE_RAISED,BF_BOTTOM | BF_LEFT | BF_RIGHT);
|
|---|
| 632 |
|
|---|
| 633 | //Draw notch
|
|---|
| 634 |
|
|---|
| 635 | triangle.left = points[0].x;
|
|---|
| 636 | triangle.bottom = points[0].y;
|
|---|
| 637 | triangle.right = points[1].x;
|
|---|
| 638 | triangle.top = points[1].y;
|
|---|
| 639 | DrawEdge(hdc,&triangle,EDGE_RAISED,BF_DIAGONAL | BF_DIAGONAL_ENDTOPRIGHT);
|
|---|
| 640 |
|
|---|
| 641 |
|
|---|
| 642 | triangle.left = points[1].x;
|
|---|
| 643 | triangle.top = points[1].y;
|
|---|
| 644 | triangle.right = points[2].x;
|
|---|
| 645 | triangle.bottom = points[2].y;
|
|---|
| 646 | DrawEdge(hdc,&triangle,EDGE_RAISED,BF_DIAGONAL | BF_DIAGONAL_ENDBOTTOMRIGHT);
|
|---|
| 647 |
|
|---|
| 648 | } else //Bottom
|
|---|
| 649 | {
|
|---|
| 650 |
|
|---|
| 651 | //Outline
|
|---|
| 652 |
|
|---|
| 653 | SetPolyFillMode(hdc,WINDING);
|
|---|
| 654 | points[0].x = thumb.left;
|
|---|
| 655 | points[0].y = thumb.top;
|
|---|
| 656 | points[1].x = thumb.right;
|
|---|
| 657 | points[1].y = thumb.top;
|
|---|
| 658 | points[2].x = thumb.right;
|
|---|
| 659 | points[2].y = thumb.bottom;
|
|---|
| 660 | points[3].x = thumb.right-(thumb.right-thumb.left)/2;
|
|---|
| 661 | points[3].y = thumb.bottom+(thumb.right-thumb.left)/2;
|
|---|
| 662 | points[4].x = thumb.left;
|
|---|
| 663 | points[4].y = thumb.bottom;
|
|---|
| 664 | points[5].x = points[0].x;
|
|---|
| 665 | points[5].y = points[0].y;
|
|---|
| 666 | Polygon(hdc,points,6);
|
|---|
| 667 |
|
|---|
| 668 | //Edge
|
|---|
| 669 |
|
|---|
| 670 | thumb.right++;
|
|---|
| 671 | thumb.bottom++;
|
|---|
| 672 | DrawEdge(hdc,&thumb,EDGE_RAISED,BF_TOP | BF_LEFT | BF_RIGHT);
|
|---|
| 673 |
|
|---|
| 674 | //Draw notch
|
|---|
| 675 |
|
|---|
| 676 | triangle.right = points[2].x;
|
|---|
| 677 | triangle.top = points[2].y;
|
|---|
| 678 | triangle.left = points[3].x;
|
|---|
| 679 | triangle.bottom = points[3].y;
|
|---|
| 680 | DrawEdge(hdc,&triangle,EDGE_RAISED,BF_DIAGONAL | BF_DIAGONAL_ENDBOTTOMLEFT);
|
|---|
| 681 | triangle.right = points[3].x;
|
|---|
| 682 | triangle.bottom = points[3].y;
|
|---|
| 683 | triangle.left = points[4].x;
|
|---|
| 684 | triangle.top = points[4].y;
|
|---|
| 685 | DrawEdge(hdc,&triangle,EDGE_RAISED,BF_DIAGONAL | BF_DIAGONAL_ENDTOPLEFT);
|
|---|
| 686 |
|
|---|
| 687 | }
|
|---|
| 688 | }
|
|---|
| 689 | }
|
|---|
| 690 | SelectObject(hdc,hbrOld);
|
|---|
| 691 | DeleteObject(hbr);
|
|---|
| 692 | }
|
|---|
| 693 | }
|
|---|
| 694 |
|
|---|
| 695 | //draw the trackbar
|
|---|
| 696 |
|
|---|
| 697 | static VOID TRACKBAR_Draw(HWND hwnd,HDC hdc)
|
|---|
| 698 | {
|
|---|
| 699 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 700 | DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
|---|
| 701 | RECT rcClient,rcChannel,rcSelection;
|
|---|
| 702 | HBRUSH hBrush;
|
|---|
| 703 | int i;
|
|---|
| 704 | NMCUSTOMDRAW cdraw;
|
|---|
| 705 | LRESULT cdctlres,cdres;
|
|---|
| 706 |
|
|---|
| 707 | GetClientRect(hwnd,&rcClient);
|
|---|
| 708 |
|
|---|
| 709 | //Custom draw
|
|---|
| 710 | cdraw.dwDrawStage = CDDS_PREPAINT;
|
|---|
| 711 | cdraw.hdc = hdc;
|
|---|
| 712 | cdraw.dwItemSpec = 0;
|
|---|
| 713 | cdraw.uItemState = CDIS_DEFAULT;
|
|---|
| 714 | cdraw.rc = rcClient;
|
|---|
| 715 | cdraw.lItemlParam = 0;
|
|---|
| 716 |
|
|---|
| 717 | cdctlres = sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 718 |
|
|---|
| 719 | if (cdctlres & CDRF_SKIPDEFAULT) return;
|
|---|
| 720 |
|
|---|
| 721 | //Background
|
|---|
| 722 | hBrush = CreateSolidBrush(infoPtr->clrBk);
|
|---|
| 723 | FillRect(hdc,&rcClient,hBrush);
|
|---|
| 724 | DeleteObject(hBrush);
|
|---|
| 725 |
|
|---|
| 726 | if (infoPtr->flags & TB_DRAGPOSVALID)
|
|---|
| 727 | {
|
|---|
| 728 | infoPtr->nPos = infoPtr->dragPos;
|
|---|
| 729 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
|---|
| 730 | }
|
|---|
| 731 |
|
|---|
| 732 | if (infoPtr->flags & TB_THUMBCHANGED)
|
|---|
| 733 | {
|
|---|
| 734 | if (infoPtr->flags & TB_THUMBSIZECHANGED)
|
|---|
| 735 | {
|
|---|
| 736 | TRACKBAR_CalcChannel(hwnd,infoPtr);
|
|---|
| 737 | TRACKBAR_CalcSelection(hwnd,infoPtr);
|
|---|
| 738 | }
|
|---|
| 739 | TRACKBAR_CalcThumb(hwnd,infoPtr);
|
|---|
| 740 | }
|
|---|
| 741 | if (infoPtr->flags & TB_SELECTIONCHANGED) TRACKBAR_CalcSelection(hwnd,infoPtr);
|
|---|
| 742 | infoPtr->flags &= ~ (TB_THUMBCHANGED | TB_SELECTIONCHANGED | TB_DRAGPOSVALID);
|
|---|
| 743 |
|
|---|
| 744 | /* draw channel */
|
|---|
| 745 |
|
|---|
| 746 | if (cdctlres & CDRF_NOTIFYITEMDRAW)
|
|---|
| 747 | {
|
|---|
| 748 | cdraw.dwDrawStage = CDDS_ITEMPREPAINT;
|
|---|
| 749 | cdraw.dwItemSpec = TBCD_CHANNEL;
|
|---|
| 750 | cdraw.rc = infoPtr->rcChannel;
|
|---|
| 751 |
|
|---|
| 752 | cdres = sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 753 | } else cdres = 0;
|
|---|
| 754 |
|
|---|
| 755 | if (!(cdres & CDRF_SKIPDEFAULT))
|
|---|
| 756 | {
|
|---|
| 757 | rcChannel = infoPtr->rcChannel;
|
|---|
| 758 | rcSelection = infoPtr->rcSelection;
|
|---|
| 759 | DrawEdge(hdc,&rcChannel,EDGE_SUNKEN,BF_RECT | BF_ADJUST);
|
|---|
| 760 |
|
|---|
| 761 | if (dwStyle & TBS_ENABLESELRANGE) /* fill the channel */
|
|---|
| 762 | {
|
|---|
| 763 | HBRUSH hbr = CreateSolidBrush(RGB(255,255,255));
|
|---|
| 764 | FillRect(hdc,&rcChannel,hbr);
|
|---|
| 765 | DeleteObject(hbr);
|
|---|
| 766 | if (((dwStyle & TBS_VERT) && (rcSelection.top != rcSelection.bottom)) ||
|
|---|
| 767 | ((!(dwStyle & TBS_VERT)) && (rcSelection.left != rcSelection.right)))
|
|---|
| 768 | {
|
|---|
| 769 | hbr = CreateSolidBrush (COLOR_HIGHLIGHT);
|
|---|
| 770 | FillRect (hdc,&rcSelection,hbr);
|
|---|
| 771 | DeleteObject(hbr);
|
|---|
| 772 | }
|
|---|
| 773 | }
|
|---|
| 774 |
|
|---|
| 775 | if (cdctlres & CDRF_NOTIFYITEMDRAW)
|
|---|
| 776 | {
|
|---|
| 777 | cdraw.dwDrawStage = CDDS_ITEMPOSTPAINT;
|
|---|
| 778 |
|
|---|
| 779 | sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 780 | }
|
|---|
| 781 | }
|
|---|
| 782 |
|
|---|
| 783 | /* draw tics */
|
|---|
| 784 |
|
|---|
| 785 | if (cdctlres & CDRF_NOTIFYITEMDRAW)
|
|---|
| 786 | {
|
|---|
| 787 | cdraw.dwDrawStage = CDDS_ITEMPREPAINT;
|
|---|
| 788 | cdraw.dwItemSpec = TBCD_TICS;
|
|---|
| 789 | SetRectEmpty(&cdraw.rc);
|
|---|
| 790 |
|
|---|
| 791 | cdres = sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 792 | } else cdres = 0;
|
|---|
| 793 |
|
|---|
| 794 | if (!(cdres & CDRF_SKIPDEFAULT))
|
|---|
| 795 | {
|
|---|
| 796 | if (!(dwStyle & TBS_NOTICKS))
|
|---|
| 797 | {
|
|---|
| 798 | int ticFlags = dwStyle & 0x0f;
|
|---|
| 799 | COLORREF clrTic = GetSysColor(COLOR_3DDKSHADOW);
|
|---|
| 800 | INT range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 801 | INT width = (dwStyle & TBS_VERT) ? rcChannel.bottom-rcChannel.top:rcChannel.right-rcChannel.left;
|
|---|
| 802 |
|
|---|
| 803 | //check if maximum of visible marks is reached
|
|---|
| 804 | if ((dwStyle & TBS_AUTOTICKS) && (infoPtr->uNumTics > 1) && ((INT)(width*infoPtr->tics[0]/range) == (INT)(width*infoPtr->tics[1]/range)))
|
|---|
| 805 | {
|
|---|
| 806 | //draw all pixels at once -> much faster
|
|---|
| 807 | if (dwStyle & TBS_VERT)
|
|---|
| 808 | {
|
|---|
| 809 | if ((ticFlags & TBS_LEFT) || (ticFlags & TBS_BOTH))
|
|---|
| 810 | TRACKBAR_FillVertTics(infoPtr,hdc,ticFlags | TBS_LEFT,clrTic);
|
|---|
| 811 | if (!(ticFlags & TBS_LEFT) || (ticFlags & TBS_BOTH))
|
|---|
| 812 | TRACKBAR_FillVertTics(infoPtr,hdc,ticFlags & ~TBS_LEFT,clrTic);
|
|---|
| 813 | } else
|
|---|
| 814 | {
|
|---|
| 815 | if ((ticFlags & TBS_TOP) || (ticFlags & TBS_BOTH))
|
|---|
| 816 | TRACKBAR_FillHorzTics(infoPtr,hdc,ticFlags | TBS_TOP,clrTic);
|
|---|
| 817 | if (!(ticFlags & TBS_TOP) || (ticFlags & TBS_BOTH))
|
|---|
| 818 | TRACKBAR_FillHorzTics(infoPtr,hdc,ticFlags & ~TBS_TOP,clrTic);
|
|---|
| 819 | }
|
|---|
| 820 | } else
|
|---|
| 821 | {
|
|---|
| 822 | for (i = 0;i < infoPtr->uNumTics;i++)
|
|---|
| 823 | TRACKBAR_DrawTics(infoPtr,hdc,infoPtr->tics[i],ticFlags,clrTic);
|
|---|
| 824 | }
|
|---|
| 825 |
|
|---|
| 826 | TRACKBAR_DrawTics(infoPtr,hdc,0,ticFlags | TIC_LEFTEDGE,clrTic);
|
|---|
| 827 | TRACKBAR_DrawTics(infoPtr,hdc,0,ticFlags | TIC_RIGHTEDGE,clrTic);
|
|---|
| 828 |
|
|---|
| 829 | if ((dwStyle & TBS_ENABLESELRANGE) &&
|
|---|
| 830 | ((dwStyle & TBS_VERT && rcSelection.bottom != rcSelection.top) ||
|
|---|
| 831 | (!(dwStyle & TBS_VERT) && rcSelection.left != rcSelection.right)))
|
|---|
| 832 | {
|
|---|
| 833 | TRACKBAR_DrawTics(infoPtr,hdc,infoPtr->nSelMin,ticFlags | TIC_SELECTIONMARKMIN,clrTic);
|
|---|
| 834 | TRACKBAR_DrawTics(infoPtr,hdc,infoPtr->nSelMax,ticFlags | TIC_SELECTIONMARKMAX,clrTic);
|
|---|
| 835 | }
|
|---|
| 836 | }
|
|---|
| 837 |
|
|---|
| 838 | if (cdctlres & CDRF_NOTIFYITEMDRAW)
|
|---|
| 839 | {
|
|---|
| 840 | cdraw.dwDrawStage = CDDS_ITEMPOSTPAINT;
|
|---|
| 841 |
|
|---|
| 842 | sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 843 | }
|
|---|
| 844 | }
|
|---|
| 845 |
|
|---|
| 846 | /* draw thumb */
|
|---|
| 847 |
|
|---|
| 848 | if (cdctlres & CDRF_NOTIFYITEMDRAW)
|
|---|
| 849 | {
|
|---|
| 850 | cdraw.dwDrawStage = CDDS_ITEMPREPAINT;
|
|---|
| 851 | cdraw.dwItemSpec = TBCD_THUMB;
|
|---|
| 852 | cdraw.rc = infoPtr->rcFullThumb;
|
|---|
| 853 |
|
|---|
| 854 | cdres = sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 855 | } else cdres = 0;
|
|---|
| 856 |
|
|---|
| 857 | if (!(cdres & CDRF_SKIPDEFAULT))
|
|---|
| 858 | {
|
|---|
| 859 | TRACKBAR_DrawThumb(infoPtr,hwnd,hdc,dwStyle);
|
|---|
| 860 |
|
|---|
| 861 | if (cdctlres & CDRF_NOTIFYITEMDRAW)
|
|---|
| 862 | {
|
|---|
| 863 | cdraw.dwDrawStage = CDDS_ITEMPOSTPAINT;
|
|---|
| 864 |
|
|---|
| 865 | sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 866 | }
|
|---|
| 867 |
|
|---|
| 868 | }
|
|---|
| 869 |
|
|---|
| 870 | if (infoPtr->bFocus && IsWindowEnabled(hwnd)) DrawFocusRect(hdc,&rcClient);
|
|---|
| 871 |
|
|---|
| 872 | if (cdctlres & CDRF_NOTIFYPOSTPAINT)
|
|---|
| 873 | {
|
|---|
| 874 | cdraw.dwDrawStage = CDDS_POSTPAINT;
|
|---|
| 875 | cdraw.dwItemSpec = 0;
|
|---|
| 876 | GetClientRect(hwnd,&cdraw.rc);
|
|---|
| 877 |
|
|---|
| 878 | sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
|
|---|
| 879 | }
|
|---|
| 880 |
|
|---|
| 881 | }
|
|---|
| 882 |
|
|---|
| 883 | //update thumb position
|
|---|
| 884 |
|
|---|
| 885 | static VOID TRACKBAR_UpdateThumbPosition(HWND hwnd,INT lastPos,BOOL mustRedraw)
|
|---|
| 886 | {
|
|---|
| 887 | HDC hdc;
|
|---|
| 888 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 889 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 890 | RECT lastRect,newRect,updateRect;
|
|---|
| 891 | HDC hdcCompatible;
|
|---|
| 892 | HBITMAP bitmap,oldbmp;
|
|---|
| 893 |
|
|---|
| 894 | //last
|
|---|
| 895 | lastRect = infoPtr->rcFullThumb;
|
|---|
| 896 |
|
|---|
| 897 | //new
|
|---|
| 898 | if (infoPtr->flags & TB_DRAGPOSVALID)
|
|---|
| 899 | {
|
|---|
| 900 | infoPtr->nPos = infoPtr->dragPos;
|
|---|
| 901 | infoPtr->flags &= ~TB_DRAGPOSVALID;
|
|---|
| 902 | }
|
|---|
| 903 | if (!mustRedraw && (infoPtr->nPos == lastPos)) return;
|
|---|
| 904 |
|
|---|
| 905 | if (dwStyle & TBS_NOTHUMB) return;
|
|---|
| 906 |
|
|---|
| 907 | TRACKBAR_CalcThumb(hwnd,infoPtr);
|
|---|
| 908 | infoPtr->flags &= ~TB_THUMBCHANGED;
|
|---|
| 909 | newRect = infoPtr->rcFullThumb;
|
|---|
| 910 |
|
|---|
| 911 | //same rect?
|
|---|
| 912 | if (!mustRedraw && EqualRect(&lastRect,&newRect)) return;
|
|---|
| 913 |
|
|---|
| 914 | //3D frame adjustation
|
|---|
| 915 | lastRect.right++;
|
|---|
| 916 | lastRect.bottom++;
|
|---|
| 917 | newRect.right++;
|
|---|
| 918 | newRect.bottom++;
|
|---|
| 919 |
|
|---|
| 920 | //BitBlt from memory -> no flickering
|
|---|
| 921 | updateRect.left = MIN(lastRect.left,newRect.left);
|
|---|
| 922 | updateRect.right = MAX(lastRect.right,newRect.right);
|
|---|
| 923 | updateRect.top = MIN(lastRect.top,newRect.top);
|
|---|
| 924 | updateRect.bottom = MAX(lastRect.bottom,newRect.bottom);
|
|---|
| 925 | hdc = GetDC(hwnd);
|
|---|
| 926 | hdcCompatible = CreateCompatibleDC(hdc);
|
|---|
| 927 | bitmap = CreateCompatibleBitmap(hdc,updateRect.right,updateRect.bottom);
|
|---|
| 928 | oldbmp = SelectObject(hdcCompatible,bitmap);
|
|---|
| 929 | TRACKBAR_Draw(hwnd,hdcCompatible);
|
|---|
| 930 | if (dwStyle & TBS_VERT)
|
|---|
| 931 | {
|
|---|
| 932 | if ((lastRect.top > newRect.top) && (lastRect.top < newRect.bottom))
|
|---|
| 933 | BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,lastRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
|
|---|
| 934 | else if ((lastRect.bottom < newRect.bottom) && (lastRect.bottom > newRect.top))
|
|---|
| 935 | BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,newRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
|
|---|
| 936 | else
|
|---|
| 937 | {
|
|---|
| 938 | BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
|
|---|
| 939 | BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
|
|---|
| 940 | }
|
|---|
| 941 | } else
|
|---|
| 942 | {
|
|---|
| 943 | if ((lastRect.right > newRect.left) && (lastRect.right < newRect.right))
|
|---|
| 944 | BitBlt(hdc,lastRect.left,lastRect.top,newRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
|
|---|
| 945 | else if ((lastRect.left < newRect.right) && (lastRect.left > newRect.left))
|
|---|
| 946 | BitBlt(hdc,newRect.left,newRect.top,lastRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
|
|---|
| 947 | else
|
|---|
| 948 | {
|
|---|
| 949 | BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
|
|---|
| 950 | BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
|
|---|
| 951 | }
|
|---|
| 952 | }
|
|---|
| 953 | SelectObject(hdcCompatible,oldbmp);
|
|---|
| 954 | DeleteObject(bitmap);
|
|---|
| 955 | DeleteDC(hdcCompatible);
|
|---|
| 956 | ReleaseDC(hwnd,hdc);
|
|---|
| 957 | }
|
|---|
| 958 |
|
|---|
| 959 | //redraw everything
|
|---|
| 960 |
|
|---|
| 961 | static VOID TRACKBAR_Refresh (HWND hwnd)
|
|---|
| 962 | {
|
|---|
| 963 | HDC hdc;
|
|---|
| 964 |
|
|---|
| 965 | hdc = GetDC (hwnd);
|
|---|
| 966 | TRACKBAR_Draw(hwnd,hdc);
|
|---|
| 967 | ReleaseDC(hwnd,hdc);
|
|---|
| 968 | }
|
|---|
| 969 |
|
|---|
| 970 | static VOID
|
|---|
| 971 | TRACKBAR_AlignBuddies (HWND hwnd, TRACKBAR_INFO *infoPtr)
|
|---|
| 972 | {
|
|---|
| 973 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 974 | HWND hwndParent = GetParent(hwnd);
|
|---|
| 975 | RECT rcSelf,rcBuddy;
|
|---|
| 976 | INT x, y;
|
|---|
| 977 |
|
|---|
| 978 | GetWindowRect(hwnd,&rcSelf);
|
|---|
| 979 | MapWindowPoints(HWND_DESKTOP,hwndParent,(LPPOINT)&rcSelf,2);
|
|---|
| 980 |
|
|---|
| 981 | /* align buddy left or above */
|
|---|
| 982 | if (infoPtr->hwndBuddyLA)
|
|---|
| 983 | {
|
|---|
| 984 | GetWindowRect(infoPtr->hwndBuddyLA,&rcBuddy);
|
|---|
| 985 |
|
|---|
| 986 | if (dwStyle & TBS_VERT)
|
|---|
| 987 | { //above
|
|---|
| 988 | x = (infoPtr->rcChannel.right+infoPtr->rcChannel.left)/2-(rcBuddy.right-rcBuddy.left)/2+rcSelf.left;
|
|---|
| 989 | y = rcSelf.top-(rcBuddy.bottom-rcBuddy.top);
|
|---|
| 990 | } else
|
|---|
| 991 | { //left
|
|---|
| 992 | x = rcSelf.left-(rcBuddy.right-rcBuddy.left);
|
|---|
| 993 | y = (infoPtr->rcChannel.bottom+infoPtr->rcChannel.top)/2-(rcBuddy.bottom-rcBuddy.top)/2+rcSelf.top;
|
|---|
| 994 | }
|
|---|
| 995 |
|
|---|
| 996 | SetWindowPos(infoPtr->hwndBuddyLA,0,x,y,0,0,SWP_NOZORDER | SWP_NOSIZE);
|
|---|
| 997 | }
|
|---|
| 998 |
|
|---|
| 999 |
|
|---|
| 1000 | /* align buddy right or below */
|
|---|
| 1001 | if (infoPtr->hwndBuddyRB)
|
|---|
| 1002 | {
|
|---|
| 1003 | GetWindowRect(infoPtr->hwndBuddyRB,&rcBuddy);
|
|---|
| 1004 |
|
|---|
| 1005 | if (dwStyle & TBS_VERT)
|
|---|
| 1006 | { //below
|
|---|
| 1007 | x = (infoPtr->rcChannel.right+infoPtr->rcChannel.left)/2-(rcBuddy.right-rcBuddy.left)/2+rcSelf.left;
|
|---|
| 1008 | y = rcSelf.bottom;
|
|---|
| 1009 | } else
|
|---|
| 1010 | { //right
|
|---|
| 1011 | x = rcSelf.right;
|
|---|
| 1012 | y = (infoPtr->rcChannel.bottom+infoPtr->rcChannel.top)/2-(rcBuddy.bottom-rcBuddy.top)/2+rcSelf.top;
|
|---|
| 1013 | }
|
|---|
| 1014 |
|
|---|
| 1015 | SetWindowPos(infoPtr->hwndBuddyRB,0,x,y,0,0,SWP_NOZORDER | SWP_NOSIZE);
|
|---|
| 1016 | }
|
|---|
| 1017 | }
|
|---|
| 1018 |
|
|---|
| 1019 |
|
|---|
| 1020 | static LRESULT
|
|---|
| 1021 | TRACKBAR_ClearSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1022 | {
|
|---|
| 1023 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1024 |
|
|---|
| 1025 | if (infoPtr->nSelMin != infoPtr->nSelMax)
|
|---|
| 1026 | {
|
|---|
| 1027 | infoPtr->nSelMin = 0;
|
|---|
| 1028 | infoPtr->nSelMax = 0;
|
|---|
| 1029 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1030 |
|
|---|
| 1031 | if ((BOOL)wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1032 | }
|
|---|
| 1033 |
|
|---|
| 1034 | return 0;
|
|---|
| 1035 | }
|
|---|
| 1036 |
|
|---|
| 1037 |
|
|---|
| 1038 | static LRESULT
|
|---|
| 1039 | TRACKBAR_ClearTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1040 | {
|
|---|
| 1041 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1042 |
|
|---|
| 1043 | if (!(GetWindowLongA(hwnd, GWL_STYLE) & (TBS_AUTOTICKS | TBS_NOTICKS))) return 0;
|
|---|
| 1044 |
|
|---|
| 1045 | if (infoPtr->tics)
|
|---|
| 1046 | {
|
|---|
| 1047 | COMCTL32_Free(infoPtr->tics);
|
|---|
| 1048 | infoPtr->tics = NULL;
|
|---|
| 1049 | infoPtr->uNumTics = 0;
|
|---|
| 1050 |
|
|---|
| 1051 | if (wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1052 | }
|
|---|
| 1053 |
|
|---|
| 1054 | return 0;
|
|---|
| 1055 | }
|
|---|
| 1056 |
|
|---|
| 1057 |
|
|---|
| 1058 | static LRESULT
|
|---|
| 1059 | TRACKBAR_GetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1060 | {
|
|---|
| 1061 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 1062 |
|
|---|
| 1063 | if (wParam)
|
|---|
| 1064 | return (LRESULT)infoPtr->hwndBuddyLA; //left or above
|
|---|
| 1065 | else
|
|---|
| 1066 | return (LRESULT)infoPtr->hwndBuddyRB; //right or below
|
|---|
| 1067 | }
|
|---|
| 1068 |
|
|---|
| 1069 |
|
|---|
| 1070 | static LRESULT
|
|---|
| 1071 | TRACKBAR_GetChannelRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1072 | {
|
|---|
| 1073 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1074 | LPRECT lprc = (LPRECT)lParam;
|
|---|
| 1075 |
|
|---|
| 1076 | if (lprc == NULL) return 0;
|
|---|
| 1077 |
|
|---|
| 1078 | CopyRect(lprc,&infoPtr->rcChannel);
|
|---|
| 1079 |
|
|---|
| 1080 | return 0;
|
|---|
| 1081 | }
|
|---|
| 1082 |
|
|---|
| 1083 |
|
|---|
| 1084 | static LRESULT
|
|---|
| 1085 | TRACKBAR_GetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1086 | {
|
|---|
| 1087 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1088 |
|
|---|
| 1089 | return infoPtr->nLineSize;
|
|---|
| 1090 | }
|
|---|
| 1091 |
|
|---|
| 1092 |
|
|---|
| 1093 | static LRESULT
|
|---|
| 1094 | TRACKBAR_GetNumTics (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1095 | {
|
|---|
| 1096 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1097 |
|
|---|
| 1098 | if (GetWindowLongA(hwnd, GWL_STYLE) & TBS_NOTICKS) return 0;
|
|---|
| 1099 |
|
|---|
| 1100 | return infoPtr->uNumTics+2; //includes last and first tick
|
|---|
| 1101 | }
|
|---|
| 1102 |
|
|---|
| 1103 |
|
|---|
| 1104 | static LRESULT
|
|---|
| 1105 | TRACKBAR_GetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1106 | {
|
|---|
| 1107 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1108 |
|
|---|
| 1109 | return infoPtr->nPageSize;
|
|---|
| 1110 | }
|
|---|
| 1111 |
|
|---|
| 1112 |
|
|---|
| 1113 | static LRESULT
|
|---|
| 1114 | TRACKBAR_GetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1115 | {
|
|---|
| 1116 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1117 |
|
|---|
| 1118 | return infoPtr->nPos;
|
|---|
| 1119 | }
|
|---|
| 1120 |
|
|---|
| 1121 |
|
|---|
| 1122 | static LRESULT
|
|---|
| 1123 | TRACKBAR_GetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1124 | {
|
|---|
| 1125 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1126 |
|
|---|
| 1127 | return infoPtr->nRangeMax;
|
|---|
| 1128 | }
|
|---|
| 1129 |
|
|---|
| 1130 |
|
|---|
| 1131 | static LRESULT
|
|---|
| 1132 | TRACKBAR_GetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1133 | {
|
|---|
| 1134 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1135 |
|
|---|
| 1136 | return infoPtr->nRangeMin;
|
|---|
| 1137 | }
|
|---|
| 1138 |
|
|---|
| 1139 |
|
|---|
| 1140 | static LRESULT
|
|---|
| 1141 | TRACKBAR_GetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1142 | {
|
|---|
| 1143 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1144 |
|
|---|
| 1145 | return infoPtr->nSelMax;
|
|---|
| 1146 | }
|
|---|
| 1147 |
|
|---|
| 1148 |
|
|---|
| 1149 | static LRESULT
|
|---|
| 1150 | TRACKBAR_GetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1151 | {
|
|---|
| 1152 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1153 |
|
|---|
| 1154 | return infoPtr->nSelMin;
|
|---|
| 1155 | }
|
|---|
| 1156 |
|
|---|
| 1157 |
|
|---|
| 1158 | static LRESULT
|
|---|
| 1159 | TRACKBAR_GetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1160 | {
|
|---|
| 1161 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1162 |
|
|---|
| 1163 | return infoPtr->uThumbLen;
|
|---|
| 1164 | }
|
|---|
| 1165 |
|
|---|
| 1166 | static LRESULT
|
|---|
| 1167 | TRACKBAR_GetPTics (HWND hwnd)
|
|---|
| 1168 | {
|
|---|
| 1169 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1170 |
|
|---|
| 1171 | return (LRESULT)infoPtr->tics;
|
|---|
| 1172 | }
|
|---|
| 1173 |
|
|---|
| 1174 | static LRESULT
|
|---|
| 1175 | TRACKBAR_GetThumbRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1176 | {
|
|---|
| 1177 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1178 | LPRECT lprc = (LPRECT)lParam;
|
|---|
| 1179 |
|
|---|
| 1180 | if (lprc == NULL) return 0;
|
|---|
| 1181 |
|
|---|
| 1182 | CopyRect(lprc,&infoPtr->rcFullThumb);
|
|---|
| 1183 |
|
|---|
| 1184 | return 0;
|
|---|
| 1185 | }
|
|---|
| 1186 |
|
|---|
| 1187 |
|
|---|
| 1188 | static LRESULT
|
|---|
| 1189 | TRACKBAR_GetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1190 | {
|
|---|
| 1191 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1192 | INT iTic;
|
|---|
| 1193 |
|
|---|
| 1194 | iTic = (INT)wParam;
|
|---|
| 1195 | if ((iTic < 0) || (iTic > infoPtr->uNumTics)) return -1;
|
|---|
| 1196 |
|
|---|
| 1197 | return (LRESULT)infoPtr->tics[iTic];
|
|---|
| 1198 |
|
|---|
| 1199 | }
|
|---|
| 1200 |
|
|---|
| 1201 |
|
|---|
| 1202 | static LRESULT
|
|---|
| 1203 | TRACKBAR_GetTicPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1204 | {
|
|---|
| 1205 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1206 | INT iTic, range, width, pos;
|
|---|
| 1207 |
|
|---|
| 1208 |
|
|---|
| 1209 | iTic = (INT)wParam;
|
|---|
| 1210 | if ((iTic < 0) || (iTic > infoPtr->uNumTics)) return -1;
|
|---|
| 1211 |
|
|---|
| 1212 | range = infoPtr->nRangeMax-infoPtr->nRangeMin;
|
|---|
| 1213 | width = infoPtr->rcChannel.right-infoPtr->rcChannel.left;
|
|---|
| 1214 | pos = infoPtr->rcChannel.left+(width*(infoPtr->tics[iTic]-infoPtr->nRangeMin))/range;
|
|---|
| 1215 |
|
|---|
| 1216 | return (LRESULT) pos;
|
|---|
| 1217 | }
|
|---|
| 1218 |
|
|---|
| 1219 |
|
|---|
| 1220 | static LRESULT
|
|---|
| 1221 | TRACKBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1222 | {
|
|---|
| 1223 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1224 |
|
|---|
| 1225 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS)
|
|---|
| 1226 | return (LRESULT)infoPtr->hwndToolTip;
|
|---|
| 1227 | return 0;
|
|---|
| 1228 | }
|
|---|
| 1229 |
|
|---|
| 1230 |
|
|---|
| 1231 | static LRESULT
|
|---|
| 1232 | TRACKBAR_SetBuddy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1233 | {
|
|---|
| 1234 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 1235 | HWND hwndTemp;
|
|---|
| 1236 |
|
|---|
| 1237 | if (!(GetParent(lParam) == GetParent(hwnd))) return wParam ? infoPtr->hwndBuddyLA:infoPtr->hwndBuddyRB;
|
|---|
| 1238 |
|
|---|
| 1239 | if (wParam)
|
|---|
| 1240 | {
|
|---|
| 1241 | /* buddy is left or above */
|
|---|
| 1242 | hwndTemp = infoPtr->hwndBuddyLA;
|
|---|
| 1243 | infoPtr->hwndBuddyLA = (HWND)lParam;
|
|---|
| 1244 | } else
|
|---|
| 1245 | {
|
|---|
| 1246 | /* buddy is right or below */
|
|---|
| 1247 | hwndTemp = infoPtr->hwndBuddyRB;
|
|---|
| 1248 | infoPtr->hwndBuddyRB = (HWND)lParam;
|
|---|
| 1249 | }
|
|---|
| 1250 |
|
|---|
| 1251 | TRACKBAR_AlignBuddies(hwnd,infoPtr);
|
|---|
| 1252 |
|
|---|
| 1253 | return (LRESULT)hwndTemp;
|
|---|
| 1254 | }
|
|---|
| 1255 |
|
|---|
| 1256 |
|
|---|
| 1257 | static LRESULT
|
|---|
| 1258 | TRACKBAR_SetLineSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1259 | {
|
|---|
| 1260 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1261 | INT nTemp = infoPtr->nLineSize;
|
|---|
| 1262 |
|
|---|
| 1263 | infoPtr->nLineSize = (INT)lParam;
|
|---|
| 1264 |
|
|---|
| 1265 | return nTemp;
|
|---|
| 1266 | }
|
|---|
| 1267 |
|
|---|
| 1268 |
|
|---|
| 1269 | static LRESULT
|
|---|
| 1270 | TRACKBAR_SetPageSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1271 | {
|
|---|
| 1272 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1273 | INT nTemp = infoPtr->nPageSize;
|
|---|
| 1274 |
|
|---|
| 1275 | infoPtr->nPageSize = (INT)lParam;
|
|---|
| 1276 |
|
|---|
| 1277 | return nTemp;
|
|---|
| 1278 | }
|
|---|
| 1279 |
|
|---|
| 1280 |
|
|---|
| 1281 | static LRESULT
|
|---|
| 1282 | TRACKBAR_SetPos (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1283 | {
|
|---|
| 1284 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1285 | INT lastPos = infoPtr->nPos;
|
|---|
| 1286 |
|
|---|
| 1287 | infoPtr->nPos = (INT)LOWORD(lParam);
|
|---|
| 1288 |
|
|---|
| 1289 | if (lastPos == infoPtr->nPos) return 0; //nothing changed
|
|---|
| 1290 |
|
|---|
| 1291 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
|---|
| 1292 | infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 1293 |
|
|---|
| 1294 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
|---|
| 1295 | infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 1296 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
|---|
| 1297 |
|
|---|
| 1298 | if (wParam) TRACKBAR_UpdateThumbPosition(hwnd,lastPos,FALSE);
|
|---|
| 1299 |
|
|---|
| 1300 | return 0;
|
|---|
| 1301 | }
|
|---|
| 1302 |
|
|---|
| 1303 |
|
|---|
| 1304 | static LRESULT
|
|---|
| 1305 | TRACKBAR_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1306 | {
|
|---|
| 1307 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1308 | int newMin,newMax;
|
|---|
| 1309 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 1310 |
|
|---|
| 1311 | newMin = (INT)LOWORD(lParam);
|
|---|
| 1312 | newMax = (INT)HIWORD(lParam);
|
|---|
| 1313 |
|
|---|
| 1314 | if (newMin == newMax) return 0;
|
|---|
| 1315 | if (newMin > newMax)
|
|---|
| 1316 | { //exchange
|
|---|
| 1317 | int x;
|
|---|
| 1318 |
|
|---|
| 1319 | x = newMin;
|
|---|
| 1320 | newMin = newMax;
|
|---|
| 1321 | newMax = x;
|
|---|
| 1322 | }
|
|---|
| 1323 | if ((newMin == infoPtr->nRangeMin) && (newMax == infoPtr->nRangeMax)) return 0;
|
|---|
| 1324 |
|
|---|
| 1325 | infoPtr->nRangeMin = newMin;
|
|---|
| 1326 | infoPtr->nRangeMax = newMax;
|
|---|
| 1327 |
|
|---|
| 1328 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
|---|
| 1329 | {
|
|---|
| 1330 | infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 1331 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
|---|
| 1332 | }
|
|---|
| 1333 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
|---|
| 1334 | {
|
|---|
| 1335 | infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 1336 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
|---|
| 1337 | }
|
|---|
| 1338 |
|
|---|
| 1339 | if (infoPtr->nSelMin < infoPtr->nRangeMin)
|
|---|
| 1340 | {
|
|---|
| 1341 | infoPtr->nSelMin = infoPtr->nRangeMin;
|
|---|
| 1342 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1343 | }
|
|---|
| 1344 | if (infoPtr->nSelMin > infoPtr->nRangeMax)
|
|---|
| 1345 | {
|
|---|
| 1346 | infoPtr->nSelMin = infoPtr->nRangeMax;
|
|---|
| 1347 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1348 | }
|
|---|
| 1349 | if (infoPtr->nSelMax < infoPtr->nRangeMin)
|
|---|
| 1350 | {
|
|---|
| 1351 | infoPtr->nSelMax = infoPtr->nRangeMin;
|
|---|
| 1352 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1353 | }
|
|---|
| 1354 | if (infoPtr->nSelMax > infoPtr->nRangeMax)
|
|---|
| 1355 | {
|
|---|
| 1356 | infoPtr->nSelMax = infoPtr->nRangeMax;
|
|---|
| 1357 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1358 | }
|
|---|
| 1359 |
|
|---|
| 1360 | infoPtr->nPageSize = (infoPtr->nRangeMax-infoPtr->nRangeMin)/5;
|
|---|
| 1361 | if (infoPtr->nPageSize == 0) infoPtr->nPageSize = 1;
|
|---|
| 1362 | TRACKBAR_RecalculateTics(hwnd,infoPtr,TRUE);
|
|---|
| 1363 |
|
|---|
| 1364 | if (wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1365 |
|
|---|
| 1366 | return 0;
|
|---|
| 1367 | }
|
|---|
| 1368 |
|
|---|
| 1369 |
|
|---|
| 1370 | static LRESULT
|
|---|
| 1371 | TRACKBAR_SetRangeMax (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1372 | {
|
|---|
| 1373 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1374 |
|
|---|
| 1375 | if ((INT)lParam <= infoPtr->nRangeMin) return 0;
|
|---|
| 1376 | if (infoPtr->nRangeMax == (INT)lParam) return 0;
|
|---|
| 1377 |
|
|---|
| 1378 | infoPtr->nRangeMax = (INT)lParam;
|
|---|
| 1379 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
|---|
| 1380 | {
|
|---|
| 1381 | infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 1382 | infoPtr->flags |=TB_THUMBPOSCHANGED;
|
|---|
| 1383 | }
|
|---|
| 1384 |
|
|---|
| 1385 | infoPtr->nPageSize = (infoPtr->nRangeMax-infoPtr->nRangeMin)/5;
|
|---|
| 1386 | if (infoPtr->nPageSize == 0) infoPtr->nPageSize = 1;
|
|---|
| 1387 | TRACKBAR_RecalculateTics(hwnd,infoPtr,TRUE);
|
|---|
| 1388 |
|
|---|
| 1389 | if (wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1390 |
|
|---|
| 1391 | return 0;
|
|---|
| 1392 | }
|
|---|
| 1393 |
|
|---|
| 1394 |
|
|---|
| 1395 | static LRESULT
|
|---|
| 1396 | TRACKBAR_SetRangeMin (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1397 | {
|
|---|
| 1398 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1399 |
|
|---|
| 1400 | if ((INT)lParam >= infoPtr->nRangeMax) return 0;
|
|---|
| 1401 | if (infoPtr->nRangeMin == (INT)lParam) return 0;
|
|---|
| 1402 |
|
|---|
| 1403 | infoPtr->nRangeMin = (INT)lParam;
|
|---|
| 1404 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
|---|
| 1405 | {
|
|---|
| 1406 | infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 1407 | infoPtr->flags |=TB_THUMBPOSCHANGED;
|
|---|
| 1408 | }
|
|---|
| 1409 |
|
|---|
| 1410 | infoPtr->nPageSize = (infoPtr->nRangeMax-infoPtr->nRangeMin)/5;
|
|---|
| 1411 | if (infoPtr->nPageSize == 0) infoPtr->nPageSize = 1;
|
|---|
| 1412 | TRACKBAR_RecalculateTics(hwnd,infoPtr,TRUE);
|
|---|
| 1413 |
|
|---|
| 1414 | if (wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1415 |
|
|---|
| 1416 | return 0;
|
|---|
| 1417 | }
|
|---|
| 1418 |
|
|---|
| 1419 |
|
|---|
| 1420 | static LRESULT
|
|---|
| 1421 | TRACKBAR_SetTicFreq (HWND hwnd, WPARAM wParam)
|
|---|
| 1422 | {
|
|---|
| 1423 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1424 |
|
|---|
| 1425 | if (infoPtr->uTicFreq == (UINT)wParam) return 0;
|
|---|
| 1426 |
|
|---|
| 1427 | if (!(GetWindowLongA(hwnd,GWL_STYLE) & TBS_AUTOTICKS)) return 0;
|
|---|
| 1428 |
|
|---|
| 1429 | infoPtr->uTicFreq = (UINT)wParam;
|
|---|
| 1430 |
|
|---|
| 1431 | TRACKBAR_RecalculateTics(hwnd,infoPtr,FALSE);
|
|---|
| 1432 |
|
|---|
| 1433 | TRACKBAR_Refresh(hwnd);
|
|---|
| 1434 |
|
|---|
| 1435 | return 0;
|
|---|
| 1436 | }
|
|---|
| 1437 |
|
|---|
| 1438 |
|
|---|
| 1439 | static LRESULT
|
|---|
| 1440 | TRACKBAR_SetSel(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
|---|
| 1441 | {
|
|---|
| 1442 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1443 | INT newMin,newMax,oldMin,oldMax;
|
|---|
| 1444 |
|
|---|
| 1445 | oldMin = infoPtr->nSelMin;
|
|---|
| 1446 | oldMax = infoPtr->nSelMax;
|
|---|
| 1447 | newMin = (INT)LOWORD(lParam);
|
|---|
| 1448 | newMax = (INT)HIWORD(lParam);
|
|---|
| 1449 |
|
|---|
| 1450 | if ((infoPtr->nSelMin == newMin) && (infoPtr->nSelMax == newMax)) return 0;
|
|---|
| 1451 | infoPtr->nSelMin = newMin;
|
|---|
| 1452 | infoPtr->nSelMax = newMax;
|
|---|
| 1453 |
|
|---|
| 1454 | if (infoPtr->nSelMin < infoPtr->nRangeMin) infoPtr->nSelMin = infoPtr->nRangeMin;
|
|---|
| 1455 | if (infoPtr->nSelMin > infoPtr->nRangeMax) infoPtr->nSelMin = infoPtr->nRangeMax;
|
|---|
| 1456 | if (infoPtr->nSelMax > infoPtr->nRangeMax) infoPtr->nSelMax = infoPtr->nRangeMax;
|
|---|
| 1457 | if (infoPtr->nSelMax < infoPtr->nRangeMin) infoPtr->nSelMax = infoPtr->nRangeMin;
|
|---|
| 1458 |
|
|---|
| 1459 | if (infoPtr->nSelMin > infoPtr->nSelMax) infoPtr->nSelMin = infoPtr->nSelMax;
|
|---|
| 1460 |
|
|---|
| 1461 | if (!GetWindowLongA(hwnd, GWL_STYLE) & TBS_ENABLESELRANGE) return 0;
|
|---|
| 1462 |
|
|---|
| 1463 | if ((oldMin != newMin) || (oldMax != newMax))
|
|---|
| 1464 | {
|
|---|
| 1465 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1466 | if (wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1467 | }
|
|---|
| 1468 |
|
|---|
| 1469 | return 0;
|
|---|
| 1470 | }
|
|---|
| 1471 |
|
|---|
| 1472 |
|
|---|
| 1473 | static LRESULT
|
|---|
| 1474 | TRACKBAR_SetSelEnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1475 | {
|
|---|
| 1476 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1477 | INT oldMax;
|
|---|
| 1478 |
|
|---|
| 1479 | if (infoPtr->nSelMax == (INT)lParam) return 0;
|
|---|
| 1480 |
|
|---|
| 1481 | oldMax = infoPtr->nSelMax;
|
|---|
| 1482 | infoPtr->nSelMax = (INT)lParam;
|
|---|
| 1483 |
|
|---|
| 1484 | if (infoPtr->nSelMax > infoPtr->nRangeMax) infoPtr->nSelMax = infoPtr->nRangeMax;
|
|---|
| 1485 | if (infoPtr->nSelMax < infoPtr->nRangeMin) infoPtr->nSelMax = infoPtr->nRangeMin;
|
|---|
| 1486 |
|
|---|
| 1487 | if (infoPtr->nSelMin > infoPtr->nSelMax) infoPtr->nSelMin = infoPtr->nSelMax;
|
|---|
| 1488 |
|
|---|
| 1489 | if (!GetWindowLongA(hwnd,GWL_STYLE) & TBS_ENABLESELRANGE) return 0;
|
|---|
| 1490 |
|
|---|
| 1491 | if (oldMax != infoPtr->nSelMax)
|
|---|
| 1492 | {
|
|---|
| 1493 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1494 | if (wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1495 | }
|
|---|
| 1496 |
|
|---|
| 1497 | return 0;
|
|---|
| 1498 | }
|
|---|
| 1499 |
|
|---|
| 1500 |
|
|---|
| 1501 | static LRESULT
|
|---|
| 1502 | TRACKBAR_SetSelStart (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1503 | {
|
|---|
| 1504 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1505 | INT oldMin;
|
|---|
| 1506 |
|
|---|
| 1507 | if (infoPtr->nSelMin == (INT)lParam) return 0;
|
|---|
| 1508 |
|
|---|
| 1509 | oldMin = infoPtr->nSelMin;
|
|---|
| 1510 | infoPtr->nSelMin = (INT)lParam;
|
|---|
| 1511 |
|
|---|
| 1512 | if (infoPtr->nSelMin < infoPtr->nRangeMin) infoPtr->nSelMin = infoPtr->nRangeMin;
|
|---|
| 1513 | if (infoPtr->nSelMin > infoPtr->nRangeMax) infoPtr->nSelMin = infoPtr->nRangeMax;
|
|---|
| 1514 |
|
|---|
| 1515 | if (infoPtr->nSelMin > infoPtr->nSelMax) infoPtr->nSelMin = infoPtr->nSelMax;
|
|---|
| 1516 |
|
|---|
| 1517 | if (!GetWindowLongA(hwnd,GWL_STYLE) & TBS_ENABLESELRANGE) return 0;
|
|---|
| 1518 |
|
|---|
| 1519 | if (oldMin != infoPtr->nSelMin)
|
|---|
| 1520 | {
|
|---|
| 1521 | infoPtr->flags |= TB_SELECTIONCHANGED;
|
|---|
| 1522 | if (wParam) TRACKBAR_Refresh(hwnd);
|
|---|
| 1523 | }
|
|---|
| 1524 |
|
|---|
| 1525 | return 0;
|
|---|
| 1526 | }
|
|---|
| 1527 |
|
|---|
| 1528 |
|
|---|
| 1529 | static LRESULT
|
|---|
| 1530 | TRACKBAR_SetThumbLength (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1531 | {
|
|---|
| 1532 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 1533 |
|
|---|
| 1534 | if (infoPtr->uThumbLen == (UINT)wParam) return 0;
|
|---|
| 1535 |
|
|---|
| 1536 | if (GetWindowLongA(hwnd,GWL_STYLE) & TBS_FIXEDLENGTH) return 0;
|
|---|
| 1537 |
|
|---|
| 1538 | infoPtr->uThumbLen = MAX((UINT)wParam,THUMB_MINLEN);
|
|---|
| 1539 | infoPtr->flags |= TB_THUMBSIZECHANGED | TB_THUMBCHANGED;
|
|---|
| 1540 |
|
|---|
| 1541 | TRACKBAR_Refresh(hwnd);
|
|---|
| 1542 |
|
|---|
| 1543 | return 0;
|
|---|
| 1544 | }
|
|---|
| 1545 |
|
|---|
| 1546 | static void TRACKBAR_QuickSort(LPLONG list,INT lo,INT hi)
|
|---|
| 1547 | {
|
|---|
| 1548 | INT i,j,x,y;
|
|---|
| 1549 |
|
|---|
| 1550 | i = lo;
|
|---|
| 1551 | j = hi;
|
|---|
| 1552 | x = list[(lo+hi)/2];
|
|---|
| 1553 | do
|
|---|
| 1554 | {
|
|---|
| 1555 | while (list[i] < x) i++;
|
|---|
| 1556 | while (x < list[j]) j--;
|
|---|
| 1557 | if (i <= j)
|
|---|
| 1558 | {
|
|---|
| 1559 | y = list[i];
|
|---|
| 1560 | list[i] = list[j];
|
|---|
| 1561 | list[j] = y;
|
|---|
| 1562 | i++;
|
|---|
| 1563 | j--;
|
|---|
| 1564 | }
|
|---|
| 1565 | } while (i <= j);
|
|---|
| 1566 | if (lo < j) TRACKBAR_QuickSort(list,lo,j);
|
|---|
| 1567 | if (i < hi) TRACKBAR_QuickSort(list,i,hi);
|
|---|
| 1568 | }
|
|---|
| 1569 |
|
|---|
| 1570 | static LRESULT
|
|---|
| 1571 | TRACKBAR_SetTic (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1572 | {
|
|---|
| 1573 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1574 | INT nPos = (INT)lParam;
|
|---|
| 1575 | INT x;
|
|---|
| 1576 |
|
|---|
| 1577 | if (!(GetWindowLongA(hwnd, GWL_STYLE) & (TBS_AUTOTICKS | TBS_NOTICKS))) return 0;
|
|---|
| 1578 |
|
|---|
| 1579 | if ((nPos < infoPtr->nRangeMin) || (nPos > infoPtr->nRangeMax)) return FALSE;
|
|---|
| 1580 |
|
|---|
| 1581 | //Check if tick exists
|
|---|
| 1582 | for (x = 0;x < infoPtr->uNumTics;x++)
|
|---|
| 1583 | {
|
|---|
| 1584 | if (infoPtr->tics[x] == nPos) return TRUE; //value is ok
|
|---|
| 1585 | }
|
|---|
| 1586 |
|
|---|
| 1587 | infoPtr->uNumTics++;
|
|---|
| 1588 | infoPtr->tics = (LONG*)COMCTL32_ReAlloc(infoPtr->tics,infoPtr->uNumTics*sizeof(DWORD));
|
|---|
| 1589 | infoPtr->tics[infoPtr->uNumTics-1] = nPos;
|
|---|
| 1590 |
|
|---|
| 1591 | //Quicksort the list
|
|---|
| 1592 | TRACKBAR_QuickSort(infoPtr->tics,0,infoPtr->uNumTics-1);
|
|---|
| 1593 |
|
|---|
| 1594 | TRACKBAR_Refresh(hwnd);
|
|---|
| 1595 |
|
|---|
| 1596 | return TRUE;
|
|---|
| 1597 | }
|
|---|
| 1598 |
|
|---|
| 1599 |
|
|---|
| 1600 | static LRESULT
|
|---|
| 1601 | TRACKBAR_SetTipSide (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1602 | {
|
|---|
| 1603 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 1604 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 1605 | INT fTemp = infoPtr->fLocation;
|
|---|
| 1606 |
|
|---|
| 1607 | if (dwStyle & TBS_VERT)
|
|---|
| 1608 | {
|
|---|
| 1609 | if ((wParam == TBTS_LEFT) || (wParam == TBTS_RIGHT)) infoPtr->fLocation = (INT)wParam;
|
|---|
| 1610 | } else
|
|---|
| 1611 | {
|
|---|
| 1612 | if ((wParam == TBTS_TOP) || (wParam == TBTS_BOTTOM)) infoPtr->fLocation = (INT)wParam;
|
|---|
| 1613 | }
|
|---|
| 1614 |
|
|---|
| 1615 | return fTemp;
|
|---|
| 1616 | }
|
|---|
| 1617 |
|
|---|
| 1618 |
|
|---|
| 1619 | static LRESULT
|
|---|
| 1620 | TRACKBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1621 | {
|
|---|
| 1622 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1623 |
|
|---|
| 1624 | infoPtr->hwndToolTip = (HWND)wParam;
|
|---|
| 1625 |
|
|---|
| 1626 | return 0;
|
|---|
| 1627 | }
|
|---|
| 1628 |
|
|---|
| 1629 | static LRESULT
|
|---|
| 1630 | TRACKBAR_InitializeThumb (HWND hwnd)
|
|---|
| 1631 | {
|
|---|
| 1632 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1633 | RECT clientRect;
|
|---|
| 1634 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 1635 | INT scaleSize;
|
|---|
| 1636 |
|
|---|
| 1637 | GetClientRect(hwnd,&clientRect);
|
|---|
| 1638 | infoPtr->uThumbLen = THUMB_LEN; /* initial thumb length */
|
|---|
| 1639 |
|
|---|
| 1640 | scaleSize = 2*BORDER_SIZE;
|
|---|
| 1641 | if (dwStyle & TBS_NOTICKS) scaleSize += 0;
|
|---|
| 1642 | else if (dwStyle & TBS_BOTH) scaleSize += 2*(SCALE_SIZE+SCALE_SPACE);
|
|---|
| 1643 | else scaleSize += SCALE_SIZE+SCALE_SPACE;
|
|---|
| 1644 |
|
|---|
| 1645 | if (dwStyle & TBS_VERT)
|
|---|
| 1646 | {
|
|---|
| 1647 | INT width = clientRect.right-clientRect.left;
|
|---|
| 1648 |
|
|---|
| 1649 | if (infoPtr->uThumbLen+scaleSize > width) infoPtr->uThumbLen = MAX(width-scaleSize,THUMB_MINLEN);
|
|---|
| 1650 | } else
|
|---|
| 1651 | {
|
|---|
| 1652 | INT height = clientRect.bottom-clientRect.top;
|
|---|
| 1653 |
|
|---|
| 1654 | if (infoPtr->uThumbLen+scaleSize > height) infoPtr->uThumbLen = MAX(height-scaleSize,THUMB_MINLEN);
|
|---|
| 1655 | }
|
|---|
| 1656 |
|
|---|
| 1657 | TRACKBAR_CalcChannel(hwnd,infoPtr);
|
|---|
| 1658 | TRACKBAR_CalcThumb(hwnd,infoPtr);
|
|---|
| 1659 |
|
|---|
| 1660 | infoPtr->flags &= ~TB_SELECTIONCHANGED;
|
|---|
| 1661 |
|
|---|
| 1662 | return 0;
|
|---|
| 1663 | }
|
|---|
| 1664 |
|
|---|
| 1665 |
|
|---|
| 1666 | static LRESULT
|
|---|
| 1667 | TRACKBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1668 | {
|
|---|
| 1669 | TRACKBAR_INFO *infoPtr;
|
|---|
| 1670 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 1671 |
|
|---|
| 1672 | infoPtr = (TRACKBAR_INFO*)initControl(hwnd,sizeof(TRACKBAR_INFO));
|
|---|
| 1673 |
|
|---|
| 1674 | /* set default values */
|
|---|
| 1675 | infoPtr->nRangeMin = 0;
|
|---|
| 1676 | infoPtr->nRangeMax = 100;
|
|---|
| 1677 | infoPtr->nLineSize = 1;
|
|---|
| 1678 | infoPtr->nPageSize = 20;
|
|---|
| 1679 | infoPtr->nSelMin = 0;
|
|---|
| 1680 | infoPtr->nSelMax = 0;
|
|---|
| 1681 | infoPtr->nPos = 0;
|
|---|
| 1682 |
|
|---|
| 1683 | infoPtr->uNumTics = 0; /* start and end tic are not included in count*/
|
|---|
| 1684 | infoPtr->uTicFreq = 1;
|
|---|
| 1685 | infoPtr->tics = NULL;
|
|---|
| 1686 | infoPtr->clrBk = GetSysColor(COLOR_3DFACE);
|
|---|
| 1687 |
|
|---|
| 1688 | infoPtr->hwndBuddyLA = 0;
|
|---|
| 1689 | infoPtr->hwndBuddyRB = 0;
|
|---|
| 1690 | infoPtr->flags = 0;
|
|---|
| 1691 | infoPtr->bFocus = FALSE;
|
|---|
| 1692 |
|
|---|
| 1693 | if (dwStyle & TBS_VERT)
|
|---|
| 1694 | {
|
|---|
| 1695 | infoPtr->fLocation = (dwStyle & TBS_LEFT) ? TBTS_RIGHT : TBTS_LEFT;
|
|---|
| 1696 | } else
|
|---|
| 1697 | {
|
|---|
| 1698 | infoPtr->fLocation = (dwStyle & TBS_TOP) ? TBTS_BOTTOM : TBTS_TOP;
|
|---|
| 1699 | }
|
|---|
| 1700 |
|
|---|
| 1701 | TRACKBAR_InitializeThumb (hwnd);
|
|---|
| 1702 |
|
|---|
| 1703 | /* Create tooltip control */
|
|---|
| 1704 | if (dwStyle & TBS_TOOLTIPS)
|
|---|
| 1705 | {
|
|---|
| 1706 | UINT uFlags = TTF_TRACK | TTF_ABSOLUTE;
|
|---|
| 1707 |
|
|---|
| 1708 | if (dwStyle & TBS_VERT)
|
|---|
| 1709 | if (infoPtr->fLocation == TBTS_RIGHT)
|
|---|
| 1710 | uFlags |= TTF_ALIGNRIGHT | TTF_VCENTER;
|
|---|
| 1711 | else
|
|---|
| 1712 | uFlags |= TTF_ALIGNLEFT | TTF_VCENTER;
|
|---|
| 1713 | else
|
|---|
| 1714 | if (infoPtr->fLocation == TBTS_TOP)
|
|---|
| 1715 | uFlags |= TTF_ALIGNTOP | TTF_HCENTER;
|
|---|
| 1716 | else
|
|---|
| 1717 | uFlags |= TTF_ALIGNBOTTOM | TTF_HCENTER;
|
|---|
| 1718 |
|
|---|
| 1719 | infoPtr->hwndToolTip = createToolTip(hwnd,uFlags,TRUE);
|
|---|
| 1720 | }
|
|---|
| 1721 |
|
|---|
| 1722 | return 0;
|
|---|
| 1723 | }
|
|---|
| 1724 |
|
|---|
| 1725 |
|
|---|
| 1726 | static LRESULT
|
|---|
| 1727 | TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1728 | {
|
|---|
| 1729 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1730 |
|
|---|
| 1731 | /* delete tooltip control */
|
|---|
| 1732 | destroyToolTip(infoPtr->hwndToolTip);
|
|---|
| 1733 |
|
|---|
| 1734 | COMCTL32_Free(infoPtr->tics);
|
|---|
| 1735 | doneControl(hwnd);
|
|---|
| 1736 |
|
|---|
| 1737 | return 0;
|
|---|
| 1738 | }
|
|---|
| 1739 |
|
|---|
| 1740 | static VOID TRACKBAR_CalcToolTipPos(HWND hwnd,DWORD dwStyle,TRACKBAR_INFO *infoPtr,POINT *pt)
|
|---|
| 1741 | {
|
|---|
| 1742 | if (dwStyle & TBS_VERT)
|
|---|
| 1743 | {
|
|---|
| 1744 | if (infoPtr->fLocation == TBTS_RIGHT)
|
|---|
| 1745 | {
|
|---|
| 1746 | pt->x = infoPtr->rcFullThumb.right+TOOLTIP_SPACE;
|
|---|
| 1747 | pt->y = infoPtr->rcFullThumb.top+(infoPtr->rcFullThumb.bottom-infoPtr->rcFullThumb.top)/2;
|
|---|
| 1748 | } else
|
|---|
| 1749 | {
|
|---|
| 1750 | pt->x = infoPtr->rcFullThumb.left-TOOLTIP_SPACE;
|
|---|
| 1751 | pt->y = infoPtr->rcFullThumb.top+(infoPtr->rcFullThumb.bottom-infoPtr->rcFullThumb.top)/2;
|
|---|
| 1752 | }
|
|---|
| 1753 |
|
|---|
| 1754 | } else
|
|---|
| 1755 | {
|
|---|
| 1756 | if (infoPtr->fLocation == TBTS_TOP)
|
|---|
| 1757 | {
|
|---|
| 1758 | pt->x = infoPtr->rcFullThumb.left+(infoPtr->rcFullThumb.right-infoPtr->rcFullThumb.left)/2;
|
|---|
| 1759 | pt->y = infoPtr->rcFullThumb.top-TOOLTIP_SPACE;
|
|---|
| 1760 | } else
|
|---|
| 1761 | {
|
|---|
| 1762 | pt->x = infoPtr->rcFullThumb.left+(infoPtr->rcFullThumb.right-infoPtr->rcFullThumb.left)/2;
|
|---|
| 1763 | pt->y = infoPtr->rcFullThumb.bottom+TOOLTIP_SPACE;
|
|---|
| 1764 | }
|
|---|
| 1765 | }
|
|---|
| 1766 | ClientToScreen(hwnd,pt);
|
|---|
| 1767 | }
|
|---|
| 1768 |
|
|---|
| 1769 | static LRESULT
|
|---|
| 1770 | TRACKBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1771 | {
|
|---|
| 1772 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1773 | DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
|
|---|
| 1774 | int clickPlace,prevPos,vertical;
|
|---|
| 1775 | DOUBLE clickPos;
|
|---|
| 1776 | RECT thumb,fullThumb;
|
|---|
| 1777 | POINT clickPoint;
|
|---|
| 1778 |
|
|---|
| 1779 | SetFocus (hwnd);
|
|---|
| 1780 |
|
|---|
| 1781 | vertical = dwStyle & TBS_VERT;
|
|---|
| 1782 | clickPoint.x = (INT)LOWORD(lParam);
|
|---|
| 1783 | clickPoint.y = (INT)HIWORD(lParam);
|
|---|
| 1784 |
|
|---|
| 1785 |
|
|---|
| 1786 | if (vertical) clickPlace = clickPoint.y;
|
|---|
| 1787 | else clickPlace = clickPoint.x;
|
|---|
| 1788 |
|
|---|
| 1789 | //Button down on thumb?
|
|---|
| 1790 | thumb = infoPtr->rcThumb;
|
|---|
| 1791 | fullThumb = infoPtr->rcFullThumb;
|
|---|
| 1792 | if ((vertical &&
|
|---|
| 1793 | (clickPoint.y >= thumb.top) &&
|
|---|
| 1794 | (clickPoint.y <= thumb.bottom) &&
|
|---|
| 1795 | (((dwStyle & TBS_BOTH) &&
|
|---|
| 1796 | (clickPoint.x >= thumb.left) &&
|
|---|
| 1797 | (clickPoint.x <= thumb.right)
|
|---|
| 1798 | ) ||
|
|---|
| 1799 | ((dwStyle & TBS_LEFT) &&
|
|---|
| 1800 | (clickPoint.x <= thumb.right) &&
|
|---|
| 1801 | ((clickPoint.x >= thumb.left) ||
|
|---|
| 1802 | ((clickPoint.x >= fullThumb.left) &&
|
|---|
| 1803 | ((thumb.left-clickPoint.x <= clickPoint.y-thumb.top) &&
|
|---|
| 1804 | (thumb.left-clickPoint.x <= thumb.bottom-clickPoint.y)
|
|---|
| 1805 | )
|
|---|
| 1806 | )
|
|---|
| 1807 | )
|
|---|
| 1808 | ) ||
|
|---|
| 1809 | (!(dwStyle & (TBS_BOTH | TBS_LEFT)) &&
|
|---|
| 1810 | (clickPoint.x >= thumb.left) &&
|
|---|
| 1811 | ((clickPoint.x <= thumb.right) ||
|
|---|
| 1812 | ((clickPoint.x <= fullThumb.right) &&
|
|---|
| 1813 | ((clickPoint.x-thumb.right <= clickPoint.y-thumb.top) &&
|
|---|
| 1814 | (clickPoint.x-thumb.right <= thumb.bottom-clickPoint.y)
|
|---|
| 1815 | )
|
|---|
| 1816 | )
|
|---|
| 1817 | )
|
|---|
| 1818 | ))
|
|---|
| 1819 | ) ||
|
|---|
| 1820 | (!vertical &&
|
|---|
| 1821 | (clickPoint.x >= thumb.left) &&
|
|---|
| 1822 | (clickPoint.x <= thumb.right) &&
|
|---|
| 1823 | (((dwStyle & TBS_BOTH) &&
|
|---|
| 1824 | (clickPoint.y >= thumb.top) &&
|
|---|
| 1825 | (clickPoint.y <= thumb.bottom)
|
|---|
| 1826 | ) ||
|
|---|
| 1827 | ((dwStyle & TBS_TOP) &&
|
|---|
| 1828 | (clickPoint.y <= thumb.bottom) &&
|
|---|
| 1829 | ((clickPoint.y >= thumb.top) ||
|
|---|
| 1830 | ((clickPoint.y >= fullThumb.top) &&
|
|---|
| 1831 | ((thumb.top-clickPoint.y <= clickPoint.x-thumb.left) &&
|
|---|
| 1832 | (thumb.top-clickPoint.y <= thumb.right-clickPoint.x)
|
|---|
| 1833 | )
|
|---|
| 1834 | )
|
|---|
| 1835 | )
|
|---|
| 1836 | ) ||
|
|---|
| 1837 | (!(dwStyle & (TBS_BOTH | TBS_TOP)) &&
|
|---|
| 1838 | (clickPoint.y >= thumb.top) &&
|
|---|
| 1839 | ((clickPoint.y <= thumb.bottom) ||
|
|---|
| 1840 | ((clickPoint.y <= fullThumb.bottom) &&
|
|---|
| 1841 | ((clickPoint.y-thumb.bottom <= clickPoint.x-thumb.left) &&
|
|---|
| 1842 | (clickPoint.y-thumb.bottom <= thumb.right-clickPoint.x)
|
|---|
| 1843 | )
|
|---|
| 1844 | )
|
|---|
| 1845 | )
|
|---|
| 1846 | ))
|
|---|
| 1847 | ))
|
|---|
| 1848 | {
|
|---|
| 1849 | infoPtr->flags |= TB_DRAG_MODE;
|
|---|
| 1850 | if (dwStyle & TBS_TOOLTIPS)
|
|---|
| 1851 | { /* enable tooltip */
|
|---|
| 1852 | TTTOOLINFOA ti;
|
|---|
| 1853 | POINT pt;
|
|---|
| 1854 | char buf[80];
|
|---|
| 1855 |
|
|---|
| 1856 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 1857 | ti.uId = 0;
|
|---|
| 1858 | ti.hwnd = (UINT)hwnd;
|
|---|
| 1859 | ti.hinst = 0;
|
|---|
| 1860 | sprintf (buf,"%d",infoPtr->nPos);
|
|---|
| 1861 | ti.lpszText = (LPSTR)buf;
|
|---|
| 1862 |
|
|---|
| 1863 | infoPtr->flags |= TB_SHOW_TOOLTIP;
|
|---|
| 1864 | SetCapture(hwnd);
|
|---|
| 1865 |
|
|---|
| 1866 | SendMessageA(infoPtr->hwndToolTip,TTM_UPDATETIPTEXTA,0,(LPARAM)&ti);
|
|---|
| 1867 | TRACKBAR_CalcToolTipPos(hwnd,dwStyle,infoPtr,&pt);
|
|---|
| 1868 | SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x,pt.y));
|
|---|
| 1869 |
|
|---|
| 1870 | SendMessageA(infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)TRUE,(LPARAM)&ti);
|
|---|
| 1871 | }
|
|---|
| 1872 | SetCapture(hwnd);
|
|---|
| 1873 | TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos,TRUE); //change arrow color
|
|---|
| 1874 | return 0;
|
|---|
| 1875 | }
|
|---|
| 1876 | else if ((vertical &&
|
|---|
| 1877 | (clickPoint.y >= thumb.top) &&
|
|---|
| 1878 | (clickPoint.y <= thumb.bottom)) ||
|
|---|
| 1879 | (!vertical &&
|
|---|
| 1880 | (clickPoint.x >= thumb.left) &&
|
|---|
| 1881 | (clickPoint.x <= thumb.right)))
|
|---|
| 1882 | {
|
|---|
| 1883 | //ScrollMode
|
|---|
| 1884 | infoPtr->flags |= TB_SCROLL_MODE;
|
|---|
| 1885 | SetCapture(hwnd);
|
|---|
| 1886 | SetTimer(hwnd,SCROLL_TIMER_ID,SCROLL_TIME,NULL);
|
|---|
| 1887 |
|
|---|
| 1888 | return 0;
|
|---|
| 1889 | }
|
|---|
| 1890 |
|
|---|
| 1891 | clickPos = TRACKBAR_ConvertPlaceToPosition(infoPtr,clickPlace,vertical);
|
|---|
| 1892 | prevPos = infoPtr->nPos;
|
|---|
| 1893 |
|
|---|
| 1894 | if (clickPos > prevPos)
|
|---|
| 1895 | { /* similar to VK_NEXT */
|
|---|
| 1896 | infoPtr->nPos += infoPtr->nPageSize;
|
|---|
| 1897 | if (infoPtr->nPos > infoPtr->nRangeMax) infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 1898 | if (prevPos != infoPtr->nPos) TRACKBAR_SendNotify(hwnd,TB_PAGEUP);
|
|---|
| 1899 | } else
|
|---|
| 1900 | { /* similar to VK_PRIOR */
|
|---|
| 1901 | infoPtr->nPos -= infoPtr->nPageSize;
|
|---|
| 1902 | if (infoPtr->nPos < infoPtr->nRangeMin) infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 1903 | if (prevPos != infoPtr->nPos) TRACKBAR_SendNotify(hwnd,TB_PAGEDOWN);
|
|---|
| 1904 | }
|
|---|
| 1905 |
|
|---|
| 1906 | if (prevPos != infoPtr->nPos)
|
|---|
| 1907 | {
|
|---|
| 1908 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
|---|
| 1909 | TRACKBAR_UpdateThumbPosition(hwnd,prevPos,TRUE);
|
|---|
| 1910 | }
|
|---|
| 1911 |
|
|---|
| 1912 | //ScrollMode
|
|---|
| 1913 | infoPtr->flags |= TB_SCROLL_MODE;
|
|---|
| 1914 | SetCapture(hwnd);
|
|---|
| 1915 | SetTimer(hwnd,SCROLL_TIMER_ID,SCROLL_TIME,NULL);
|
|---|
| 1916 |
|
|---|
| 1917 | return 0;
|
|---|
| 1918 | }
|
|---|
| 1919 |
|
|---|
| 1920 |
|
|---|
| 1921 | static LRESULT
|
|---|
| 1922 | TRACKBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 1923 | {
|
|---|
| 1924 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 1925 |
|
|---|
| 1926 | if (infoPtr->flags & TB_DRAG_MODE)
|
|---|
| 1927 | {
|
|---|
| 1928 | TRACKBAR_SendNotify(hwnd,TB_ENDTRACK);
|
|---|
| 1929 |
|
|---|
| 1930 | infoPtr->flags &= ~TB_DRAG_MODE;
|
|---|
| 1931 |
|
|---|
| 1932 | if (GetCapture() == hwnd)
|
|---|
| 1933 | {
|
|---|
| 1934 | sendNotify(hwnd,NM_RELEASEDCAPTURE);
|
|---|
| 1935 |
|
|---|
| 1936 | ReleaseCapture();
|
|---|
| 1937 | }
|
|---|
| 1938 |
|
|---|
| 1939 | TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos,TRUE); //change arrow color
|
|---|
| 1940 | }
|
|---|
| 1941 |
|
|---|
| 1942 | if (infoPtr->flags & TB_SCROLL_MODE)
|
|---|
| 1943 | {
|
|---|
| 1944 | infoPtr->flags &= ~TB_SCROLL_MODE;
|
|---|
| 1945 |
|
|---|
| 1946 | if (GetCapture() == hwnd)
|
|---|
| 1947 | {
|
|---|
| 1948 | sendNotify(hwnd,NM_RELEASEDCAPTURE);
|
|---|
| 1949 |
|
|---|
| 1950 | ReleaseCapture();
|
|---|
| 1951 | }
|
|---|
| 1952 |
|
|---|
| 1953 | KillTimer(hwnd,SCROLL_TIMER_ID);
|
|---|
| 1954 | }
|
|---|
| 1955 |
|
|---|
| 1956 | if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS)
|
|---|
| 1957 | { /* disable tooltip */
|
|---|
| 1958 | TTTOOLINFOA ti;
|
|---|
| 1959 |
|
|---|
| 1960 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 1961 | ti.uId = 0;
|
|---|
| 1962 | ti.hwnd = (UINT)hwnd;
|
|---|
| 1963 |
|
|---|
| 1964 | infoPtr->flags &= ~TB_SHOW_TOOLTIP;
|
|---|
| 1965 | SendMessageA (infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)FALSE,(LPARAM)&ti);
|
|---|
| 1966 | }
|
|---|
| 1967 |
|
|---|
| 1968 | return 0;
|
|---|
| 1969 | }
|
|---|
| 1970 |
|
|---|
| 1971 |
|
|---|
| 1972 | static LRESULT TRACKBAR_Timer(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
|---|
| 1973 | {
|
|---|
| 1974 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 1975 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 1976 | POINT mousePoint;
|
|---|
| 1977 | INT mousePlace,prevPos,newPos,vertical;
|
|---|
| 1978 | DOUBLE mousePos;
|
|---|
| 1979 |
|
|---|
| 1980 | GetCursorPos(&mousePoint);
|
|---|
| 1981 | ScreenToClient(hwnd,&mousePoint);
|
|---|
| 1982 |
|
|---|
| 1983 | vertical = dwStyle & TBS_VERT;
|
|---|
| 1984 | if (vertical) mousePlace = mousePoint.y;
|
|---|
| 1985 | else mousePlace = mousePoint.x;
|
|---|
| 1986 |
|
|---|
| 1987 | mousePos = TRACKBAR_ConvertPlaceToPosition(infoPtr,mousePlace,vertical);
|
|---|
| 1988 | prevPos = infoPtr->nPos;
|
|---|
| 1989 |
|
|---|
| 1990 | if (mousePos > (INT)mousePos+0.5) newPos = mousePos+1;
|
|---|
| 1991 | else newPos = mousePos;
|
|---|
| 1992 | if (newPos == prevPos) return 0;
|
|---|
| 1993 |
|
|---|
| 1994 | if (newPos > prevPos)
|
|---|
| 1995 | { /* similar to VK_NEXT */
|
|---|
| 1996 | infoPtr->nPos += infoPtr->nPageSize;
|
|---|
| 1997 | if (infoPtr->nPos > infoPtr->nRangeMax) infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 1998 | if (prevPos != infoPtr->nPos) TRACKBAR_SendNotify(hwnd,TB_PAGEUP);
|
|---|
| 1999 | } else
|
|---|
| 2000 | { /* similar to VK_PRIOR */
|
|---|
| 2001 | infoPtr->nPos -= infoPtr->nPageSize;
|
|---|
| 2002 | if (infoPtr->nPos < infoPtr->nRangeMin) infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 2003 | if (prevPos != infoPtr->nPos) TRACKBAR_SendNotify(hwnd,TB_PAGEDOWN);
|
|---|
| 2004 | }
|
|---|
| 2005 |
|
|---|
| 2006 | if (prevPos != infoPtr->nPos)
|
|---|
| 2007 | {
|
|---|
| 2008 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
|---|
| 2009 | TRACKBAR_UpdateThumbPosition(hwnd,prevPos,FALSE);
|
|---|
| 2010 | }
|
|---|
| 2011 |
|
|---|
| 2012 | return 0;
|
|---|
| 2013 | }
|
|---|
| 2014 |
|
|---|
| 2015 | static LRESULT
|
|---|
| 2016 | TRACKBAR_SetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
|---|
| 2017 | {
|
|---|
| 2018 | //wParam = new format
|
|---|
| 2019 |
|
|---|
| 2020 | return FALSE; //previous was no Unicode
|
|---|
| 2021 | }
|
|---|
| 2022 |
|
|---|
| 2023 | static LRESULT
|
|---|
| 2024 | TRACKBAR_CaptureChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2025 | {
|
|---|
| 2026 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 2027 |
|
|---|
| 2028 | if (infoPtr->flags & TB_DRAGPOSVALID)
|
|---|
| 2029 | {
|
|---|
| 2030 | int lastPos = infoPtr->nPos;
|
|---|
| 2031 | infoPtr->nPos = infoPtr->dragPos;
|
|---|
| 2032 | if (lastPos != infoPtr->nPos) TRACKBAR_UpdateThumbPosition(hwnd,lastPos,TRUE);
|
|---|
| 2033 | }
|
|---|
| 2034 |
|
|---|
| 2035 | infoPtr->flags &= ~ TB_DRAGPOSVALID;
|
|---|
| 2036 |
|
|---|
| 2037 | if (infoPtr->flags & TB_SCROLL_MODE)
|
|---|
| 2038 | {
|
|---|
| 2039 | infoPtr->flags &= ~TB_SCROLL_MODE;
|
|---|
| 2040 | KillTimer(hwnd,SCROLL_TIMER_ID);
|
|---|
| 2041 | }
|
|---|
| 2042 |
|
|---|
| 2043 | TRACKBAR_SendNotify(hwnd,TB_ENDTRACK);
|
|---|
| 2044 | return 0;
|
|---|
| 2045 | }
|
|---|
| 2046 |
|
|---|
| 2047 |
|
|---|
| 2048 | static LRESULT
|
|---|
| 2049 | TRACKBAR_Paint (HWND hwnd, WPARAM wParam)
|
|---|
| 2050 | {
|
|---|
| 2051 | HDC hdc;
|
|---|
| 2052 | PAINTSTRUCT ps;
|
|---|
| 2053 |
|
|---|
| 2054 | hdc = wParam == 0 ? BeginPaint(hwnd,&ps) : (HDC)wParam;
|
|---|
| 2055 | TRACKBAR_Draw(hwnd,hdc);
|
|---|
| 2056 | if (!wParam) EndPaint(hwnd,&ps);
|
|---|
| 2057 | return 0;
|
|---|
| 2058 | }
|
|---|
| 2059 |
|
|---|
| 2060 |
|
|---|
| 2061 | static LRESULT
|
|---|
| 2062 | TRACKBAR_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2063 | {
|
|---|
| 2064 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 2065 | HDC hdc;
|
|---|
| 2066 | RECT rcClient;
|
|---|
| 2067 |
|
|---|
| 2068 | // TRACE (trackbar,"\n");
|
|---|
| 2069 | if (!infoPtr->bFocus && IsWindowEnabled(hwnd))
|
|---|
| 2070 | {
|
|---|
| 2071 | infoPtr->bFocus = TRUE;
|
|---|
| 2072 |
|
|---|
| 2073 | GetClientRect (hwnd,&rcClient);
|
|---|
| 2074 | hdc = GetDC (hwnd);
|
|---|
| 2075 | DrawFocusRect (hdc,&rcClient);
|
|---|
| 2076 | ReleaseDC(hwnd,hdc);
|
|---|
| 2077 |
|
|---|
| 2078 | }
|
|---|
| 2079 | return 0;
|
|---|
| 2080 | }
|
|---|
| 2081 |
|
|---|
| 2082 | static LRESULT
|
|---|
| 2083 | TRACKBAR_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2084 | {
|
|---|
| 2085 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 2086 | HDC hdc;
|
|---|
| 2087 | RECT rcClient;
|
|---|
| 2088 |
|
|---|
| 2089 | // TRACE (trackbar,"\n");
|
|---|
| 2090 |
|
|---|
| 2091 | infoPtr->flags &= ~TB_DRAG_MODE;
|
|---|
| 2092 | if (infoPtr->bFocus && IsWindowEnabled(hwnd))
|
|---|
| 2093 | {
|
|---|
| 2094 | infoPtr->bFocus = FALSE;
|
|---|
| 2095 |
|
|---|
| 2096 | GetClientRect(hwnd,&rcClient);
|
|---|
| 2097 | hdc = GetDC (hwnd);
|
|---|
| 2098 | DrawFocusRect(hdc,&rcClient); //XOR removes
|
|---|
| 2099 | ReleaseDC(hwnd,hdc);
|
|---|
| 2100 | }
|
|---|
| 2101 |
|
|---|
| 2102 | return 0;
|
|---|
| 2103 | }
|
|---|
| 2104 |
|
|---|
| 2105 | static LRESULT
|
|---|
| 2106 | TRACKBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2107 | {
|
|---|
| 2108 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 2109 |
|
|---|
| 2110 | TRACKBAR_CalcChannel (hwnd, infoPtr);
|
|---|
| 2111 | TRACKBAR_AlignBuddies (hwnd, infoPtr);
|
|---|
| 2112 |
|
|---|
| 2113 | return 0;
|
|---|
| 2114 | }
|
|---|
| 2115 |
|
|---|
| 2116 |
|
|---|
| 2117 | static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code)
|
|---|
| 2118 | {
|
|---|
| 2119 | if (GetWindowLongA(hwnd, GWL_STYLE) & TBS_VERT)
|
|---|
| 2120 | return sendVScroll(hwnd,code);
|
|---|
| 2121 | else
|
|---|
| 2122 | return sendHScroll(hwnd,code);
|
|---|
| 2123 | }
|
|---|
| 2124 |
|
|---|
| 2125 |
|
|---|
| 2126 | static LRESULT
|
|---|
| 2127 | TRACKBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2128 | {
|
|---|
| 2129 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
|
|---|
| 2130 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
|---|
| 2131 | SHORT clickPlace;
|
|---|
| 2132 | DOUBLE dragPos;
|
|---|
| 2133 |
|
|---|
| 2134 | if (!(infoPtr->flags & TB_DRAG_MODE)) return TRUE;
|
|---|
| 2135 |
|
|---|
| 2136 | if (dwStyle & TBS_VERT) clickPlace = (SHORT)HIWORD(lParam);
|
|---|
| 2137 | else clickPlace = (SHORT)LOWORD(lParam);
|
|---|
| 2138 |
|
|---|
| 2139 | dragPos = TRACKBAR_ConvertPlaceToPosition(infoPtr,clickPlace,dwStyle & TBS_VERT);
|
|---|
| 2140 | if (dragPos > ((INT)dragPos)+0.5) infoPtr->dragPos = dragPos + 1;
|
|---|
| 2141 | else infoPtr->dragPos = dragPos;
|
|---|
| 2142 |
|
|---|
| 2143 | if (infoPtr->nPos == infoPtr->dragPos) return TRUE; //nothing changed
|
|---|
| 2144 |
|
|---|
| 2145 | infoPtr->flags |= TB_DRAGPOSVALID;
|
|---|
| 2146 |
|
|---|
| 2147 | TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos,FALSE); //infoPtr->nPos now set
|
|---|
| 2148 |
|
|---|
| 2149 | TRACKBAR_SendNotify(hwnd,TB_THUMBTRACK | (infoPtr->nPos << 16));
|
|---|
| 2150 |
|
|---|
| 2151 | if (infoPtr->flags & TB_SHOW_TOOLTIP)
|
|---|
| 2152 | {
|
|---|
| 2153 | POINT pt;
|
|---|
| 2154 | TTTOOLINFOA ti;
|
|---|
| 2155 | char buf[80];
|
|---|
| 2156 |
|
|---|
| 2157 | ti.cbSize = sizeof(TTTOOLINFOA);
|
|---|
| 2158 | ti.hwnd = hwnd;
|
|---|
| 2159 | ti.uId = 0;
|
|---|
| 2160 | ti.hinst = 0;
|
|---|
| 2161 | sprintf(buf,"%d",infoPtr->nPos);
|
|---|
| 2162 | ti.lpszText = (LPSTR)buf;
|
|---|
| 2163 |
|
|---|
| 2164 | SendMessageA(infoPtr->hwndToolTip,TTM_UPDATETIPTEXTA,0,(LPARAM)&ti);
|
|---|
| 2165 | TRACKBAR_CalcToolTipPos(hwnd,dwStyle,infoPtr,&pt);
|
|---|
| 2166 | SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x,pt.y));
|
|---|
| 2167 | }
|
|---|
| 2168 |
|
|---|
| 2169 | return 0;
|
|---|
| 2170 | }
|
|---|
| 2171 |
|
|---|
| 2172 | static LRESULT
|
|---|
| 2173 | TRACKBAR_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
|---|
| 2174 | {
|
|---|
| 2175 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 2176 | BOOL oldFocus = infoPtr->bFocus;
|
|---|
| 2177 |
|
|---|
| 2178 | if (wParam) infoPtr->bFocus = (GetFocus() == hwnd);
|
|---|
| 2179 | else infoPtr->bFocus = FALSE;
|
|---|
| 2180 |
|
|---|
| 2181 | if (oldFocus != infoPtr->bFocus) TRACKBAR_Refresh(hwnd);
|
|---|
| 2182 | else TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos,TRUE);
|
|---|
| 2183 |
|
|---|
| 2184 | return 0;
|
|---|
| 2185 | }
|
|---|
| 2186 |
|
|---|
| 2187 | static LRESULT
|
|---|
| 2188 | TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|---|
| 2189 | {
|
|---|
| 2190 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 2191 | INT pos;
|
|---|
| 2192 |
|
|---|
| 2193 | // TRACE (trackbar, "%x\n",wParam);
|
|---|
| 2194 |
|
|---|
| 2195 | if (infoPtr->flags & TB_DRAG_MODE) return TRUE;
|
|---|
| 2196 |
|
|---|
| 2197 | pos = infoPtr->nPos;
|
|---|
| 2198 | switch (wParam) {
|
|---|
| 2199 | case VK_LEFT:
|
|---|
| 2200 | case VK_UP:
|
|---|
| 2201 | if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
|
|---|
| 2202 | infoPtr->nPos -= infoPtr->nLineSize;
|
|---|
| 2203 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
|---|
| 2204 | infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 2205 | TRACKBAR_SendNotify(hwnd,TB_LINEUP);
|
|---|
| 2206 | break;
|
|---|
| 2207 | case VK_RIGHT:
|
|---|
| 2208 | case VK_DOWN:
|
|---|
| 2209 | if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
|
|---|
| 2210 | infoPtr->nPos += infoPtr->nLineSize;
|
|---|
| 2211 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
|---|
| 2212 | infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 2213 | TRACKBAR_SendNotify (hwnd, TB_LINEDOWN);
|
|---|
| 2214 | break;
|
|---|
| 2215 | case VK_NEXT:
|
|---|
| 2216 | if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
|
|---|
| 2217 | infoPtr->nPos += infoPtr->nPageSize;
|
|---|
| 2218 | if (infoPtr->nPos > infoPtr->nRangeMax)
|
|---|
| 2219 | infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 2220 | TRACKBAR_SendNotify (hwnd, TB_PAGEUP);
|
|---|
| 2221 | break;
|
|---|
| 2222 | case VK_PRIOR:
|
|---|
| 2223 | if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
|
|---|
| 2224 | infoPtr->nPos -= infoPtr->nPageSize;
|
|---|
| 2225 | if (infoPtr->nPos < infoPtr->nRangeMin)
|
|---|
| 2226 | infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 2227 | TRACKBAR_SendNotify (hwnd, TB_PAGEDOWN);
|
|---|
| 2228 | break;
|
|---|
| 2229 | case VK_HOME:
|
|---|
| 2230 | if (infoPtr->nPos == infoPtr->nRangeMin) return FALSE;
|
|---|
| 2231 | infoPtr->nPos = infoPtr->nRangeMin;
|
|---|
| 2232 | TRACKBAR_SendNotify (hwnd, TB_TOP);
|
|---|
| 2233 | break;
|
|---|
| 2234 | case VK_END:
|
|---|
| 2235 | if (infoPtr->nPos == infoPtr->nRangeMax) return FALSE;
|
|---|
| 2236 | infoPtr->nPos = infoPtr->nRangeMax;
|
|---|
| 2237 | TRACKBAR_SendNotify (hwnd, TB_BOTTOM);
|
|---|
| 2238 | break;
|
|---|
| 2239 | }
|
|---|
| 2240 |
|
|---|
| 2241 | if (pos != infoPtr->nPos)
|
|---|
| 2242 | {
|
|---|
| 2243 | infoPtr->flags |= TB_THUMBPOSCHANGED;
|
|---|
| 2244 | TRACKBAR_UpdateThumbPosition(hwnd,pos,FALSE);
|
|---|
| 2245 | }
|
|---|
| 2246 |
|
|---|
| 2247 | return TRUE;
|
|---|
| 2248 | }
|
|---|
| 2249 |
|
|---|
| 2250 |
|
|---|
| 2251 | static LRESULT
|
|---|
| 2252 | TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
|
|---|
| 2253 | {
|
|---|
| 2254 | TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
|
|---|
| 2255 |
|
|---|
| 2256 | if (infoPtr->flags & TB_DRAG_MODE) return TRUE;
|
|---|
| 2257 |
|
|---|
| 2258 | switch (wParam) {
|
|---|
| 2259 | case VK_LEFT:
|
|---|
| 2260 | case VK_UP:
|
|---|
| 2261 | case VK_RIGHT:
|
|---|
| 2262 | case VK_DOWN:
|
|---|
| 2263 | case VK_NEXT:
|
|---|
| 2264 | case VK_PRIOR:
|
|---|
| 2265 | case VK_HOME:
|
|---|
| 2266 | case VK_END:
|
|---|
| 2267 | TRACKBAR_SendNotify (hwnd, TB_ENDTRACK);
|
|---|
| 2268 | }
|
|---|
| 2269 | return TRUE;
|
|---|
| 2270 | }
|
|---|
| 2271 |
|
|---|
| 2272 |
|
|---|
| 2273 | static LRESULT WINAPI
|
|---|
| 2274 | TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|---|
| 2275 | {
|
|---|
| 2276 | switch (uMsg)
|
|---|
| 2277 | {
|
|---|
| 2278 | case TBM_CLEARSEL:
|
|---|
| 2279 | return TRACKBAR_ClearSel (hwnd, wParam, lParam);
|
|---|
| 2280 |
|
|---|
| 2281 | case TBM_CLEARTICS:
|
|---|
| 2282 | return TRACKBAR_ClearTics (hwnd, wParam, lParam);
|
|---|
| 2283 |
|
|---|
| 2284 | case TBM_GETBUDDY:
|
|---|
| 2285 | return TRACKBAR_GetBuddy (hwnd, wParam, lParam);
|
|---|
| 2286 |
|
|---|
| 2287 | case TBM_GETCHANNELRECT:
|
|---|
| 2288 | return TRACKBAR_GetChannelRect (hwnd, wParam, lParam);
|
|---|
| 2289 |
|
|---|
| 2290 | case TBM_GETLINESIZE:
|
|---|
| 2291 | return TRACKBAR_GetLineSize (hwnd, wParam, lParam);
|
|---|
| 2292 |
|
|---|
| 2293 | case TBM_GETNUMTICS:
|
|---|
| 2294 | return TRACKBAR_GetNumTics (hwnd, wParam, lParam);
|
|---|
| 2295 |
|
|---|
| 2296 | case TBM_GETPAGESIZE:
|
|---|
| 2297 | return TRACKBAR_GetPageSize (hwnd, wParam, lParam);
|
|---|
| 2298 |
|
|---|
| 2299 | case TBM_GETPOS:
|
|---|
| 2300 | return TRACKBAR_GetPos (hwnd, wParam, lParam);
|
|---|
| 2301 |
|
|---|
| 2302 | case TBM_GETPTICS:
|
|---|
| 2303 | return TRACKBAR_GetPTics (hwnd);
|
|---|
| 2304 |
|
|---|
| 2305 | case TBM_GETRANGEMAX:
|
|---|
| 2306 | return TRACKBAR_GetRangeMax (hwnd, wParam, lParam);
|
|---|
| 2307 |
|
|---|
| 2308 | case TBM_GETRANGEMIN:
|
|---|
| 2309 | return TRACKBAR_GetRangeMin (hwnd, wParam, lParam);
|
|---|
| 2310 |
|
|---|
| 2311 | case TBM_GETSELEND:
|
|---|
| 2312 | return TRACKBAR_GetSelEnd (hwnd, wParam, lParam);
|
|---|
| 2313 |
|
|---|
| 2314 | case TBM_GETSELSTART:
|
|---|
| 2315 | return TRACKBAR_GetSelStart (hwnd, wParam, lParam);
|
|---|
| 2316 |
|
|---|
| 2317 | case TBM_GETTHUMBLENGTH:
|
|---|
| 2318 | return TRACKBAR_GetThumbLength (hwnd, wParam, lParam);
|
|---|
| 2319 |
|
|---|
| 2320 | case TBM_GETTHUMBRECT:
|
|---|
| 2321 | return TRACKBAR_GetThumbRect (hwnd, wParam, lParam);
|
|---|
| 2322 |
|
|---|
| 2323 | case TBM_GETTIC:
|
|---|
| 2324 | return TRACKBAR_GetTic (hwnd, wParam, lParam);
|
|---|
| 2325 |
|
|---|
| 2326 | case TBM_GETTICPOS:
|
|---|
| 2327 | return TRACKBAR_GetTicPos (hwnd, wParam, lParam);
|
|---|
| 2328 |
|
|---|
| 2329 | case TBM_GETTOOLTIPS:
|
|---|
| 2330 | return TRACKBAR_GetToolTips (hwnd, wParam, lParam);
|
|---|
| 2331 |
|
|---|
| 2332 | case TBM_SETBUDDY:
|
|---|
| 2333 | return TRACKBAR_SetBuddy (hwnd, wParam, lParam);
|
|---|
| 2334 |
|
|---|
| 2335 | case TBM_SETLINESIZE:
|
|---|
| 2336 | return TRACKBAR_SetLineSize (hwnd, wParam, lParam);
|
|---|
| 2337 |
|
|---|
| 2338 | case TBM_SETPAGESIZE:
|
|---|
| 2339 | return TRACKBAR_SetPageSize (hwnd, wParam, lParam);
|
|---|
| 2340 |
|
|---|
| 2341 | case TBM_SETPOS:
|
|---|
| 2342 | return TRACKBAR_SetPos (hwnd, wParam, lParam);
|
|---|
| 2343 |
|
|---|
| 2344 | case TBM_SETRANGE:
|
|---|
| 2345 | return TRACKBAR_SetRange (hwnd, wParam, lParam);
|
|---|
| 2346 |
|
|---|
| 2347 | case TBM_SETRANGEMAX:
|
|---|
| 2348 | return TRACKBAR_SetRangeMax (hwnd, wParam, lParam);
|
|---|
| 2349 |
|
|---|
| 2350 | case TBM_SETRANGEMIN:
|
|---|
| 2351 | return TRACKBAR_SetRangeMin (hwnd, wParam, lParam);
|
|---|
| 2352 |
|
|---|
| 2353 | case TBM_SETSEL:
|
|---|
| 2354 | return TRACKBAR_SetSel (hwnd, wParam, lParam);
|
|---|
| 2355 |
|
|---|
| 2356 | case TBM_SETSELEND:
|
|---|
| 2357 | return TRACKBAR_SetSelEnd (hwnd, wParam, lParam);
|
|---|
| 2358 |
|
|---|
| 2359 | case TBM_SETSELSTART:
|
|---|
| 2360 | return TRACKBAR_SetSelStart (hwnd, wParam, lParam);
|
|---|
| 2361 |
|
|---|
| 2362 | case TBM_SETTHUMBLENGTH:
|
|---|
| 2363 | return TRACKBAR_SetThumbLength (hwnd, wParam, lParam);
|
|---|
| 2364 |
|
|---|
| 2365 | case TBM_SETTIC:
|
|---|
| 2366 | return TRACKBAR_SetTic (hwnd, wParam, lParam);
|
|---|
| 2367 |
|
|---|
| 2368 | case TBM_SETTICFREQ:
|
|---|
| 2369 | return TRACKBAR_SetTicFreq (hwnd, wParam);
|
|---|
| 2370 |
|
|---|
| 2371 | case TBM_SETTIPSIDE:
|
|---|
| 2372 | return TRACKBAR_SetTipSide (hwnd, wParam, lParam);
|
|---|
| 2373 |
|
|---|
| 2374 | case TBM_SETTOOLTIPS:
|
|---|
| 2375 | return TRACKBAR_SetToolTips (hwnd, wParam, lParam);
|
|---|
| 2376 |
|
|---|
| 2377 | case TBM_SETUNICODEFORMAT:
|
|---|
| 2378 | return TRACKBAR_SetUnicodeFormat(hwnd,wParam,lParam);
|
|---|
| 2379 |
|
|---|
| 2380 | case WM_CAPTURECHANGED:
|
|---|
| 2381 | return TRACKBAR_CaptureChanged (hwnd, wParam, lParam);
|
|---|
| 2382 |
|
|---|
| 2383 | case WM_CREATE:
|
|---|
| 2384 | return TRACKBAR_Create (hwnd, wParam, lParam);
|
|---|
| 2385 |
|
|---|
| 2386 | case WM_DESTROY:
|
|---|
| 2387 | return TRACKBAR_Destroy (hwnd, wParam, lParam);
|
|---|
| 2388 |
|
|---|
| 2389 | case WM_ENABLE:
|
|---|
| 2390 | return TRACKBAR_Enable(hwnd,wParam,lParam);
|
|---|
| 2391 |
|
|---|
| 2392 | case WM_ERASEBKGND:
|
|---|
| 2393 | return 1;
|
|---|
| 2394 |
|
|---|
| 2395 | case WM_GETDLGCODE:
|
|---|
| 2396 | return DLGC_WANTARROWS;
|
|---|
| 2397 |
|
|---|
| 2398 | case WM_KEYDOWN:
|
|---|
| 2399 | return TRACKBAR_KeyDown (hwnd, wParam, lParam);
|
|---|
| 2400 |
|
|---|
| 2401 | case WM_KEYUP:
|
|---|
| 2402 | return TRACKBAR_KeyUp (hwnd, wParam);
|
|---|
| 2403 |
|
|---|
| 2404 | case WM_LBUTTONDOWN:
|
|---|
| 2405 | return TRACKBAR_LButtonDown (hwnd, wParam, lParam);
|
|---|
| 2406 |
|
|---|
| 2407 | case WM_LBUTTONUP:
|
|---|
| 2408 | return TRACKBAR_LButtonUp (hwnd, wParam, lParam);
|
|---|
| 2409 |
|
|---|
| 2410 | case WM_TIMER:
|
|---|
| 2411 | return TRACKBAR_Timer(hwnd,wParam,lParam);
|
|---|
| 2412 |
|
|---|
| 2413 | case WM_MOUSEMOVE:
|
|---|
| 2414 | return TRACKBAR_MouseMove (hwnd, wParam, lParam);
|
|---|
| 2415 |
|
|---|
| 2416 | case WM_PAINT:
|
|---|
| 2417 | return TRACKBAR_Paint (hwnd, wParam);
|
|---|
| 2418 |
|
|---|
| 2419 | case WM_SETFOCUS:
|
|---|
| 2420 | return TRACKBAR_SetFocus (hwnd, wParam, lParam);
|
|---|
| 2421 |
|
|---|
| 2422 | case WM_KILLFOCUS:
|
|---|
| 2423 | return TRACKBAR_KillFocus (hwnd, wParam, lParam);
|
|---|
| 2424 |
|
|---|
| 2425 | case WM_SIZE:
|
|---|
| 2426 | return TRACKBAR_Size (hwnd, wParam, lParam);
|
|---|
| 2427 |
|
|---|
| 2428 | case WM_WININICHANGE:
|
|---|
| 2429 | return TRACKBAR_InitializeThumb (hwnd);
|
|---|
| 2430 |
|
|---|
| 2431 | default:
|
|---|
| 2432 | // if (uMsg >= WM_USER)
|
|---|
| 2433 | // ERR (trackbar, "unknown msg %04x wp=%08x lp=%08lx\n",
|
|---|
| 2434 | // uMsg, wParam, lParam);
|
|---|
| 2435 | return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
|
|---|
| 2436 | }
|
|---|
| 2437 | return 0;
|
|---|
| 2438 | }
|
|---|
| 2439 |
|
|---|
| 2440 |
|
|---|
| 2441 | VOID
|
|---|
| 2442 | TRACKBAR_Register (VOID)
|
|---|
| 2443 | {
|
|---|
| 2444 | WNDCLASSA wndClass;
|
|---|
| 2445 |
|
|---|
| 2446 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
|---|
| 2447 | wndClass.style = CS_GLOBALCLASS;
|
|---|
| 2448 | wndClass.lpfnWndProc = (WNDPROC)TRACKBAR_WindowProc;
|
|---|
| 2449 | wndClass.cbClsExtra = 0;
|
|---|
| 2450 | wndClass.cbWndExtra = sizeof(TRACKBAR_INFO *);
|
|---|
| 2451 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
|---|
| 2452 | wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
|---|
| 2453 | wndClass.lpszClassName = TRACKBAR_CLASSA;
|
|---|
| 2454 |
|
|---|
| 2455 | RegisterClassA (&wndClass);
|
|---|
| 2456 | }
|
|---|
| 2457 |
|
|---|
| 2458 |
|
|---|
| 2459 | VOID
|
|---|
| 2460 | TRACKBAR_Unregister (VOID)
|
|---|
| 2461 | {
|
|---|
| 2462 | UnregisterClassA (TRACKBAR_CLASSA, (HINSTANCE)NULL);
|
|---|
| 2463 | }
|
|---|
| 2464 |
|
|---|