summaryrefslogtreecommitdiffstats
path: root/generic/tkColor.c
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)
commitccdd8d3ab00162ae1628413134fbda50e17212e9 (patch)
treeac49bac7b0a5b38a5c7103eb9cfe0c6a7caf8afc /generic/tkColor.c
parent52f37b7b2bdb8369bd206d66ad5b4c499daebf7c (diff)
parent35c5d43f01e2ff6e8cc9f7585adceb7bcbbbbcf9 (diff)
downloadtk-ccdd8d3ab00162ae1628413134fbda50e17212e9.zip
tk-ccdd8d3ab00162ae1628413134fbda50e17212e9.tar.gz
tk-ccdd8d3ab00162ae1628413134fbda50e17212e9.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/tkColor.c')
-rw-r--r--generic/tkColor.c51
1 files changed, 45 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__ */