summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2020-08-12 13:20:55 (GMT)
committerculler <culler>2020-08-12 13:20:55 (GMT)
commitb80a12fe1ac29d3ba04737c7cd7b698db23d38f0 (patch)
treeded552c42b6ed001a9dd8e813a06288eccefd200 /macosx
parent589d0dde98f21d4046bf3fa2fb4112c90863b8ad (diff)
downloadtk-b80a12fe1ac29d3ba04737c7cd7b698db23d38f0.zip
tk-b80a12fe1ac29d3ba04737c7cd7b698db23d38f0.tar.gz
tk-b80a12fe1ac29d3ba04737c7cd7b698db23d38f0.tar.bz2
Aqua - automatically support all NSColors in the System ColorList.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXColor.c31
-rw-r--r--macosx/tkMacOSXColor.h15
2 files changed, 32 insertions, 14 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 89bddb9..e65bf35 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -40,6 +40,8 @@ void initColorTable()
Tcl_HashSearch search;
Tcl_HashEntry *hPtr;
int newPtr, index = 0;
+ NSColorList *systemColorList = [NSColorList colorListNamed:@"System"];
+ NSString *key;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
if (@available(macOS 10.14, *)) {
@@ -50,6 +52,7 @@ void initColorTable()
/*
* Build a hash table for looking up a color by its name.
+ * First add all of the static entries from tkMacOSXColor.h
*/
for (entry = systemColorData; entry->name != NULL; entry++) {
@@ -81,6 +84,32 @@ void initColorTable()
}
/*
+ * Add all of the colors in the System ColorList.
+ */
+
+ for (key in [systemColorList allKeys]) {
+ int length = [key lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+ char *name;
+ entry = ckalloc(sizeof(SystemColorDatum));
+ bzero(entry, sizeof(SystemColorDatum));
+ name = ckalloc(length + 1);
+ strcpy(name, key.UTF8String);
+ name[0] = toupper(name[0]);
+ entry->type=semantic;
+ entry->name = name;
+ entry->selector = [key retain];
+ hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr);
+ if (newPtr == 0) {
+ oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
+ entry->index = oldEntry->index;
+ [oldEntry->selector release];
+ } else {
+ entry->index = index++;
+ }
+ Tcl_SetHashValue(hPtr, entry);
+ }
+
+ /*
* Build an array for looking up a color by its index.
*/
@@ -211,7 +240,7 @@ GetEntryFromPixel(
/*
*----------------------------------------------------------------------
*
- * GetRGB --
+ * GetRGBA --
*
* 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
diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h
index 535d15d..da62955 100644
--- a/macosx/tkMacOSXColor.h
+++ b/macosx/tkMacOSXColor.h
@@ -241,27 +241,16 @@ 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 },
-
-{"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 },
+/* Color to use for notebook tab labels. */
#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 },
+/* Semantic colors that we simulate on older systems which don't supoort them. */
{"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 }
};