diff options
-rw-r--r-- | generic/tkCmds.c | 16 | ||||
-rw-r--r-- | generic/tkTest.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.c | 747 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.h | 276 | ||||
-rw-r--r-- | macosx/tkMacOSXConstants.h | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 9 | ||||
-rw-r--r-- | macosx/tkMacOSXImage.c | 24 | ||||
-rw-r--r-- | macosx/tkMacOSXPort.h | 26 | ||||
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 1 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXTest.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 7 | ||||
-rw-r--r-- | macosx/tkMacOSXXStubs.c | 4 | ||||
-rw-r--r-- | tests/unixEmbed.test | 12 |
14 files changed, 684 insertions, 456 deletions
diff --git a/generic/tkCmds.c b/generic/tkCmds.c index c9026ef..6a06185 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -1741,7 +1741,23 @@ Tk_WinfoObjCmd( if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin) != TCL_OK) { return TCL_ERROR; } +#ifdef TK_HAS_DYNAMIC_COLORS + + /* + * Make sure that the TkColor used for the winfo rgb command is + * destroyed when we are through with it, so we do not get stale RGB + * values next time. + */ + + { + Colormap temp = Tk_Colormap(tkwin); + Tk_Colormap(tkwin) = TK_DYNAMIC_COLORMAP; + colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); + Tk_Colormap(tkwin) = temp; + } +#else colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); +#endif if (colorPtr == NULL) { return TCL_ERROR; } diff --git a/generic/tkTest.c b/generic/tkTest.c index b104f13..b4f1fad 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -1601,7 +1601,7 @@ ImageDisplay( * Drawing is not possible on the first call to DisplayImage. * Save the message, but do not log it until the actual display. */ - + if (instPtr->displayFailed == False) { sprintf(instPtr->buffer, "%s display %d %d %d %d", instPtr->masterPtr->imageName, imageX, imageY, width, height); diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index af708b1..fe16d53 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -1,5 +1,5 @@ /* - * tkMacOSXColor.c -- + * TkMacOSXColor.c -- * * This file maintains a database of color values for the Tk * toolkit, in order to avoid round-trips to the server to @@ -9,6 +9,7 @@ * Copyright (c) 1994-1996 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright (c) 2020 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -16,302 +17,226 @@ #include "tkMacOSXPrivate.h" #include "tkColor.h" +#include "tkMacOSXColor.h" + +static Tcl_HashTable systemColors; +static int numSystemColors; +static int rgbColorIndex; +static int controlAccentIndex; +static Bool useFakeAccentColor = NO; +static SystemColorDatum **systemColorIndex; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 +static NSAppearance *lightAqua = nil; +static NSAppearance *darkAqua = nil; +#endif +static NSColorSpace* sRGB = NULL; +static CGFloat windowBackground[4] = + {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; -/* - * The colorType specifies how the color value should be interpreted. For the - * unique rgbColor entry, the RGB values are generated from the pixel value of - * an XColor. The ttkBackground and semantic types are dynamic, meaning - * that they change when dark mode is enabled on OSX 10.13 and later. - */ - -enum colorType { - clearColor, /* There should be only one of these. */ - rgbColor, /* There should be only one of these. */ - appearance, /* There should be only one of these. */ - HIBrush, /* The value is a HITheme brush color table index. */ - HIText, /* The value is a HITheme text color table index. */ - HIBackground, /* The value is a HITheme background color table index. */ - ttkBackground, /* The value can be used as a parameter.*/ - semantic, /* The value can be used as a parameter.*/ -}; - -/* +void initColorTable() +{ + Tcl_InitHashTable(&systemColors, TCL_STRING_KEYS); + SystemColorDatum *entry, *oldEntry; + Tcl_HashSearch search; + Tcl_HashEntry *hPtr; + int newPtr, index = 0; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; + lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; +#endif - */ + /* + * Build a hash table for looking up a color by its name. + */ -struct SystemColorMapEntry { - const char *name; - enum colorType type; - long value; -}; /* unsigned char pixelCode; */ + for (entry = systemColorData; entry->name != NULL; entry++) { + hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr); + if (entry->type == semantic) { + NSString *colorName = [[NSString alloc] + initWithCString:entry->macName + encoding:NSUTF8StringEncoding]; + SEL colorSelector = NSSelectorFromString(colorName); + if (![NSColor respondsToSelector:colorSelector]) { + if ([colorName isEqualToString:@"controlAccentColor"]) { + useFakeAccentColor = YES; + } else { + /* Uncomment to print all unsupported colors: */ + /* printf("Unsupported color %s\n", colorName.UTF8String); */ + continue; + } + } + entry->selector = [colorName retain]; + } + if (newPtr == 0) { + oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + entry->index = oldEntry->index; + [oldEntry->selector release]; + } else { + entry->index = index++; + } + Tcl_SetHashValue(hPtr, entry); + } -/* - * 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 ! - */ + /* + * Build an array for looking up a color by its index. + */ -#define MIN_PIXELCODE 30 -static const struct SystemColorMapEntry systemColorMap[] = { - { "Transparent", clearColor, 0 }, /* 30: TRANSPARENT_PIXEL */ - { "Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 31 */ - { "HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 32 */ - { "HighlightText", HIBrush, kThemeBrushBlack }, /* 33 */ - { "HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 34 */ - { "ButtonText", HIText, kThemeTextColorPushButtonActive }, /* 35 */ - { "PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 36 */ - { "ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, /* 37 */ - { "SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 38 */ - { "ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, /* 39 */ - { "AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 40 */ - { "WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, /* 41 */ - { "SheetBackground", HIBrush, kThemeBrushSheetBackground }, /* 42 */ - { "MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 43 */ - { "Black", HIBrush, kThemeBrushBlack }, /* 44 */ - { "MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, /* 45 */ - { "White", HIBrush, kThemeBrushWhite }, /* 46 */ - { "Menu", HIBrush, kThemeBrushMenuBackground }, /* 47 */ - { "DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, /* 48 */ - { "MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, /* 49 */ - { "DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, /* 50 */ - { "MenuText", HIText, kThemeTextColorMenuItemActive }, /* 51 */ - { "AppearanceColor", appearance, 0 }, /* 52: APPEARANCE_PIXEL */ - { "AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, /* 53 */ - { "AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, /* 54 */ - { "ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive }, /* 55 */ - { "ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive }, /* 56 */ - { "UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, /* 57 */ - { "UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, /* 58 */ - { "ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, /* 59 */ - { "ListViewBackground", HIBrush, kThemeBrushListViewBackground }, /* 60 */ - { "IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, /* 61 */ - { "ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, /* 62 */ - { "ChasingArrows", HIBrush, kThemeBrushChasingArrows }, /* 63 */ - { "DragHilite", HIBrush, kThemeBrushDragHilite }, /* 64 */ - { "DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, /* 65 */ - { "FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, /* 66 */ - { "ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, /* 67 */ - { "ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, /* 68 */ - { "FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, /* 69 */ - { "PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, /* 70 */ - { "PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, /* 71 */ - { "PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, /* 72 */ - { "AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, /* 73 */ - { "IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, /* 74 */ - { "StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, /* 75 */ - { "ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, /* 76 */ - { "ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, /* 77 */ - { "ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, /* 78 */ - { "ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, /* 79 */ - { "ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, /* 80 */ - { "ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, /* 81 */ - { "ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, /* 82 */ - { "ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, /* 83 */ - { "ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, /* 84 */ - { "ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight }, /* 85 */ - { "ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow }, /* 86 */ - { "ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight }, /* 87 */ - { "ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow }, /* 88 */ - { "ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight }, /* 89 */ - { "ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow }, /* 90 */ - { "ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight }, /* 91 */ - { "ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow }, /* 92 */ - { "ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight }, /* 93 */ - { "BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight }, /* 94 */ - { "BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark }, /* 95 */ - { "BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight }, /* 96 */ - { "BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark }, /* 97 */ - { "NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground }, /* 98 */ - { "MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground }, /* 99 */ - { "SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque }, /* 100 */ - { "DrawerBackground", HIBrush, kThemeBrushDrawerBackground }, /* 101 */ - { "ToolbarBackground", HIBrush, kThemeBrushToolbarBackground }, /* 102 */ - { "SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent }, /* 103 */ - { "MenuBackground", HIBrush, kThemeBrushMenuBackground }, /* 104 */ - { "Pixel", rgbColor, 0 }, /* 105: PIXEL_MAGIC */ - { "MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 106 */ - { "ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground }, /* 107 */ - { "ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, /* 108 */ - { "ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, /* 109 */ - { "BlackText", HIText, kThemeTextColorBlack }, /* 110 */ - { "DialogActiveText", HIText, kThemeTextColorDialogActive }, /* 111 */ - { "DialogInactiveText", HIText, kThemeTextColorDialogInactive }, /* 112 */ - { "AlertActiveText", HIText, kThemeTextColorAlertActive }, /* 113 */ - { "AlertInactiveText", HIText, kThemeTextColorAlertInactive }, /* 114 */ - { "ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive }, /* 115 */ - { "ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive }, /* 116 */ - { "WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive }, /* 117 */ - { "WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive }, /* 118 */ - { "PlacardActiveText", HIText, kThemeTextColorPlacardActive }, /* 119 */ - { "PlacardInactiveText", HIText, kThemeTextColorPlacardInactive }, /* 120 */ - { "PlacardPressedText", HIText, kThemeTextColorPlacardPressed }, /* 121 */ - { "PushButtonActiveText", HIText, kThemeTextColorPushButtonActive }, /* 122 */ - { "PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive }, /* 123 */ - { "PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed }, /* 124 */ - { "BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive }, /* 125 */ - { "BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive }, /* 126 */ - { "BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed }, /* 127 */ - { "PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive }, /* 128 */ - { "PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive }, /* 129 */ - { "PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed }, /* 130 */ - { "IconLabelText", HIText, kThemeTextColorIconLabel }, /* 131 */ - { "ListViewText", HIText, kThemeTextColorListView }, /* 132 */ - { "DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, /* 133 */ - { "DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, /* 134 */ - { "MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, /* 135 */ - { "MovableModalWindowTitleInactiveText",HIText, kThemeTextColorMovableModalWindowTitleInactive }, /* 136 */ - { "UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, /* 137 */ - { "UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, /* 138 */ - { "PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, /* 139 */ - { "PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive }, /* 140 */ - { "RootMenuActiveText", HIText, kThemeTextColorRootMenuActive }, /* 141 */ - { "RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected }, /* 142 */ - { "RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled }, /* 143 */ - { "MenuItemActiveText", HIText, kThemeTextColorMenuItemActive }, /* 144 */ - { "MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected }, /* 145 */ - { "MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled }, /* 146 */ - { "PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive }, /* 147 */ - { "PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive }, /* 148 */ - { "TabFrontActiveText", HIText, kThemeTextColorTabFrontActive }, /* 149 */ - { "TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive }, /* 150 */ - { "TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed }, /* 151 */ - { "TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive }, /* 152 */ - { "TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive }, /* 153 */ - { "IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected }, /* 154 */ - { "BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive }, /* 155 */ - { "BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive }, /* 156 */ - { "NotificationText", HIText, kThemeTextColorNotification }, /* 157 */ - { "SystemDetailText", HIText, kThemeTextColorSystemDetail }, /* 158 */ - { "WhiteText", HIText, kThemeTextColorWhite }, /* 159 */ - { "TabPaneBackground", HIBackground, kThemeBackgroundTabPane }, /* 160 */ - { "PlacardBackground", HIBackground, kThemeBackgroundPlacard }, /* 161 */ - { "WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader }, /* 162 */ - { "ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, /* 163 */ - { "SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, /* 164 */ - { "MetalBackground", HIBackground, kThemeBackgroundMetal }, /* 165 */ + numSystemColors = index; + systemColorIndex = ckalloc(numSystemColors * sizeof(SystemColorDatum*)); + for (hPtr = Tcl_FirstHashEntry(&systemColors, &search); hPtr != NULL; + hPtr = Tcl_NextHashEntry(&search)) { + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + if (entry == NULL) { + Tcl_Panic("Unsupported semantic color with no supported backup!"); + } + systemColorIndex[entry->index] = entry; + } /* - * Colors based on "semantic" NSColors. + * Remember the indexes of some special entries. */ - { "WindowBackgroundColor", ttkBackground, 0 }, /* 166 */ - { "WindowBackgroundColor1", ttkBackground, 1 }, /* 167 */ - { "WindowBackgroundColor2", ttkBackground, 2 }, /* 168 */ - { "WindowBackgroundColor3", ttkBackground, 3 }, /* 169 */ - { "WindowBackgroundColor4", ttkBackground, 4 }, /* 170 */ - { "WindowBackgroundColor5", ttkBackground, 5 }, /* 171 */ - { "WindowBackgroundColor6", ttkBackground, 6 }, /* 172 */ - { "WindowBackgroundColor7", ttkBackground, 7 }, /* 173 */ - { "TextColor", semantic, 0 }, /* 174 */ - { "SelectedTextColor", semantic, 1 }, /* 175 */ - { "LabelColor", semantic, 2 }, /* 176 */ - { "ControlTextColor", semantic, 3 }, /* 177 */ - { "DisabledControlTextColor", semantic, 4 }, /* 178 */ - { "SelectedTabTextColor", semantic, 5 }, /* 179 */ - { "TextBackgroundColor", semantic, 6 }, /* 180 */ - { "SelectedTextBackgroundColor", semantic, 7 }, /* 181 */ - { "ControlAccentColor", semantic, 8 }, /* 182 */ - /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ - { "SecondaryLabelColor", ttkBackground, 14 }, /* 183 */ - { "LinkColor", semantic, 9 }, /* 184 */ - { NULL, 0, 0 } -}; -#define FIRST_SEMANTIC_COLOR 166 -#define MAX_PIXELCODE 184 - + hPtr = Tcl_FindHashEntry(&systemColors, "Pixel"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + rgbColorIndex = entry->index; + hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + controlAccentIndex = entry->index; +} + /* *---------------------------------------------------------------------- * - * GetEntryFromPixelCode -- + * TkMacOSXRGBPixel -- + * + * Return an unsigned long value suitable for use in the pixel + * field of an XColor with the specified red, green and blue + * intensities. The inputs are cast as unsigned longs but are + * expected to have values representable by an unsigned char. * - * Extract a SystemColorMapEntry from the table. + * This is called in the TkpGetPixel macro, used in xcolor.c, + * and in ImageGetPixel. * * Results: - * Returns false if the code is out of bounds. + * An unsigned long that can be used as the pixel field of an XColor. * * Side effects: * None. - * *---------------------------------------------------------------------- */ - -static bool -GetEntryFromPixelCode( - unsigned char code, - struct SystemColorMapEntry *entry) +MODULE_SCOPE +unsigned long +TkMacOSXRGBPixel( + unsigned long red, + unsigned long green, + unsigned long blue) { - if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) { - *entry = systemColorMap[code - MIN_PIXELCODE]; - return true; - } else { - return false; - } + MacPixel p; + p.pixel.colortype = rgbColor; + p.pixel.value = ((red & 0xff) << 16) | + ((green & 0xff) << 8) | + (blue & 0xff); + return p.ulong; } /* *---------------------------------------------------------------------- * - * SetCGColorComponents -- + * TkMacOSXClearPixel -- * - * Set the components of a CGColorRef from an XColor pixel value and a - * system color map entry. The pixel value is only used in the case where - * the color is of type rgbColor. In that case the normalized XColor RGB - * values are copied into the CGColorRef. + * Return the unsigned long value that appears in the pixel + * field of the XColor for systemTransparentColor. + * + * This is used in tkMacOSXImage.c. * * Results: - * OSStatus + * The unsigned long that appears in the pixel field of the XColor + * for systemTransparentPixel. * * Side effects: * None. - * *---------------------------------------------------------------------- */ +MODULE_SCOPE +unsigned long TkMacOSXClearPixel( + void) +{ + MacPixel p; + p.pixel.value = 0; + p.pixel.colortype = clearColor; + return p.ulong; +} + /* - * Apple claims that linkColor is available in 10.10 but the declaration - * does not appear in NSColor.h until later. Declaring it in a category - * appears to be harmless and stops the compiler warnings. + *---------------------------------------------------------------------- + * + * GetEntryFromPixel -- + * + * Look up a SystemColorDatum which describes the XColor with + * the specified value as its pixel field. + * + * Results: + * A pointer to a SystemColorDatum, or NULL if the pixel value is + * invalid. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- */ -@interface NSColor(TkColor) -#if MAC_OS_X_VERSION_MAX_ALLOWED > 101200 -@property(class, strong, readonly) NSColor *linkColor; -#elif MAC_OS_X_VERSION_MAX_ALLOWED > 1080 -@property(strong, readonly) NSColor *linkColor; -#else -@property(assign, readonly) NSColor *linkColor; -#endif -@end +SystemColorDatum* +GetEntryFromPixel( + unsigned long pixel) +{ + MacPixel p; + int index = rgbColorIndex; -static NSColorSpace* sRGB = NULL; -static CGFloat windowBackground[4] = - {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; + p.ulong = pixel; + if (p.pixel.colortype != rgbColor) { + index = p.pixel.value; + } + if (index < numSystemColors) { + return systemColorIndex[index]; + } else { + return NULL; + } +} + -static OSStatus -SetCGColorComponents( - struct SystemColorMapEntry entry, +/* + *---------------------------------------------------------------------- + * + * GetRGB -- + * + * Given a SystemColorDatum and a pointer to an array of 4 CGFloats, store + * the associated RGBA color values in the array. In the case of the + * RGBColor datum, the unsigned long pixel value containing the RGB values + * must also be provided as the pixel parameter. Otherwise the pixel + * parameter is ignored. + * + * Results: + * None + * + * Side effects: + * The array rgba is filled in. + * + *---------------------------------------------------------------------- + */ + +static void +GetRGBA( + SystemColorDatum *entry, unsigned long pixel, - CGColorRef *c) + CGFloat *rgba) { - OSStatus err = noErr; NSColor *bgColor, *color = nil; - CGFloat rgba[4] = {0, 0, 0, 1}; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } - - /* - * This function is called before our autorelease pool is set up, - * so it needs its own pool. - */ - - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - switch (entry.type) { - case HIBrush: - err = ChkErr(HIThemeBrushCreateCGColor, entry.value, c); - return err; + switch (entry->type) { case rgbColor: rgba[0] = ((pixel >> 16) & 0xff) / 255.0; rgba[1] = ((pixel >> 8) & 0xff) / 255.0; @@ -325,7 +250,7 @@ SetCGColorComponents( */ if ([NSApp macOSVersion] < 101400) { - for (int i=0; i<3; i++) { + for (int i = 0; i < 3; i++) { rgba[i] = windowBackground[i]; } } else { @@ -334,105 +259,101 @@ SetCGColorComponents( } if (rgba[0] + rgba[1] + rgba[2] < 1.5) { for (int i=0; i<3; i++) { - rgba[i] += entry.value*8.0 / 255.0; + rgba[i] += entry->value*8.0 / 255.0; } } else { for (int i=0; i<3; i++) { - rgba[i] -= entry.value*8.0 / 255.0; + rgba[i] -= entry->value*8.0 / 255.0; } } break; case semantic: - switch (entry.value) { - case 0: - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - break; - case 1: - color = [[NSColor selectedTextColor] colorUsingColorSpace:sRGB]; - break; - case 2: - if ([NSApp macOSVersion] > 100900) { - -#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 - color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; + if (entry->index == controlAccentIndex && useFakeAccentColor) { +#if MAC_OS_X_VERSION_MAX_ALLOWED < 101500 + color = [NSColor colorForControlTint: [NSColor currentControlTint]]; #endif - } else { - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - } - break; - case 3: - color = [[NSColor controlTextColor] colorUsingColorSpace:sRGB]; - break; - case 4: - color = [[NSColor disabledControlTextColor] - colorUsingColorSpace:sRGB]; - break; - case 5: - if ([NSApp macOSVersion] > 100600) { - color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; - } else { - color = [[NSColor blackColor] colorUsingColorSpace:sRGB]; - } - break; - case 6: - color = [[NSColor textBackgroundColor] colorUsingColorSpace:sRGB]; - break; - case 7: - color = [[NSColor selectedTextBackgroundColor] - colorUsingColorSpace:sRGB]; - break; - case 8: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - if (@available(macOS 14, *)) { - color = [[NSColor controlAccentColor] colorUsingColorSpace:sRGB]; + } else { + color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; + } + [color getComponents: rgba]; + break; + case clearColor: + rgba[3] = 0; + case HIText: +#ifdef __LP64__ + color = [[NSColor textColor] colorUsingColorSpace:sRGB]; + [color getComponents: rgba]; #else - if(false) { -#endif - } else { - color = [[NSColor - colorForControlTint:[NSColor currentControlTint]] - colorUsingColorSpace: sRGB]; - } - break; - case 9: - if ([NSApp macOSVersion] >= 101100) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 - color = [[NSColor linkColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor blueColor] colorUsingColorSpace:sRGB]; - } - break; - default: - if ([NSApp macOSVersion] >= 101000) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 - color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; + { + RGBColor rgb; + err = GetThemeTextColor(kThemeTextColorPushButtonActive, 32, + true, &rgb); + if (err == noErr) { + rgba[0] = (CGFLoat) rgb.red / 65535; + rgba[1] = (CGFLoat) rgb.green / 65535; + rgba[2] = (CGFLoat) rgb.blue / 65535; } - break; } +#endif + break; + case HIBackground: + color = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB]; [color getComponents: rgba]; break; - case clearColor: - rgba[3] = 0.0; + default: break; + } +} + +/* + *---------------------------------------------------------------------- + * + * SetCGColorComponents -- + * + * Set the components of a CGColorRef from an XColor pixel value and a + * SystemColorDatum. The pixel value is only used in the case where + * the color is of type rgbColor. In that case the normalized XColor RGB + * values are copied into the CGColorRef. Otherwise the components are + * computed from the SystemColorDatum. + * + * In 64 bit macOS systems there are no HITheme functions which convert + * HIText or HIBackground colors to CGColors. (GetThemeTextColor was + * removed, and it was never possible with backgrounds.) On 64-bit systems + * we replace all HIText colors by systemTextColor and all HIBackground + * colors by systemWindowBackgroundColor. + * + * Results: + * True if the function succeeds, false otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static Bool +SetCGColorComponents( + SystemColorDatum *entry, + unsigned long pixel, + CGColorRef *c) +{ + CGFloat rgba[4] = {0, 0, 0, 1}; /* - * There are no HITheme functions which convert Text or background colors - * to CGColors. (GetThemeTextColor has been removed, and it was never - * possible with backgrounds.) If we get one of these we return black. + * This function is called before our autorelease pool is set up, + * so it needs its own pool. */ - case HIText: - case HIBackground: - default: - break; + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + + if (entry->type == HIBrush) { + OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c); + return err == noErr; } + GetRGBA(entry, pixel, rgba); *c = CGColorCreate(sRGB.CGColorSpace, rgba); [pool drain]; - return err; + return true; } /* @@ -457,7 +378,6 @@ TkMacOSXInDarkMode(Tk_Window tkwin) int result = false; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - static NSAppearanceName darkAqua = @"NSAppearanceNameDarkAqua"; if ([NSApp macOSVersion] >= 101400) { TkWindow *winPtr = (TkWindow*) tkwin; @@ -466,10 +386,9 @@ TkMacOSXInDarkMode(Tk_Window tkwin) view = TkMacOSXDrawableView(winPtr->privatePtr); } if (view) { - result = [view.effectiveAppearance.name isEqualToString:darkAqua]; + result = (view.effectiveAppearance.name == NSAppearanceNameDarkAqua); } else { - result = [[NSAppearance currentAppearance].name - isEqualToString:darkAqua]; + result = ([NSAppearance currentAppearance].name == NSAppearanceNameDarkAqua); } } #endif @@ -482,14 +401,13 @@ TkMacOSXInDarkMode(Tk_Window tkwin) * * TkSetMacColor -- * - * Sets the components of a CGColorRef from an XColor pixel value. - * The high order byte of the pixel value is used as an index into - * the system color table, and then SetCGColorComponents is called - * with the table entry and the pixel value. + * Sets the components of a CGColorRef from an XColor pixel value. The + * pixel value is used to look up the color in the system color table, and + * then SetCGColorComponents is called with the table entry and the pixel + * value. * * Results: - * Returns false if the high order byte is not a valid index, true - * otherwise. + * Returns false if the color is not found, true otherwise. * * Side effects: * The variable macColor is set to a new CGColorRef, the caller is @@ -504,13 +422,13 @@ TkSetMacColor( void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; - OSStatus err = -1; - struct SystemColorMapEntry entry; + SystemColorDatum *entry = GetEntryFromPixel(pixel); - if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) { - err = ChkErr(SetCGColorComponents, entry, pixel, color); + if (entry) { + return SetCGColorComponents(entry, pixel, color); + } else { + return false; } - return (err == noErr); } /* @@ -631,9 +549,10 @@ TkMacOSXCreateCGColor( * TkMacOSXGetNSColor -- * * Creates an autoreleased NSColor from a X style pixel value. + * The return value is nil if the pixel value is invalid. * * Results: - * Returns nil if not a real pixel, NSColor* otherwise. + * A possibly nil pointer to an NSColor. * * Side effects: * None @@ -667,10 +586,9 @@ TkMacOSXGetNSColor( * * TkMacOSXSetColorInContext -- * - * Sets fill and stroke color in the given CG context from an X - * pixel value, or if the pixel code indicates a system color, - * sets the corresponding brush, textColor or background via - * HITheme APIs if available or Appearance mgr APIs. + * Sets the fill and stroke colors in the given CGContext to the CGColor + * which corresponds to the XColor having the specified value for its pixel + * field. * * Results: * None. @@ -689,37 +607,32 @@ TkMacOSXSetColorInContext( { OSStatus err = noErr; CGColorRef cgColor = nil; - struct SystemColorMapEntry entry; + SystemColorDatum *entry = GetEntryFromPixel(pixel); CGRect rect; - int code = (pixel >> 24) & 0xff; HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};; - if (code < FIRST_SEMANTIC_COLOR) { - cgColor = CopyCachedColor(gc, pixel); - } - if (!cgColor && GetEntryFromPixelCode(code, &entry)) { - switch (entry.type) { + if (entry) { + switch (entry->type) { case HIBrush: - err = ChkErr(HIThemeSetFill, entry.value, NULL, context, + err = ChkErr(HIThemeSetFill, entry->value, NULL, context, kHIThemeOrientationNormal); if (err == noErr) { - err = ChkErr(HIThemeSetStroke, entry.value, NULL, context, + err = ChkErr(HIThemeSetStroke, entry->value, NULL, context, kHIThemeOrientationNormal); } break; case HIText: - err = ChkErr(HIThemeSetTextFill, entry.value, NULL, context, + err = ChkErr(HIThemeSetTextFill, entry->value, NULL, context, kHIThemeOrientationNormal); break; case HIBackground: - info.kind = entry.value; + info.kind = entry->value; rect = CGContextGetClipBoundingBox(context); err = ChkErr(HIThemeApplyBackground, &rect, &info, context, kHIThemeOrientationNormal); break; default: - err = ChkErr(SetCGColorComponents, entry, pixel, &cgColor); - if (err == noErr) { + if (SetCGColorComponents(entry, pixel, &cgColor)){ SetCachedColor(gc, pixel, cgColor); } break; @@ -740,15 +653,20 @@ TkMacOSXSetColorInContext( * * TkpGetColor -- * - * Allocate a new TkColor for the color with the given name. + * Create a new TkColor for the color with the given name, for use in the + * specified window. The colormap field is set to lightColormap if the + * window has a LightAqua appearance, or darkColormap if the window has a + * DarkAqua appearance. TkColors with different colormaps are managed + * separately in the per-display table of TkColors maintained by Tk. + * + * This function is called by Tk_GetColor. * * Results: * Returns a newly allocated TkColor, or NULL on failure. * * Side effects: - * May invalidate the colormap cache associated with tkwin upon - * allocating a new colormap entry. Allocates a new TkColor - * structure. + * + * Allocates memory for the TkColor structure. * *---------------------------------------------------------------------- */ @@ -759,31 +677,60 @@ TkpGetColor( Tk_Uid name) /* Name of color to be allocated (in form * suitable for passing to XParseColor). */ { - Display *display = tkwin != None ? Tk_Display(tkwin) : NULL; - Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None; + Display *display = NULL; TkColor *tkColPtr; XColor color; + Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap; + static Bool initialized = NO; + static NSColorSpace* sRGB = NULL; + + if (!initialized) { + initialized = YES; + sRGB = [NSColorSpace sRGBColorSpace]; + initColorTable(); + } + if (tkwin) { + display = Tk_Display(tkwin); + } /* - * Check to see if this is a system color. Otherwise, XParseColor - * will do all the work. + * Check to see if this is a system color. If not, just call XParseColor. */ if (strncasecmp(name, "system", 6) == 0) { - Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1); - int idx, result; - - result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap, - sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx); - Tcl_DecrRefCount(strPtr); - if (result == TCL_OK) { - OSStatus err; + Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&systemColors, name + 6); + MacPixel p; + + if (hPtr != NULL) { + SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr); CGColorRef c; - unsigned char pixelCode = idx + MIN_PIXELCODE; - struct SystemColorMapEntry entry = systemColorMap[idx]; - err = ChkErr(SetCGColorComponents, entry, 0, &c); - if (err == noErr) { + p.pixel.colortype = entry->type; + p.pixel.value = entry->index; + color.pixel = p.ulong; + if (entry->type == semantic) { + CGFloat rgba[4]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + NSAppearance *savedAppearance = [NSAppearance currentAppearance]; + NSAppearance *windowAppearance; + if (TkMacOSXInDarkMode(tkwin)) { + windowAppearance = darkAqua; + colormap = darkColormap; + } else { + windowAppearance = lightAqua; + colormap = lightColormap; + } + [NSAppearance setCurrentAppearance:windowAppearance]; + GetRGBA(entry, p.ulong, rgba); + [NSAppearance setCurrentAppearance:savedAppearance]; +#else + GetRGBA(entry, p.ulong, rgba); +#endif + color.red = rgba[0] * 65535.0; + color.green = rgba[1] * 65535.0; + color.blue = rgba[2] * 65535.0; + goto validXColor; + } else if (SetCGColorComponents(entry, 0, &c)) { const size_t n = CGColorGetNumberOfComponents(c); const CGFloat *rgba = CGColorGetComponents(c); @@ -799,25 +746,19 @@ TkpGetColor( default: Tcl_Panic("CGColor with %d components", (int) n); } - color.pixel = ((((((pixelCode << 8) - | ((color.red >> 8) & 0xff)) << 8) - | ((color.green >> 8) & 0xff)) << 8) - | ((color.blue >> 8) & 0xff)); CGColorRelease(c); goto validXColor; } - CGColorRelease(c); } } - if (TkParseColor(display, colormap, name, &color) == 0) { return NULL; } validXColor: tkColPtr = (TkColor *)ckalloc(sizeof(TkColor)); + tkColPtr->colormap = colormap; tkColPtr->color = color; - return tkColPtr; } @@ -826,19 +767,19 @@ validXColor: * * TkpGetColorByValue -- * - * Given a desired set of red-green-blue intensities for a color, - * locate a pixel value to use to draw that color in a given - * window. + * Given an pointer to an XColor, construct a TkColor whose red, green and + * blue intensities match those of the XColor as closely as possible. For + * the Macintosh, this means that the colortype bitfield of the pixel + * value will be RGBColor and that the color intensities stored in its + * 24-bit value bitfield are computed from the 16-bit red green and blue + * values in the XColor by dividing by 256. * * Results: - * The return value is a pointer to an TkColor structure that - * indicates the closest red, blue, and green intensities available - * to those specified in colorPtr, and also specifies a pixel - * value to use to draw in that color. + * A pointer to a newly allocated TkColor structure. * * Side effects: * May invalidate the colormap cache for the specified window. - * Allocates a new TkColor structure. + * Allocates memory for a TkColor structure. * *---------------------------------------------------------------------- */ @@ -855,7 +796,7 @@ TkpGetColorByValue( tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; tkColPtr->color.blue = colorPtr->blue; - tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color); + tkColPtr->color.pixel = TkpGetPixel(colorPtr); return tkColPtr; } @@ -896,14 +837,15 @@ XCreateColormap( Visual *visual, /* Not used. */ int alloc) /* Not used. */ { - static Colormap index = 1; + static Colormap index = 16; (void)display; (void)window; (void)visual; (void)alloc; /* - * Just return a new value each time. + * Just return a new value each time, large enough that it will not + * conflict with any value of the macColormap enum. */ return index++; } @@ -934,9 +876,8 @@ XFreeColors( (void)planes; /* - * The Macintosh version of Tk uses TrueColor. Nothing - * needs to be done to release colors as there really is - * no colormap in the Tk sense. + * Nothing needs to be done to release colors as there really is no + * colormap in the Tk sense. */ return Success; } diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h new file mode 100644 index 0000000..535d15d --- /dev/null +++ b/macosx/tkMacOSXColor.h @@ -0,0 +1,276 @@ +#ifndef MACOSXCOLOR_H +#define MACOSXCOLOR_H +/* + * The generic Tk code uses the X11 GC type to describe a graphics context. + * (A GC is a pointer to a struct XGCValues). The foreground and background + * colors in a GC are unsigned longs. These are meant to be used as indexes + * into a table of XColors, where an XColor is declared in Xlib.h as: + * typedef struct { + * unsigned long pixel; + * unsigned short red, green, blue; + * char flags; + * char pad; + * } XColor; + * + * The xlib function XParseColor creates XColors from strings. It recognizes + * literal hexadecimal color specifications such as "#RRGGBB" as well as the + * standard X11 color names. When XParseColor creates an XColor it fills in + * all of the fields except for the pixel field, and then passes the XColor + * to TkpGetPixel to get a value to use for the pixel field. Since TkpGetPixel + * is platform specific, each platform is free to choose a value which can + * be used to set the foreground or background color in the platform's graphics + * context. + * + * Tk represents a color by a struct TkColor, which extends the XColor struct. + * Tk provides a mapping from color names to TkColors which extends the mapping + * provided by XParseColor but also allows for platform specific color names. + * By convention, these platform specific color names begin with the string + * "system". The mapping from names to TkColors is implemented by the function + * TkpGetColor defined for the Macintosh in this file. The pixel field in the + * XColor contained in a TkColor will be stored in the X11 graphics context. + * In X11 the pixel field is used as an index into a colormap. On the Mac + * the high order byte of the pixel is used to indicate a color type and + * the low 24 bits are either used as an rgb value (if the type is rgbColor) + * or as an index into a table of color descriptions. + */ + +enum colorType { + rgbColor, /* The 24 bit value is an rgb color. */ + clearColor, /* The unique rgba color with all channels 0. */ + HIBrush, /* A HITheme brush color.*/ + HIText, /* A HITheme text color. */ + HIBackground, /* A HITheme background color. */ + ttkBackground, /* A background color which indicates nesting level.*/ + semantic, /* A semantic NSColor.*/ +}; + +typedef struct xpixel_t { + unsigned value: 24; /* Either RGB or an index into systemColorMap. */ + unsigned colortype: 8; +} xpixel; + +typedef union MacPixel_t { + unsigned long ulong; + xpixel pixel; +} MacPixel; + +/* + * We maintain two colormaps, one for the LightAqua appearance and one for the + * DarkAqua appearance. + */ + +enum macColormap { + noColormap, + lightColormap, + darkColormap, +}; + +/* + * In TkMacOSXColor.c a Tk hash table is constructed from the static data + * below to map system color names to CGColors. + */ + +typedef struct { + const char *name; + enum colorType type; + int value; + const char *macName; + /* Fields below are filled in after or during construction of the hash table. */ + int index; + NSString *selector; +} SystemColorDatum; + +/* + * WARNING: Semantic colors which are not supported on all systems must be + * preceded by a backup color with the same name which *is* supported. Systems + * which do support the color will replace the backup value when the table is + * constructed. Failing to ensure this will result in a Tcl_Panic abort. + */ + +static SystemColorDatum systemColorData[] = { +{"Pixel", rgbColor, 0, NULL, 0, NULL }, +{"Transparent", clearColor, 0, NULL, 0, NULL }, + +{"Highlight", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL }, +{"HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL }, +{"HighlightText", HIBrush, kThemeBrushBlack, NULL, 0, NULL }, +{"HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL }, +{"PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL }, +{"ButtonFace", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL }, +{"SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL }, +{"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL }, +{"AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL }, +{"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL }, +{"SheetBackground", HIBrush, kThemeBrushSheetBackground, NULL, 0, NULL }, +{"MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL }, +{"Menu", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL }, +{"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive, NULL, 0, NULL }, +{"DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive, NULL, 0, NULL }, +{"AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive, NULL, 0, NULL }, +{"AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive, NULL, 0, NULL }, +{"ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive, NULL, 0, NULL }, +{"ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive, NULL, 0, NULL }, +{"UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive, NULL, 0, NULL }, +{"UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive, NULL, 0, NULL }, +{"ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground, NULL, 0, NULL }, +{"ListViewBackground", HIBrush, kThemeBrushListViewBackground, NULL, 0, NULL }, +{"IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground, NULL, 0, NULL }, +{"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator, NULL, 0, NULL }, +{"ChasingArrows", HIBrush, kThemeBrushChasingArrows, NULL, 0, NULL }, +{"DragHilite", HIBrush, kThemeBrushDragHilite, NULL, 0, NULL }, +{"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL }, +{"FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground, NULL, 0, NULL }, +{"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive, NULL, 0, NULL }, +{"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive, NULL, 0, NULL }, +{"FocusHighlight", HIBrush, kThemeBrushFocusHighlight, NULL, 0, NULL }, +{"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive, NULL, 0, NULL }, +{"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed, NULL, 0, NULL }, +{"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive, NULL, 0, NULL }, +{"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark, NULL, 0, NULL }, +{"IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected, NULL, 0, NULL }, +{"StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill, NULL, 0, NULL }, +{"ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill, NULL, 0, NULL }, +{"ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL }, +{"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive, NULL, 0, NULL }, +{"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL }, +{"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive, NULL, 0, NULL }, +{"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed, NULL, 0, NULL }, +{"ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow, NULL, 0, NULL }, +{"ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight, NULL, 0, NULL }, +{"ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow, NULL, 0, NULL }, +{"ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight, NULL, 0, NULL }, +{"ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow, NULL, 0, NULL }, +{"ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight, NULL, 0, NULL }, +{"ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow, NULL, 0, NULL }, +{"ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight, NULL, 0, NULL }, +{"ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow, NULL, 0, NULL }, +{"ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight, NULL, 0, NULL }, +{"ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow, NULL, 0, NULL }, +{"ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight, NULL, 0, NULL }, +{"BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight, NULL, 0, NULL }, +{"BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark, NULL, 0, NULL }, +{"BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight, NULL, 0, NULL }, +{"BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark, NULL, 0, NULL }, +{"NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground, NULL, 0, NULL }, +{"MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground, NULL, 0, NULL }, +{"SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque, NULL, 0, NULL }, +{"DrawerBackground", HIBrush, kThemeBrushDrawerBackground, NULL, 0, NULL }, +{"ToolbarBackground", HIBrush, kThemeBrushToolbarBackground, NULL, 0, NULL }, +{"SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent, NULL, 0, NULL }, +{"MenuBackground", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL }, +{"MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL }, +{"ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground, NULL, 0, NULL }, +{"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground, NULL, 0, NULL }, +{"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider, NULL, 0, NULL }, + +{"ButtonText", HIText, kThemeTextColorPushButtonActive, NULL, 0, NULL }, +{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected, NULL, 0, NULL }, +{"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled, NULL, 0, NULL }, +{"MenuText", HIText, kThemeTextColorMenuItemActive, NULL, 0, NULL }, +{"BlackText", HIText, kThemeTextColorBlack, NULL, 0, NULL }, +{"DialogActiveText", HIText, kThemeTextColorDialogActive, NULL, 0, NULL }, +{"DialogInactiveText", HIText, kThemeTextColorDialogInactive, NULL, 0, NULL }, +{"AlertActiveText", HIText, kThemeTextColorAlertActive, NULL, 0, NULL }, +{"AlertInactiveText", HIText, kThemeTextColorAlertInactive, NULL, 0, NULL }, +{"ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive, NULL, 0, NULL }, +{"ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive, NULL, 0, NULL }, +{"WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive, NULL, 0, NULL }, +{"WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive, NULL, 0, NULL }, +{"PlacardActiveText", HIText, kThemeTextColorPlacardActive, NULL, 0, NULL }, +{"PlacardInactiveText", HIText, kThemeTextColorPlacardInactive, NULL, 0, NULL }, +{"PlacardPressedText", HIText, kThemeTextColorPlacardPressed, NULL, 0, NULL }, +{"PushButtonActiveText", HIText, kThemeTextColorPushButtonActive, NULL, 0, NULL }, +{"PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive, NULL, 0, NULL }, +{"PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed, NULL, 0, NULL }, +{"BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive, NULL, 0, NULL }, +{"BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive, NULL, 0, NULL }, +{"BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed, NULL, 0, NULL }, +{"PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive, NULL, 0, NULL }, +{"PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive, NULL, 0, NULL }, +{"PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed, NULL, 0, NULL }, +{"IconLabelText", HIText, kThemeTextColorIconLabel, NULL, 0, NULL }, +{"ListViewText", HIText, kThemeTextColorListView, NULL, 0, NULL }, +{"DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive, NULL, 0, NULL }, +{"DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive, NULL, 0, NULL }, +{"MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive, NULL, 0, NULL }, +{"MovableModalWindowTitleInactiveText", HIText, kThemeTextColorMovableModalWindowTitleInactive, NULL, 0, NULL }, +{"UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive, NULL, 0, NULL }, +{"UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive, NULL, 0, NULL }, +{"PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive, NULL, 0, NULL }, +{"PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive, NULL, 0, NULL }, +{"RootMenuActiveText", HIText, kThemeTextColorRootMenuActive, NULL, 0, NULL }, +{"RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected, NULL, 0, NULL }, +{"RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled, NULL, 0, NULL }, +{"MenuItemActiveText", HIText, kThemeTextColorMenuItemActive, NULL, 0, NULL }, +{"MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected, NULL, 0, NULL }, +{"MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled, NULL, 0, NULL }, +{"PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive, NULL, 0, NULL }, +{"PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive, NULL, 0, NULL }, +{"TabFrontActiveText", HIText, kThemeTextColorTabFrontActive, NULL, 0, NULL }, +{"TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive, NULL, 0, NULL }, +{"TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed, NULL, 0, NULL }, +{"TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive, NULL, 0, NULL }, +{"TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive, NULL, 0, NULL }, +{"IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected, NULL, 0, NULL }, +{"BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive, NULL, 0, NULL }, +{"BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive, NULL, 0, NULL }, +{"NotificationText", HIText, kThemeTextColorNotification, NULL, 0, NULL }, +{"SystemDetailText", HIText, kThemeTextColorSystemDetail, NULL, 0, NULL }, +{"PlacardBackground", HIBackground, kThemeBackgroundPlacard, NULL, 0, NULL }, +{"WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader, NULL, 0, NULL }, +{"ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader, NULL, 0, NULL }, +{"MetalBackground", HIBackground, kThemeBackgroundMetal, NULL, 0, NULL }, + +{"SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox, NULL, 0, NULL }, +{"TabPaneBackground", HIBackground, kThemeBackgroundTabPane, NULL, 0, NULL }, +{"WhiteText", HIText, kThemeTextColorWhite, NULL, 0, NULL }, +{"Black", HIBrush, kThemeBrushBlack, NULL, 0, NULL }, +{"White", HIBrush, kThemeBrushWhite, NULL, 0, NULL }, + + /* + * Dynamic Colors + */ + +{"WindowBackgroundColor", ttkBackground, 0, NULL, 0, NULL }, +{"WindowBackgroundColor1", ttkBackground, 1, NULL, 0, NULL }, +{"WindowBackgroundColor2", ttkBackground, 2, NULL, 0, NULL }, +{"WindowBackgroundColor3", ttkBackground, 3, NULL, 0, NULL }, +{"WindowBackgroundColor4", ttkBackground, 4, NULL, 0, NULL }, +{"WindowBackgroundColor5", ttkBackground, 5, NULL, 0, NULL }, +{"WindowBackgroundColor6", ttkBackground, 6, NULL, 0, NULL }, +{"WindowBackgroundColor7", ttkBackground, 7, NULL, 0, NULL }, +/* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ +{"SecondaryLabelColor", ttkBackground, 14, NULL, 0, NULL }, + +{"TextColor", semantic, 0, "textColor", 0, NULL }, +{"SelectedTextColor", semantic, 0, "selectedTextColor", 0, NULL }, +{"LabelColor", semantic, 0, "textColor", 0, NULL }, +{"LabelColor", semantic, 0, "labelColor", 0, NULL }, +{"ControlTextColor", semantic, 0, "controlTextColor", 0, NULL }, +{"DisabledControlTextColor", semantic, 0, "disabledControlTextColor", 0, NULL }, +#if MAC_OS_X_VERSION_MAX_ALLOWED > 1060 +{"SelectedTabTextColor", semantic, 0, "whiteColor", 0, NULL }, +#else +{"SelectedTabTextColor", semantic, 0, "blackColor", 0, NULL }, +#endif +{"TextBackgroundColor", semantic, 0, "textBackgroundColor", 0, NULL }, +{"SelectedTextBackgroundColor", semantic, 0, "selectedTextBackgroundColor", 0, NULL }, +{"ControlAccentColor", semantic, 0, "controlAccentColor", 0, NULL }, +{"LinkColor", semantic, 0, "blueColor", 0, NULL }, +{"LinkColor", semantic, 0, "linkColor", 0, NULL }, +{"PlaceholderTextColor", semantic, 0, "grayColor", 0, NULL }, +{"PlaceholderTextColor", semantic, 0, "placeholderTextColor", 0, NULL }, +{"SeparatorColor", semantic, 0, "grayColor", 0, NULL }, +{"SeparatorColor", semantic, 0, "separatorColor", 0, NULL }, +{NULL, 0, 0, NULL, 0, NULL } +}; + +#endif +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index e019ea1..19ffd2c 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -106,6 +106,8 @@ typedef NSInteger NSModalResponse; #define graphicsContextWithGraphicsPort graphicsContextWithCGContext #endif - +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 +#define NSWindowStyleMaskTexturedBackground 0 #endif +#endif diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index b6a834f..ddcbfd7 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -43,6 +43,7 @@ static int cgAntiAliasLimit = 0; static int useThemedToplevel = 0; static int useThemedFrame = 0; +static unsigned long transparentColor; /* * Prototypes for functions used only in this file. @@ -100,6 +101,7 @@ TkMacOSXInitCGDrawing( (char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } + transparentColor = TkMacOSXClearPixel(); } return TCL_OK; } @@ -546,7 +548,7 @@ TkMacOSXGetNSImageWithBitmap( unsigned long origBackground = gc->background; - gc->background = TRANSPARENT_PIXEL << 24; + gc->background = transparentColor; XSetClipOrigin(display, gc, 0, 0); XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); gc->background = origBackground; @@ -665,17 +667,18 @@ TkMacOSXDrawCGImage( dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff); if (CGImageIsMask(image)) { if (macDraw->flags & TK_IS_BW_PIXMAP) { + /* * Set fill color to black; background comes from the context, * or is transparent. */ - if (imageBackground != TRANSPARENT_PIXEL << 24) { + if (imageBackground != transparentColor) { CGContextClearRect(context, dstBounds); } CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0); } else { - if (imageBackground != TRANSPARENT_PIXEL << 24) { + if (imageBackground != transparentColor) { TkMacOSXSetColorInContext(gc, imageBackground, context); CGContextFillRect(context, dstBounds); } diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 07a20ac..5440d03 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -306,7 +306,11 @@ DestroyImage( * Get a single pixel from an image. * * Results: - * Returns the 32 bit pixel value. + * The XColor structure contains an unsigned long field named pixel which + * identifies the color. This function returns the unsigned long that + * would be used as the pixel value of an XColor that has the same red + * green and blue components as the XImage pixel at the specified + * location. * * Side effects: * None. @@ -322,13 +326,18 @@ ImageGetPixel( { unsigned char r = 0, g = 0, b = 0; + /* + * Compute 8 bit red green and blue values, which are passed as inputs to + * TkMacOSXRGBPixel to produce the pixel value. + */ + if (image && image->data) { unsigned char *srcPtr = ((unsigned char*) image->data) + (y * image->bytes_per_line) + (((image->xoffset + x) * image->bits_per_pixel) / NBBY); switch (image->bits_per_pixel) { - case 32: + case 32: /* 8 bits per channel */ r = (*((unsigned int*) srcPtr) >> 16) & 0xff; g = (*((unsigned int*) srcPtr) >> 8) & 0xff; b = (*((unsigned int*) srcPtr) ) & 0xff; @@ -338,12 +347,12 @@ ImageGetPixel( r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3]; }*/ break; - case 16: + case 16: /* 5 bits per channel */ r = (*((unsigned short*) srcPtr) >> 7) & 0xf8; g = (*((unsigned short*) srcPtr) >> 2) & 0xf8; b = (*((unsigned short*) srcPtr) << 3) & 0xf8; break; - case 8: + case 8: /* 2 bits per channel */ r = (*srcPtr << 2) & 0xc0; g = (*srcPtr << 4) & 0xc0; b = (*srcPtr << 6) & 0xc0; @@ -351,7 +360,7 @@ ImageGetPixel( g |= g >> 2 | g >> 4 | g >> 6; b |= b >> 2 | b >> 4 | b >> 6; break; - case 4: { + case 4: { /* 1 bit per channel */ unsigned char c = (x % 2) ? *srcPtr : (*srcPtr >> 4); r = (c & 0x04) ? 0xff : 0; @@ -359,12 +368,13 @@ ImageGetPixel( b = (c & 0x01) ? 0xff : 0; break; } - case 1: + case 1: /* Black-white bitmap. */ r = g = b = ((*srcPtr) & (0x80 >> (x % 8))) ? 0xff : 0; break; } } - return (PIXEL_MAGIC << 24) | (r << 16) | (g << 8) | b; + + return TkMacOSXRGBPixel(r, g, b); } /* diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index 28010ec..87f438d 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -131,29 +131,15 @@ */ #define TK_NO_DOUBLE_BUFFERING 1 +#define TK_HAS_DYNAMIC_COLORS 1 +#define TK_DYNAMIC_COLORMAP 0x0fffffff /* - * Magic pixel code values for system colors. - * - * NOTE: values must be kept in sync with indices into the - * systemColorMap array in tkMacOSXColor.c ! - */ - -#define TRANSPARENT_PIXEL 30 -#define APPEARANCE_PIXEL 52 -#define PIXEL_MAGIC ((unsigned char) 0x69) - -/* - * The following macro returns the pixel value that corresponds to the - * 16-bit RGB values in the given XColor structure. - * The format is: (PIXEL_MAGIC << 24) | (R << 16) | (G << 8) | B - * where each of R, G and B is the high order byte of a 16-bit component. + * Used by xcolor.c */ -#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \ - | (((p)->red >> 8) & 0xff)) << 8) \ - | (((p)->green >> 8) & 0xff)) << 8) \ - | (((p)->blue >> 8) & 0xff)) - +MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green, + unsigned long blue); +#define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8)) #endif /* _TKMACPORT */ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index aa9b1f7..ed597ca 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -310,6 +310,7 @@ MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, NSRect *bounds); MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData); +MODULE_SCOPE unsigned long TkMacOSXClearPixel(void); #pragma mark Private Objective-C Classes diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 51eba68..c1014bc 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -212,7 +212,7 @@ XMapWindow( * we handle this event immediately and then process the idle * events that it generates. */ - + Tk_HandleEvent(&event); while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } else { @@ -330,7 +330,7 @@ XUnmapWindow( * we handle this event immediately and then process the idle * events that it generates. */ - + Tk_HandleEvent(&event); while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } else { diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 5bbcde0..6653fbd 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -30,7 +30,7 @@ static int PressButtonObjCmd (ClientData dummy, Tcl_Interp *interp, static int InjectKeyEventObjCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int MenuBarHeightObjCmd (ClientData dummy, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); + int objc, Tcl_Obj *const *objv); /* @@ -117,10 +117,10 @@ DebuggerObjCmd( static int MenuBarHeightObjCmd( - ClientData clientData, /* Not used. */ + TCL_UNUSED(void *), /* Not used. */ Tcl_Interp *interp, /* Not used. */ - int objc, /* Not used. */ - Tcl_Obj *const objv[]) /* Not used. */ + TCL_UNUSED(int), /* Not used. */ + TCL_UNUSED(Tcl_Obj *const *)) /* Not used. */ { static int height = 0; if (height == 0) { diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 8ef3c71..4ad94ed 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1152,13 +1152,6 @@ ConfigureRestrictProc( Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); } -- (BOOL) isOpaque -{ - NSWindow *w = [self window]; - return (w && (([w styleMask] & NSTexturedBackgroundWindowMask) || - ![w isOpaque]) ? NO : YES); -} - /* * On Catalina this is never called and drawRect clips to the rect that * is passed to it by AppKit. diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index c6ea384..f1ac020 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -256,8 +256,8 @@ XkbOpenDisplay( */ screen->root = ROOT_ID; screen->display = display; - screen->black_pixel = 0x00000000 | PIXEL_MAGIC << 24; - screen->white_pixel = 0x00FFFFFF | PIXEL_MAGIC << 24; + screen->black_pixel = 0x00000000; + screen->white_pixel = 0x00FFFFFF; screen->ext_data = (XExtData *) &maxBounds; screen->root_visual = (Visual *)ckalloc(sizeof(Visual)); diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index b322ef7..2496c43 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -1238,13 +1238,12 @@ test unixEmbed-10.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con deleteWindows } -body { frame .f1 -container 1 -width 200 -height 50 - update pack .f1 - update + update idletasks toplevel .t1 -use [winfo id .f1] -width 150 -height 80 - update + update idletasks wm geometry .t1 +40+50 - update + update idletasks wm geometry .t1 } -cleanup { deleteWindows @@ -1256,10 +1255,11 @@ test unixEmbed-10.2 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con } -body { frame .f1 -container 1 -width 200 -height 50 pack .f1 + update idletasks toplevel .t1 -use [winfo id .f1] -width 150 -height 80 - update + update idletasks wm geometry .t1 70x300+10+20 - update + update idletasks wm geometry .t1 } -cleanup { deleteWindows |