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 /unix | |
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 'unix')
-rw-r--r-- | unix/tkUnixColor.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/unix/tkUnixColor.c b/unix/tkUnixColor.c index 9bfe8bb..43500ad 100644 --- a/unix/tkUnixColor.c +++ b/unix/tkUnixColor.c @@ -136,6 +136,25 @@ TkpGetColor( if (*name != '#') { XColor screen; + 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 gotWebColor; + } else { + const char *p = tkWebColors[((*name - 'A') & 0x1f)]; + if (p) { + const char *q = name; + while (!((*p - *(++q)) & 0xdf)) { + if (!*p++) { + name = p; + goto gotWebColor; + } + } + } + } + } if (strlen(name) > 99) { /* Don't bother to parse this. [Bug 2809525]*/ return (TkColor *) NULL; @@ -155,6 +174,7 @@ TkpGetColor( FindClosestColor(tkwin, &screen, &color); } } else { + gotWebColor: if (TkParseColor(display, colormap, name, &color) == 0) { return NULL; } @@ -420,6 +440,7 @@ TkpCmapStressed( return 0; } + /* * Local Variables: * mode: c |