Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix bug [0d63621b6c]: Aqua ttk uses incorrect background colors. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | bug-0d63621b6c |
Files: | files | file ages | folders |
SHA3-256: |
a90a32fdf4cae8ce692fcd6029d429e6 |
User & Date: | culler 2019-02-24 17:08:37 |
Original Comment: | Fix bug [0d3621b]: Aqua ttk uses incorrect background colors. |
Context
2019-02-25
| ||
02:19 | Remove some unneeded code. check-in: e2eb16dc user: culler tags: bug-0d63621b6c | |
2019-02-24
| ||
17:08 | Fix bug [0d63621b6c]: Aqua ttk uses incorrect background colors. check-in: a90a32fd user: culler tags: bug-0d63621b6c | |
2019-02-23
| ||
21:16 | Fix bug [9771ae0f0b]: In Aqua, deiconifying a transient of a withdrawn window can create a zombie. check-in: b2b91450 user: culler tags: core-8-6-branch | |
Changes
Changes to macosx/tkMacOSXColor.c.
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include "tkColor.h" struct SystemColorMapEntry { const char *name; ThemeBrush brush; ThemeTextColor textColor; ThemeBackgroundKind background; }; /* unsigned char pixelCode; */ /* * Array of system color definitions: the array index is required to equal the * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept * in sync with the public pixel code values in tkMacOSXPort.h ! */ #define MIN_PIXELCODE 30 static const struct SystemColorMapEntry systemColorMap[] = { | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > | | | 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 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | #include "tkColor.h" struct SystemColorMapEntry { const char *name; ThemeBrush brush; ThemeTextColor textColor; ThemeBackgroundKind background; int depth; }; /* unsigned char pixelCode; */ /* * Array of system color definitions: the array index is required to equal the * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept * in sync with the public pixel code values in tkMacOSXPort.h ! */ #define MIN_PIXELCODE 30 static const struct SystemColorMapEntry systemColorMap[] = { { "Transparent", 0, 0, 0, 0 }, /* 30: TRANSPARENT_PIXEL */ { "Highlight", kThemeBrushPrimaryHighlightColor, 0, 0, 0 }, /* 31: HIGHLIGHT_PIXEL */ { "HighlightSecondary", kThemeBrushSecondaryHighlightColor, 0, 0, 0 }, /* 32: HIGHLIGHT_SECONDARY_PIXEL */ { "HighlightText", kThemeBrushBlack, 0, 0, 0 }, /* 33: HIGHLIGHT_TEXT_PIXEL */ { "HighlightAlternate", kThemeBrushAlternatePrimaryHighlightColor, 0, 0, 0 }, /* 34: HIGHLIGHT_ALTERNATE_PIXEL */ { "ButtonText", 0, kThemeTextColorPushButtonActive, 0, 0 }, /* 35: CONTROL_TEXT_PIXEL */ { "PrimaryHighlightColor", kThemeBrushPrimaryHighlightColor, 0, 0, 0 }, /* 36 */ { "ButtonFace", kThemeBrushButtonFaceActive, 0, 0, 0 }, /* 37: CONTROL_BODY_PIXEL */ { "SecondaryHighlightColor", kThemeBrushSecondaryHighlightColor, 0, 0, 0 }, /* 38 */ { "ButtonFrame", kThemeBrushButtonFrameActive, 0, 0, 0 }, /* 39: CONTROL_FRAME_PIXEL */ { "AlternatePrimaryHighlightColor", kThemeBrushAlternatePrimaryHighlightColor, 0, 0, 0 }, /* 40 */ { "WindowBody", kThemeBrushDocumentWindowBackground, 0, 0, 0 }, /* 41: WINDOW_BODY_PIXEL */ { "SheetBackground", kThemeBrushSheetBackground, 0, 0, 0 }, /* 42 */ { "MenuActive", kThemeBrushMenuBackgroundSelected, 0, 0, 0 }, /* 43: MENU_ACTIVE_PIXEL */ { "Black", kThemeBrushBlack, 0, 0, 0 }, /* 44 */ { "MenuActiveText", 0, kThemeTextColorMenuItemSelected, 0, 0 }, /* 45: MENU_ACTIVE_TEXT_PIXEL */ { "White", kThemeBrushWhite, 0, 0, 0 }, /* 46 */ { "Menu", kThemeBrushMenuBackground, 0, 0, 0 }, /* 47: MENU_BACKGROUND_PIXEL */ { "DialogBackgroundActive", kThemeBrushDialogBackgroundActive, 0, 0, 0 }, /* 48 */ { "MenuDisabled", 0, kThemeTextColorMenuItemDisabled, 0, 0 }, /* 49: MENU_DISABLED_PIXEL */ { "DialogBackgroundInactive", kThemeBrushDialogBackgroundInactive, 0, 0, 0 }, /* 50 */ { "MenuText", 0, kThemeTextColorMenuItemActive, 0, 0 }, /* 51: MENU_TEXT_PIXEL */ { "AppearanceColor", 0, 0, 0, 0 }, /* 52: APPEARANCE_PIXEL */ { "AlertBackgroundActive", kThemeBrushAlertBackgroundActive, 0, 0, 0 }, /* 53 */ { "AlertBackgroundInactive", kThemeBrushAlertBackgroundInactive, 0, 0, 0 }, /* 54 */ { "ModelessDialogBackgroundActive", kThemeBrushModelessDialogBackgroundActive, 0, 0, 0 }, /* 55 */ { "ModelessDialogBackgroundInactive", kThemeBrushModelessDialogBackgroundInactive, 0, 0, 0 }, /* 56 */ { "UtilityWindowBackgroundActive", kThemeBrushUtilityWindowBackgroundActive, 0, 0, 0 }, /* 57 */ { "UtilityWindowBackgroundInactive", kThemeBrushUtilityWindowBackgroundInactive, 0, 0, 0 }, /* 58 */ { "ListViewSortColumnBackground", kThemeBrushListViewSortColumnBackground, 0, 0, 0 }, /* 59 */ { "ListViewBackground", kThemeBrushListViewBackground, 0, 0, 0 }, /* 60 */ { "IconLabelBackground", kThemeBrushIconLabelBackground, 0, 0, 0 }, /* 61 */ { "ListViewSeparator", kThemeBrushListViewSeparator, 0, 0, 0 }, /* 62 */ { "ChasingArrows", kThemeBrushChasingArrows, 0, 0, 0 }, /* 63 */ { "DragHilite", kThemeBrushDragHilite, 0, 0, 0 }, /* 64 */ { "DocumentWindowBackground", kThemeBrushDocumentWindowBackground, 0, 0, 0 }, /* 65 */ { "FinderWindowBackground", kThemeBrushFinderWindowBackground, 0, 0, 0 }, /* 66 */ { "ScrollBarDelimiterActive", kThemeBrushScrollBarDelimiterActive, 0, 0, 0 }, /* 67 */ { "ScrollBarDelimiterInactive", kThemeBrushScrollBarDelimiterInactive, 0, 0, 0 }, /* 68 */ { "FocusHighlight", kThemeBrushFocusHighlight, 0, 0, 0 }, /* 69 */ { "PopupArrowActive", kThemeBrushPopupArrowActive, 0, 0, 0 }, /* 70 */ { "PopupArrowPressed", kThemeBrushPopupArrowPressed, 0, 0, 0 }, /* 71 */ { "PopupArrowInactive", kThemeBrushPopupArrowInactive, 0, 0, 0 }, /* 72 */ { "AppleGuideCoachmark", kThemeBrushAppleGuideCoachmark, 0, 0, 0 }, /* 73 */ { "IconLabelBackgroundSelected", kThemeBrushIconLabelBackgroundSelected, 0, 0, 0 }, /* 74 */ { "StaticAreaFill", kThemeBrushStaticAreaFill, 0, 0, 0 }, /* 75 */ { "ActiveAreaFill", kThemeBrushActiveAreaFill, 0, 0, 0 }, /* 76 */ { "ButtonFrameActive", kThemeBrushButtonFrameActive, 0, 0, 0 }, /* 77 */ { "ButtonFrameInactive", kThemeBrushButtonFrameInactive, 0, 0, 0 }, /* 78 */ { "ButtonFaceActive", kThemeBrushButtonFaceActive, 0, 0, 0 }, /* 79 */ { "ButtonFaceInactive", kThemeBrushButtonFaceInactive, 0, 0, 0 }, /* 80 */ { "ButtonFacePressed", kThemeBrushButtonFacePressed, 0, 0, 0 }, /* 81 */ { "ButtonActiveDarkShadow", kThemeBrushButtonActiveDarkShadow, 0, 0, 0 }, /* 82 */ { "ButtonActiveDarkHighlight", kThemeBrushButtonActiveDarkHighlight, 0, 0, 0 }, /* 83 */ { "ButtonActiveLightShadow", kThemeBrushButtonActiveLightShadow, 0, 0, 0 }, /* 84 */ { "ButtonActiveLightHighlight", kThemeBrushButtonActiveLightHighlight, 0, 0, 0 }, /* 85 */ { "ButtonInactiveDarkShadow", kThemeBrushButtonInactiveDarkShadow, 0, 0, 0 }, /* 86 */ { "ButtonInactiveDarkHighlight", kThemeBrushButtonInactiveDarkHighlight, 0, 0, 0 }, /* 87 */ { "ButtonInactiveLightShadow", kThemeBrushButtonInactiveLightShadow, 0, 0, 0 }, /* 88 */ { "ButtonInactiveLightHighlight", kThemeBrushButtonInactiveLightHighlight, 0, 0, 0 }, /* 89 */ { "ButtonPressedDarkShadow", kThemeBrushButtonPressedDarkShadow, 0, 0, 0 }, /* 90 */ { "ButtonPressedDarkHighlight", kThemeBrushButtonPressedDarkHighlight, 0, 0, 0 }, /* 91 */ { "ButtonPressedLightShadow", kThemeBrushButtonPressedLightShadow, 0, 0, 0 }, /* 92 */ { "ButtonPressedLightHighlight", kThemeBrushButtonPressedLightHighlight, 0, 0, 0 }, /* 93 */ { "BevelActiveLight", kThemeBrushBevelActiveLight, 0, 0, 0 }, /* 94 */ { "BevelActiveDark", kThemeBrushBevelActiveDark, 0, 0, 0 }, /* 95 */ { "BevelInactiveLight", kThemeBrushBevelInactiveLight, 0, 0, 0 }, /* 96 */ { "BevelInactiveDark", kThemeBrushBevelInactiveDark, 0, 0, 0 }, /* 97 */ { "NotificationWindowBackground", kThemeBrushNotificationWindowBackground, 0, 0, 0 }, /* 98 */ { "MovableModalBackground", kThemeBrushMovableModalBackground, 0, 0, 0 }, /* 99 */ { "SheetBackgroundOpaque", kThemeBrushSheetBackgroundOpaque, 0, 0, 0 }, /* 100 */ { "DrawerBackground", kThemeBrushDrawerBackground, 0, 0, 0 }, /* 101 */ { "ToolbarBackground", kThemeBrushToolbarBackground, 0, 0, 0 }, /* 102 */ { "SheetBackgroundTransparent", kThemeBrushSheetBackgroundTransparent, 0, 0, 0 }, /* 103 */ { "MenuBackground", kThemeBrushMenuBackground, 0, 0, 0 }, /* 104 */ { "Pixel", 0, 0, 0, 0 }, /* 105: PIXEL_MAGIC */ { "MenuBackgroundSelected", kThemeBrushMenuBackgroundSelected, 0, 0, 0 }, /* 106 */ { "ListViewOddRowBackground", kThemeBrushListViewOddRowBackground, 0, 0, 0 }, /* 107 */ { "ListViewEvenRowBackground", kThemeBrushListViewEvenRowBackground, 0, 0, 0 }, /* 108 */ { "ListViewColumnDivider", kThemeBrushListViewColumnDivider, 0, 0, 0 }, /* 109 */ { "BlackText", 0, kThemeTextColorBlack, 0, 0 }, /* 110 */ { "DialogActiveText", 0, kThemeTextColorDialogActive, 0, 0 }, /* 111 */ { "DialogInactiveText", 0, kThemeTextColorDialogInactive, 0, 0 }, /* 112 */ { "AlertActiveText", 0, kThemeTextColorAlertActive, 0, 0 }, /* 113 */ { "AlertInactiveText", 0, kThemeTextColorAlertInactive, 0, 0 }, /* 114 */ { "ModelessDialogActiveText", 0, kThemeTextColorModelessDialogActive, 0, 0 }, /* 115 */ { "ModelessDialogInactiveText", 0, kThemeTextColorModelessDialogInactive, 0, 0 }, /* 116 */ { "WindowHeaderActiveText", 0, kThemeTextColorWindowHeaderActive, 0, 0 }, /* 117 */ { "WindowHeaderInactiveText", 0, kThemeTextColorWindowHeaderInactive, 0, 0 }, /* 118 */ { "PlacardActiveText", 0, kThemeTextColorPlacardActive, 0, 0 }, /* 119 */ { "PlacardInactiveText", 0, kThemeTextColorPlacardInactive, 0, 0 }, /* 120 */ { "PlacardPressedText", 0, kThemeTextColorPlacardPressed, 0, 0 }, /* 121 */ { "PushButtonActiveText", 0, kThemeTextColorPushButtonActive, 0, 0 }, /* 122 */ { "PushButtonInactiveText", 0, kThemeTextColorPushButtonInactive, 0, 0 }, /* 123 */ { "PushButtonPressedText", 0, kThemeTextColorPushButtonPressed, 0, 0 }, /* 124 */ { "BevelButtonActiveText", 0, kThemeTextColorBevelButtonActive, 0, 0 }, /* 125 */ { "BevelButtonInactiveText", 0, kThemeTextColorBevelButtonInactive, 0, 0 }, /* 126 */ { "BevelButtonPressedText", 0, kThemeTextColorBevelButtonPressed, 0, 0 }, /* 127 */ { "PopupButtonActiveText", 0, kThemeTextColorPopupButtonActive, 0, 0 }, /* 128 */ { "PopupButtonInactiveText", 0, kThemeTextColorPopupButtonInactive, 0, 0 }, /* 129 */ { "PopupButtonPressedText", 0, kThemeTextColorPopupButtonPressed, 0, 0 }, /* 130 */ { "IconLabelText", 0, kThemeTextColorIconLabel, 0, 0 }, /* 131 */ { "ListViewText", 0, kThemeTextColorListView, 0, 0 }, /* 132 */ { "DocumentWindowTitleActiveText", 0, kThemeTextColorDocumentWindowTitleActive, 0, 0 }, /* 133 */ { "DocumentWindowTitleInactiveText", 0, kThemeTextColorDocumentWindowTitleInactive, 0, 0 }, /* 134 */ { "MovableModalWindowTitleActiveText", 0, kThemeTextColorMovableModalWindowTitleActive, 0, 0 }, /* 135 */ { "MovableModalWindowTitleInactiveText",0, kThemeTextColorMovableModalWindowTitleInactive, 0, 0 }, /* 136 */ { "UtilityWindowTitleActiveText", 0, kThemeTextColorUtilityWindowTitleActive, 0, 0 }, /* 137 */ { "UtilityWindowTitleInactiveText", 0, kThemeTextColorUtilityWindowTitleInactive, 0, 0 }, /* 138 */ { "PopupWindowTitleActiveText", 0, kThemeTextColorPopupWindowTitleActive, 0, 0 }, /* 139 */ { "PopupWindowTitleInactiveText", 0, kThemeTextColorPopupWindowTitleInactive, 0, 0 }, /* 140 */ { "RootMenuActiveText", 0, kThemeTextColorRootMenuActive, 0, 0 }, /* 141 */ { "RootMenuSelectedText", 0, kThemeTextColorRootMenuSelected, 0, 0 }, /* 142 */ { "RootMenuDisabledText", 0, kThemeTextColorRootMenuDisabled, 0, 0 }, /* 143 */ { "MenuItemActiveText", 0, kThemeTextColorMenuItemActive, 0, 0 }, /* 144 */ { "MenuItemSelectedText", 0, kThemeTextColorMenuItemSelected, 0, 0 }, /* 145 */ { "MenuItemDisabledText", 0, kThemeTextColorMenuItemDisabled, 0, 0 }, /* 146 */ { "PopupLabelActiveText", 0, kThemeTextColorPopupLabelActive, 0, 0 }, /* 147 */ { "PopupLabelInactiveText", 0, kThemeTextColorPopupLabelInactive, 0, 0 }, /* 148 */ { "TabFrontActiveText", 0, kThemeTextColorTabFrontActive, 0, 0 }, /* 149 */ { "TabNonFrontActiveText", 0, kThemeTextColorTabNonFrontActive, 0, 0 }, /* 150 */ { "TabNonFrontPressedText", 0, kThemeTextColorTabNonFrontPressed, 0, 0 }, /* 151 */ { "TabFrontInactiveText", 0, kThemeTextColorTabFrontInactive, 0, 0 }, /* 152 */ { "TabNonFrontInactiveText", 0, kThemeTextColorTabNonFrontInactive, 0, 0 }, /* 153 */ { "IconLabelSelectedText", 0, kThemeTextColorIconLabelSelected, 0, 0 }, /* 154 */ { "BevelButtonStickyActiveText", 0, kThemeTextColorBevelButtonStickyActive, 0, 0 }, /* 155 */ { "BevelButtonStickyInactiveText", 0, kThemeTextColorBevelButtonStickyInactive, 0, 0 }, /* 156 */ { "NotificationText", 0, kThemeTextColorNotification, 0, 0 }, /* 157 */ { "SystemDetailText", 0, kThemeTextColorSystemDetail, 0, 0 }, /* 158 */ { "WhiteText", 0, kThemeTextColorWhite, 0, 0 }, /* 159 */ { "TabPaneBackground", 0, 0, kThemeBackgroundTabPane, 0 }, /* 160 */ { "PlacardBackground", 0, 0, kThemeBackgroundPlacard, 0 }, /* 161 */ { "WindowHeaderBackground", 0, 0, kThemeBackgroundWindowHeader, 0 }, /* 162 */ { "ListViewWindowHeaderBackground", 0, 0, kThemeBackgroundListViewWindowHeader, 0 }, /* 163 */ { "SecondaryGroupBoxBackground", 0, 0, kThemeBackgroundSecondaryGroupBox, 0 }, /* 164 */ { "MetalBackground", 0, 0, kThemeBackgroundMetal, 0 }, /* 165 */ { "TtkBackground", kThemeBrushModelessDialogBackgroundActive, 0, 0, 0 }, /* 166 */ { "TtkBackground1", 0, 0, 0, 1 }, /* 167 */ { "TtkBackground2", 0, 0, 0, 2 }, /* 168 */ { "TtkBackground3", 0, 0, 0, 3 }, /* 169 */ { "TtkBackground4", 0, 0, 0, 4 }, /* 170 */ { "TtkBackground5", 0, 0, 0, 5 }, /* 171 */ { "TtkBackground6", 0, 0, 0, 6 }, /* 172 */ { "TtkBackground7", 0, 0, 0, 7 }, /* 173 */ { NULL, 0, 0, 0, 0 } }; #define MAX_PIXELCODE 173 /* *---------------------------------------------------------------------- * * GetThemeFromPixelCode -- * * When given a pixel code corresponding to a theme system color, |
︙ | ︙ | |||
189 190 191 192 193 194 195 | * *---------------------------------------------------------------------- */ static int GetThemeFromPixelCode( unsigned char code, | < | < > | < < | | | > > < | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | * *---------------------------------------------------------------------- */ static int GetThemeFromPixelCode( unsigned char code, struct SystemColorMapEntry *entry) { bool zeroEntry = false; if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) { *entry = systemColorMap[code - MIN_PIXELCODE]; } else { entry->brush=0; entry->textColor=0; entry->background=0; entry->depth=0; zeroEntry = true; } if (zeroEntry && code != PIXEL_MAGIC && code != TRANSPARENT_PIXEL) { return false; } else { return true; } } /* |
︙ | ︙ | |||
229 230 231 232 233 234 235 | * *---------------------------------------------------------------------- */ static OSStatus GetThemeColor( unsigned long pixel, | < | < > > > | | | > > > > | | | | | | | | | | | | | | | | | | | 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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | * *---------------------------------------------------------------------- */ static OSStatus GetThemeColor( unsigned long pixel, struct SystemColorMapEntry entry, CGColorRef *c) { OSStatus err = noErr; static double RB1 = 0.8897365196078432; static double G1 = 0.8936734068627451; static double DELTA = 0.031495098039215685; if (entry.brush) { err = ChkErr(HIThemeBrushCreateCGColor, entry.brush, c); /*} else if (textColor) { err = ChkErr(GetThemeTextColor, textColor, 32, true, c);*/ } else { CGFloat rgba[4] = {0, 0, 0, 1}; if (entry.depth) { rgba[0] = RB1 - DELTA*(entry.depth - 1); rgba[1] = G1 - DELTA*(entry.depth - 1); rgba[2] = RB1 - DELTA*(entry.depth - 1); } else { switch ((pixel >> 24) & 0xff) { case PIXEL_MAGIC: { unsigned short red, green, blue; red = (pixel >> 16) & 0xff; green = (pixel >> 8) & 0xff; blue = (pixel ) & 0xff; red |= red << 8; green |= green << 8; blue |= blue << 8; rgba[0] = red / 65535.0; rgba[1] = green / 65535.0; rgba[2] = blue / 65535.0; break; } case TRANSPARENT_PIXEL: rgba[3] = 0.0; break; } } static CGColorSpaceRef deviceRGBSpace = NULL; if (!deviceRGBSpace) { deviceRGBSpace = CGColorSpaceCreateDeviceRGB(); } *c = CGColorCreate(deviceRGBSpace, rgba ); } return err; |
︙ | ︙ | |||
295 296 297 298 299 300 301 | int TkSetMacColor( unsigned long pixel, /* Pixel value to convert. */ void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; OSStatus err = -1; | < | < | < | < | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | int TkSetMacColor( unsigned long pixel, /* Pixel value to convert. */ void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; OSStatus err = -1; struct SystemColorMapEntry entry; if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &entry)) { err = ChkErr(GetThemeColor, pixel, entry, color); } return (err == noErr); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
482 483 484 485 486 487 488 | TkMacOSXSetColorInContext( GC gc, unsigned long pixel, CGContextRef context) { OSStatus err = -1; CGColorRef cgColor = CopyCachedColor(gc, pixel); | < | < | < | | | | | | | | < | 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 | TkMacOSXSetColorInContext( GC gc, unsigned long pixel, CGContextRef context) { OSStatus err = -1; CGColorRef cgColor = CopyCachedColor(gc, pixel); struct SystemColorMapEntry entry; if (!cgColor && GetThemeFromPixelCode((pixel >> 24) & 0xff, &entry)) { if (entry.brush) { err = ChkErr(HIThemeSetFill, entry.brush, NULL, context, kHIThemeOrientationNormal); if (err == noErr) { err = ChkErr(HIThemeSetStroke, entry.brush, NULL, context, kHIThemeOrientationNormal); } } else if (entry.textColor) { err = ChkErr(HIThemeSetTextFill, entry.textColor, NULL, context, kHIThemeOrientationNormal); } else if (entry.background) { CGRect rect = CGContextGetClipBoundingBox(context); HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive, entry.background }; err = ChkErr(HIThemeApplyBackground, &rect, &info, context, kHIThemeOrientationNormal); } if (err == noErr) { return; } err = ChkErr(GetThemeColor, pixel, entry, &cgColor); if (err == noErr) { SetCachedColor(gc, pixel, cgColor); } } else if (!cgColor) { TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel); } if (cgColor) { |
︙ | ︙ | |||
568 569 570 571 572 573 574 | result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap, sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx); Tcl_DecrRefCount(strPtr); if (result == TCL_OK) { OSStatus err; CGColorRef c; unsigned char pixelCode = idx + MIN_PIXELCODE; | | < < | | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap, sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx); Tcl_DecrRefCount(strPtr); if (result == TCL_OK) { OSStatus err; CGColorRef c; unsigned char pixelCode = idx + MIN_PIXELCODE; struct SystemColorMapEntry entry = systemColorMap[idx]; err = ChkErr(GetThemeColor, 0, entry, &c); if (err == noErr) { const size_t n = CGColorGetNumberOfComponents(c); const CGFloat *rgba = CGColorGetComponents(c); switch (n) { case 4: color.red = rgba[0] * 65535.0; |
︙ | ︙ |
Changes to macosx/tkMacOSXInt.h.
︙ | ︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #define TK_SCROLLBAR_GROW 0x01 #define TK_CLIP_INVALID 0x02 #define TK_HOST_EXISTS 0x04 #define TK_DRAWN_UNDER_MENU 0x08 #define TK_IS_PIXMAP 0x10 #define TK_IS_BW_PIXMAP 0x20 #define TK_DO_NOT_DRAW 0x40 /* * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the * TkWindow structure for the window, but in the MacWin. This way we can * still tell what the correct port is after the TKWindow structure has been * freed. This actually happens when you bind destroy of a toplevel to | > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #define TK_SCROLLBAR_GROW 0x01 #define TK_CLIP_INVALID 0x02 #define TK_HOST_EXISTS 0x04 #define TK_DRAWN_UNDER_MENU 0x08 #define TK_IS_PIXMAP 0x10 #define TK_IS_BW_PIXMAP 0x20 #define TK_DO_NOT_DRAW 0x40 #define TTK_HAS_DARKER_BG 0x80 /* * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the * TkWindow structure for the window, but in the MacWin. This way we can * still tell what the correct port is after the TKWindow structure has been * freed. This actually happens when you bind destroy of a toplevel to |
︙ | ︙ |
Changes to macosx/ttkMacOSXTheme.c.
︙ | ︙ | |||
28 29 30 31 32 33 34 | * The QuickDraw/Carbon coordinate system is relative to the * top-level window, not to the Tk_Window. BoxToRect() * accounts for this. */ #include "tkMacOSXPrivate.h" #include "ttk/ttkTheme.h" | | | | | | | | 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | * The QuickDraw/Carbon coordinate system is relative to the * top-level window, not to the Tk_Window. BoxToRect() * accounts for this. */ #include "tkMacOSXPrivate.h" #include "ttk/ttkTheme.h" #include <math.h> /* * Use this version in the core: */ #define BEGIN_DRAWING(d) { \ TkMacOSXDrawingContext dc; \ if (!TkMacOSXSetupDrawingContext((d), NULL, 1, &dc)) {return;} #define END_DRAWING \ TkMacOSXRestoreDrawingContext(&dc); } #define HIOrientation kHIThemeOrientationNormal #ifdef __LP64__ #define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum)) #else #define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum)) #endif /* __LP64__ */ /*---------------------------------------------------------------------- * +++ Utilities. */ /* * BoxToRect -- * Convert a Ttk_Box in Tk coordinates relative to the given Drawable * to a native Rect relative to the containing port. */ static inline CGRect BoxToRect(Drawable d, Ttk_Box b) { MacDrawable *md = (MacDrawable*)d; CGRect rect; rect.origin.y = b.y + md->yOff; |
︙ | ︙ | |||
131 132 133 134 135 136 137 | { kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0 }, { kThemeAdornmentFocus, TTK_STATE_FOCUS, 0 }, { kThemeAdornmentNone, 0, 0 } }; /* * computeButtonDrawInfo -- | | | | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | { kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0 }, { kThemeAdornmentFocus, TTK_STATE_FOCUS, 0 }, { kThemeAdornmentNone, 0, 0 } }; /* * computeButtonDrawInfo -- * Fill in an appearance manager HIThemeButtonDrawInfo record. */ static inline HIThemeButtonDrawInfo computeButtonDrawInfo( ThemeButtonParams *params, Ttk_State state) { const HIThemeButtonDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = params ? params->kind : 0, .value = Ttk_StateTableLookup(ButtonValueTable, state), .adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state), |
︙ | ︙ | |||
313 314 315 316 317 318 319 | .style = Ttk_StateTableLookup(TabStyleTable, state), .direction = kThemeTabNorth, .size = kHIThemeTabSizeNormal, .adornment = Ttk_StateTableLookup(TabAdornmentTable, state), .kind = kHIThemeTabKindNormal, .position = Ttk_StateTableLookup(TabPositionTable, state), }; | < | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | .style = Ttk_StateTableLookup(TabStyleTable, state), .direction = kThemeTabNorth, .size = kHIThemeTabSizeNormal, .adornment = Ttk_StateTableLookup(TabAdornmentTable, state), .kind = kHIThemeTabKindNormal, .position = Ttk_StateTableLookup(TabPositionTable, state), }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawTab, &bounds, &info, dc.context, HIOrientation, NULL); END_DRAWING } static Ttk_ElementSpec TabElementSpec = { TK_STYLE_VERSION_2, |
︙ | ︙ | |||
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | *paddingPtr = Ttk_MakePadding(9, 5, 9, 9); } static void PaneElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, b); HIThemeTabPaneDrawInfo info = { .version = 1, .state = Ttk_StateTableLookup(ThemeStateTable, state), .direction = kThemeTabNorth, .size = kHIThemeTabSizeNormal, .kind = kHIThemeTabKindNormal, .adornment = kHIThemeTabPaneAdornmentNormal, }; | > < > > > | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | *paddingPtr = Ttk_MakePadding(9, 5, 9, 9); } static void PaneElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { TkWindow *winPtr = (TkWindow *)tkwin; CGRect bounds = BoxToRect(d, b); HIThemeTabPaneDrawInfo info = { .version = 1, .state = Ttk_StateTableLookup(ThemeStateTable, state), .direction = kThemeTabNorth, .size = kHIThemeTabSizeNormal, .kind = kHIThemeTabKindNormal, .adornment = kHIThemeTabPaneAdornmentNormal, }; bounds.origin.y -= kThemeMetricTabFrameOverlap; bounds.size.height += kThemeMetricTabFrameOverlap; BEGIN_DRAWING(d) ChkErr(HIThemeDrawTabPane, &bounds, &info, dc.context, HIOrientation); END_DRAWING if (winPtr->privatePtr != NULL) { winPtr->privatePtr->flags |= TTK_HAS_DARKER_BG; } } static Ttk_ElementSpec PaneElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, PaneElementSize, |
︙ | ︙ | |||
387 388 389 390 391 392 393 394 395 396 397 | *paddingPtr = Ttk_UniformPadding(4); } static void GroupElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { CGRect bounds = BoxToRect(d, b); const HIThemeGroupBoxDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), | > | < > > > | | | 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 | *paddingPtr = Ttk_UniformPadding(4); } static void GroupElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { TkWindow *winPtr = (TkWindow *)tkwin; CGRect bounds = BoxToRect(d, b); const HIThemeGroupBoxDrawInfo info = { .version = 0, .state = Ttk_StateTableLookup(ThemeStateTable, state), .kind = kHIThemeGroupBoxKindPrimary, }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawGroupBox, &bounds, &info, dc.context, HIOrientation); END_DRAWING if (winPtr->privatePtr != NULL) { winPtr->privatePtr->flags |= TTK_HAS_DARKER_BG; } } static Ttk_ElementSpec GroupElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, GroupElementSize, GroupElementDraw }; /*---------------------------------------------------------------------- * +++ Entry element -- * 3 pixels padding for focus rectangle * 2 pixels padding for EditTextFrame */ typedef struct { Tcl_Obj *backgroundObj; } EntryElement; static Ttk_ElementOptionSpec EntryElementOptions[] = { |
︙ | ︙ | |||
472 473 474 475 476 477 478 | EntryElementDraw }; /*---------------------------------------------------------------------- * +++ Combobox: * * NOTES: | | | | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | EntryElementDraw }; /*---------------------------------------------------------------------- * +++ Combobox: * * NOTES: * kThemeMetricComboBoxLargeDisclosureWidth -> 17 * Padding and margins guesstimated by trial-and-error. */ static Ttk_Padding ComboboxPadding = { 2, 3, 17, 1 }; static Ttk_Padding ComboboxMargins = { 3, 3, 4, 4 }; static void ComboboxElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, |
︙ | ︙ | |||
521 522 523 524 525 526 527 | /*---------------------------------------------------------------------- * +++ Spinbuttons. * | | | | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | /*---------------------------------------------------------------------- * +++ Spinbuttons. * * From Apple HIG, part III, section "Controls", "The Stepper Control": * there should be 2 pixels of space between the stepper control (AKA * IncDecButton, AKA "little arrows") and the text field it modifies. */ static Ttk_Padding SpinbuttonMargins = {2,0,2,0}; static void SpinButtonElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { |
︙ | ︙ | |||
571 572 573 574 575 576 577 | SpinButtonElementSize, SpinButtonElementDraw }; /*---------------------------------------------------------------------- * +++ DrawThemeTrack-based elements -- | | | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | SpinButtonElementSize, SpinButtonElementDraw }; /*---------------------------------------------------------------------- * +++ DrawThemeTrack-based elements -- * Progress bars and scales. (See also: <<NOTE-TRACKS>>) */ static Ttk_StateTable ThemeTrackEnableTable[] = { { kThemeTrackDisabled, TTK_STATE_DISABLED, 0 }, { kThemeTrackInactive, TTK_STATE_BACKGROUND, 0 }, { kThemeTrackActive, 0, 0 } /* { kThemeTrackNothingToScroll, ?, ? }, */ |
︙ | ︙ | |||
776 777 778 779 780 781 782 | PbarElementSize, PbarElementDraw }; /*---------------------------------------------------------------------- * +++ Separator element. * | | | | | 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 | PbarElementSize, PbarElementDraw }; /*---------------------------------------------------------------------- * +++ Separator element. * * DrawThemeSeparator() guesses the orientation of the line from the width * and height of the rectangle, so the same element can can be used for * horizontal, vertical, and general separators. */ static void SeparatorElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { *widthPtr = *heightPtr = 1; |
︙ | ︙ | |||
866 867 868 869 870 871 872 | SizegripElementSize, SizegripElementDraw }; /*---------------------------------------------------------------------- * +++ Background and fill elements. * | > | > > | | > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > | < | < < | | | 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 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 971 972 973 974 975 976 | SizegripElementSize, SizegripElementDraw }; /*---------------------------------------------------------------------- * +++ Background and fill elements. * * 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. * * The first attempt at implementing this attempted to match colors by * drawing all widgets with the system background color used for dialog * windows. (In particular, ttk widgets were meant for use in windows like * those in the Apple preferences application.) The code chose either the * active background or the inactive background based on the ttk state. * (Note that current OS releases use the same color #ebebeb in both * states.) * * Unfortunately, there is a problem with this approach. The Appkit * GroupBox (used for ttk LabelFrames) and TabbedPane (used for the Notebook * widget) both place their content inside a rectangle with rounded corners * which is darker than 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. In this case the inner widget uses an even * darker rounded rectangle. In Mojave's preferences panes, these darker * gray colors appear to be #e3e4e3 and #dbdcdb respectively. The first of * these is close but not quite equal to the system color * BackgroundSecondary GroupBox, which appears to be #e3e3e3. The HITheme * library, which we use to draw these widgets, uses #e2e3e3, which again is * slightly different. Since none of these quite match, we use a hardwired * RGB color which matches that used by HITheme. * * 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) { TkWindow *winPtr = (TkWindow *)tkwin; CGRect bounds = BoxToRect(d, b); ThemeBrush brush; static double RB1 = 0.8897365196078432; static double G1 = 0.8936734068627451; static double DELTA = 0.031495098039215685; int depth = 0; for (TkWindow *topPtr = winPtr->parentPtr; topPtr != NULL; topPtr = topPtr->parentPtr) { if (topPtr->privatePtr && (topPtr->privatePtr->flags & TTK_HAS_DARKER_BG)) { depth++; } else { Tk_Uid className = Tk_Class(topPtr); if (className) { if ((strcmp(className, "TLabelFrame") == 0) || (strcmp(className, "TNotebook") == 0)) { depth++; } } } } BEGIN_DRAWING(d) switch(depth) { case 0: brush = (state & TTK_STATE_BACKGROUND) ? kThemeBrushModelessDialogBackgroundInactive : kThemeBrushModelessDialogBackgroundActive; ChkErr(HIThemeSetFill, brush, NULL, dc.context, HIOrientation); break; case 1: CGContextSetRGBFillColor(dc.context, RB1, G1, RB1, 1.0); break; default: /* Really, you should not be nesting this deeply ... */ CGContextSetRGBFillColor(dc.context, RB1 - DELTA*(depth - 1), G1 - DELTA*(depth - 1), RB1 - DELTA*(depth - 1), 1.0); break; } CGContextFillRect(dc.context, bounds); //QDSetPatternOrigin(PatternOrigin(tkwin, d)); END_DRAWING } static void BackgroundElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { FillElementDraw(clientData, elementRecord, tkwin, d, Ttk_WinBox(tkwin), state); } static Ttk_ElementSpec FillElementSpec = { TK_STYLE_VERSION_2, sizeof(NullElement), TtkNullElementOptions, TtkNullElementSize, |
︙ | ︙ | |||
919 920 921 922 923 924 925 | TtkNullElementSize, BackgroundElementDraw }; /*---------------------------------------------------------------------- * +++ ToolbarBackground element -- toolbar style for frames. * | | | | | | | | 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 | TtkNullElementSize, BackgroundElementDraw }; /*---------------------------------------------------------------------- * +++ ToolbarBackground element -- toolbar style for frames. * * This is very similar to the normal background element, but uses a * different ThemeBrush in order to get the lighter pinstripe effect * used in toolbars. We use SetThemeBackground() rather than * ApplyThemeBackground() in order to get the right style. * * <URL: http://developer.apple.com/documentation/Carbon/Reference/ * Appearance_Manager/appearance_manager/constant_7.html#/ * /apple_ref/doc/uid/TP30000243/C005321> * */ static void ToolbarBackgroundElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { ThemeBrush brush = kThemeBrushToolbarBackground; |
︙ | ︙ | |||
953 954 955 956 957 958 959 | TtkNullElementOptions, TtkNullElementSize, ToolbarBackgroundElementDraw }; /*---------------------------------------------------------------------- * +++ Treeview header | | | 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 | TtkNullElementOptions, TtkNullElementSize, ToolbarBackgroundElementDraw }; /*---------------------------------------------------------------------- * +++ Treeview header * Redefine the header to use a kThemeListHeaderButton. */ #define TTK_TREEVIEW_STATE_SORTARROW TTK_STATE_USER1 static Ttk_StateTable TreeHeaderValueTable[] = { { kThemeButtonOn, TTK_STATE_ALTERNATE}, { kThemeButtonOn, TTK_STATE_SELECTED}, { kThemeButtonOff, 0} |
︙ | ︙ |