summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-02-15 20:57:48 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-02-15 20:57:48 (GMT)
commit3db9fce4a20b8969cd5c73671c76dd4918d048f9 (patch)
treeb69a457a0eaaa41f3bf3c89239cd80372fd4b53e /generic
parent751529e39515a7968bd597326de78c0f9f220f44 (diff)
parent05750b46ee02ad06be61476b42f8a1a8d8a87597 (diff)
downloadtk-3db9fce4a20b8969cd5c73671c76dd4918d048f9.zip
tk-3db9fce4a20b8969cd5c73671c76dd4918d048f9.tar.gz
tk-3db9fce4a20b8969cd5c73671c76dd4918d048f9.tar.bz2
[Bug 3486474]: Inconsistent color scaling
Diffstat (limited to 'generic')
-rw-r--r--generic/tkColor.c56
-rw-r--r--generic/tkCursor.c4
-rw-r--r--generic/tkImgBmap.c4
-rw-r--r--generic/tkImgPhoto.c2
-rw-r--r--generic/tkInt.h7
-rw-r--r--generic/tkStubInit.c6
6 files changed, 73 insertions, 6 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c
index 6836c52..ebfcf22 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -798,7 +798,61 @@ TkDebugColor(
}
return resultPtr;
}
-
+
+#ifndef __WIN32__
+/* This function is not necessary for Win32,
+ * since XParseColor already does the right thing */
+Status
+TkParseColor(
+ Display * display, /* The display */
+ Colormap map, /* Color map */
+ _Xconst char* spec, /* String to be parsed */
+ XColor * colorPtr)
+{
+ if (*spec == '#') {
+ char buf[14];
+ buf[0] = '#'; buf[13] = '\0';
+ if (!*(++spec) || !*(++spec) || !*(++spec)) {
+ /* Not at least 3 hex digits, so invalid */
+ return 0;
+ } else if (!*(++spec)) {
+ /* Exactly 3 hex digits */
+ buf[9] = buf[10] = buf[11] = buf[12] = *(--spec);
+ buf[5] = buf[6] = buf[7] = buf[8] = *(--spec);
+ buf[1] = buf[2] = buf[3] = buf[4] = *(--spec);
+ spec = buf;
+ } else if (!*(++spec) || !*(++spec)) {
+ /* Not at least 6 hex digits, so invalid */
+ return 0;
+ } else if (!*(++spec)) {
+ /* Exactly 6 hex digits */
+ buf[10] = buf[12] = *(--spec);
+ buf[9] = buf[11] = *(--spec);
+ buf[6] = buf[8] = *(--spec);
+ buf[5] = buf[7] = *(--spec);
+ buf[2] = buf[4] = *(--spec);
+ buf[1] = buf[3] = *(--spec);
+ spec = buf;
+ } else if (!*(++spec) || !*(++spec)) {
+ /* Not at least 9 hex digits, so invalid */
+ return 0;
+ } else if (!*(++spec)) {
+ /* Exactly 9 hex digits */
+ buf[11] = *(--spec);
+ buf[10] = *(--spec);
+ buf[9] = buf[12] = *(--spec);
+ buf[7] = *(--spec);
+ buf[6] = *(--spec);
+ buf[5] = buf[8] = *(--spec);
+ buf[3] = *(--spec);
+ buf[2] = *(--spec);
+ buf[1] = buf[4] = *(--spec);
+ spec = buf;
+ }
+ }
+ return XParseColor(display, map, spec, colorPtr);
+}
+#endif /* __WIN32__ */
/*
* Local Variables:
* mode: c
diff --git a/generic/tkCursor.c b/generic/tkCursor.c
index 606a349..410aea9 100644
--- a/generic/tkCursor.c
+++ b/generic/tkCursor.c
@@ -349,11 +349,11 @@ Tk_GetCursorFromData(
* add it to the database.
*/
- if (XParseColor(dataKey.display, Tk_Colormap(tkwin), fg, &fgColor) == 0) {
+ if (TkParseColor(dataKey.display, Tk_Colormap(tkwin), fg, &fgColor) == 0) {
Tcl_AppendResult(interp, "invalid color name \"", fg, "\"", NULL);
goto error;
}
- if (XParseColor(dataKey.display, Tk_Colormap(tkwin), bg, &bgColor) == 0) {
+ if (TkParseColor(dataKey.display, Tk_Colormap(tkwin), bg, &bgColor) == 0) {
Tcl_AppendResult(interp, "invalid color name \"", bg, "\"", NULL);
goto error;
}
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
index 88c96d5..8598e88 100644
--- a/generic/tkImgBmap.c
+++ b/generic/tkImgBmap.c
@@ -1247,7 +1247,7 @@ ImgBmapPostscript(
if ((masterPtr->bgUid != NULL) && (masterPtr->bgUid[0] != '\000')) {
XColor color;
- XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid,
+ TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid,
&color);
if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
return TCL_ERROR;
@@ -1269,7 +1269,7 @@ ImgBmapPostscript(
if ((masterPtr->fgUid != NULL) && (masterPtr->data != NULL)) {
XColor color;
- XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid,
+ TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid,
&color);
if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
return TCL_ERROR;
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 6075da8..ffff4fc 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -1160,7 +1160,7 @@ ImgPhotoCmd(
}
}
- if (!XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
+ if (!TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
colorString, &color)) {
Tcl_AppendResult(interp, "can't parse color \"",
colorString, "\"", NULL);
diff --git a/generic/tkInt.h b/generic/tkInt.h
index bd40a88..42ef495 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1179,6 +1179,13 @@ MODULE_SCOPE void TkUnderlineCharsInContext(Display *display,
int firstByte, int lastByte);
MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont,
Tcl_UniChar c, struct TkFontAttributes *faPtr);
+#ifdef __WIN32__
+#define TkParseColor XParseColor
+#else
+MODULE_SCOPE Status TkParseColor (Display * display,
+ Colormap map, _Xconst char* spec,
+ XColor * colorPtr);
+#endif
/*
* Unsupported commands.
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index 9c154e8..170ada7 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -45,6 +45,12 @@ MODULE_SCOPE TkIntXlibStubs tkIntXlibStubs;
MODULE_SCOPE TkPlatStubs tkPlatStubs;
MODULE_SCOPE TkStubs tkStubs;
+#ifndef __WIN32__
+/* Make sure that extensions which call XParseColor through
+ * the stub table, call TkParseColor in stead. See bug #3486474 */
+# define XParseColor TkParseColor
+#endif
+
/*
* WARNING: The contents of this file is automatically generated by the
* tools/genStubs.tcl script. Any modifications to the function declarations