Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add quotes to the "processing * option" error-messages, for consistancy. Some indenting fixes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-branch |
Files: | files | file ages | folders |
SHA3-256: |
4cd35ddbc926b493f45af57c1cc4af75 |
User & Date: | jan.nijtmans 2024-06-14 15:45:33 |
Context
2024-06-14
| ||
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 | |
16:08 | Add quotes to the "processing * option" error-messages, for consistancy. Some indenting fixes check-in: 44d3ea9c user: jan.nijtmans tags: trunk, main | |
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 | |
07:24 | Fix [1576528fff]: image read file with -from option check-in: 1d4d20df user: jan.nijtmans tags: core-8-branch | |
Changes
Changes to generic/tkButton.c.
︙ | ︙ | |||
779 780 781 782 783 784 785 | { TkButton *butPtr = (TkButton *)clientData; int index; int result; Tcl_Obj *objPtr; if (objc < 2) { | | | 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | { TkButton *butPtr = (TkButton *)clientData; int index; int result; Tcl_Obj *objPtr; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } result = Tcl_GetIndexFromObjStruct(interp, objv[1], commandNames[butPtr->type], sizeof(char *), "option", 0, &index); if (result != TCL_OK) { return result; } |
︙ | ︙ | |||
1125 1126 1127 1128 1129 1130 1131 | * appropriate value, initialize the variable if it doesn't exist, * then set a trace on the variable to monitor future changes to * its value. */ valuePtr = Tcl_ObjGetVar2(interp, namePtr, NULL, TCL_GLOBAL_ONLY); butPtr->flags &= ~SELECTED; | | | | | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | * appropriate value, initialize the variable if it doesn't exist, * then set a trace on the variable to monitor future changes to * its value. */ valuePtr = Tcl_ObjGetVar2(interp, namePtr, NULL, TCL_GLOBAL_ONLY); butPtr->flags &= ~SELECTED; butPtr->flags &= ~TRISTATED; if (valuePtr != NULL) { const char *value = Tcl_GetString(valuePtr); if (strcmp(value, Tcl_GetString(butPtr->onValuePtr)) == 0) { butPtr->flags |= SELECTED; } else if (strcmp(value, Tcl_GetString(butPtr->tristateValuePtr)) == 0) { butPtr->flags |= TRISTATED; /* * For checkbuttons if the tristate value is the * same as the offvalue then prefer off to tristate */ if (butPtr->offValuePtr && strcmp(value, Tcl_GetString(butPtr->offValuePtr)) == 0) { butPtr->flags &= ~TRISTATED; } } } else { if (Tcl_ObjSetVar2(interp, namePtr, NULL, (butPtr->type == TYPE_CHECK_BUTTON) ? butPtr->offValuePtr : Tcl_NewObj(), TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { continue; |
︙ | ︙ | |||
1254 1255 1256 1257 1258 1259 1260 | /* * The button must display the contents of an image or bitmap. */ if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->widthPtr, &butPtr->width) != TCL_OK) { widthError: | | | | 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 | /* * The button must display the contents of an image or bitmap. */ if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->widthPtr, &butPtr->width) != TCL_OK) { widthError: Tcl_AddErrorInfo(interp, "\n (processing \"-width\" option)"); continue; } if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->heightPtr, &butPtr->height) != TCL_OK) { heightError: Tcl_AddErrorInfo(interp, "\n (processing \"-height\" option)"); continue; } } else { /* * The button displays an ordinary text string. */ |
︙ | ︙ | |||
1652 1653 1654 1655 1656 1657 1658 | value = Tcl_GetString(valuePtr); } if (strcmp(value, Tcl_GetString(butPtr->onValuePtr)) == 0) { if (butPtr->flags & SELECTED) { return NULL; } butPtr->flags |= SELECTED; | | | | | | | | 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 | value = Tcl_GetString(valuePtr); } if (strcmp(value, Tcl_GetString(butPtr->onValuePtr)) == 0) { if (butPtr->flags & SELECTED) { return NULL; } butPtr->flags |= SELECTED; butPtr->flags &= ~TRISTATED; } else if (butPtr->offValuePtr && strcmp(value, Tcl_GetString(butPtr->offValuePtr)) == 0) { if (!(butPtr->flags & (SELECTED | TRISTATED))) { return NULL; } butPtr->flags &= ~(SELECTED | TRISTATED); } else if (strcmp(value, Tcl_GetString(butPtr->tristateValuePtr)) == 0) { if (butPtr->flags & TRISTATED) { return NULL; } butPtr->flags |= TRISTATED; butPtr->flags &= ~SELECTED; } else if (butPtr->flags & (SELECTED | TRISTATED)) { butPtr->flags &= ~(SELECTED | TRISTATED); } else { return NULL; } redisplay: |
︙ | ︙ |
Changes to generic/tkInt.h.
︙ | ︙ | |||
967 968 969 970 971 972 973 | typedef struct { XKeyEvent keyEvent; /* The real event from X11. */ #ifdef _WIN32 # ifndef XMaxTransChars # define XMaxTransChars 7 # endif | | < | 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | typedef struct { XKeyEvent keyEvent; /* The real event from X11. */ #ifdef _WIN32 # ifndef XMaxTransChars # define XMaxTransChars 7 # endif char trans_chars[XMaxTransChars]; /* translated characters */ unsigned char nbytes; #elif !defined(MAC_OSX_TK) char *charValuePtr; /* A pointer to a string that holds the key's * %A substitution text (before backslash * adding), or NULL if that has not been * computed yet. If non-NULL, this string was * allocated with ckalloc(). */ |
︙ | ︙ |
Changes to generic/tkMenubutton.c.
︙ | ︙ | |||
566 567 568 569 570 571 572 | * Recompute the geometry for the button. */ if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) { if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString, &mbPtr->width) != TCL_OK) { widthError: | | | | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | * Recompute the geometry for the button. */ if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) { if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString, &mbPtr->width) != TCL_OK) { widthError: Tcl_AddErrorInfo(interp, "\n (processing \"-width\" option)"); continue; } if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString, &mbPtr->height) != TCL_OK) { heightError: Tcl_AddErrorInfo(interp, "\n (processing \"-height\" option)"); continue; } } else { if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width) != TCL_OK) { goto widthError; } |
︙ | ︙ |
Changes to generic/tkMessage.c.
︙ | ︙ | |||
849 850 851 852 853 854 855 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { | | | | | | | | | | | | | | | | | | | | | | 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) { void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MessageTextVarProc, probe); if (probe == (void *)msgPtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * textVarName, which means it is not unset and not * the cause of this unset trace. Instead some outdated * former variable must be, and we should ignore it. */ return NULL; } Tcl_SetVar2(interp, msgPtr->textVarName, NULL, msgPtr->string, TCL_GLOBAL_ONLY); Tcl_TraceVar2(interp, msgPtr->textVarName, NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MessageTextVarProc, clientData); } return NULL; |
︙ | ︙ |
Changes to library/button.tcl.
︙ | ︙ | |||
748 749 750 751 752 753 754 | $w configure -state normal } # Restore the original button "selected" color; but only if the user # has not changed it in the meantime. if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} { | | | | | 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | $w configure -state normal } # Restore the original button "selected" color; but only if the user # has not changed it in the meantime. if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} { if {[$w cget -selectcolor] eq $Priv($w,selectcolor) || ([info exist Priv($w,aselectcolor)] && [$w cget -selectcolor] eq $Priv($w,aselectcolor))} { $w configure -selectcolor $Priv($w,selectcolor) } } unset -nocomplain Priv($w,selectcolor) Priv($w,aselectcolor) # Restore the original button relief if it was changed by Tk. That is # signaled by the existence of Priv($w,prelief). |
︙ | ︙ |
Changes to library/tk.tcl.
︙ | ︙ | |||
14 15 16 17 18 19 20 | package require -exact tk 8.7b1 # Create a ::tk namespace namespace eval ::tk { # Set up the msgcat commands namespace eval msgcat { namespace export mc mcmax | | | | | | | | | | | | | | | | | | | | | | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | package require -exact tk 8.7b1 # Create a ::tk namespace namespace eval ::tk { # Set up the msgcat commands namespace eval msgcat { namespace export mc mcmax if {[interp issafe] || [catch {package require msgcat}]} { # The msgcat package is not available. Supply our own # minimal replacement. proc mc {src args} { return [format $src {*}$args] } proc mcmax {args} { set max 0 foreach string $args { set len [string length $string] if {$len>$max} { set max $len } } return $max } } else { # Get the commands from the msgcat package that Tk uses. namespace import ::msgcat::mc namespace import ::msgcat::mcmax ::msgcat::mcload [file join $::tk_library msgs] } } namespace import ::tk::msgcat::* } # and a ::ttk namespace namespace eval ::ttk { if {$::tk_library ne ""} { # avoid file join to work in safe interps, but this is also x-plat ok |
︙ | ︙ | |||
494 495 496 497 498 499 500 | # ---------------------------------------------------------------------- # Read in files that define all of the class bindings. # ---------------------------------------------------------------------- if {$::tk_library ne ""} { proc ::tk::SourceLibFile {file} { | | | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | # ---------------------------------------------------------------------- # Read in files that define all of the class bindings. # ---------------------------------------------------------------------- if {$::tk_library ne ""} { proc ::tk::SourceLibFile {file} { namespace eval :: [list source -encoding utf-8 [file join $::tk_library $file.tcl]] } namespace eval ::tk { SourceLibFile icons SourceLibFile iconbadges SourceLibFile button SourceLibFile entry SourceLibFile listbox |
︙ | ︙ | |||
720 721 722 723 724 725 726 | proc ::tk::mac::DoScriptText {script} { uplevel #0 $script eval $script } #This procedure is required to silence warnings generated #by inline AppleScript execution. proc ::tk::mac::GetDynamicSdef {} { | | | | 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | proc ::tk::mac::DoScriptText {script} { uplevel #0 $script eval $script } #This procedure is required to silence warnings generated #by inline AppleScript execution. proc ::tk::mac::GetDynamicSdef {} { puts "" } } if {[info commands ::tk::endOfWord] eq ""} { proc ::tk::endOfWord {str start {locale {}}} { if {$start < 0} { set start -1 } |
︙ | ︙ |
Changes to macosx/tkMacOSXButton.c.
︙ | ︙ | |||
204 205 206 207 208 209 210 | Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } else { Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } | | | | | | | | | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } else { Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } /* * Display image or bitmap or text for labels or custom controls. */ DrawButtonImageAndText(butPtr); needhighlight = 1; } else { /* * Draw the native portion of the buttons. */ TkMacOSXDrawButton(macButtonPtr, dpPtr->gc, pixmap); /* * Ask for the highlight border, if needed. */ if (butPtr->highlightWidth < 3) { needhighlight = 1; } } /* * Draw highlight border, if needed. */ if (needhighlight) { GC gc = NULL; if ((butPtr->flags & GOT_FOCUS) && butPtr->highlightColorPtr) { gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap); } else if (butPtr->type == TYPE_LABEL) { gc = Tk_GCForColor(Tk_3DBorderColor(butPtr->highlightBorder), pixmap); } if (gc) { TkMacOSXDrawSolidBorder(tkwin, gc, 0, butPtr->highlightWidth); } |
︙ | ︙ | |||
364 365 366 367 368 369 370 | /* * Allow room to shift the image. */ width += 2; height += 2; } } else { /* Text only */ | | | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | /* * Allow room to shift the image. */ width += 2; 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); |
︙ | ︙ | |||
392 393 394 395 396 397 398 | width += butPtr->inset*2; height += butPtr->inset*2; if ([NSApp macOSVersion] == 100600) { width += 12; } if (mbPtr->btnkind == kThemePushButton) { | | | | | | | | 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 | 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); } |
︙ | ︙ | |||
449 450 451 452 453 454 455 | int imageXOffset = 0, imageYOffset = 0; int textXOffset = 0, textYOffset = 0; int width = 0, height = 0; int fullWidth = 0, fullHeight = 0; DrawParams *dpPtr = &mbPtr->drawParams; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { | | | | | | | | | | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | int imageXOffset = 0, imageYOffset = 0; int textXOffset = 0, textYOffset = 0; int width = 0, height = 0; int fullWidth = 0, fullHeight = 0; DrawParams *dpPtr = &mbPtr->drawParams; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } pixmap = (Pixmap) Tk_WindowId(tkwin); if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } 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: /* Image is above or below text */ if (butPtr->compound == COMPOUND_TOP) { textYOffset = height + butPtr->padY; } else { imageYOffset = butPtr->textHeight + butPtr->padY; |
︙ | ︙ | |||
522 523 524 525 526 527 528 | textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; default: break; } | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; default: break; } TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX + butPtr->borderWidth, butPtr->padY + butPtr->borderWidth, fullWidth + butPtr->indicatorSpace, fullHeight, &x, &y); x += butPtr->indicatorSpace; if (dpPtr->relief == TK_RELIEF_SUNKEN) { x += dpPtr->offset; y += dpPtr->offset; } else if (dpPtr->relief == TK_RELIEF_RAISED) { x -= dpPtr->offset; y -= dpPtr->offset; } if (pressed) { x += dpPtr->offset; y += dpPtr->offset; } imageXOffset += x; imageYOffset += y; if (butPtr->image != NULL) { if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) { Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } } else { XSetClipOrigin(butPtr->display, dpPtr->gc, imageXOffset, imageYOffset); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc, 0, 0, (unsigned int) width, (unsigned int) height, imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); } y += 1; /* Tweak to match native buttons. */ Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1); Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, x + textXOffset, y + textYOffset, butPtr->underline); } else if (haveImage) { /* Image only */ int x = 0, y; TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX + butPtr->borderWidth, butPtr->padY + butPtr->borderWidth, width + butPtr->indicatorSpace, height, &x, &y); x += butPtr->indicatorSpace; if (pressed) { x += dpPtr->offset; y += dpPtr->offset; } imageXOffset += x; imageYOffset += y; |
︙ | ︙ | |||
606 607 608 609 610 611 612 | XSetClipOrigin(butPtr->display, dpPtr->gc, x, y); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc, 0, 0, (unsigned int) width, (unsigned int) height, imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); } } else { /* Text only */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 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 | XSetClipOrigin(butPtr->display, dpPtr->gc, x, y); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc, 0, 0, (unsigned int) width, (unsigned int) height, imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); } } else { /* Text only */ int x, y; TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, butPtr->textWidth + butPtr->indicatorSpace, butPtr->textHeight, &x, &y); x += butPtr->indicatorSpace; y += 1; /* Tweak to match native buttons */ Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, x, y, 0, -1); } /* * If the button is disabled with a stipple rather than a special * foreground color, generate the stippled effect. If the widget is * selected and we use a different background color when selected, must * temporarily modify the GC so the stippling is the right color. */ if (mbPtr->useTkText) { if ((butPtr->state == STATE_DISABLED) && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) { if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->selectBorder)->pixel); } /* * Stipple the whole button if no disabledFg was specified, * otherwise restrict stippling only to displayed image */ if (butPtr->disabledFg == NULL) { XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin)); } else { XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, imageXOffset, imageYOffset, (unsigned) imageWidth, (unsigned) imageHeight); } if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL) ) { XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->normalBorder)->pixel); } } /* * Draw the border and traversal highlight last. This way, if the * 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); } } } /* *---------------------------------------------------------------------- * * TkpDestroyButton -- |
︙ | ︙ | |||
691 692 693 694 695 696 697 | void TkpDestroyButton( TkButton *butPtr) { MacButton *mbPtr = (MacButton *) butPtr; /* Mac button. */ if (mbPtr->defaultPulseHandler) { | | | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | void TkpDestroyButton( TkButton *butPtr) { MacButton *mbPtr = (MacButton *) butPtr; /* Mac button. */ if (mbPtr->defaultPulseHandler) { Tcl_DeleteTimerHandler(mbPtr->defaultPulseHandler); } } /* *-------------------------------------------------------------- * * TkMacOSXDrawButton -- |
︙ | ︙ | |||
716 717 718 719 720 721 722 | *-------------------------------------------------------------- */ static void TkMacOSXDrawButton( MacButton *mbPtr, /* Mac button. */ TCL_UNUSED(GC), /* The GC we are drawing into - needed for | | | | | | | | | | | | | | | | | 716 717 718 719 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 | *-------------------------------------------------------------- */ static void TkMacOSXDrawButton( MacButton *mbPtr, /* Mac button. */ TCL_UNUSED(GC), /* The GC we are drawing into - needed for * the bevel button */ Pixmap pixmap) /* The pixmap we are drawing into - needed * for the bevel button */ { TkButton *butPtr = (TkButton *) mbPtr; TkWindow *winPtr = (TkWindow *) butPtr->tkwin; HIRect cntrRect; TkMacOSXDrawingContext dc; DrawParams *dpPtr = &mbPtr->drawParams; int useNewerHITools = 1; TkMacOSXComputeButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo); cntrRect = CGRectMake(winPtr->privatePtr->xOff, winPtr->privatePtr->yOff, Tk_Width(butPtr->tkwin), Tk_Height(butPtr->tkwin)); cntrRect = CGRectInset(cntrRect, butPtr->inset, butPtr->inset); if (useNewerHITools == 1) { HIRect contHIRec; static HIThemeButtonDrawInfo hiinfo; ButtonBackgroundDrawCB(&cntrRect, mbPtr, 32, true); if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } hiinfo.version = 0; hiinfo.state = mbPtr->drawinfo.state; hiinfo.kind = mbPtr->btnkind; hiinfo.value = mbPtr->drawinfo.value; hiinfo.adornment = mbPtr->drawinfo.adornment; hiinfo.animation.time.current = CFAbsoluteTimeGetCurrent(); if (hiinfo.animation.time.start == 0) { hiinfo.animation.time.start = hiinfo.animation.time.current; } /* * To avoid buttons with white text on a white background, we set the * state to inactive in Dark Mode unless the button is pressed or is a * -default active button. This isn't perfect but it is mostly usable. * Using a ttk::button would be a much better choice, however. */ if ([NSApp macOSVersion] < 101500) { if (TkMacOSXInDarkMode(butPtr->tkwin) && mbPtr->drawinfo.state != kThemeStatePressed && !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) { hiinfo.state = kThemeStateInactive; } } HIThemeDrawButton(&cntrRect, &hiinfo, dc.context, kHIThemeOrientationNormal, &contHIRec); TkMacOSXRestoreDrawingContext(&dc); ButtonContentDrawCB(&contHIRec, mbPtr->btnkind, &mbPtr->drawinfo, (MacButton *) mbPtr, 32, true); } else { if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } TkMacOSXRestoreDrawingContext(&dc); |
︙ | ︙ | |||
815 816 817 818 819 820 821 | MacButton *mbPtr = (MacButton *) ptr; TkButton *butPtr = (TkButton *) mbPtr; Tk_Window tkwin = butPtr->tkwin; Pixmap pixmap; int usehlborder = 0; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { | | | | | | | | | 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 843 844 845 846 847 848 | MacButton *mbPtr = (MacButton *) ptr; TkButton *butPtr = (TkButton *) mbPtr; Tk_Window tkwin = butPtr->tkwin; Pixmap pixmap; int usehlborder = 0; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } pixmap = (Pixmap) Tk_WindowId(tkwin); if (butPtr->type != TYPE_LABEL) { switch (mbPtr->btnkind) { case kThemeSmallBevelButton: case kThemeBevelButton: case kThemeRoundedBevelButton: case kThemePushButton: usehlborder = 1; break; } } if (usehlborder) { Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } else { Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); } } /* *-------------------------------------------------------------- * * ButtonContentDrawCB -- |
︙ | ︙ | |||
866 867 868 869 870 871 872 | TCL_UNUSED(SInt16), TCL_UNUSED(Boolean)) { TkButton *butPtr = (TkButton *) ptr; Tk_Window tkwin = butPtr->tkwin; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { | | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | TCL_UNUSED(SInt16), TCL_UNUSED(Boolean)) { TkButton *butPtr = (TkButton *) ptr; Tk_Window tkwin = butPtr->tkwin; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } /* * Overlay Tk elements over button native region: drawing elements within * button boundaries/native region causes unpredictable metrics. */ |
︙ | ︙ | |||
946 947 948 949 950 951 952 | TkButton *butPtr, ThemeButtonKind *btnkind, HIThemeButtonDrawInfo *drawinfo) { MacButton *mbPtr = (MacButton *) butPtr; if (butPtr->borderWidth <= 2) { | | | | | | | 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 | TkButton *butPtr, ThemeButtonKind *btnkind, HIThemeButtonDrawInfo *drawinfo) { MacButton *mbPtr = (MacButton *) butPtr; if (butPtr->borderWidth <= 2) { *btnkind = kThemeSmallBevelButton; } else if (butPtr->borderWidth == 3) { *btnkind = kThemeBevelButton; } else if (butPtr->borderWidth == 4) { *btnkind = kThemeRoundedBevelButton; } else { *btnkind = kThemePushButton; } if ((butPtr->image == NULL) && (butPtr->bitmap == None)) { switch (butPtr->type) { case TYPE_BUTTON: *btnkind = kThemePushButton; break; case TYPE_RADIO_BUTTON: if (butPtr->borderWidth <= 1) { *btnkind = kThemeSmallRadioButton; } else { |
︙ | ︙ | |||
978 979 980 981 982 983 984 | *btnkind = kThemeCheckBox; } break; } } if (butPtr->indicatorOn) { | | | | | | | | | | | | | | | | | | | | | | | | | 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 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 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 | *btnkind = kThemeCheckBox; } break; } } if (butPtr->indicatorOn) { switch (butPtr->type) { case TYPE_RADIO_BUTTON: if (butPtr->borderWidth <= 1) { *btnkind = kThemeSmallRadioButton; } else { *btnkind = kThemeRadioButton; } break; case TYPE_CHECK_BUTTON: if (butPtr->borderWidth <= 1) { *btnkind = kThemeSmallCheckBox; } else { *btnkind = kThemeCheckBox; } break; } } else { if (butPtr->type == TYPE_RADIO_BUTTON || butPtr->type == TYPE_CHECK_BUTTON) { if (*btnkind == kThemePushButton) { *btnkind = kThemeBevelButton; } } } if (butPtr->flags & SELECTED) { drawinfo->value = kThemeButtonOn; } else if (butPtr->flags & TRISTATED) { drawinfo->value = kThemeButtonMixed; } else { drawinfo->value = kThemeButtonOff; } if ((mbPtr->flags & FIRST_DRAW) != 0) { mbPtr->flags &= ~FIRST_DRAW; if (Tk_MacOSXIsAppInFront()) { mbPtr->flags |= ACTIVE; } } drawinfo->state = kThemeStateInactive; if ((mbPtr->flags & ACTIVE) == 0) { if (butPtr->state == STATE_DISABLED) { drawinfo->state = kThemeStateUnavailableInactive; } else { drawinfo->state = kThemeStateInactive; } } else if (butPtr->state == STATE_DISABLED) { drawinfo->state = kThemeStateUnavailable; } else if (butPtr->state == STATE_ACTIVE) { drawinfo->state = kThemeStatePressed; } else { drawinfo->state = kThemeStateActive; } drawinfo->adornment = kThemeAdornmentNone; if (butPtr->defaultState == DEFAULT_ACTIVE) { if (drawinfo->state != kThemeStatePressed) { drawinfo->adornment |= kThemeAdornmentDefault; } /* * Older macOS systems (10.9 and earlier) use an animation to * indicate the active button. This is simulated by redrawing * the button periodically. */ if (!mbPtr->defaultPulseHandler && ([NSApp macOSVersion] <= 100900)) { mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler( PULSE_TIMER_MSECS, PulseDefaultButtonProc, butPtr); } } else if (mbPtr->defaultPulseHandler) { Tcl_DeleteTimerHandler(mbPtr->defaultPulseHandler); } if (butPtr->highlightWidth >= 3) { if ((butPtr->flags & GOT_FOCUS)) { drawinfo->adornment |= kThemeAdornmentFocus; } } } /* *---------------------------------------------------------------------- * * TkMacOSXComputeButtonDrawParams -- |
︙ | ︙ | |||
1087 1088 1089 1090 1091 1092 1093 | { MacButton *mbPtr = (MacButton *) butPtr; dpPtr->hasImageOrBitmap = ((butPtr->image != NULL) || (butPtr->bitmap != None)); if (butPtr->type != TYPE_LABEL) { | | | | | | | 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | { MacButton *mbPtr = (MacButton *) butPtr; dpPtr->hasImageOrBitmap = ((butPtr->image != NULL) || (butPtr->bitmap != None)); if (butPtr->type != TYPE_LABEL) { dpPtr->offset = 0; if (dpPtr->hasImageOrBitmap) { switch (mbPtr->btnkind) { case kThemeSmallBevelButton: case kThemeBevelButton: case kThemeRoundedBevelButton: case kThemePushButton: dpPtr->offset = 1; break; } } } dpPtr->border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { dpPtr->gc = butPtr->disabledGC; } else if (butPtr->type == TYPE_BUTTON && butPtr->state == STATE_ACTIVE) { dpPtr->gc = butPtr->activeTextGC; |
︙ | ︙ | |||
1183 1184 1185 1186 1187 1188 1189 | * Fix 40ada90762: any idle calls to TkpDisplayButton need to be canceled * in case the button is destroyed and has its data freed before the idle * event is handled (DestroyButton only cancels calls when REDRAW_PENDING * is set, which is not the case after calling TkpDisplayButton directly). */ Tcl_CancelIdleCall(TkpDisplayButton, clientData); mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler( | | | 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 | * Fix 40ada90762: any idle calls to TkpDisplayButton need to be canceled * in case the button is destroyed and has its data freed before the idle * event is handled (DestroyButton only cancels calls when REDRAW_PENDING * is set, which is not the case after calling TkpDisplayButton directly). */ Tcl_CancelIdleCall(TkpDisplayButton, clientData); mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler( PULSE_TIMER_MSECS, PulseDefaultButtonProc, clientData); } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to tests/button.test.
︙ | ︙ | |||
3364 3365 3366 3367 3368 3369 3370 | test button-5.17 {ConfigureButton - -width option} -body { button .b -text "Button 1" catch {.b configure -width 1i} return $errorInfo } -cleanup { destroy .b } -result {expected integer but got "1i" | | | | | 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 | test button-5.17 {ConfigureButton - -width option} -body { button .b -text "Button 1" catch {.b configure -width 1i} return $errorInfo } -cleanup { destroy .b } -result {expected integer but got "1i" (processing "-width" option) invoked from within ".b configure -width 1i"} test button-5.18 {ConfigureButton - -height option} -body { button .b -text "Button 1" .b configure -height 0.5c } -cleanup { destroy .b } -returnCodes {error} -result {expected integer but got "0.5c"} test button-5.19 {ConfigureButton - -height option} -body { button .b -text "Button 1" catch {.b configure -height 0.5c} return $errorInfo } -cleanup { destroy .b } -result {expected integer but got "0.5c" (processing "-height" option) invoked from within ".b configure -height 0.5c"} #ex 6.16 test button-5.20 {ConfigureButton - -width option} -body { button .b -bitmap questhead .b configure -width abc } -cleanup { destroy .b } -returnCodes {error} -result {expected screen distance but got "abc"} test button-5.21 {ConfigureButton - -width option} -body { button .b -bitmap questhead catch {.b configure -width abc} return $errorInfo } -cleanup { destroy .b } -result {expected screen distance but got "abc" (processing "-width" option) invoked from within ".b configure -width abc"} test button-5.22 {ConfigureButton - -height option} -constraints { testImageType } -setup { image create test image1 } -body { |
︙ | ︙ | |||
3424 3425 3426 3427 3428 3429 3430 | button .b -image image1 catch {.b configure -height 0.5x} return $errorInfo } -cleanup { destroy .b image delete image1 } -result {expected screen distance but got "0.5x" | | | 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 | button .b -image image1 catch {.b configure -height 0.5x} return $errorInfo } -cleanup { destroy .b image delete image1 } -result {expected screen distance but got "0.5x" (processing "-height" option) invoked from within ".b configure -height 0.5x"} #ex 6.18 test button-5.24 {ConfigureButton - computing geometry} -constraints { fonts } -body { button .b -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ |
︙ | ︙ |
Changes to tests/menubut.test.
︙ | ︙ | |||
400 401 402 403 404 405 406 | } -body { button .mb1 -text "Menubutton 1" catch {.mb1 configure -width 1i} return $errorInfo } -cleanup { deleteWindows } -result {expected integer but got "1i" | | | | | 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 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | } -body { button .mb1 -text "Menubutton 1" catch {.mb1 configure -width 1i} return $errorInfo } -cleanup { deleteWindows } -result {expected integer but got "1i" (processing "-width" option) invoked from within ".mb1 configure -width 1i"} test menubutton-4.3 {ConfigureMenuButton procedure} -setup { deleteWindows } -body { button .mb1 -text "Menubutton 1" .mb1 configure -height 0.5c } -cleanup { deleteWindows } -returnCodes error -result {expected integer but got "0.5c"} test menubutton-4.4 {ConfigureMenuButton procedure} -setup { deleteWindows } -body { button .mb1 -text "Menubutton 1" catch {.mb1 configure -height 0.5c} return $errorInfo } -cleanup { deleteWindows } -result {expected integer but got "0.5c" (processing "-height" option) invoked from within ".mb1 configure -height 0.5c"} test menubutton-4.5 {ConfigureMenuButton procedure} -setup { deleteWindows } -body { button .mb1 -bitmap questhead .mb1 configure -width abc } -cleanup { deleteWindows } -returnCodes error -result {expected screen distance but got "abc"} test menubutton-4.6 {ConfigureMenuButton procedure} -setup { deleteWindows } -body { button .mb1 -bitmap questhead catch {.mb1 configure -width abc} return $errorInfo } -cleanup { deleteWindows } -result {expected screen distance but got "abc" (processing "-width" option) invoked from within ".mb1 configure -width abc"} test menubutton-4.7 {ConfigureMenuButton procedure} -constraints { testImageType } -setup { deleteWindows |
︙ | ︙ | |||
473 474 475 476 477 478 479 | button .mb1 -image image1 catch {.mb1 configure -height 0.5x} return $errorInfo } -cleanup { deleteWindows imageCleanup } -result {expected screen distance but got "0.5x" | | | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | button .mb1 -image image1 catch {.mb1 configure -height 0.5x} return $errorInfo } -cleanup { deleteWindows imageCleanup } -result {expected screen distance but got "0.5x" (processing "-height" option) invoked from within ".mb1 configure -height 0.5x"} test menubutton-4.9 {ConfigureMenuButton procedure} -constraints { nonPortable fonts } -setup { deleteWindows |
︙ | ︙ |
Changes to win/tkWinButton.c.
︙ | ︙ | |||
619 620 621 622 623 624 625 | /* * Compute width of default ring and offset for pushed buttons. */ if (butPtr->type == TYPE_LABEL) { defaultWidth = butPtr->highlightWidth; | | | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | /* * Compute width of default ring and offset for pushed buttons. */ if (butPtr->type == TYPE_LABEL) { defaultWidth = butPtr->highlightWidth; offset = 0; } else if (butPtr->type == TYPE_BUTTON) { defaultWidth = ((butPtr->defaultState == DEFAULT_ACTIVE) ? butPtr->highlightWidth : 0); offset = 1; } else { defaultWidth = 0; if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { |
︙ | ︙ | |||
925 926 927 928 929 930 931 | Tk_Draw3DRectangle(tkwin, pixmap, border, defaultWidth, defaultWidth, Tk_Width(tkwin) - 2*defaultWidth, Tk_Height(tkwin) - 2*defaultWidth, butPtr->borderWidth, relief); } if (defaultWidth != 0) { | | | | | | | | 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 | 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) { highlightColor = (int) Tk_3DBorderColor(butPtr->highlightBorder)->pixel; } else { highlightColor = (int) butPtr->highlightColorPtr->pixel; } TkWinFillRect(dc, 0, 0, Tk_Width(tkwin), defaultWidth, highlightColor); TkWinFillRect(dc, 0, 0, defaultWidth, Tk_Height(tkwin), highlightColor); TkWinFillRect(dc, 0, Tk_Height(tkwin) - defaultWidth, Tk_Width(tkwin), defaultWidth, highlightColor); |
︙ | ︙ | |||
1445 1446 1447 1448 1449 1450 1451 | case BN_CLICKED: { /* * OOPS: chromium fires WM_NULL regularly to ping if plugin is still * alive. When using an external window (i.e. via the tcl plugin), this * causes all buttons to fire once a second, so we need to make sure * that we are not dealing with the chromium life check. */ | | | 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 | case BN_CLICKED: { /* * OOPS: chromium fires WM_NULL regularly to ping if plugin is still * alive. When using an external window (i.e. via the tcl plugin), this * causes all buttons to fire once a second, so we need to make sure * that we are not dealing with the chromium life check. */ if (wParam != 0 || lParam != 0) { int code; Tcl_Interp *interp = butPtr->info.interp; if (butPtr->info.state != STATE_DISABLED) { Tcl_Preserve(interp); code = TkInvokeButton((TkButton*)butPtr); if (code != TCL_OK && code != TCL_CONTINUE |
︙ | ︙ |