summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2021-10-30 20:20:54 (GMT)
committermarc_culler <marc.culler@gmail.com>2021-10-30 20:20:54 (GMT)
commit0b1cc20f76bcf0efdd0f75e825628e6f4761cf7c (patch)
treeab194bf0a55d003bb6e95bc75c76be6ff5c1c802 /macosx
parentae9ec0f179b4d64a2fc92134c8d909c628e5a86d (diff)
downloadtk-0b1cc20f76bcf0efdd0f75e825628e6f4761cf7c.zip
tk-0b1cc20f76bcf0efdd0f75e825628e6f4761cf7c.tar.gz
tk-0b1cc20f76bcf0efdd0f75e825628e6f4761cf7c.tar.bz2
Buttons
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXColor.c15
-rw-r--r--macosx/tkMacOSXColor.h4
-rw-r--r--macosx/tkMacOSXDefault.h4
-rw-r--r--macosx/ttkMacOSXTheme.c14
4 files changed, 30 insertions, 7 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index f82305e..afb21b2 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) {
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..e327b77 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,7 +68,7 @@
#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_BUTTON_FG BLACK
#define DEF_CHKRAD_FG DEF_BUTTON_FG
#define DEF_BUTTON_FONT "TkDefaultFont"
#define DEF_BUTTON_HEIGHT "0"
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 8379812..188272e 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
@@ -720,8 +723,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)) {