summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-09-28 10:42:31 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-09-28 10:42:31 (GMT)
commit909217df3c0c2f0f162731db5d8cd8f36c00c6e5 (patch)
treeac49bac7b0a5b38a5c7103eb9cfe0c6a7caf8afc /generic
parent0e0d9b0e10ba2a3152820bae02018b0cd17fcb42 (diff)
parentca628a3dcc069bbebb21f385893a43cca232ae7d (diff)
downloadtk-909217df3c0c2f0f162731db5d8cd8f36c00c6e5.zip
tk-909217df3c0c2f0f162731db5d8cd8f36c00c6e5.tar.gz
tk-909217df3c0c2f0f162731db5d8cd8f36c00c6e5.tar.bz2
Add 8 colors to the supported color list (aqua, crimson, fuchsia, indigo, lime, olive, silver and teal), part of TIP #403
Diffstat (limited to 'generic')
-rw-r--r--generic/tkColor.c51
-rw-r--r--generic/tkInt.h2
2 files changed, 47 insertions, 6 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c
index 1111c51..76d0baa 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -416,8 +416,8 @@ Tk_GCForColor(
if (tkColPtr->gc == None) {
gcValues.foreground = tkColPtr->color.pixel;
- tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen),
- drawable, GCForeground, &gcValues);
+ tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen), drawable,
+ GCForeground, &gcValues);
}
return tkColPtr->gc;
}
@@ -800,8 +800,35 @@ TkDebugColor(
}
#ifndef __WIN32__
+
/* This function is not necessary for Win32,
* since XParseColor already does the right thing */
+
+#undef XParseColor
+
+CONST char *CONST tkWebColors[20] = {
+ /* 'a' */ "qua\0#0000ffffffff",
+ /* 'b' */ NULL,
+ /* 'c' */ "rimson\0#dcdc14143c3c",
+ /* 'd' */ NULL,
+ /* 'e' */ NULL,
+ /* 'f' */ "uchsia\0#ffff0000ffff",
+ /* 'g' */ NULL,
+ /* 'h' */ NULL,
+ /* 'i' */ "ndigo\0#4b4b00008282",
+ /* 'j' */ NULL,
+ /* 'k' */ NULL,
+ /* 'l' */ "ime\0#0000ffff0000",
+ /* 'm' */ NULL,
+ /* 'n' */ NULL,
+ /* 'o' */ "live\0#808080800000",
+ /* 'p' */ NULL,
+ /* 'q' */ NULL,
+ /* 'r' */ NULL,
+ /* 's' */ "ilver\0#c0c0c0c0c0c0",
+ /* 't' */ "eal\0#000080808080"
+};
+
Status
TkParseColor(
Display *display, /* The display */
@@ -854,12 +881,24 @@ TkParseColor(
} else {
name -= 13;
}
- } else {
- if (strlen(name) > 99) {
- /* Don't bother to parse this. [Bug 2809525]*/
- return 0;
+ goto done;
+ } else if (((*name - 'A') & 0xdf) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
+ const char *p = tkWebColors[((*name - 'A') & 0x1f)];
+ if (p) {
+ const char *q = name;
+ while (!((*p - *(++q)) & 0xdf)) {
+ if (!*p++) {
+ name = p;
+ goto done;
+ }
+ }
}
}
+ if (strlen(name) > 99) {
+ /* Don't bother to parse this. [Bug 2809525]*/
+ return 0;
+ }
+done:
return XParseColor(display, map, name, color);
}
#endif /* __WIN32__ */
diff --git a/generic/tkInt.h b/generic/tkInt.h
index c30eceb..9a36e1e 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -971,6 +971,8 @@ MODULE_SCOPE TkMainInfo *tkMainWindowList;
MODULE_SCOPE Tk_ImageType tkPhotoImageType;
MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable;
+MODULE_SCOPE CONST char *const tkWebColors[20];
+
#include "tkIntDecls.h"
#ifdef BUILD_tk