| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "tkInt.h" |
| 17 |
#include "tkScale.h" |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
static void DisplayHorizontalScale _ANSI_ARGS_((TkScale *scalePtr, |
| 24 |
Drawable drawable, XRectangle *drawnAreaPtr)); |
| 25 |
static void DisplayHorizontalValue _ANSI_ARGS_((TkScale *scalePtr, |
| 26 |
Drawable drawable, double value, int top)); |
| 27 |
static void DisplayVerticalScale _ANSI_ARGS_((TkScale *scalePtr, |
| 28 |
Drawable drawable, XRectangle *drawnAreaPtr)); |
| 29 |
static void DisplayVerticalValue _ANSI_ARGS_((TkScale *scalePtr, |
| 30 |
Drawable drawable, double value, int rightEdge)); |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
TkScale * |
| 49 |
TkpCreateScale(tkwin) |
| 50 |
Tk_Window tkwin; |
| 51 |
{ |
| 52 |
return (TkScale *) ckalloc(sizeof(TkScale)); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
void |
| 74 |
TkpDestroyScale(scalePtr) |
| 75 |
TkScale *scalePtr; |
| 76 |
{ |
| 77 |
Tcl_EventuallyFree((ClientData) scalePtr, TCL_DYNAMIC); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
static void |
| 101 |
DisplayVerticalScale(scalePtr, drawable, drawnAreaPtr) |
| 102 |
TkScale *scalePtr; |
| 103 |
Drawable drawable; |
| 104 |
|
| 105 |
XRectangle *drawnAreaPtr; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
{ |
| 111 |
Tk_Window tkwin = scalePtr->tkwin; |
| 112 |
int x, y, width, height, shadowWidth; |
| 113 |
double tickValue, tickInterval = scalePtr->tickInterval; |
| 114 |
Tk_3DBorder sliderBorder; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
if (!(scalePtr->flags & REDRAW_OTHER)) { |
| 121 |
drawnAreaPtr->x = scalePtr->vertTickRightX; |
| 122 |
drawnAreaPtr->y = scalePtr->inset; |
| 123 |
drawnAreaPtr->width = scalePtr->vertTroughX + scalePtr->width |
| 124 |
+ 2*scalePtr->borderWidth - scalePtr->vertTickRightX; |
| 125 |
drawnAreaPtr->height -= 2*scalePtr->inset; |
| 126 |
} |
| 127 |
Tk_Fill3DRectangle(tkwin, drawable, scalePtr->bgBorder, |
| 128 |
drawnAreaPtr->x, drawnAreaPtr->y, drawnAreaPtr->width, |
| 129 |
drawnAreaPtr->height, 0, TK_RELIEF_FLAT); |
| 130 |
if (scalePtr->flags & REDRAW_OTHER) { |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
if (tickInterval != 0) { |
| 136 |
double ticks, maxTicks; |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
ticks = fabs((scalePtr->toValue - scalePtr->fromValue) |
| 143 |
/ tickInterval); |
| 144 |
maxTicks = (double) Tk_Height(tkwin) |
| 145 |
/ (double) scalePtr->fontHeight; |
| 146 |
if (ticks > maxTicks) { |
| 147 |
tickInterval *= (ticks / maxTicks); |
| 148 |
} |
| 149 |
for (tickValue = scalePtr->fromValue; ; |
| 150 |
tickValue += tickInterval) { |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
tickValue = TkRoundToResolution(scalePtr, tickValue); |
| 157 |
if (scalePtr->toValue >= scalePtr->fromValue) { |
| 158 |
if (tickValue > scalePtr->toValue) { |
| 159 |
break; |
| 160 |
} |
| 161 |
} else { |
| 162 |
if (tickValue < scalePtr->toValue) { |
| 163 |
break; |
| 164 |
} |
| 165 |
} |
| 166 |
DisplayVerticalValue(scalePtr, drawable, tickValue, |
| 167 |
scalePtr->vertTickRightX); |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
if (scalePtr->showValue) { |
| 177 |
DisplayVerticalValue(scalePtr, drawable, scalePtr->value, |
| 178 |
scalePtr->vertValueRightX); |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
Tk_Draw3DRectangle(tkwin, drawable, |
| 186 |
scalePtr->bgBorder, scalePtr->vertTroughX, scalePtr->inset, |
| 187 |
scalePtr->width + 2*scalePtr->borderWidth, |
| 188 |
Tk_Height(tkwin) - 2*scalePtr->inset, scalePtr->borderWidth, |
| 189 |
TK_RELIEF_SUNKEN); |
| 190 |
XFillRectangle(scalePtr->display, drawable, scalePtr->troughGC, |
| 191 |
scalePtr->vertTroughX + scalePtr->borderWidth, |
| 192 |
scalePtr->inset + scalePtr->borderWidth, |
| 193 |
(unsigned) scalePtr->width, |
| 194 |
(unsigned) (Tk_Height(tkwin) - 2*scalePtr->inset |
| 195 |
- 2*scalePtr->borderWidth)); |
| 196 |
if (scalePtr->state == STATE_ACTIVE) { |
| 197 |
sliderBorder = scalePtr->activeBorder; |
| 198 |
} else { |
| 199 |
sliderBorder = scalePtr->bgBorder; |
| 200 |
} |
| 201 |
width = scalePtr->width; |
| 202 |
height = scalePtr->sliderLength/2; |
| 203 |
x = scalePtr->vertTroughX + scalePtr->borderWidth; |
| 204 |
y = TkScaleValueToPixel(scalePtr, scalePtr->value) - height; |
| 205 |
shadowWidth = scalePtr->borderWidth/2; |
| 206 |
if (shadowWidth == 0) { |
| 207 |
shadowWidth = 1; |
| 208 |
} |
| 209 |
Tk_Draw3DRectangle(tkwin, drawable, sliderBorder, x, y, width, |
| 210 |
2*height, shadowWidth, scalePtr->sliderRelief); |
| 211 |
x += shadowWidth; |
| 212 |
y += shadowWidth; |
| 213 |
width -= 2*shadowWidth; |
| 214 |
height -= shadowWidth; |
| 215 |
Tk_Fill3DRectangle(tkwin, drawable, sliderBorder, x, y, width, |
| 216 |
height, shadowWidth, scalePtr->sliderRelief); |
| 217 |
Tk_Fill3DRectangle(tkwin, drawable, sliderBorder, x, y+height, |
| 218 |
width, height, shadowWidth, scalePtr->sliderRelief); |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
if ((scalePtr->flags & REDRAW_OTHER) && (scalePtr->labelLength != 0)) { |
| 225 |
Tk_FontMetrics fm; |
| 226 |
|
| 227 |
Tk_GetFontMetrics(scalePtr->tkfont, &fm); |
| 228 |
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC, |
| 229 |
scalePtr->tkfont, scalePtr->label, |
| 230 |
scalePtr->labelLength, scalePtr->vertLabelX, |
| 231 |
scalePtr->inset + (3*fm.ascent)/2); |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
static void |
| 255 |
DisplayVerticalValue(scalePtr, drawable, value, rightEdge) |
| 256 |
register TkScale *scalePtr; |
| 257 |
|
| 258 |
Drawable drawable; |
| 259 |
|
| 260 |
double value; |
| 261 |
|
| 262 |
|
| 263 |
int rightEdge; |
| 264 |
|
| 265 |
{ |
| 266 |
register Tk_Window tkwin = scalePtr->tkwin; |
| 267 |
int y, width, length; |
| 268 |
char valueString[PRINT_CHARS]; |
| 269 |
Tk_FontMetrics fm; |
| 270 |
|
| 271 |
Tk_GetFontMetrics(scalePtr->tkfont, &fm); |
| 272 |
y = TkScaleValueToPixel(scalePtr, value) + fm.ascent/2; |
| 273 |
sprintf(valueString, scalePtr->format, value); |
| 274 |
length = (int) strlen(valueString); |
| 275 |
width = Tk_TextWidth(scalePtr->tkfont, valueString, length); |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
if ((y - fm.ascent) < (scalePtr->inset + SPACING)) { |
| 283 |
y = scalePtr->inset + SPACING + fm.ascent; |
| 284 |
} |
| 285 |
if ((y + fm.descent) > (Tk_Height(tkwin) - scalePtr->inset - SPACING)) { |
| 286 |
y = Tk_Height(tkwin) - scalePtr->inset - SPACING - fm.descent; |
| 287 |
} |
| 288 |
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC, |
| 289 |
scalePtr->tkfont, valueString, length, rightEdge - width, y); |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
static void |
| 313 |
DisplayHorizontalScale(scalePtr, drawable, drawnAreaPtr) |
| 314 |
TkScale *scalePtr; |
| 315 |
Drawable drawable; |
| 316 |
|
| 317 |
XRectangle *drawnAreaPtr; |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
{ |
| 323 |
register Tk_Window tkwin = scalePtr->tkwin; |
| 324 |
int x, y, width, height, shadowWidth; |
| 325 |
double tickValue, tickInterval = scalePtr->tickInterval; |
| 326 |
Tk_3DBorder sliderBorder; |
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
if (!(scalePtr->flags & REDRAW_OTHER)) { |
| 333 |
drawnAreaPtr->x = scalePtr->inset; |
| 334 |
drawnAreaPtr->y = scalePtr->horizValueY; |
| 335 |
drawnAreaPtr->width -= 2*scalePtr->inset; |
| 336 |
drawnAreaPtr->height = scalePtr->horizTroughY + scalePtr->width |
| 337 |
+ 2*scalePtr->borderWidth - scalePtr->horizValueY; |
| 338 |
} |
| 339 |
Tk_Fill3DRectangle(tkwin, drawable, scalePtr->bgBorder, |
| 340 |
drawnAreaPtr->x, drawnAreaPtr->y, drawnAreaPtr->width, |
| 341 |
drawnAreaPtr->height, 0, TK_RELIEF_FLAT); |
| 342 |
if (scalePtr->flags & REDRAW_OTHER) { |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
if (tickInterval != 0) { |
| 348 |
char valueString[PRINT_CHARS]; |
| 349 |
double ticks, maxTicks; |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
ticks = fabs((scalePtr->toValue - scalePtr->fromValue) |
| 357 |
/ tickInterval); |
| 358 |
sprintf(valueString, scalePtr->format, scalePtr->fromValue); |
| 359 |
maxTicks = (double) Tk_Width(tkwin) |
| 360 |
/ (double) Tk_TextWidth(scalePtr->tkfont, valueString, -1); |
| 361 |
if (ticks > maxTicks) { |
| 362 |
tickInterval *= (ticks / maxTicks); |
| 363 |
} |
| 364 |
for (tickValue = scalePtr->fromValue; ; |
| 365 |
tickValue += tickInterval) { |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
tickValue = TkRoundToResolution(scalePtr, tickValue); |
| 372 |
if (scalePtr->toValue >= scalePtr->fromValue) { |
| 373 |
if (tickValue > scalePtr->toValue) { |
| 374 |
break; |
| 375 |
} |
| 376 |
} else { |
| 377 |
if (tickValue < scalePtr->toValue) { |
| 378 |
break; |
| 379 |
} |
| 380 |
} |
| 381 |
DisplayHorizontalValue(scalePtr, drawable, tickValue, |
| 382 |
scalePtr->horizTickY); |
| 383 |
} |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
if (scalePtr->showValue) { |
| 392 |
DisplayHorizontalValue(scalePtr, drawable, scalePtr->value, |
| 393 |
scalePtr->horizValueY); |
| 394 |
} |
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
y = scalePtr->horizTroughY; |
| 401 |
Tk_Draw3DRectangle(tkwin, drawable, |
| 402 |
scalePtr->bgBorder, scalePtr->inset, y, |
| 403 |
Tk_Width(tkwin) - 2*scalePtr->inset, |
| 404 |
scalePtr->width + 2*scalePtr->borderWidth, |
| 405 |
scalePtr->borderWidth, TK_RELIEF_SUNKEN); |
| 406 |
XFillRectangle(scalePtr->display, drawable, scalePtr->troughGC, |
| 407 |
scalePtr->inset + scalePtr->borderWidth, |
| 408 |
y + scalePtr->borderWidth, |
| 409 |
(unsigned) (Tk_Width(tkwin) - 2*scalePtr->inset |
| 410 |
- 2*scalePtr->borderWidth), |
| 411 |
(unsigned) scalePtr->width); |
| 412 |
if (scalePtr->state == STATE_ACTIVE) { |
| 413 |
sliderBorder = scalePtr->activeBorder; |
| 414 |
} else { |
| 415 |
sliderBorder = scalePtr->bgBorder; |
| 416 |
} |
| 417 |
width = scalePtr->sliderLength/2; |
| 418 |
height = scalePtr->width; |
| 419 |
x = TkScaleValueToPixel(scalePtr, scalePtr->value) - width; |
| 420 |
y += scalePtr->borderWidth; |
| 421 |
shadowWidth = scalePtr->borderWidth/2; |
| 422 |
if (shadowWidth == 0) { |
| 423 |
shadowWidth = 1; |
| 424 |
} |
| 425 |
Tk_Draw3DRectangle(tkwin, drawable, sliderBorder, |
| 426 |
x, y, 2*width, height, shadowWidth, scalePtr->sliderRelief); |
| 427 |
x += shadowWidth; |
| 428 |
y += shadowWidth; |
| 429 |
width -= shadowWidth; |
| 430 |
height -= 2*shadowWidth; |
| 431 |
Tk_Fill3DRectangle(tkwin, drawable, sliderBorder, x, y, width, height, |
| 432 |
shadowWidth, scalePtr->sliderRelief); |
| 433 |
Tk_Fill3DRectangle(tkwin, drawable, sliderBorder, x+width, y, |
| 434 |
width, height, shadowWidth, scalePtr->sliderRelief); |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
if ((scalePtr->flags & REDRAW_OTHER) && (scalePtr->labelLength != 0)) { |
| 441 |
Tk_FontMetrics fm; |
| 442 |
|
| 443 |
Tk_GetFontMetrics(scalePtr->tkfont, &fm); |
| 444 |
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC, |
| 445 |
scalePtr->tkfont, scalePtr->label, |
| 446 |
scalePtr->labelLength, scalePtr->inset + fm.ascent/2, |
| 447 |
scalePtr->horizLabelY + fm.ascent); |
| 448 |
} |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
static void |
| 471 |
DisplayHorizontalValue(scalePtr, drawable, value, top) |
| 472 |
register TkScale *scalePtr; |
| 473 |
|
| 474 |
Drawable drawable; |
| 475 |
|
| 476 |
double value; |
| 477 |
|
| 478 |
|
| 479 |
int top; |
| 480 |
|
| 481 |
{ |
| 482 |
register Tk_Window tkwin = scalePtr->tkwin; |
| 483 |
int x, y, length, width; |
| 484 |
char valueString[PRINT_CHARS]; |
| 485 |
Tk_FontMetrics fm; |
| 486 |
|
| 487 |
x = TkScaleValueToPixel(scalePtr, value); |
| 488 |
Tk_GetFontMetrics(scalePtr->tkfont, &fm); |
| 489 |
y = top + fm.ascent; |
| 490 |
sprintf(valueString, scalePtr->format, value); |
| 491 |
length = (int) strlen(valueString); |
| 492 |
width = Tk_TextWidth(scalePtr->tkfont, valueString, length); |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
x -= (width)/2; |
| 500 |
if (x < (scalePtr->inset + SPACING)) { |
| 501 |
x = scalePtr->inset + SPACING; |
| 502 |
} |
| 503 |
if (x > (Tk_Width(tkwin) - scalePtr->inset)) { |
| 504 |
x = Tk_Width(tkwin) - scalePtr->inset - SPACING - width; |
| 505 |
} |
| 506 |
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC, |
| 507 |
scalePtr->tkfont, valueString, length, x, y); |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
void |
| 528 |
TkpDisplayScale(clientData) |
| 529 |
ClientData clientData; |
| 530 |
{ |
| 531 |
TkScale *scalePtr = (TkScale *) clientData; |
| 532 |
Tk_Window tkwin = scalePtr->tkwin; |
| 533 |
Tcl_Interp *interp = scalePtr->interp; |
| 534 |
Pixmap pixmap; |
| 535 |
int result; |
| 536 |
char string[PRINT_CHARS]; |
| 537 |
XRectangle drawnArea; |
| 538 |
|
| 539 |
scalePtr->flags &= ~REDRAW_PENDING; |
| 540 |
if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) { |
| 541 |
goto done; |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
Tcl_Preserve((ClientData) scalePtr); |
| 548 |
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) { |
| 549 |
Tcl_Preserve((ClientData) interp); |
| 550 |
result = LangDoCallback(scalePtr->interp, scalePtr->command,0,1,scalePtr->format, scalePtr->value); |
| 551 |
if (result != TCL_OK) { |
| 552 |
Tcl_AddErrorInfo(interp, "\n (command executed by scale)"); |
| 553 |
Tcl_BackgroundError(interp); |
| 554 |
} |
| 555 |
Tcl_Release((ClientData) interp); |
| 556 |
} |
| 557 |
scalePtr->flags &= ~INVOKE_COMMAND; |
| 558 |
if (scalePtr->flags & SCALE_DELETED) { |
| 559 |
Tcl_Release((ClientData) scalePtr); |
| 560 |
return; |
| 561 |
} |
| 562 |
Tcl_Release((ClientData) scalePtr); |
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
pixmap = Tk_GetPixmap(scalePtr->display, Tk_WindowId(tkwin), |
| 572 |
Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); |
| 573 |
drawnArea.x = 0; |
| 574 |
drawnArea.y = 0; |
| 575 |
drawnArea.width = Tk_Width(tkwin); |
| 576 |
drawnArea.height = Tk_Height(tkwin); |
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
if (scalePtr->orient == ORIENT_VERTICAL) { |
| 585 |
DisplayVerticalScale(scalePtr, pixmap, &drawnArea); |
| 586 |
} else { |
| 587 |
DisplayHorizontalScale(scalePtr, pixmap, &drawnArea); |
| 588 |
} |
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
if (scalePtr->flags & REDRAW_OTHER) { |
| 597 |
if (scalePtr->relief != TK_RELIEF_FLAT) { |
| 598 |
Tk_Draw3DRectangle(tkwin, pixmap, scalePtr->bgBorder, |
| 599 |
scalePtr->highlightWidth, scalePtr->highlightWidth, |
| 600 |
Tk_Width(tkwin) - 2*scalePtr->highlightWidth, |
| 601 |
Tk_Height(tkwin) - 2*scalePtr->highlightWidth, |
| 602 |
scalePtr->borderWidth, scalePtr->relief); |
| 603 |
} |
| 604 |
if (scalePtr->highlightWidth != 0) { |
| 605 |
GC gc; |
| 606 |
|
| 607 |
if (scalePtr->flags & GOT_FOCUS) { |
| 608 |
gc = Tk_GCForColor(scalePtr->highlightColorPtr, pixmap); |
| 609 |
} else { |
| 610 |
gc = Tk_GCForColor( |
| 611 |
Tk_3DBorderColor(scalePtr->highlightBorder), pixmap); |
| 612 |
} |
| 613 |
Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, pixmap); |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
XCopyArea(scalePtr->display, pixmap, Tk_WindowId(tkwin), |
| 623 |
scalePtr->copyGC, drawnArea.x, drawnArea.y, drawnArea.width, |
| 624 |
drawnArea.height, drawnArea.x, drawnArea.y); |
| 625 |
Tk_FreePixmap(scalePtr->display, pixmap); |
| 626 |
|
| 627 |
done: |
| 628 |
scalePtr->flags &= ~REDRAW_ALL; |
| 629 |
} |
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
int |
| 651 |
TkpScaleElement(scalePtr, x, y) |
| 652 |
TkScale *scalePtr; |
| 653 |
int x, y; |
| 654 |
{ |
| 655 |
int sliderFirst; |
| 656 |
|
| 657 |
if (scalePtr->orient == ORIENT_VERTICAL) { |
| 658 |
if ((x < scalePtr->vertTroughX) |
| 659 |
|| (x >= (scalePtr->vertTroughX + 2*scalePtr->borderWidth + |
| 660 |
scalePtr->width))) { |
| 661 |
return OTHER; |
| 662 |
} |
| 663 |
if ((y < scalePtr->inset) |
| 664 |
|| (y >= (Tk_Height(scalePtr->tkwin) - scalePtr->inset))) { |
| 665 |
return OTHER; |
| 666 |
} |
| 667 |
sliderFirst = TkScaleValueToPixel(scalePtr, scalePtr->value) |
| 668 |
- scalePtr->sliderLength/2; |
| 669 |
if (y < sliderFirst) { |
| 670 |
return TROUGH1; |
| 671 |
} |
| 672 |
if (y < (sliderFirst+scalePtr->sliderLength)) { |
| 673 |
return SLIDER; |
| 674 |
} |
| 675 |
return TROUGH2; |
| 676 |
} |
| 677 |
|
| 678 |
if ((y < scalePtr->horizTroughY) |
| 679 |
|| (y >= (scalePtr->horizTroughY + 2*scalePtr->borderWidth + |
| 680 |
scalePtr->width))) { |
| 681 |
return OTHER; |
| 682 |
} |
| 683 |
if ((x < scalePtr->inset) |
| 684 |
|| (x >= (Tk_Width(scalePtr->tkwin) - scalePtr->inset))) { |
| 685 |
return OTHER; |
| 686 |
} |
| 687 |
sliderFirst = TkScaleValueToPixel(scalePtr, scalePtr->value) |
| 688 |
- scalePtr->sliderLength/2; |
| 689 |
if (x < sliderFirst) { |
| 690 |
return TROUGH1; |
| 691 |
} |
| 692 |
if (x < (sliderFirst+scalePtr->sliderLength)) { |
| 693 |
return SLIDER; |
| 694 |
} |
| 695 |
return TROUGH2; |
| 696 |
} |