Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Better fix for [4d0a6f32b7]: Unique behavior of some options in the message widget in 8.7/9.0. No longer cache PIXEL values in button's and message. With testcases |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-branch |
Files: | files | file ages | folders |
SHA3-256: |
4df5ec982c70a554b16affa5e0e59ada |
User & Date: | jan.nijtmans 2024-06-14 20:20:39 |
Context
2024-06-16
| ||
12:05 | Remove TK_OPTION_NULL_OK usage in tkPlace.c, doesn't belong there. Some indenting and varname consistancy check-in: 951d538b user: jan.nijtmans tags: core-8-branch | |
2024-06-14
| ||
22:16 | Better fix for [4d0a6f32b7]: Unique behavior of some options in the message widget in 8.7/9.0. No longer cache PIXEL values in button's and message. With testcases check-in: 7111710c user: jan.nijtmans tags: trunk, main | |
20:20 | Better fix for [4d0a6f32b7]: Unique behavior of some options in the message widget in 8.7/9.0. No longer cache PIXEL values in button's and message. With testcases check-in: 4df5ec98 user: jan.nijtmans tags: core-8-branch | |
15:45 | Add quotes to the "processing * option" error-messages, for consistancy. Some indenting fixes check-in: 4cd35ddb user: jan.nijtmans tags: core-8-branch | |
10:33 | Merge 8.7. Add testcases Closed-Leaf check-in: 4f594dc0 user: jan.nijtmans tags: bug-4d0a6f32b7, core-bug-4d0a6f32b7 | |
Changes
Changes to generic/tkButton.c.
︙ | ︙ | |||
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | if ((butPtr->state == STATE_ACTIVE) && !Tk_StrictMotif(butPtr->tkwin)) { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->activeBorder); } else { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } if (butPtr->borderWidth < 0) { butPtr->borderWidth = 0; } if (butPtr->highlightWidth < 0) { butPtr->highlightWidth = 0; } if (butPtr->padX < 0) { butPtr->padX = 0; } if (butPtr->padY < 0) { butPtr->padY = 0; } if (butPtr->type >= TYPE_CHECK_BUTTON) { Tcl_Obj *valuePtr, *namePtr; if (butPtr->selVarNamePtr == NULL) { butPtr->selVarNamePtr = Tcl_NewStringObj( | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | if ((butPtr->state == STATE_ACTIVE) && !Tk_StrictMotif(butPtr->tkwin)) { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->activeBorder); } else { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } if (butPtr->wrapLength < 0) { butPtr->wrapLength = 0; if (butPtr->wrapLengthPtr) { Tcl_DecrRefCount(butPtr->wrapLengthPtr); } butPtr->wrapLengthPtr = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->wrapLengthPtr); } if (butPtr->borderWidth < 0) { butPtr->borderWidth = 0; if (butPtr->borderWidthPtr) { Tcl_DecrRefCount(butPtr->borderWidthPtr); } butPtr->borderWidthPtr = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->borderWidthPtr); } if (butPtr->highlightWidth < 0) { butPtr->highlightWidth = 0; if (butPtr->highlightWidthPtr) { Tcl_DecrRefCount(butPtr->highlightWidthPtr); } butPtr->highlightWidthPtr = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->highlightWidthPtr); } if (butPtr->padX < 0) { butPtr->padX = 0; if (butPtr->padXPtr) { Tcl_DecrRefCount(butPtr->padXPtr); } butPtr->padXPtr = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->padXPtr); } if (butPtr->padY < 0) { butPtr->padY = 0; if (butPtr->padYPtr) { Tcl_DecrRefCount(butPtr->padYPtr); } butPtr->padYPtr = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->padYPtr); } if (butPtr->type >= TYPE_CHECK_BUTTON) { Tcl_Obj *valuePtr, *namePtr; if (butPtr->selVarNamePtr == NULL) { butPtr->selVarNamePtr = Tcl_NewStringObj( |
︙ | ︙ | |||
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 | goto redraw; } else if (eventPtr->type == DestroyNotify) { DestroyButton(butPtr); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { butPtr->flags |= GOT_FOCUS; if (butPtr->highlightWidth > 0) { goto redraw; } } } else if (eventPtr->type == FocusOut) { if (eventPtr->xfocus.detail != NotifyInferior) { butPtr->flags &= ~GOT_FOCUS; if (butPtr->highlightWidth > 0) { goto redraw; } } } return; | > > | 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 | goto redraw; } else if (eventPtr->type == DestroyNotify) { DestroyButton(butPtr); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { butPtr->flags |= GOT_FOCUS; Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); if (butPtr->highlightWidth > 0) { goto redraw; } } } else if (eventPtr->type == FocusOut) { if (eventPtr->xfocus.detail != NotifyInferior) { butPtr->flags &= ~GOT_FOCUS; Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); if (butPtr->highlightWidth > 0) { goto redraw; } } } return; |
︙ | ︙ |
Changes to generic/tkMessage.c.
︙ | ︙ | |||
50 51 52 53 54 55 56 | * including terminating NULL. */ char *textVarName; /* Name of variable (malloc'ed) or NULL. * If non-NULL, message displays the contents * of this variable. */ Tk_3DBorder border; /* Structure used to draw 3-D border and * background. NULL means a border hasn't been * created yet. */ | | | | | < | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | * including terminating NULL. */ char *textVarName; /* Name of variable (malloc'ed) or NULL. * If non-NULL, message displays the contents * of this variable. */ Tk_3DBorder border; /* Structure used to draw 3-D border and * background. NULL means a border hasn't been * created yet. */ Tcl_Obj *borderWidthObj; /* Width of border. */ int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw * around widget when it has the focus. * 0 means don't draw a highlight. */ XColor *highlightBgColorPtr; /* Color for drawing traversal highlight * area when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ Tk_Font tkfont; /* Information about text font, or NULL. */ XColor *fgColorPtr; /* Foreground color in normal mode. */ Tcl_Obj *padXObj, *padYObj; /* Tcl_Obj rep's of padX, padY values. */ Tcl_Obj *widthObj; /* User-requested width, in pixels. 0 means * compute width using aspect ratio. */ int aspect; /* Desired aspect ratio for window * (100*width/height). */ int msgWidth; /* Width in pixels needed to display * message. */ int msgHeight; /* Height in pixels needed to display * message. */ Tk_Anchor anchor; /* Where to position text within window region |
︙ | ︙ | |||
89 90 91 92 93 94 95 | Tk_Cursor cursor; /* Current cursor for window, or None. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ int flags; /* Various flags; see below for * definitions. */ | < < < < < | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | Tk_Cursor cursor; /* Current cursor for window, or None. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ int flags; /* Various flags; see below for * definitions. */ } Message; /* * Flag bits for messages: * * REDRAW_PENDING: Non-zero means a DoWhenIdle handler * has already been queued to redraw |
︙ | ︙ | |||
117 118 119 120 121 122 123 | /* * Information used for argv parsing. */ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MESSAGE_ANCHOR, | | | | | | | | | | | | | | | | | | | | | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | /* * Information used for argv parsing. */ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MESSAGE_ANCHOR, TCL_INDEX_NONE, offsetof(Message, anchor), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_INT, "-aspect", "aspect", "Aspect", DEF_MESSAGE_ASPECT, TCL_INDEX_NONE, offsetof(Message, aspect), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_MESSAGE_BG_COLOR, TCL_INDEX_NONE, offsetof(Message, border), 0, DEF_MESSAGE_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_MESSAGE_BORDER_WIDTH, offsetof(Message, borderWidthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MESSAGE_CURSOR, TCL_INDEX_NONE, offsetof(Message, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_MESSAGE_FONT, TCL_INDEX_NONE, offsetof(Message, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_MESSAGE_FG, TCL_INDEX_NONE, offsetof(Message, fgColorPtr), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, TCL_INDEX_NONE, offsetof(Message, highlightBgColorPtr), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_MESSAGE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Message, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, offsetof(Message, highlightWidthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_MESSAGE_JUSTIFY, TCL_INDEX_NONE, offsetof(Message, justify), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_MESSAGE_PADX, offsetof(Message, padXObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", DEF_MESSAGE_PADY, offsetof(Message, padYObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MESSAGE_RELIEF, TCL_INDEX_NONE, offsetof(Message, relief), 0, 0, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_MESSAGE_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Message, takeFocus), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_MESSAGE_TEXT, TCL_INDEX_NONE, offsetof(Message, string), 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_MESSAGE_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Message, textVarName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-width", "width", "Width", DEF_MESSAGE_WIDTH, offsetof(Message, widthObj), TCL_INDEX_NONE, 0, 0 ,0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; /* * Forward declarations for functions defined later in this file: */ |
︙ | ︙ | |||
450 451 452 453 454 455 456 457 458 459 460 461 462 463 | Message *msgPtr, /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of valid entries in argv. */ Tcl_Obj *const objv[], /* Arguments. */ TCL_UNUSED(int)) /* Flags to pass to Tk_ConfigureWidget. */ { Tk_SavedOptions savedOptions; /* * Eliminate any existing trace on a variable monitored by the message. */ if (msgPtr->textVarName != NULL) { Tcl_UntraceVar2(interp, msgPtr->textVarName, NULL, | > | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | Message *msgPtr, /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of valid entries in argv. */ Tcl_Obj *const objv[], /* Arguments. */ TCL_UNUSED(int)) /* Flags to pass to Tk_ConfigureWidget. */ { Tk_SavedOptions savedOptions; int width, borderWidth, highlightWidth, padX, padY; /* * Eliminate any existing trace on a variable monitored by the message. */ if (msgPtr->textVarName != NULL) { Tcl_UntraceVar2(interp, msgPtr->textVarName, NULL, |
︙ | ︙ | |||
499 500 501 502 503 504 505 | * A few other options need special processing, such as setting the * background from a 3-D border or handling special defaults that couldn't * be specified to Tk_ConfigureWidget. */ msgPtr->numChars = TkNumUtfChars(msgPtr->string, TCL_INDEX_NONE); | > > > > > > > > > > > > > > > > > > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | * A few other options need special processing, such as setting the * background from a 3-D border or handling special defaults that couldn't * be specified to Tk_ConfigureWidget. */ msgPtr->numChars = TkNumUtfChars(msgPtr->string, TCL_INDEX_NONE); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width); if (width < 0) { if (msgPtr->widthObj) { Tcl_DecrRefCount(msgPtr->widthObj); } msgPtr->widthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(msgPtr->widthObj); } Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth); if (borderWidth < 0) { if (msgPtr->borderWidthObj) { Tcl_DecrRefCount(msgPtr->borderWidthObj); } msgPtr->borderWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(msgPtr->borderWidthObj); } Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth); if (highlightWidth < 0) { if (msgPtr->highlightWidthObj) { Tcl_DecrRefCount(msgPtr->highlightWidthObj); } msgPtr->highlightWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(msgPtr->highlightWidthObj); } if (!msgPtr->padXObj) { msgPtr->padXObj = Tcl_NewIntObj(-1); Tcl_IncrRefCount(msgPtr->padXObj); } Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX); if (padX < 0) { if (strcmp(Tcl_GetString(msgPtr->padXObj), "-1")) { Tcl_DecrRefCount(msgPtr->padXObj); msgPtr->padXObj = Tcl_NewIntObj(-1); Tcl_IncrRefCount(msgPtr->padXObj); } } if (!msgPtr->padYObj) { msgPtr->padYObj = Tcl_NewIntObj(-1); Tcl_IncrRefCount(msgPtr->padYObj); } Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY); if (padY < 0) { if (strcmp(Tcl_GetString(msgPtr->padYObj), "-1")) { Tcl_DecrRefCount(msgPtr->padYObj); msgPtr->padYObj = Tcl_NewIntObj(-1); Tcl_IncrRefCount(msgPtr->padYObj); } } Tk_FreeSavedOptions(&savedOptions); MessageWorldChanged(msgPtr); return TCL_OK; } |
︙ | ︙ | |||
532 533 534 535 536 537 538 | static void MessageWorldChanged( void *instanceData) /* Information about widget. */ { XGCValues gcValues; GC gc = NULL; | < < < < < < < < < | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | static void MessageWorldChanged( void *instanceData) /* Information about widget. */ { XGCValues gcValues; GC gc = NULL; Message *msgPtr = (Message *)instanceData; if (msgPtr->border != NULL) { Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border); } gcValues.font = Tk_FontId(msgPtr->tkfont); gcValues.foreground = msgPtr->fgColorPtr->pixel; gc = Tk_GetGC(msgPtr->tkwin, GCForeground | GCFont, &gcValues); if (msgPtr->textGC != NULL) { Tk_FreeGC(msgPtr->display, msgPtr->textGC); } msgPtr->textGC = gc; /* * Recompute the desired geometry for the window, and arrange for the * window to be redisplayed. */ ComputeMessageGeometry(msgPtr); if ((msgPtr->tkwin != NULL) && Tk_IsMapped(msgPtr->tkwin) |
︙ | ︙ | |||
593 594 595 596 597 598 599 600 601 602 | static void ComputeMessageGeometry( Message *msgPtr) /* Information about window. */ { int width, inc, height; int thisWidth, thisHeight, maxWidth; int aspect, lowerBound, upperBound, inset; Tk_FreeTextLayout(msgPtr->textLayout); | > > > | > > > > > > > > > > > | | | | | 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | static void ComputeMessageGeometry( Message *msgPtr) /* Information about window. */ { int width, inc, height; int thisWidth, thisHeight, maxWidth; int aspect, lowerBound, upperBound, inset; int borderWidth, highlightWidth, padX, padY; Tk_FontMetrics fm; Tk_FreeTextLayout(msgPtr->textLayout); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY); Tk_GetFontMetrics(msgPtr->tkfont, &fm); if (padX < 0) { padX = fm.ascent / 2; } if (padY < 0) { padY = fm.ascent / 4; } inset = borderWidth + highlightWidth; /* * Compute acceptable bounds for the final aspect ratio. */ aspect = msgPtr->aspect/10; if (aspect < 5) { aspect = 5; } lowerBound = msgPtr->aspect - aspect; upperBound = msgPtr->aspect + aspect; /* * Do the computation in multiple passes: start off with a very wide * window, and compute its height. Then change the width and try again. * Reduce the size of the change and iterate until dimensions are found * that approximate the desired aspect ratio. Or, if the user gave an * explicit width then just use that. */ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width); if (width > 0) { inc = 0; } else { width = WidthOfScreen(Tk_Screen(msgPtr->tkwin))/2; inc = width/2; } for ( ; ; inc /= 2) { msgPtr->textLayout = Tk_ComputeTextLayout(msgPtr->tkfont, msgPtr->string, msgPtr->numChars, width, msgPtr->justify, 0, &thisWidth, &thisHeight); maxWidth = thisWidth + 2 * (inset + padX); height = thisHeight + 2 * (inset + padY); if (inc <= 2) { break; } aspect = (100 * maxWidth) / height; if (aspect < lowerBound) { |
︙ | ︙ | |||
675 676 677 678 679 680 681 | static void DisplayMessage( void *clientData) /* Information about window. */ { Message *msgPtr = (Message *)clientData; Tk_Window tkwin = msgPtr->tkwin; int x, y; | > > > > | > > > > > | > > > > > | | | | | | | | | | | | | | | 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | static void DisplayMessage( void *clientData) /* Information about window. */ { Message *msgPtr = (Message *)clientData; Tk_Window tkwin = msgPtr->tkwin; int x, y; int width, borderWidth, highlightWidth, padX, padY; Tk_FontMetrics fm; Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX); Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY); Tk_GetFontMetrics(msgPtr->tkfont, &fm); if (padX < 0) { padX = fm.ascent / 2; } if (padY < 0) { padY = fm.ascent / 4; } width = highlightWidth; msgPtr->flags &= ~REDRAW_PENDING; if ((msgPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } if (msgPtr->border != NULL) { width += borderWidth; } if (msgPtr->relief == TK_RELIEF_FLAT) { width = highlightWidth; } Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), msgPtr->border, width, width, Tk_Width(tkwin) - 2 * width, Tk_Height(tkwin) - 2 * width, 0, TK_RELIEF_FLAT); /* * Compute starting y-location for message based on message size and * anchor option. */ TkComputeAnchor(msgPtr->anchor, tkwin, padX, padY, msgPtr->msgWidth, msgPtr->msgHeight, &x, &y); Tk_DrawTextLayout(Tk_Display(tkwin), Tk_WindowId(tkwin), msgPtr->textGC, msgPtr->textLayout, x, y, 0, -1); if (width > highlightWidth) { Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), msgPtr->border, highlightWidth, highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth, Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, msgPtr->relief); } if (highlightWidth > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (msgPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(msgPtr->highlightColorPtr,Tk_WindowId(tkwin)); Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, highlightWidth, Tk_WindowId(tkwin)); } else { Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, highlightWidth, Tk_WindowId(tkwin)); } } } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | static void MessageEventProc( void *clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { Message *msgPtr = (Message *)clientData; if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) || (eventPtr->type == ConfigureNotify)) { goto redraw; } else if (eventPtr->type == DestroyNotify) { DestroyMessage(clientData); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { msgPtr->flags |= GOT_FOCUS; | > > | > | | 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | static void MessageEventProc( void *clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { Message *msgPtr = (Message *)clientData; int highlightWidth; if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) || (eventPtr->type == ConfigureNotify)) { goto redraw; } else if (eventPtr->type == DestroyNotify) { DestroyMessage(clientData); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { msgPtr->flags |= GOT_FOCUS; Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth); if (highlightWidth > 0) { goto redraw; } } } else if (eventPtr->type == FocusOut) { if (eventPtr->xfocus.detail != NotifyInferior) { msgPtr->flags &= ~GOT_FOCUS; Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth); if (highlightWidth > 0) { goto redraw; } } } return; redraw: |
︙ | ︙ |
Changes to macosx/tkMacOSXButton.c.
︙ | ︙ | |||
190 191 192 193 194 195 196 197 198 199 200 201 202 203 | butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } pixmap = (Pixmap) Tk_WindowId(tkwin); if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) { macButtonPtr->useTkText = 0; } else { macButtonPtr->useTkText = 1; } if (macButtonPtr->useTkText) { if (butPtr->type == TYPE_BUTTON) { | > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } pixmap = (Pixmap) Tk_WindowId(tkwin); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) { macButtonPtr->useTkText = 0; } else { macButtonPtr->useTkText = 1; } if (macButtonPtr->useTkText) { if (butPtr->type == TYPE_BUTTON) { |
︙ | ︙ | |||
309 310 311 312 313 314 315 316 317 318 319 320 321 | Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, text, TCL_INDEX_NONE, butPtr->wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); | > > > | | | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXPtr, &butPtr->padX); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYPtr, &butPtr->padY); if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, text, TCL_INDEX_NONE, butPtr->wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); txtWidth = butPtr->textWidth + 2 * butPtr->padX; txtHeight = butPtr->textHeight + 2 * butPtr->padY; haveText = 1; } if (haveImage) { if (haveText) { /* Image and Text */ switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: |
︙ | ︙ | |||
338 339 340 341 342 343 344 | break; case COMPOUND_LEFT: case COMPOUND_RIGHT: /* * Image is left or right of text. */ | | | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | break; case COMPOUND_LEFT: case COMPOUND_RIGHT: /* * Image is left or right of text. */ width += txtWidth + 2 * butPtr->padX; height = (height > txtHeight ? height : txtHeight); break; case COMPOUND_CENTER: /* * Image and text are superimposed. */ |
︙ | ︙ | |||
368 369 370 371 372 373 374 | height += 2; } } else { /* Text only */ width = txtWidth + butPtr->indicatorSpace; height = txtHeight; if (butPtr->width > 0) { charWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); | | | | | < | | | | | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | height += 2; } } else { /* Text only */ width = txtWidth + butPtr->indicatorSpace; height = txtHeight; if (butPtr->width > 0) { charWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); width = butPtr->width * charWidth + 2 * butPtr->padX; } if (butPtr->height > 0) { Tk_GetFontMetrics(butPtr->tkfont, &fm); height = butPtr->height * fm.linespace + 2 * butPtr->padY; } } /* * Now figure out the size of the border decorations for the button. */ Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); butPtr->inset = butPtr->borderWidth + butPtr->highlightWidth; width += butPtr->inset * 2; height += butPtr->inset * 2; if ([NSApp macOSVersion] == 100600) { width += 12; } if (mbPtr->btnkind == kThemePushButton) { HIRect tmpRect; HIRect contBounds; /* * A PushButton has a minimum size. We make sure that we are not * underestimating the size by requesting the content size of a * Pushbutton whose overall size is our content size expanded by the * standard padding. */ tmpRect = CGRectMake(0, 0, width + 2 * HI_PADX, height + 2 * HI_PADY); HIThemeGetButtonContentBounds(&tmpRect, &mbPtr->drawinfo, &contBounds); if (height < contBounds.size.height) { height = (int)contBounds.size.height; } if (width < contBounds.size.width) { width = (int)contBounds.size.width; } height += 2 * HI_PADY; width += 2 * HI_PADX; } Tk_GeometryRequest(butPtr->tkwin, width, height); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
469 470 471 472 473 474 475 476 477 478 479 480 481 482 | imageWidth = width; imageHeight = height; if (mbPtr->drawinfo.state == kThemeStatePressed) { pressed = 1; } haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { /* Image and Text */ int x, y; switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: | > > > > > | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | imageWidth = width; imageHeight = height; if (mbPtr->drawinfo.state == kThemeStatePressed) { pressed = 1; } Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXPtr, &butPtr->padX); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYPtr, &butPtr->padY); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { /* Image and Text */ int x, y; switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: |
︙ | ︙ | |||
662 663 664 665 666 667 668 | * button's contents overflow they'll be covered up by the border. */ if (dpPtr->relief != TK_RELIEF_FLAT) { int inset = butPtr->highlightWidth; Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset, | | | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | * button's contents overflow they'll be covered up by the border. */ if (dpPtr->relief != TK_RELIEF_FLAT) { int inset = butPtr->highlightWidth; Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset, Tk_Width(tkwin) - 2 * inset, Tk_Height(tkwin) - 2 * inset, butPtr->borderWidth, dpPtr->relief); } } } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
700 701 702 703 704 705 706 | } /* *-------------------------------------------------------------- * * TkMacOSXDrawButton -- * | | | | | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | } /* *-------------------------------------------------------------- * * TkMacOSXDrawButton -- * * This function draws the tk button using Mac controls. In addition, * this code may apply custom colors passed in the TkButton. * * Results: * None. * * Side effects: * The control is created, or reinitialised as needed * *-------------------------------------------------------------- */ |
︙ | ︙ | |||
789 790 791 792 793 794 795 | } /* *-------------------------------------------------------------- * * ButtonBackgroundDrawCB -- * | | | | | | 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | } /* *-------------------------------------------------------------- * * ButtonBackgroundDrawCB -- * * This function draws the background that lies under checkboxes and * radiobuttons. * * Results: * None. * * Side effects: * The background gets updated to the current color. * *-------------------------------------------------------------- */ static void ButtonBackgroundDrawCB( TCL_UNUSED(const HIRect *), |
︙ | ︙ | |||
843 844 845 846 847 848 849 | } /* *-------------------------------------------------------------- * * ButtonContentDrawCB -- * | | | | | 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | } /* *-------------------------------------------------------------- * * ButtonContentDrawCB -- * * This function draws the label and image for the button. * * Results: * None. * * Side effects: * The content of the button gets updated. * *-------------------------------------------------------------- */ static void ButtonContentDrawCB ( TCL_UNUSED(const HIRect *), TCL_UNUSED(ThemeButtonKind), |
︙ | ︙ | |||
932 933 934 935 936 937 938 | * Carbon Appearance control. These are determined by the various tk * button parameters * * Results: * None. * * Side effects: | | > > > | 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | * Carbon Appearance control. These are determined by the various tk * button parameters * * Results: * None. * * Side effects: * Sets the btnkind and drawinfo parameters * *---------------------------------------------------------------------- */ static void TkMacOSXComputeButtonParams( TkButton *butPtr, ThemeButtonKind *btnkind, HIThemeButtonDrawInfo *drawinfo) { MacButton *mbPtr = (MacButton *) butPtr; Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); if (butPtr->borderWidth <= 2) { *btnkind = kThemeSmallBevelButton; } else if (butPtr->borderWidth == 3) { *btnkind = kThemeBevelButton; } else if (butPtr->borderWidth == 4) { *btnkind = kThemeRoundedBevelButton; } else { |
︙ | ︙ |
Changes to tests/button.test.
︙ | ︙ | |||
2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 | # Additional check to make sure that -selectcolor may be empty in # checkbox widgets checkbutton .c .c configure -selectcolor {} } -cleanup { destroy .c } -result {} # ex-tests 3.* test button-2.1 {ButtonCreate - not enough arguments} -body { button } -returnCodes {error} -result {wrong # args: should be "button pathName ?-option value ...?"} test button-2.2 {ButtonCreate procedure - setting label class} -body { | > > > > > > > > > > > | 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 | # Additional check to make sure that -selectcolor may be empty in # checkbox widgets checkbutton .c .c configure -selectcolor {} } -cleanup { destroy .c } -result {} test button-1.271 {configuration options: fallback to default} -setup { checkbutton .c -borderwidth -2 -highlightthickness -2 -font {Helvetica -12 bold} pack .c update } -body { .c configure -padx -2 -pady -2 -wraplength -2 list [.c cget -padx] [.c cget -pady] [.c cget -borderwidth] [.c cget -highlightthickness] [.c cget -wraplength] } -cleanup { destroy .c } -result {0 0 0 0 0} # ex-tests 3.* test button-2.1 {ButtonCreate - not enough arguments} -body { button } -returnCodes {error} -result {wrong # args: should be "button pathName ?-option value ...?"} test button-2.2 {ButtonCreate procedure - setting label class} -body { |
︙ | ︙ |
Changes to tests/message.test.
︙ | ︙ | |||
389 390 391 392 393 394 395 396 397 398 399 400 401 402 | pack .m update } -body { .m configure -width badValue } -cleanup { destroy .m } -returnCodes {error} -result {expected screen distance but got "badValue"} test message-2.1 {Tk_MessageObjCmd procedure} -body { message } -returnCodes {error} -result {wrong # args: should be "message pathName ?-option value ...?"} test message-2.2 {Tk_MessageObjCmd procedure} -body { | > > > > > > > > > > | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | pack .m update } -body { .m configure -width badValue } -cleanup { destroy .m } -returnCodes {error} -result {expected screen distance but got "badValue"} test message-1.39 {configuration options, fallback to default} -setup { message .m -borderwidth -2 -highlightthickness -2 -font {Helvetica -12 bold} pack .m update } -body { .m configure -padx -2 -pady -2 -width -2 list [.m cget -padx] [.m cget -pady] [.m cget -borderwidth] [.m cget -highlightthickness] [.m cget -width] } -cleanup { destroy .m } -result {-1 -1 0 0 0} test message-2.1 {Tk_MessageObjCmd procedure} -body { message } -returnCodes {error} -result {wrong # args: should be "message pathName ?-option value ...?"} test message-2.2 {Tk_MessageObjCmd procedure} -body { |
︙ | ︙ |
Changes to unix/tkUnixButton.c.
︙ | ︙ | |||
529 530 531 532 533 534 535 536 537 538 539 540 541 542 | } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } imageWidth = width; imageHeight = height; haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { textXOffset = 0; textYOffset = 0; fullWidth = 0; fullHeight = 0; | > > > > > | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } imageWidth = width; imageHeight = height; Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXPtr, &butPtr->padX); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYPtr, &butPtr->padY); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { textXOffset = 0; textYOffset = 0; fullWidth = 0; fullHeight = 0; |
︙ | ︙ | |||
721 722 723 724 725 726 727 | /* * Draw the indicator for check buttons and radio buttons. At this point, * x and y refer to the top-left corner of the text or image or bitmap. */ if ((butPtr->type == TYPE_CHECK_BUTTON || butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn | | | 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | /* * Draw the indicator for check buttons and radio buttons. At this point, * x and y refer to the top-left corner of the text or image or bitmap. */ if ((butPtr->type == TYPE_CHECK_BUTTON || butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn && butPtr->indicatorDiameter > 2 * butPtr->borderWidth) { TkBorder *selBorder = (TkBorder *) butPtr->selectBorder; XColor *selColor = NULL; int btype = (butPtr->type == TYPE_CHECK_BUTTON ? CHECK_BUTTON : RADIO_BUTTON); if (selBorder != NULL) { selColor = selBorder->bgColorPtr; |
︙ | ︙ | |||
795 796 797 798 799 800 801 | * default ring and the button and the default ring and the focus * ring. Note that we need to explicitly draw the space in the * highlightBorder color to ensure that we overwrite any overflow * text and/or a different button background color. */ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, | | | | | | | | | 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | * default ring and the button and the default ring and the focus * ring. Note that we need to explicitly draw the space in the * highlightBorder color to ensure that we overwrite any overflow * text and/or a different button background color. */ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2 * inset, Tk_Height(tkwin) - 2 * inset, 2, TK_RELIEF_FLAT); inset += 2; Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2 * inset, Tk_Height(tkwin) - 2 * inset, 1, TK_RELIEF_SUNKEN); inset++; Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2 * inset, Tk_Height(tkwin) - 2 * inset, 2, TK_RELIEF_FLAT); inset += 2; } else if (butPtr->defaultState == DEFAULT_NORMAL) { /* * Leave room for the default ring and write over any text or * background color. */ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 5, TK_RELIEF_FLAT); inset += 5; } /* * Draw the button border. */ Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset, Tk_Width(tkwin) - 2 * inset, Tk_Height(tkwin) - 2 * inset, butPtr->borderWidth, relief); } if (butPtr->highlightWidth > 0) { if (butPtr->flags & GOT_FOCUS) { gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap); } else { gc = Tk_GCForColor(Tk_3DBorderColor(butPtr->highlightBorder), |
︙ | ︙ | |||
883 884 885 886 887 888 889 890 891 892 893 894 895 896 | void TkpComputeButtonGeometry( TkButton *butPtr) /* Button whose geometry may have changed. */ { int width, height, avgWidth, txtWidth, txtHeight; int haveImage = 0, haveText = 0; Tk_FontMetrics fm; butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; /* * Leave room for the default ring if needed. */ | > > > > > | 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | void TkpComputeButtonGeometry( TkButton *butPtr) /* Button whose geometry may have changed. */ { int width, height, avgWidth, txtWidth, txtHeight; int haveImage = 0, haveText = 0; Tk_FontMetrics fm; Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXPtr, &butPtr->padX); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYPtr, &butPtr->padY); butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; /* * Leave room for the default ring if needed. */ |
︙ | ︙ | |||
977 978 979 980 981 982 983 | if (butPtr->type == TYPE_CHECK_BUTTON) { butPtr->indicatorDiameter = (65*height)/100; } else { butPtr->indicatorDiameter = (75*height)/100; } } | | | | 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | if (butPtr->type == TYPE_CHECK_BUTTON) { butPtr->indicatorDiameter = (65*height)/100; } else { butPtr->indicatorDiameter = (75*height)/100; } } width += 2 * butPtr->padX; height += 2 * butPtr->padY; } else { if (haveImage) { if (butPtr->width > 0) { width = butPtr->width; } if (butPtr->height > 0) { height = butPtr->height; |
︙ | ︙ | |||
1021 1022 1023 1024 1025 1026 1027 | * When issuing the geometry request, add extra space for the indicator, * if any, and for the border and padding, plus two extra pixels so the * display can be offset by 1 pixel in either direction for the raised or * lowered effect. */ if ((butPtr->image == NULL) && (butPtr->bitmap == None)) { | | | | | 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 | * When issuing the geometry request, add extra space for the indicator, * if any, and for the border and padding, plus two extra pixels so the * display can be offset by 1 pixel in either direction for the raised or * lowered effect. */ if ((butPtr->image == NULL) && (butPtr->bitmap == None)) { width += 2 * butPtr->padX; height += 2 * butPtr->padY; } if ((butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin)) { width += 2; height += 2; } Tk_GeometryRequest(butPtr->tkwin, (int) (width + butPtr->indicatorSpace + 2 * butPtr->inset), (int) (height + 2 * butPtr->inset)); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to win/tkWinButton.c.
︙ | ︙ | |||
561 562 563 564 565 566 567 568 569 570 571 572 573 574 | Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { gc = butPtr->disabledGC; } else if ((butPtr->state == STATE_ACTIVE) && !Tk_StrictMotif(butPtr->tkwin)) { gc = butPtr->activeTextGC; border = butPtr->activeBorder; | > > > > > | 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXPtr, &butPtr->padX); Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYPtr, &butPtr->padY); border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { gc = butPtr->disabledGC; } else if ((butPtr->state == STATE_ACTIVE) && !Tk_StrictMotif(butPtr->tkwin)) { gc = butPtr->activeTextGC; border = butPtr->activeBorder; |
︙ | ︙ | |||
920 921 922 923 924 925 926 | * Draw the border and traversal highlight last. This way, if the button's * contents overflow they'll be covered up by the border. */ if (relief != TK_RELIEF_FLAT) { Tk_Draw3DRectangle(tkwin, pixmap, border, defaultWidth, defaultWidth, | | | | 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | * Draw the border and traversal highlight last. This way, if the button's * contents overflow they'll be covered up by the border. */ if (relief != TK_RELIEF_FLAT) { Tk_Draw3DRectangle(tkwin, pixmap, border, defaultWidth, defaultWidth, Tk_Width(tkwin) - 2 * defaultWidth, Tk_Height(tkwin) - 2 * defaultWidth, butPtr->borderWidth, relief); } if (defaultWidth != 0) { int highlightColor; dc = TkWinGetDrawableDC(butPtr->display, pixmap, &state); if (butPtr->type == TYPE_LABEL) { |
︙ | ︙ | |||
996 997 998 999 1000 1001 1002 | /* Vertical and horizontal dialog units size in pixels. */ double vDLU, hDLU; Tk_FontMetrics fm; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); | | | | | 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | /* Vertical and horizontal dialog units size in pixels. */ double vDLU, hDLU; Tk_FontMetrics fm; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; butPtr->indicatorSpace = 0; if (!tsdPtr->initialized) { InitBoxes(butPtr->tkwin); } |
︙ | ︙ | |||
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 | /* * If the button is compound (i.e., it shows both an image and text), the * new geometry is a combination of the image and text geometry. We only * honor the compound bit if the button has both text and an image, * because otherwise it is not really a compound button. */ if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: /* * Image is above or below text. */ | > > > | 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 | /* * If the button is compound (i.e., it shows both an image and text), the * new geometry is a combination of the image and text geometry. We only * honor the compound bit if the button has both text and an image, * because otherwise it is not really a compound button. */ Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXPtr, &butPtr->padX); Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYPtr, &butPtr->padY); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: /* * Image is above or below text. */ |
︙ | ︙ | |||
1261 1262 1263 1264 1265 1266 1267 | width = butPtr->width; } if (butPtr->height > 0) { height = butPtr->height; } | | | | 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | width = butPtr->width; } if (butPtr->height > 0) { height = butPtr->height; } width += 2 * butPtr->padX; height += 2 * butPtr->padY; } else if (haveImage) { if (butPtr->width > 0) { width = butPtr->width; } else { width = imgWidth; } if (butPtr->height > 0) { |
︙ | ︙ |