Import Tk 8.6.10
This commit is contained in:
@@ -17,11 +17,32 @@
|
||||
#include "tkMacOSXPrivate.h"
|
||||
#include "tkColor.h"
|
||||
|
||||
/*
|
||||
* 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.*/
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
struct SystemColorMapEntry {
|
||||
const char *name;
|
||||
ThemeBrush brush;
|
||||
ThemeTextColor textColor;
|
||||
ThemeBackgroundKind background;
|
||||
enum colorType type;
|
||||
long value;
|
||||
}; /* unsigned char pixelCode; */
|
||||
|
||||
/*
|
||||
@@ -32,157 +53,178 @@ struct SystemColorMapEntry {
|
||||
|
||||
#define MIN_PIXELCODE 30
|
||||
static const struct SystemColorMapEntry systemColorMap[] = {
|
||||
{ "Transparent", 0, 0, 0 }, /* 30: TRANSPARENT_PIXEL */
|
||||
{ "Highlight", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 31: HIGHLIGHT_PIXEL */
|
||||
{ "HighlightSecondary", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 32: HIGHLIGHT_SECONDARY_PIXEL */
|
||||
{ "HighlightText", kThemeBrushBlack, 0, 0 }, /* 33: HIGHLIGHT_TEXT_PIXEL */
|
||||
{ "HighlightAlternate", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 34: HIGHLIGHT_ALTERNATE_PIXEL */
|
||||
{ "ButtonText", 0, kThemeTextColorPushButtonActive, 0 }, /* 35: CONTROL_TEXT_PIXEL */
|
||||
{ "PrimaryHighlightColor", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 36 */
|
||||
{ "ButtonFace", kThemeBrushButtonFaceActive, 0, 0 }, /* 37: CONTROL_BODY_PIXEL */
|
||||
{ "SecondaryHighlightColor", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 38 */
|
||||
{ "ButtonFrame", kThemeBrushButtonFrameActive, 0, 0 }, /* 39: CONTROL_FRAME_PIXEL */
|
||||
{ "AlternatePrimaryHighlightColor", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 40 */
|
||||
{ "WindowBody", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 41: WINDOW_BODY_PIXEL */
|
||||
{ "SheetBackground", kThemeBrushSheetBackground, 0, 0 }, /* 42 */
|
||||
{ "MenuActive", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 43: MENU_ACTIVE_PIXEL */
|
||||
{ "Black", kThemeBrushBlack, 0, 0 }, /* 44 */
|
||||
{ "MenuActiveText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 45: MENU_ACTIVE_TEXT_PIXEL */
|
||||
{ "White", kThemeBrushWhite, 0, 0 }, /* 46 */
|
||||
{ "Menu", kThemeBrushMenuBackground, 0, 0 }, /* 47: MENU_BACKGROUND_PIXEL */
|
||||
{ "DialogBackgroundActive", kThemeBrushDialogBackgroundActive, 0, 0 }, /* 48 */
|
||||
{ "MenuDisabled", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 49: MENU_DISABLED_PIXEL */
|
||||
{ "DialogBackgroundInactive", kThemeBrushDialogBackgroundInactive, 0, 0 }, /* 50 */
|
||||
{ "MenuText", 0, kThemeTextColorMenuItemActive, 0 }, /* 51: MENU_TEXT_PIXEL */
|
||||
{ "AppearanceColor", 0, 0, 0 }, /* 52: APPEARANCE_PIXEL */
|
||||
{ "AlertBackgroundActive", kThemeBrushAlertBackgroundActive, 0, 0 }, /* 53 */
|
||||
{ "AlertBackgroundInactive", kThemeBrushAlertBackgroundInactive, 0, 0 }, /* 54 */
|
||||
{ "ModelessDialogBackgroundActive", kThemeBrushModelessDialogBackgroundActive, 0, 0 }, /* 55 */
|
||||
{ "ModelessDialogBackgroundInactive", kThemeBrushModelessDialogBackgroundInactive, 0, 0 }, /* 56 */
|
||||
{ "UtilityWindowBackgroundActive", kThemeBrushUtilityWindowBackgroundActive, 0, 0 }, /* 57 */
|
||||
{ "UtilityWindowBackgroundInactive", kThemeBrushUtilityWindowBackgroundInactive, 0, 0 }, /* 58 */
|
||||
{ "ListViewSortColumnBackground", kThemeBrushListViewSortColumnBackground, 0, 0 }, /* 59 */
|
||||
{ "ListViewBackground", kThemeBrushListViewBackground, 0, 0 }, /* 60 */
|
||||
{ "IconLabelBackground", kThemeBrushIconLabelBackground, 0, 0 }, /* 61 */
|
||||
{ "ListViewSeparator", kThemeBrushListViewSeparator, 0, 0 }, /* 62 */
|
||||
{ "ChasingArrows", kThemeBrushChasingArrows, 0, 0 }, /* 63 */
|
||||
{ "DragHilite", kThemeBrushDragHilite, 0, 0 }, /* 64 */
|
||||
{ "DocumentWindowBackground", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 65 */
|
||||
{ "FinderWindowBackground", kThemeBrushFinderWindowBackground, 0, 0 }, /* 66 */
|
||||
{ "ScrollBarDelimiterActive", kThemeBrushScrollBarDelimiterActive, 0, 0 }, /* 67 */
|
||||
{ "ScrollBarDelimiterInactive", kThemeBrushScrollBarDelimiterInactive, 0, 0 }, /* 68 */
|
||||
{ "FocusHighlight", kThemeBrushFocusHighlight, 0, 0 }, /* 69 */
|
||||
{ "PopupArrowActive", kThemeBrushPopupArrowActive, 0, 0 }, /* 70 */
|
||||
{ "PopupArrowPressed", kThemeBrushPopupArrowPressed, 0, 0 }, /* 71 */
|
||||
{ "PopupArrowInactive", kThemeBrushPopupArrowInactive, 0, 0 }, /* 72 */
|
||||
{ "AppleGuideCoachmark", kThemeBrushAppleGuideCoachmark, 0, 0 }, /* 73 */
|
||||
{ "IconLabelBackgroundSelected", kThemeBrushIconLabelBackgroundSelected, 0, 0 }, /* 74 */
|
||||
{ "StaticAreaFill", kThemeBrushStaticAreaFill, 0, 0 }, /* 75 */
|
||||
{ "ActiveAreaFill", kThemeBrushActiveAreaFill, 0, 0 }, /* 76 */
|
||||
{ "ButtonFrameActive", kThemeBrushButtonFrameActive, 0, 0 }, /* 77 */
|
||||
{ "ButtonFrameInactive", kThemeBrushButtonFrameInactive, 0, 0 }, /* 78 */
|
||||
{ "ButtonFaceActive", kThemeBrushButtonFaceActive, 0, 0 }, /* 79 */
|
||||
{ "ButtonFaceInactive", kThemeBrushButtonFaceInactive, 0, 0 }, /* 80 */
|
||||
{ "ButtonFacePressed", kThemeBrushButtonFacePressed, 0, 0 }, /* 81 */
|
||||
{ "ButtonActiveDarkShadow", kThemeBrushButtonActiveDarkShadow, 0, 0 }, /* 82 */
|
||||
{ "ButtonActiveDarkHighlight", kThemeBrushButtonActiveDarkHighlight, 0, 0 }, /* 83 */
|
||||
{ "ButtonActiveLightShadow", kThemeBrushButtonActiveLightShadow, 0, 0 }, /* 84 */
|
||||
{ "ButtonActiveLightHighlight", kThemeBrushButtonActiveLightHighlight, 0, 0 }, /* 85 */
|
||||
{ "ButtonInactiveDarkShadow", kThemeBrushButtonInactiveDarkShadow, 0, 0 }, /* 86 */
|
||||
{ "ButtonInactiveDarkHighlight", kThemeBrushButtonInactiveDarkHighlight, 0, 0 }, /* 87 */
|
||||
{ "ButtonInactiveLightShadow", kThemeBrushButtonInactiveLightShadow, 0, 0 }, /* 88 */
|
||||
{ "ButtonInactiveLightHighlight", kThemeBrushButtonInactiveLightHighlight, 0, 0 }, /* 89 */
|
||||
{ "ButtonPressedDarkShadow", kThemeBrushButtonPressedDarkShadow, 0, 0 }, /* 90 */
|
||||
{ "ButtonPressedDarkHighlight", kThemeBrushButtonPressedDarkHighlight, 0, 0 }, /* 91 */
|
||||
{ "ButtonPressedLightShadow", kThemeBrushButtonPressedLightShadow, 0, 0 }, /* 92 */
|
||||
{ "ButtonPressedLightHighlight", kThemeBrushButtonPressedLightHighlight, 0, 0 }, /* 93 */
|
||||
{ "BevelActiveLight", kThemeBrushBevelActiveLight, 0, 0 }, /* 94 */
|
||||
{ "BevelActiveDark", kThemeBrushBevelActiveDark, 0, 0 }, /* 95 */
|
||||
{ "BevelInactiveLight", kThemeBrushBevelInactiveLight, 0, 0 }, /* 96 */
|
||||
{ "BevelInactiveDark", kThemeBrushBevelInactiveDark, 0, 0 }, /* 97 */
|
||||
{ "NotificationWindowBackground", kThemeBrushNotificationWindowBackground, 0, 0 }, /* 98 */
|
||||
{ "MovableModalBackground", kThemeBrushMovableModalBackground, 0, 0 }, /* 99 */
|
||||
{ "SheetBackgroundOpaque", kThemeBrushSheetBackgroundOpaque, 0, 0 }, /* 100 */
|
||||
{ "DrawerBackground", kThemeBrushDrawerBackground, 0, 0 }, /* 101 */
|
||||
{ "ToolbarBackground", kThemeBrushToolbarBackground, 0, 0 }, /* 102 */
|
||||
{ "SheetBackgroundTransparent", kThemeBrushSheetBackgroundTransparent, 0, 0 }, /* 103 */
|
||||
{ "MenuBackground", kThemeBrushMenuBackground, 0, 0 }, /* 104 */
|
||||
{ "Pixel", 0, 0, 0 }, /* 105: PIXEL_MAGIC */
|
||||
{ "MenuBackgroundSelected", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 106 */
|
||||
{ "ListViewOddRowBackground", kThemeBrushListViewOddRowBackground, 0, 0 }, /* 107 */
|
||||
{ "ListViewEvenRowBackground", kThemeBrushListViewEvenRowBackground, 0, 0 }, /* 108 */
|
||||
{ "ListViewColumnDivider", kThemeBrushListViewColumnDivider, 0, 0 }, /* 109 */
|
||||
{ "BlackText", 0, kThemeTextColorBlack, 0 }, /* 110 */
|
||||
{ "DialogActiveText", 0, kThemeTextColorDialogActive, 0 }, /* 111 */
|
||||
{ "DialogInactiveText", 0, kThemeTextColorDialogInactive, 0 }, /* 112 */
|
||||
{ "AlertActiveText", 0, kThemeTextColorAlertActive, 0 }, /* 113 */
|
||||
{ "AlertInactiveText", 0, kThemeTextColorAlertInactive, 0 }, /* 114 */
|
||||
{ "ModelessDialogActiveText", 0, kThemeTextColorModelessDialogActive, 0 }, /* 115 */
|
||||
{ "ModelessDialogInactiveText", 0, kThemeTextColorModelessDialogInactive, 0 }, /* 116 */
|
||||
{ "WindowHeaderActiveText", 0, kThemeTextColorWindowHeaderActive, 0 }, /* 117 */
|
||||
{ "WindowHeaderInactiveText", 0, kThemeTextColorWindowHeaderInactive, 0 }, /* 118 */
|
||||
{ "PlacardActiveText", 0, kThemeTextColorPlacardActive, 0 }, /* 119 */
|
||||
{ "PlacardInactiveText", 0, kThemeTextColorPlacardInactive, 0 }, /* 120 */
|
||||
{ "PlacardPressedText", 0, kThemeTextColorPlacardPressed, 0 }, /* 121 */
|
||||
{ "PushButtonActiveText", 0, kThemeTextColorPushButtonActive, 0 }, /* 122 */
|
||||
{ "PushButtonInactiveText", 0, kThemeTextColorPushButtonInactive, 0 }, /* 123 */
|
||||
{ "PushButtonPressedText", 0, kThemeTextColorPushButtonPressed, 0 }, /* 124 */
|
||||
{ "BevelButtonActiveText", 0, kThemeTextColorBevelButtonActive, 0 }, /* 125 */
|
||||
{ "BevelButtonInactiveText", 0, kThemeTextColorBevelButtonInactive, 0 }, /* 126 */
|
||||
{ "BevelButtonPressedText", 0, kThemeTextColorBevelButtonPressed, 0 }, /* 127 */
|
||||
{ "PopupButtonActiveText", 0, kThemeTextColorPopupButtonActive, 0 }, /* 128 */
|
||||
{ "PopupButtonInactiveText", 0, kThemeTextColorPopupButtonInactive, 0 }, /* 129 */
|
||||
{ "PopupButtonPressedText", 0, kThemeTextColorPopupButtonPressed, 0 }, /* 130 */
|
||||
{ "IconLabelText", 0, kThemeTextColorIconLabel, 0 }, /* 131 */
|
||||
{ "ListViewText", 0, kThemeTextColorListView, 0 }, /* 132 */
|
||||
{ "DocumentWindowTitleActiveText", 0, kThemeTextColorDocumentWindowTitleActive, 0 }, /* 133 */
|
||||
{ "DocumentWindowTitleInactiveText", 0, kThemeTextColorDocumentWindowTitleInactive, 0 }, /* 134 */
|
||||
{ "MovableModalWindowTitleActiveText", 0, kThemeTextColorMovableModalWindowTitleActive, 0 }, /* 135 */
|
||||
{ "MovableModalWindowTitleInactiveText",0, kThemeTextColorMovableModalWindowTitleInactive, 0 }, /* 136 */
|
||||
{ "UtilityWindowTitleActiveText", 0, kThemeTextColorUtilityWindowTitleActive, 0 }, /* 137 */
|
||||
{ "UtilityWindowTitleInactiveText", 0, kThemeTextColorUtilityWindowTitleInactive, 0 }, /* 138 */
|
||||
{ "PopupWindowTitleActiveText", 0, kThemeTextColorPopupWindowTitleActive, 0 }, /* 139 */
|
||||
{ "PopupWindowTitleInactiveText", 0, kThemeTextColorPopupWindowTitleInactive, 0 }, /* 140 */
|
||||
{ "RootMenuActiveText", 0, kThemeTextColorRootMenuActive, 0 }, /* 141 */
|
||||
{ "RootMenuSelectedText", 0, kThemeTextColorRootMenuSelected, 0 }, /* 142 */
|
||||
{ "RootMenuDisabledText", 0, kThemeTextColorRootMenuDisabled, 0 }, /* 143 */
|
||||
{ "MenuItemActiveText", 0, kThemeTextColorMenuItemActive, 0 }, /* 144 */
|
||||
{ "MenuItemSelectedText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 145 */
|
||||
{ "MenuItemDisabledText", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 146 */
|
||||
{ "PopupLabelActiveText", 0, kThemeTextColorPopupLabelActive, 0 }, /* 147 */
|
||||
{ "PopupLabelInactiveText", 0, kThemeTextColorPopupLabelInactive, 0 }, /* 148 */
|
||||
{ "TabFrontActiveText", 0, kThemeTextColorTabFrontActive, 0 }, /* 149 */
|
||||
{ "TabNonFrontActiveText", 0, kThemeTextColorTabNonFrontActive, 0 }, /* 150 */
|
||||
{ "TabNonFrontPressedText", 0, kThemeTextColorTabNonFrontPressed, 0 }, /* 151 */
|
||||
{ "TabFrontInactiveText", 0, kThemeTextColorTabFrontInactive, 0 }, /* 152 */
|
||||
{ "TabNonFrontInactiveText", 0, kThemeTextColorTabNonFrontInactive, 0 }, /* 153 */
|
||||
{ "IconLabelSelectedText", 0, kThemeTextColorIconLabelSelected, 0 }, /* 154 */
|
||||
{ "BevelButtonStickyActiveText", 0, kThemeTextColorBevelButtonStickyActive, 0 }, /* 155 */
|
||||
{ "BevelButtonStickyInactiveText", 0, kThemeTextColorBevelButtonStickyInactive, 0 }, /* 156 */
|
||||
{ "NotificationText", 0, kThemeTextColorNotification, 0 }, /* 157 */
|
||||
{ "SystemDetailText", 0, kThemeTextColorSystemDetail, 0 }, /* 158 */
|
||||
{ "WhiteText", 0, kThemeTextColorWhite, 0 }, /* 159 */
|
||||
{ "TabPaneBackground", 0, 0, kThemeBackgroundTabPane }, /* 160 */
|
||||
{ "PlacardBackground", 0, 0, kThemeBackgroundPlacard }, /* 161 */
|
||||
{ "WindowHeaderBackground", 0, 0, kThemeBackgroundWindowHeader }, /* 162 */
|
||||
{ "ListViewWindowHeaderBackground", 0, 0, kThemeBackgroundListViewWindowHeader }, /* 163 */
|
||||
{ "SecondaryGroupBoxBackground", 0, 0, kThemeBackgroundSecondaryGroupBox }, /* 164 */
|
||||
{ "MetalBackground", 0, 0, kThemeBackgroundMetal }, /* 165 */
|
||||
{ NULL, 0, 0, 0 }
|
||||
{ "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 */
|
||||
|
||||
/*
|
||||
* Colors based on "semantic" NSColors.
|
||||
*/
|
||||
|
||||
{ "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 */
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
#define MAX_PIXELCODE 165
|
||||
#define FIRST_SEMANTIC_COLOR 166
|
||||
#define MAX_PIXELCODE 182
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* GetThemeFromPixelCode --
|
||||
* GetEntryFromPixelCode --
|
||||
*
|
||||
* When given a pixel code corresponding to a theme system color,
|
||||
* set one of brush, textColor or background to the corresponding
|
||||
* Appearance Mgr theme constant.
|
||||
* Extract a SystemColorMapEntry from the table.
|
||||
*
|
||||
* Results:
|
||||
* Returns false if not a real pixel, true otherwise.
|
||||
* Returns false if the code is out of bounds.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
@@ -190,36 +232,28 @@ static const struct SystemColorMapEntry systemColorMap[] = {
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
GetThemeFromPixelCode(
|
||||
static bool
|
||||
GetEntryFromPixelCode(
|
||||
unsigned char code,
|
||||
ThemeBrush *brush,
|
||||
ThemeTextColor *textColor,
|
||||
ThemeBackgroundKind *background)
|
||||
struct SystemColorMapEntry *entry)
|
||||
{
|
||||
if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) {
|
||||
*brush = systemColorMap[code - MIN_PIXELCODE].brush;
|
||||
*textColor = systemColorMap[code - MIN_PIXELCODE].textColor;
|
||||
*background = systemColorMap[code - MIN_PIXELCODE].background;
|
||||
} else {
|
||||
*brush = 0;
|
||||
*textColor = 0;
|
||||
*background = 0;
|
||||
}
|
||||
if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC &&
|
||||
code != TRANSPARENT_PIXEL) {
|
||||
return false;
|
||||
} else {
|
||||
*entry = systemColorMap[code - MIN_PIXELCODE];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* GetThemeColor --
|
||||
* SetCGColorComponents --
|
||||
*
|
||||
* Get RGB color for a given system color or pixel value.
|
||||
* 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.
|
||||
*
|
||||
* Results:
|
||||
* OSStatus
|
||||
@@ -230,60 +264,217 @@ GetThemeFromPixelCode(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static NSColorSpace* deviceRGB = NULL;
|
||||
static CGFloat blueAccentRGBA[4] = {0, 122.0 / 255, 1.0, 1.0};
|
||||
static CGFloat windowBackground[4] =
|
||||
{236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};
|
||||
|
||||
static OSStatus
|
||||
GetThemeColor(
|
||||
SetCGColorComponents(
|
||||
struct SystemColorMapEntry entry,
|
||||
unsigned long pixel,
|
||||
ThemeBrush brush,
|
||||
ThemeTextColor textColor,
|
||||
ThemeBackgroundKind background,
|
||||
CGColorRef *c)
|
||||
{
|
||||
OSStatus err = noErr;
|
||||
NSColor *bgColor, *color = nil;
|
||||
CGFloat rgba[4] = {0, 0, 0, 1};
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
|
||||
NSInteger colorVariant;
|
||||
static CGFloat graphiteAccentRGBA[4] =
|
||||
{152.0 / 255, 152.0 / 255, 152.0 / 255, 1.0};
|
||||
#endif
|
||||
|
||||
if (brush) {
|
||||
err = ChkErr(HIThemeBrushCreateCGColor, brush, c);
|
||||
/*} else if (textColor) {
|
||||
err = ChkErr(GetThemeTextColor, textColor, 32, true, c);*/
|
||||
} else {
|
||||
CGFloat rgba[4] = {0, 0, 0, 1};
|
||||
|
||||
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 );
|
||||
if (!deviceRGB) {
|
||||
deviceRGB = [NSColorSpace deviceRGBColorSpace];
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
case rgbColor:
|
||||
rgba[0] = ((pixel >> 16) & 0xff) / 255.0;
|
||||
rgba[1] = ((pixel >> 8) & 0xff) / 255.0;
|
||||
rgba[2] = ((pixel ) & 0xff) / 255.0;
|
||||
break;
|
||||
case ttkBackground:
|
||||
|
||||
/*
|
||||
* Prior to OSX 10.14, getComponents returns black when applied to
|
||||
* windowBackGroundColor.
|
||||
*/
|
||||
|
||||
if ([NSApp macMinorVersion] < 14) {
|
||||
for (int i=0; i<3; i++) {
|
||||
rgba[i] = windowBackground[i];
|
||||
}
|
||||
} else {
|
||||
bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
[bgColor getComponents: rgba];
|
||||
}
|
||||
if (rgba[0] + rgba[1] + rgba[2] < 1.5) {
|
||||
for (int i=0; i<3; i++) {
|
||||
rgba[i] += entry.value*8.0 / 255.0;
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<3; i++) {
|
||||
rgba[i] -= entry.value*8.0 / 255.0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case semantic:
|
||||
switch (entry.value) {
|
||||
case 0:
|
||||
color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
|
||||
break;
|
||||
case 1:
|
||||
color = [[NSColor selectedTextColor] colorUsingColorSpace: deviceRGB];
|
||||
break;
|
||||
case 2:
|
||||
if ([NSApp macMinorVersion] > 9) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
|
||||
color = [[NSColor labelColor] colorUsingColorSpace: deviceRGB];
|
||||
#endif
|
||||
} else {
|
||||
color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
color = [[NSColor controlTextColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
break;
|
||||
case 4:
|
||||
color = [[NSColor disabledControlTextColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
break;
|
||||
case 5:
|
||||
if ([NSApp macMinorVersion] > 6) {
|
||||
color = [[NSColor whiteColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
} else {
|
||||
color = [[NSColor blackColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
color = [[NSColor textBackgroundColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
break;
|
||||
case 7:
|
||||
color = [[NSColor selectedTextBackgroundColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
break;
|
||||
case 8:
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||
if (@available(macOS 10.14, *)) {
|
||||
color = [[NSColor controlAccentColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
} else {
|
||||
color = [NSColor colorWithColorSpace: deviceRGB
|
||||
components: blueAccentRGBA
|
||||
count: 4];
|
||||
}
|
||||
#else
|
||||
colorVariant = [[NSUserDefaults standardUserDefaults]
|
||||
integerForKey:@"AppleAquaColorVariant"];
|
||||
if (colorVariant == 6) {
|
||||
color = [NSColor colorWithColorSpace: deviceRGB
|
||||
components: graphiteAccentRGBA
|
||||
count: 4];
|
||||
} else {
|
||||
color = [NSColor colorWithColorSpace: deviceRGB
|
||||
components: blueAccentRGBA
|
||||
count: 4];
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||
if ([NSApp macMinorVersion] >= 10) {
|
||||
color = [[NSColor labelColor] colorUsingColorSpace:
|
||||
deviceRGB];
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
|
||||
break;
|
||||
}
|
||||
[color getComponents: rgba];
|
||||
break;
|
||||
case clearColor:
|
||||
rgba[3] = 0.0;
|
||||
break;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
case HIText:
|
||||
case HIBackground:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*c = CGColorCreate(deviceRGB.CGColorSpace, rgba);
|
||||
[pool drain];
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TkMacOSXInDarkMode --
|
||||
*
|
||||
* Tests whether the given window's NSView has a DarkAqua Appearance.
|
||||
*
|
||||
* Results:
|
||||
* Returns true if the NSView is in DarkMode, false if not.
|
||||
*
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MODULE_SCOPE Bool
|
||||
TkMacOSXInDarkMode(Tk_Window tkwin)
|
||||
{
|
||||
int result = false;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||
if ([NSApp macMinorVersion] >= 14) {
|
||||
static NSAppearanceName darkAqua = @"NSAppearanceNameDarkAqua";
|
||||
TkWindow *winPtr = (TkWindow*) tkwin;
|
||||
NSView *view = TkMacOSXDrawableView(winPtr->privatePtr);
|
||||
result = (view &&
|
||||
[view.effectiveAppearance.name isEqualToString:darkAqua]);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
* TkSetMacColor --
|
||||
*
|
||||
* Creates a CGColorRef from a X style pixel value.
|
||||
* 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.
|
||||
*
|
||||
* Results:
|
||||
* Returns false if not a real pixel, true otherwise.
|
||||
* Returns false if the high order byte is not a valid index, true
|
||||
* otherwise.
|
||||
*
|
||||
* Side effects:
|
||||
* The variable macColor is set to a new CGColorRef, the caller is
|
||||
@@ -299,14 +490,10 @@ TkSetMacColor(
|
||||
{
|
||||
CGColorRef *color = (CGColorRef*)macColor;
|
||||
OSStatus err = -1;
|
||||
ThemeBrush brush;
|
||||
ThemeTextColor textColor;
|
||||
ThemeBackgroundKind background;
|
||||
struct SystemColorMapEntry entry;
|
||||
|
||||
if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
|
||||
&background)) {
|
||||
err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
|
||||
color);
|
||||
if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) {
|
||||
err = ChkErr(SetCGColorComponents, entry, pixel, color);
|
||||
}
|
||||
return (err == noErr);
|
||||
}
|
||||
@@ -321,7 +508,7 @@ TkSetMacColor(
|
||||
* Results:
|
||||
* None resp. retained CGColorRef for CopyCachedColor()
|
||||
*
|
||||
* Side effects:
|
||||
* Side effects:M
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -450,6 +637,7 @@ TkMacOSXGetNSColor(
|
||||
if (cgColor) {
|
||||
NSColorSpace *colorSpace = [[NSColorSpace alloc]
|
||||
initWithCGColorSpace:CGColorGetColorSpace(cgColor)];
|
||||
|
||||
nsColor = [NSColor colorWithColorSpace:colorSpace
|
||||
components:CGColorGetComponents(cgColor)
|
||||
count:CGColorGetNumberOfComponents(cgColor)];
|
||||
@@ -484,48 +672,56 @@ TkMacOSXSetColorInContext(
|
||||
unsigned long pixel,
|
||||
CGContextRef context)
|
||||
{
|
||||
OSStatus err = -1;
|
||||
CGColorRef cgColor = CopyCachedColor(gc, pixel);
|
||||
ThemeBrush brush;
|
||||
ThemeTextColor textColor;
|
||||
ThemeBackgroundKind background;
|
||||
OSStatus err = noErr;
|
||||
CGColorRef cgColor = nil;
|
||||
struct SystemColorMapEntry entry;
|
||||
CGRect rect;
|
||||
int code = (pixel >> 24) & 0xff;
|
||||
HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};;
|
||||
static CGColorSpaceRef deviceRGBSpace = NULL;
|
||||
|
||||
if (!cgColor && GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush,
|
||||
&textColor, &background)) {
|
||||
if (brush) {
|
||||
err = ChkErr(HIThemeSetFill, brush, NULL, context,
|
||||
if (!deviceRGBSpace) {
|
||||
deviceRGBSpace = CGColorSpaceCreateDeviceRGB();
|
||||
}
|
||||
if (code < FIRST_SEMANTIC_COLOR) {
|
||||
cgColor = CopyCachedColor(gc, pixel);
|
||||
}
|
||||
if (!cgColor && GetEntryFromPixelCode(code, &entry)) {
|
||||
switch (entry.type) {
|
||||
case HIBrush:
|
||||
err = ChkErr(HIThemeSetFill, entry.value, NULL, context,
|
||||
kHIThemeOrientationNormal);
|
||||
if (err == noErr) {
|
||||
err = ChkErr(HIThemeSetStroke, brush, NULL, context,
|
||||
err = ChkErr(HIThemeSetStroke, entry.value, NULL, context,
|
||||
kHIThemeOrientationNormal);
|
||||
}
|
||||
} else if (textColor) {
|
||||
err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
|
||||
break;
|
||||
case HIText:
|
||||
err = ChkErr(HIThemeSetTextFill, entry.value, NULL, context,
|
||||
kHIThemeOrientationNormal);
|
||||
} else if (background) {
|
||||
CGRect rect = CGContextGetClipBoundingBox(context);
|
||||
HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
|
||||
background };
|
||||
|
||||
break;
|
||||
case HIBackground:
|
||||
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) {
|
||||
SetCachedColor(gc, pixel, cgColor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (err == noErr) {
|
||||
return;
|
||||
}
|
||||
err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
|
||||
&cgColor);
|
||||
if (err == noErr) {
|
||||
SetCachedColor(gc, pixel, cgColor);
|
||||
}
|
||||
} else if (!cgColor) {
|
||||
TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
|
||||
}
|
||||
if (cgColor) {
|
||||
CGContextSetFillColorWithColor(context, cgColor);
|
||||
CGContextSetStrokeColorWithColor(context, cgColor);
|
||||
CGColorRelease(cgColor);
|
||||
}
|
||||
if (err != noErr) {
|
||||
TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -549,7 +745,7 @@ TkMacOSXSetColorInContext(
|
||||
TkColor *
|
||||
TkpGetColor(
|
||||
Tk_Window tkwin, /* Window in which color will be used. */
|
||||
Tk_Uid name) /* Name of color to allocated (in form
|
||||
Tk_Uid name) /* Name of color to be allocated (in form
|
||||
* suitable for passing to XParseColor). */
|
||||
{
|
||||
Display *display = tkwin != None ? Tk_Display(tkwin) : NULL;
|
||||
@@ -561,22 +757,21 @@ TkpGetColor(
|
||||
* Check to see if this is a system color. Otherwise, XParseColor
|
||||
* will do all the work.
|
||||
*/
|
||||
|
||||
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);
|
||||
sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx);
|
||||
Tcl_DecrRefCount(strPtr);
|
||||
if (result == TCL_OK) {
|
||||
OSStatus err;
|
||||
CGColorRef c;
|
||||
unsigned char pixelCode = idx + MIN_PIXELCODE;
|
||||
ThemeBrush brush = systemColorMap[idx].brush;
|
||||
ThemeTextColor textColor = systemColorMap[idx].textColor;
|
||||
ThemeBackgroundKind background = systemColorMap[idx].background;
|
||||
struct SystemColorMapEntry entry = systemColorMap[idx];
|
||||
|
||||
err = ChkErr(GetThemeColor, 0, brush, textColor, background, &c);
|
||||
err = ChkErr(SetCGColorComponents, entry, 0, &c);
|
||||
if (err == noErr) {
|
||||
const size_t n = CGColorGetNumberOfComponents(c);
|
||||
const CGFloat *rgba = CGColorGetComponents(c);
|
||||
@@ -591,12 +786,12 @@ TkpGetColor(
|
||||
color.red = color.green = color.blue = rgba[0] * 65535.0;
|
||||
break;
|
||||
default:
|
||||
Tcl_Panic("CGColor with %d components", (int) n);
|
||||
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));
|
||||
| ((color.red >> 8) & 0xff)) << 8)
|
||||
| ((color.green >> 8) & 0xff)) << 8)
|
||||
| ((color.blue >> 8) & 0xff));
|
||||
CGColorRelease(c);
|
||||
goto validXColor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user