Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added a drawing procedure for dark RadioButtons and dealt with many slightly wrong ttk details. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | bug-0d63621b6c |
Files: | files | file ages | folders |
SHA3-256: |
973b11e76aa85d3daa21251229bf836b |
User & Date: | culler 2019-03-15 02:42:39.432 |
Context
2019-03-15
| ||
21:14 | Fix some conditional compilation misconfiguration. check-in: f1f399c4 user: culler tags: bug-0d63621b6c | |
02:42 | Added a drawing procedure for dark RadioButtons and dealt with many slightly wrong ttk details. check-in: 973b11e7 user: culler tags: bug-0d63621b6c | |
2019-03-13
| ||
21:46 | Added a drawing procedure for dark CheckBoxes. Added drawing primitives to make the code DRYer. check-in: e85ff3ff user: culler tags: bug-0d63621b6c | |
Changes
Changes to library/ttk/aquaTheme.tcl.
︙ | ︙ | |||
27 28 29 30 31 32 33 | # Buttons ttk::style configure TButton -anchor center -width -6 \ -foreground systemControlTextColor ttk::style map TButton \ -foreground { disabled systemDisabledControlTextColor} | > > > > > > > | > > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # Buttons ttk::style configure TButton -anchor center -width -6 \ -foreground systemControlTextColor ttk::style map TButton \ -foreground { disabled systemDisabledControlTextColor} ttk::style map TCheckbutton \ -foreground { disabled systemDisabledControlTextColor} ttk::style map TRadiobutton \ -foreground { disabled systemDisabledControlTextColor} ttk::style configure Toolbutton -padding 4 # ttk::style configure Toolbutton -padding 4 -foreground black # ttk::style map Toolbutton \ # -background { # background systemWindowBody} # Workaround for #1100117: # Actually, on Aqua we probably shouldn't stipple images in # disabled buttons even if it did work... ttk::style configure . -stipple {} # Notebook |
︙ | ︙ |
Changes to macosx/ttkMacOSXTheme.c.
︙ | ︙ | |||
108 109 110 111 112 113 114 | * and must be used in order to have a background color which responds * to Dark Mode. So we use this hard-wired RGBA color on the older systems * which don't support Dark Mode anyway. */ static CGFloat windowBackground[4] = {235.0/255, 235.0/255, 235.0/255, 1.0}; | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | * and must be used in order to have a background color which responds * to Dark Mode. So we use this hard-wired RGBA color on the older systems * which don't support Dark Mode anyway. */ static CGFloat windowBackground[4] = {235.0/255, 235.0/255, 235.0/255, 1.0}; static int GetBoxColor( CGContextRef context, Tk_Window tkwin, int depth, CGFloat *fill) { TkWindow *winPtr = (TkWindow *)tkwin; NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; |
︙ | ︙ | |||
159 160 161 162 163 164 165 | fill[i] -= (depth*8.0)/255.0; } } return depth; } /* | | | | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | fill[i] -= (depth*8.0)/255.0; } } return depth; } /* * DrawGroupBox -- * * This is a standalone drawing procedure which draws the contrasting * rounded rectangular box for LabelFrames and Notebook panes. */ static void DrawGroupBox( CGRect bounds, CGContextRef context, Tk_Window tkwin) { CGPathRef path; NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *borderColor, *bgColor; static CGFloat border[4] = {1.0, 1.0, 1.0, 0.25}; CGFloat fill[4]; GetBoxColor(context, tkwin, 1, fill); bgColor = [NSColor colorWithColorSpace: deviceRGB components: fill count: 4]; CGContextSetFillColorSpace(context, deviceRGB.CGColorSpace); CGContextSetFillColorWithColor(context, bgColor.CGColor); path = CGPathCreateWithRoundedRect(bounds, 4, 4, NULL); CGContextClipToRect(context, bounds); CGContextBeginPath(context); |
︙ | ︙ | |||
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | * * The HIToolbox does not support Dark Mode, and apparently never will, * so to make widgets look "native" we have to provide analogues of the * HITheme drawing functions to be used in DarkAqua. We continue to use * HITheme in Aqua, since it understands earlier versions of the OS. */ static CGFloat darkButtonFace[4] = {112.0/255, 113.0/255, 115.0/255, 1.0}; static CGFloat darkDisabledButtonFace[4] = {86.0/255, 87.0/255, 89.0/255, 1.0}; static CGFloat darkInactiveSelectedTab[4] = {159.0/255, 160.0/255, 161.0/255, 1.0}; static CGFloat darkTabSeparator[4] = {0.0, 0.0, 0.0, 0.25}; static CGFloat darkTopGradient[8] = {1.0, 1.0, 1.0, 0.3, 1.0, 1.0, 1.0, 0.0}; static CGFloat darkBackgroundGradient[8] = {0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.25}; | > > > | > > > > > > > > > > > > > > > > > > > > > > | 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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | * * The HIToolbox does not support Dark Mode, and apparently never will, * so to make widgets look "native" we have to provide analogues of the * HITheme drawing functions to be used in DarkAqua. We continue to use * HITheme in Aqua, since it understands earlier versions of the OS. */ /* * Colors and gradients used in Dark Mode. */ static CGFloat darkButtonFace[4] = {112.0/255, 113.0/255, 115.0/255, 1.0}; static CGFloat darkDisabledButtonFace[4] = {86.0/255, 87.0/255, 89.0/255, 1.0}; static CGFloat darkInactiveSelectedTab[4] = {159.0/255, 160.0/255, 161.0/255, 1.0}; static CGFloat darkTabSeparator[4] = {0.0, 0.0, 0.0, 0.25}; static CGFloat darkTopGradient[8] = {1.0, 1.0, 1.0, 0.3, 1.0, 1.0, 1.0, 0.0}; static CGFloat darkBackgroundGradient[8] = {0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.25}; static CGFloat darkInactiveGradient[8] = {89.0/255, 90.0/255, 93.0/255, 1.0, 119.0/255, 120.0/255, 122.0/255, 1.0}; static CGFloat darkSelectedGradient[8] = {23.0/255, 111.0/255, 232.0/255, 1.0, 20.0/255, 94.0/255, 206.0/255, 1.0}; /* * NormalizeButtonBounds -- * * Apple's Human Interface Guidelines only allow three specific heights for buttons: * Regular, small and mini. We always use the regular size. However, Ttk may * provide an arbitrary bounding rectangle. We always draw the button centered * vertically on the rectangle, and having the same width as the rectangle. * This function returns the actual bounding rectangle that will be used in * drawing the button. */ static CGRect NormalizeButtonBounds( SInt32 heightMetric, CGRect bounds) { SInt32 height; ChkErr(GetThemeMetric, heightMetric, &height); bounds.origin.y += (bounds.size.height - height)/2; bounds.size.height = height; return bounds; } /* FillButtonBackground -- * * Fills a rounded rectangle with a transparent black gradient. */ static void FillButtonBackground( |
︙ | ︙ | |||
325 326 327 328 329 330 331 | CGContextClip(context); CGContextDrawLinearGradient(context, gradient, bounds.origin, end, 0); CFRelease(path); CFRelease(gradient); } /* | | | > > > > | > > | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | CGContextClip(context); CGContextDrawLinearGradient(context, gradient, bounds.origin, end, 0); CFRelease(path); CFRelease(gradient); } /* * DrawDarkButton -- * * This is a standalone drawing procedure which draws PushButtons and * PopupButtons in the Dark Mode style. */ static void DrawDarkButton( CGRect bounds, ThemeButtonKind kind, Ttk_State state, CGContextRef context) { NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *faceColor; /* * To match the appearance of Apple's buttons we need to increase the * height by 1 pixel. */ bounds.size.height += 1; CGContextClipToRect(context, bounds); FillButtonBackground(context, bounds, 5); /* * Fill the button face with the appropriate color. */ |
︙ | ︙ | |||
401 402 403 404 405 406 407 | CGContextRestoreGState(context); } HighlightButtonBorder(context, bounds); } /* | | | | > > | > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 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 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 488 489 490 491 492 493 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 555 556 | CGContextRestoreGState(context); } HighlightButtonBorder(context, bounds); } /* * DrawDarkCheckBox -- * * This is a standalone drawing procedure which draws Checkboxes * in the Dark Mode style. */ static void DrawDarkCheckBox( CGRect bounds, Ttk_State state, CGContextRef context) { CGRect checkbounds = {{0, bounds.size.height/2 - 8},{16, 16}}; NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *stroke; CGFloat x, y; bounds = CGRectOffset(checkbounds, bounds.origin.x, bounds.origin.y); x = bounds.origin.x; y = bounds.origin.y; CGContextClipToRect(context, bounds); FillButtonBackground(context, bounds, 4); bounds = CGRectInset(bounds, 1, 1); if (!(state & TTK_STATE_BACKGROUND) && ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE))) { GradientFillButtonFace(context, bounds, 3, darkSelectedGradient, 2); } else { GradientFillButtonFace(context, bounds, 3, darkInactiveGradient, 2); } HighlightButtonBorder(context, bounds); if ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE)) { CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace); if (state & TTK_STATE_DISABLED) { stroke = [NSColor disabledControlTextColor]; } else { stroke = [NSColor controlTextColor]; } CGContextSetStrokeColorWithColor(context, stroke.CGColor); } if (state & TTK_STATE_SELECTED) { CGContextSetLineWidth(context, 1.5); CGContextBeginPath(context); CGPoint check[3] = {{x+4, y+8}, {x+7, y+11}, {x+11, y+4}}; CGContextAddLines(context, check, 3); CGContextStrokePath(context); } else if (state & TTK_STATE_ALTERNATE) { CGContextSetLineWidth(context, 2.0); CGContextBeginPath(context); CGPoint bar[2] = {{x+4, y+8}, {x+12, y+8}}; CGContextAddLines(context, bar, 2); CGContextStrokePath(context); } } /* * DrawDarkRadioButton -- * * This is a standalone drawing procedure which draws RadioButtons * in the Dark Mode style. */ static void DrawDarkRadioButton( CGRect bounds, Ttk_State state, CGContextRef context) { CGRect checkbounds = {{0, bounds.size.height/2 - 9},{18, 18}}; NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *fill; CGFloat x, y; bounds = CGRectOffset(checkbounds, bounds.origin.x, bounds.origin.y); x = bounds.origin.x; y = bounds.origin.y; CGContextClipToRect(context, bounds); FillButtonBackground(context, bounds, 9); bounds = CGRectInset(bounds, 1, 1); if (!(state & TTK_STATE_BACKGROUND) && ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE))) { GradientFillButtonFace(context, bounds, 8, darkSelectedGradient, 2); } else { GradientFillButtonFace(context, bounds, 8, darkInactiveGradient, 2); } HighlightButtonBorder(context, bounds); if ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE)) { CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace); if (state & TTK_STATE_DISABLED) { fill = [NSColor disabledControlTextColor]; } else { fill = [NSColor controlTextColor]; } CGContextSetFillColorWithColor(context, fill.CGColor); } if (state & TTK_STATE_SELECTED) { CGContextBeginPath(context); CGRect dot = {{x + 6, y + 6}, {6, 6}}; CGContextAddEllipseInRect(context, dot); CGContextFillPath(context); } else if (state & TTK_STATE_ALTERNATE) { CGRect bar = {{x + 5, y + 8}, {8, 2}}; CGContextFillRect(context, bar); } } /* * DrawDarkTab -- * * This is a standalone drawing procedure which draws Tabbed Pane * Tabs in the Dark Mode style. */ static void DrawDarkTab( CGRect bounds, Ttk_State state, CGContextRef context) { NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *faceColor, *stroke; CGRect originalBounds= bounds; |
︙ | ︙ | |||
545 546 547 548 549 550 551 | SolidFillButtonFace(context, bounds, 4, faceColor); } HighlightButtonBorder(context, bounds); } } /* | | | < < < < < | 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 | SolidFillButtonFace(context, bounds, 4, faceColor); } HighlightButtonBorder(context, bounds); } } /* * DrawDarkSeparator -- * * This is a standalone drawing procedure which draws a separator widget * in Dark Mode. */ static void DrawDarkSeparator( CGRect bounds, CGContextRef context, Tk_Window tkwin) { static CGFloat fill[4] = {1.0, 1.0, 1.0, 0.3}; NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *fillColor = [NSColor colorWithColorSpace: deviceRGB components: fill count:4]; CGContextSetFillColorWithColor(context, fillColor.CGColor); CGContextFillRect(context, bounds); } #endif /* MAC_OS_X_VERSION_MIN_REQUIRED >101300 */ /*---------------------------------------------------------------------- * +++ Button element: Used for elements drawn with DrawThemeButton. */ #define NoThemeMetric 0xFFFFFFFF typedef struct { ThemeButtonKind kind; ThemeMetric heightMetric; } ThemeButtonParams; |
︙ | ︙ | |||
615 616 617 618 619 620 621 622 623 | * computeButtonDrawInfo -- * Fill in an appearance manager HIThemeButtonDrawInfo record. */ static inline HIThemeButtonDrawInfo computeButtonDrawInfo( ThemeButtonParams *params, Ttk_State state) { const HIThemeButtonDrawInfo info = { .version = 0, | > > > > > > | | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | * computeButtonDrawInfo -- * Fill in an appearance manager HIThemeButtonDrawInfo record. */ static inline HIThemeButtonDrawInfo computeButtonDrawInfo( ThemeButtonParams *params, Ttk_State state) { /* * See ButtonElementDraw for the explanation of why we always draw * PushButtons in the active state. */ const HIThemeButtonDrawInfo info = { .version = 0, .state = params && params->kind == kThemePushButton ? kThemeStateActive : Ttk_StateTableLookup(ThemeStateTable, state), .kind = params ? params->kind : 0, .value = Ttk_StateTableLookup(ButtonValueTable, state), .adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state), }; return info; } |
︙ | ︙ | |||
648 649 650 651 652 653 654 | int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThemeButtonParams *params = clientData; const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, 0); static const CGRect scratchBounds = {{0, 0}, {100, 100}}; CGRect contentBounds; | | < | | < < < < < < | < < < < < < < < < < < | > < > | < < < | | < > > > > > > > > > > > > > > > > > | | < | < > | 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 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThemeButtonParams *params = clientData; const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, 0); static const CGRect scratchBounds = {{0, 0}, {100, 100}}; CGRect contentBounds; ButtonElementSizeNoPadding( clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); /* * To compute internal padding, query the appearance manager * for the content bounds of a dummy rectangle, then use * the difference as the padding. */ ChkErr(HIThemeGetButtonContentBounds, &scratchBounds, &info, &contentBounds); paddingPtr->left = CGRectGetMinX(contentBounds); paddingPtr->right = CGRectGetMaxX(scratchBounds) - CGRectGetMaxX(contentBounds); } static void ButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { BEGIN_DRAWING(d) ThemeButtonParams *params = clientData; CGRect bounds = BoxToRect(d, b); HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, state); bounds = NormalizeButtonBounds(params->heightMetric, bounds); if (TkMacOSXInDarkMode(tkwin)) { #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 switch (info.kind) { case kThemePushButton: case kThemePopupButton: DrawDarkButton(bounds, info.kind, state, dc.context); break; case kThemeCheckBox: DrawDarkCheckBox(bounds, state, dc.context); break; case kThemeRadioButton: DrawDarkRadioButton(bounds, state, dc.context); break; default: ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); #endif } } else { /* * Apple's PushButton and PopupButton do not change their (white) fill * color when the window is inactive although, except in 10.7 (Lion), * the color of the arrow button on a PopupButton does change. For * some reason HITheme fills inactive buttons with a transparent color * that allows the window background to show through, leading to * inconsistent behavior. We work around this by filling behind an * inactive PopupButton with a white color before asking HIToolbox to * draw it. PopupButton. For PushButtons, we simply draw them in the * active state. */ if (info.kind == kThemePopupButton && (state & TTK_STATE_BACKGROUND)) { CGRect innerBounds = CGRectInset(bounds, 1, 1); SolidFillButtonFace(dc.context, innerBounds, 4, [NSColor whiteColor]); } ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); } END_DRAWING } static Ttk_ElementSpec ButtonElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, |
︙ | ︙ | |||
820 821 822 823 824 825 826 | .adornment = Ttk_StateTableLookup(TabAdornmentTable, state), .kind = kHIThemeTabKindNormal, .position = Ttk_StateTableLookup(TabPositionTable, state), }; BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 if (TkMacOSXInDarkMode(tkwin)) { | | | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | .adornment = Ttk_StateTableLookup(TabAdornmentTable, state), .kind = kHIThemeTabKindNormal, .position = Ttk_StateTableLookup(TabPositionTable, state), }; BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 if (TkMacOSXInDarkMode(tkwin)) { DrawDarkTab(bounds, state, dc.context); } else { ChkErr(HIThemeDrawTab, &bounds, &info, dc.context, HIOrientation, NULL); } #else ChkErr(HIThemeDrawTab, &bounds, &info, dc.context, HIOrientation, NULL); #endif END_DRAWING |
︙ | ︙ | |||
860 861 862 863 864 865 866 | TkWindow *winPtr = (TkWindow *)tkwin; MacDrawable *macWin = winPtr->privatePtr; CGRect bounds = BoxToRect(d, b); bounds.origin.y -= kThemeMetricTabFrameOverlap; bounds.size.height += kThemeMetricTabFrameOverlap; BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 10800 | | | 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 | TkWindow *winPtr = (TkWindow *)tkwin; MacDrawable *macWin = winPtr->privatePtr; CGRect bounds = BoxToRect(d, b); bounds.origin.y -= kThemeMetricTabFrameOverlap; bounds.size.height += kThemeMetricTabFrameOverlap; BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 10800 DrawGroupBox(bounds, dc.context, tkwin); #else HIThemeTabPaneDrawInfo info = { .version = 1, .state = Ttk_StateTableLookup(ThemeStateTable, state), .direction = kThemeTabNorth, .size = kHIThemeTabSizeNormal, .kind = kHIThemeTabKindNormal, |
︙ | ︙ | |||
916 917 918 919 920 921 922 | Drawable d, Ttk_Box b, Ttk_State state) { TkWindow *winPtr = (TkWindow *)tkwin; CGRect bounds = BoxToRect(d, b); BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 10800 | | | 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | Drawable d, Ttk_Box b, Ttk_State state) { TkWindow *winPtr = (TkWindow *)tkwin; CGRect bounds = BoxToRect(d, b); BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 10800 DrawGroupBox(bounds, dc.context, tkwin); #else const HIThemeGroupBoxDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = kHIThemeGroupBoxKindPrimaryOpaque, }; ChkErr(HIThemeDrawGroupBox, &bounds, &info, dc.context, HIOrientation); |
︙ | ︙ | |||
1010 1011 1012 1013 1014 1015 1016 | * * NOTES: * kThemeMetricComboBoxLargeDisclosureWidth -> 17 * Padding and margins guesstimated by trial-and-error. */ static Ttk_Padding ComboboxPadding = { 2, 3, 17, 1 }; | | | 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 | * * NOTES: * kThemeMetricComboBoxLargeDisclosureWidth -> 17 * Padding and margins guesstimated by trial-and-error. */ static Ttk_Padding ComboboxPadding = { 2, 3, 17, 1 }; static Ttk_Padding ComboboxMargins = { 3, 4, 4, 3 }; static void ComboboxElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *widthPtr = 0; *heightPtr = 0; |
︙ | ︙ | |||
1331 1332 1333 1334 1335 1336 1337 | /* Separator only supports kThemeStateActive, kThemeStateInactive */ .state = Ttk_StateTableLookup(ThemeStateTable, state & TTK_STATE_BACKGROUND), }; BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 if (TkMacOSXInDarkMode(tkwin)) { | | | 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 | /* Separator only supports kThemeStateActive, kThemeStateInactive */ .state = Ttk_StateTableLookup(ThemeStateTable, state & TTK_STATE_BACKGROUND), }; BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 if (TkMacOSXInDarkMode(tkwin)) { DrawDarkSeparator(bounds, dc.context, tkwin); } else { ChkErr(HIThemeDrawSeparator, &bounds, &info, dc.context, HIOrientation); } #else ChkErr(HIThemeDrawSeparator, &bounds, &info, dc.context, HIOrientation); #endif END_DRAWING |
︙ | ︙ | |||
1411 1412 1413 1414 1415 1416 1417 | * Before drawing any ttk widget, its bounding rectangle is filled with a * background color. This color must match the background color of the * containing widget to avoid looking ugly. The need for care when doing * this is exacerbated by the fact that ttk enforces its "native look" by * not allowing user control of the background or highlight colors of ttk * widgets. * | | | | | | | | | > | > | | | | | | | | | | | | | | | 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 | * Before drawing any ttk widget, its bounding rectangle is filled with a * background color. This color must match the background color of the * containing widget to avoid looking ugly. The need for care when doing * this is exacerbated by the fact that ttk enforces its "native look" by * not allowing user control of the background or highlight colors of ttk * widgets. * * This job is made more complicated in recent versions of macOS by the fact * that the Appkit GroupBox (used for ttk LabelFrames) and TabbedPane (used * for the Notebook widget) both place their content inside a rectangle with * rounded corners that has a color which contrasts with the dialog * background color. Moreover, although the Apple human interface * guidelines recommend against doing so, there are times when one wants to * nest these widgets, for example having a GroupBox inside of a TabbedPane. * To have the right contrast, each level of nesting requires a different * color. * * Previous Tk releases used the HIThemeDrawGroupBox routine to draw * GroupBoxes and TabbedPanes. This meant that the best that could be done * was to set the GroupBox to be of kind kHIThemeGroupBoxKindPrimaryOpaque, * and set its fill color to be the system background color. If widgets * inside the box were drawn with the system background color the * backgrounds would match. But this produces a GroupBox with no contrast, * the only visual clue being a faint highlighting around the top of the * GroupBox. Moreover, the TabbedPane does not have an Opaque version, so * while it is drawn inside a contrasting rounded rectangle, the widgets * inside the pane needed to be enclosed in a frame with the system * background color. This added a visual artifact since the frame's * background color does not match the Pane's background color. That code * has now been replaced with the standalone drawing procedure * macOSXDrawGroupBox, which draws a rounded rectangle with an appropriate * contrasting background color. * * Patterned backgrounds, which are now obsolete, should be aligned with the * coordinate system of the top-level window. Apparently failing to do this * used to cause graphics anomalies when drawing into an off-screen graphics * port. The code for handling this is currently commented out. */ static void FillElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, b); BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 10800 NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *bgColor; CGFloat fill[4]; GetBoxColor(dc.context, tkwin, 0, fill); bgColor = [NSColor colorWithColorSpace: deviceRGB components: fill count: 4]; CGContextSetFillColorSpace(dc.context, deviceRGB.CGColorSpace); CGContextSetFillColorWithColor(dc.context, bgColor.CGColor); CGContextFillRect(dc.context, bounds); #else ThemeBrush brush = (state & TTK_STATE_BACKGROUND) |
︙ | ︙ |