diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-08-22 21:22:28 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-08-22 21:22:28 (GMT) |
commit | a2541b75b88d75bac86b6e83010fabb6cdffb912 (patch) | |
tree | 6daf49ce248bc2420d87b07eebe8c539828e3f45 /generic | |
parent | e11b682e0dc8fca3d036d7d5cb5a8c3ae336e5ec (diff) | |
parent | aff38ee930b8b62b99c03fd79c2fb03f8f27c85f (diff) | |
download | tk-a2541b75b88d75bac86b6e83010fabb6cdffb912.zip tk-a2541b75b88d75bac86b6e83010fabb6cdffb912.tar.gz tk-a2541b75b88d75bac86b6e83010fabb6cdffb912.tar.bz2 |
[TIP 403]: Web Colors for Tk.
New colors aqua, crimson, fuchsia, indigo, lime, olive, silver, and teal.
Modified RGB values for gray/grey, green, maroon and purple.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkColor.c | 53 | ||||
-rw-r--r-- | generic/tkInt.h | 2 |
2 files changed, 51 insertions, 4 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c index 9383a92..ea03e28 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -826,8 +826,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' */ "reen\0#000080800000", + /* 'h' */ NULL, + /* 'i' */ "ndigo\0#4b4b00008282", + /* 'j' */ NULL, + /* 'k' */ NULL, + /* 'l' */ "ime\0#0000ffff0000", + /* 'm' */ "aroon\0#808000000000", + /* 'n' */ NULL, + /* 'o' */ "live\0#808080800000", + /* 'p' */ "urple\0#808000008080", + /* 'q' */ NULL, + /* 'r' */ NULL, + /* 's' */ "ilver\0#c0c0c0c0c0c0", + /* 't' */ "eal\0#000080808080" +}; + Status TkParseColor( Display *display, /* The display */ @@ -880,12 +907,30 @@ 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])) { + if (!((name[0] - 'G') & 0xdf) && !((name[1] - 'R') & 0xdf) + && !((name[2] - 'A') & 0xdb) && !((name[3] - 'Y') & 0xdf) + && !name[4]) { + name = "#808080808080"; + goto done; + } else { + 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) { + return 0; + } +done: return XParseColor(display, map, name, color); } #endif /* __WIN32__ */ diff --git a/generic/tkInt.h b/generic/tkInt.h index 88e0c25..01cc9cb 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -944,6 +944,8 @@ MODULE_SCOPE TkMainInfo *tkMainWindowList; MODULE_SCOPE Tk_ImageType tkPhotoImageType; MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable; +MODULE_SCOPE const char *const tkWebColors[20]; + /* * The definition of pi, at least from the perspective of double-precision * floats. |