summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXButton.c10
-rw-r--r--macosx/tkMacOSXColor.c17
-rw-r--r--macosx/tkMacOSXColor.h4
-rw-r--r--macosx/tkMacOSXDefault.h7
-rw-r--r--macosx/tkMacOSXInit.c20
-rw-r--r--macosx/ttkMacOSXTheme.c89
6 files changed, 113 insertions, 34 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index b083531..f8f60f8 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -765,10 +765,12 @@ TkMacOSXDrawButton(
* Using a ttk::button would be a much better choice, however.
*/
- if (TkMacOSXInDarkMode(butPtr->tkwin) &&
- mbPtr->drawinfo.state != kThemeStatePressed &&
- !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) {
- hiinfo.state = kThemeStateInactive;
+ if ([NSApp macOSVersion] < 101500) {
+ if (TkMacOSXInDarkMode(butPtr->tkwin) &&
+ mbPtr->drawinfo.state != kThemeStatePressed &&
+ !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) {
+ hiinfo.state = kThemeStateInactive;
+ }
}
HIThemeDrawButton(&cntrRect, &hiinfo, dc.context,
kHIThemeOrientationNormal, &contHIRec);
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index f82305e..3951683 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -24,6 +24,7 @@ static int numSystemColors;
static int rgbColorIndex;
static int controlAccentIndex;
static int selectedTabTextIndex;
+static int pressedButtonTextIndex;
static Bool useFakeAccentColor = NO;
static SystemColorDatum **systemColorIndex;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
@@ -67,7 +68,8 @@ void initColorTable()
if (![NSColor respondsToSelector:colorSelector]) {
if ([colorName isEqualToString:@"controlAccentColor"]) {
useFakeAccentColor = YES;
- } else if (![colorName isEqualToString:@"selectedTabTextColor"]) {
+ } else if ( ![colorName isEqualToString:@"selectedTabTextColor"]
+ && ![colorName isEqualToString:@"pressedButtonTextColor"]) {
/* Uncomment to print all unsupported colors: */
/* printf("Unsupported color %s\n", colorName.UTF8String); */
continue;
@@ -147,6 +149,9 @@ void initColorTable()
hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor");
entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
selectedTabTextIndex = entry->index;
+ hPtr = Tcl_FindHashEntry(&systemColors, "PressedButtonTextColor");
+ entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
+ pressedButtonTextIndex = entry->index;
[pool drain];
}
@@ -278,6 +283,7 @@ GetRGBA(
CGFloat *rgba)
{
NSColor *bgColor, *color = nil;
+ int OSVersion = [NSApp macOSVersion];
if (!sRGB) {
sRGB = [NSColorSpace sRGBColorSpace];
@@ -325,12 +331,17 @@ GetRGBA(
colorUsingColorSpace:sRGB];
#endif
} else if (entry->index == selectedTabTextIndex) {
- int OSVersion = [NSApp macOSVersion];
- if (OSVersion > 100600 && OSVersion < 101600) {
+ if (OSVersion > 100600 && OSVersion < 110000) {
color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];
} else {
color = [[NSColor textColor] colorUsingColorSpace:sRGB];
}
+ } else if (entry->index == pressedButtonTextIndex) {
+ if (OSVersion < 120000) {
+ color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];
+ } else {
+ color = [[NSColor blackColor] colorUsingColorSpace:sRGB];
+ }
} else {
color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB];
}
diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h
index deffbbc..bc9d307 100644
--- a/macosx/tkMacOSXColor.h
+++ b/macosx/tkMacOSXColor.h
@@ -241,8 +241,10 @@ static SystemColorDatum systemColorData[] = {
{"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 },
-/* Color to use for notebook tab labels -- depends on OS version. */
+/* Color to use for notebook tab label text -- depends on OS version. */
{"SelectedTabTextColor", semantic, 0, "textColor", 0, NULL },
+/* Color to use for selected button labels -- depends on OS version. */
+{"PressedButtonTextColor", semantic, 0, "textColor", 0, NULL },
/* Semantic colors that we simulate on older systems which don't supoort them. */
{"ControlAccentColor", semantic, 0, "controlAccentColor", 0, NULL },
{"LabelColor", semantic, 0, "blackColor", 0, NULL },
diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h
index c0f72fb..3a8eb92 100644
--- a/macosx/tkMacOSXDefault.h
+++ b/macosx/tkMacOSXDefault.h
@@ -55,7 +55,7 @@
#define DEF_BUTTON_ANCHOR "center"
#define DEF_BUTTON_ACTIVE_BG_COLOR ACTIVE_BG
#define DEF_BUTTON_ACTIVE_BG_MONO BLACK
-#define DEF_BUTTON_ACTIVE_FG_COLOR WHITE
+#define DEF_BUTTON_ACTIVE_FG_COLOR "systemPressedButtonTextColor"
#define DEF_CHKRAD_ACTIVE_FG_COLOR ACTIVE_FG
#define DEF_BUTTON_ACTIVE_FG_MONO WHITE
#define DEF_BUTTON_BG_COLOR NORMAL_BG
@@ -68,8 +68,9 @@
#define DEF_BUTTON_DEFAULT "disabled"
#define DEF_BUTTON_DISABLED_FG_COLOR DISABLED
#define DEF_BUTTON_DISABLED_FG_MONO ""
-#define DEF_BUTTON_FG NORMAL_FG
-#define DEF_CHKRAD_FG DEF_BUTTON_FG
+#define DEF_BUTTON_FG BLACK
+#define DEF_LABEL_FG NORMAL_FG
+#define DEF_CHKRAD_FG DEF_LABEL_FG
#define DEF_BUTTON_FONT "TkDefaultFont"
#define DEF_BUTTON_HEIGHT "0"
#define DEF_BUTTON_HIGHLIGHT_BG_COLOR DEF_BUTTON_BG_COLOR
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 440383f..bd0199a 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -17,6 +17,7 @@
#include <dlfcn.h>
#include <objc/objc-auto.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
static char tkLibPath[PATH_MAX + 1] = "";
@@ -188,6 +189,7 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
*/
int minorVersion, majorVersion;
+
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion);
majorVersion = 10;
@@ -197,6 +199,24 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
majorVersion = systemVersion.majorVersion;
minorVersion = systemVersion.minorVersion;
#endif
+
+ if (majorVersion == 10 && minorVersion == 16) {
+
+ /*
+ * If a program compiled with a macOS 10.XX SDK is run on macOS 11.0 or
+ * later then it will report majorVersion 10 and minorVersion 16, no
+ * matter what the actual OS version of the host may be. And of course
+ * Apple never released macOS 10.16. To work around this we guess the
+ * OS version from the kernel release number, as reported by uname.
+ */
+
+ struct utsname name;
+ char *endptr;
+ if (uname(&name) == 0) {
+ majorVersion = strtol(name.release, &endptr, 10) - 9;
+ minorVersion = 0;
+ }
+ }
[NSApp setMacOSVersion: 10000*majorVersion + 100*minorVersion];
/*
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 8379812..3334356 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -63,7 +63,10 @@
*/
static CGFloat darkButtonFace[4] = {
- 112.0 / 255, 113.0 / 255, 115.0 / 255, 1.0
+ 90.0 / 255, 86.0 / 255, 95.0 / 255, 1.0
+};
+static CGFloat darkPressedButtonFace[4] = {
+ 114.0 / 255, 110.0 / 255, 118.0 / 255, 1.0
};
static CGFloat darkPressedBevelFace[4] = {
135.0 / 255, 136.0 / 255, 138.0 / 255, 1.0
@@ -77,6 +80,12 @@ static CGFloat darkDisabledButtonFace[4] = {
static CGFloat darkInactiveSelectedTab[4] = {
159.0 / 255, 160.0 / 255, 161.0 / 255, 1.0
};
+static CGFloat darkSelectedTab[4] = {
+ 97.0 / 255, 94.0 / 255, 102.0 / 255, 1.0
+};
+static CGFloat darkTab[4] = {
+ 44.0 / 255, 41.0 / 255, 50.0 / 255, 1.0
+};
static CGFloat darkFocusRing[4] = {
38.0 / 255, 113.0 / 255, 159.0 / 255, 1.0
};
@@ -720,8 +729,15 @@ static void DrawDarkButton(
bounds = CGRectInset(bounds, 1, 1);
if (kind == kThemePushButton && (state & TTK_STATE_PRESSED)) {
- GradientFillRoundedRectangle(context, bounds, 4,
+ if ([NSApp macOSVersion] < 120000) {
+ GradientFillRoundedRectangle(context, bounds, 4,
pressedPushButtonGradient, 2);
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkPressedButtonFace
+ count: 4];
+ SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+ }
} else if (kind == kThemePushButton &&
(state & TTK_STATE_ALTERNATE) &&
!(state & TTK_STATE_BACKGROUND)) {
@@ -996,6 +1012,7 @@ static void DrawDarkTab(
NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
NSColor *faceColor, *stroke;
CGRect originalBounds = bounds;
+ int OSVersion = [NSApp macOSVersion];
CGContextSetLineWidth(context, 1.0);
CGContextClipToRect(context, bounds);
@@ -1005,13 +1022,14 @@ static void DrawDarkTab(
* clipped off.
*/
- if (!(state & TTK_STATE_FIRST_TAB)) {
- bounds.origin.x -= 10;
- bounds.size.width += 10;
- }
-
- if (!(state & TTK_STATE_LAST_TAB)) {
- bounds.size.width += 10;
+ if (OSVersion < 110000 || !(state & TTK_STATE_SELECTED)) {
+ if (!(state & TTK_STATE_FIRST_TAB)) {
+ bounds.origin.x -= 10;
+ bounds.size.width += 10;
+ }
+ if (!(state & TTK_STATE_LAST_TAB)) {
+ bounds.size.width += 10;
+ }
}
/*
@@ -1023,13 +1041,25 @@ static void DrawDarkTab(
bounds = CGRectInset(bounds, 1, 1);
if (!(state & TTK_STATE_SELECTED)) {
if (state & TTK_STATE_DISABLED) {
- faceColor = [NSColor colorWithColorSpace: deviceRGB
- components: darkDisabledButtonFace
- count: 4];
+ if (OSVersion < 110000) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkDisabledButtonFace
+ count: 4];
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkTab
+ count: 4];
+ }
} else {
- faceColor = [NSColor colorWithColorSpace: deviceRGB
- components: darkButtonFace
- count: 4];
+ if (OSVersion < 110000) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkButtonFace
+ count: 4];
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkTab
+ count: 4];
+ }
}
SolidFillRoundedRectangle(context, bounds, 4, faceColor);
@@ -1056,21 +1086,34 @@ static void DrawDarkTab(
} else {
/*
- * This is the selected tab; paint it blue. If it is first, cover up
- * the separator line drawn by the second one. (The selected tab is
- * always drawn last.)
+ * This is the selected tab. If it is first, cover up the separator
+ * line drawn by the second one. (The selected tab is always drawn
+ * last.)
*/
if ((state & TTK_STATE_FIRST_TAB) && !(state & TTK_STATE_LAST_TAB)) {
bounds.size.width += 1;
}
if (!(state & TTK_STATE_BACKGROUND)) {
- GradientFillRoundedRectangle(context, bounds, 4,
- darkSelectedGradient, 2);
+ if (OSVersion < 110000) {
+ GradientFillRoundedRectangle(context, bounds, 4,
+ darkSelectedGradient, 2);
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkSelectedTab
+ count: 4];
+ SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+ }
} else {
- faceColor = [NSColor colorWithColorSpace: deviceRGB
- components: darkInactiveSelectedTab
- count: 4];
+ if (OSVersion < 110000) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkInactiveSelectedTab
+ count: 4];
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkSelectedTab
+ count: 4];
+ }
SolidFillRoundedRectangle(context, bounds, 4, faceColor);
}
HighlightButtonBorder(context, bounds);