summaryrefslogtreecommitdiff
path: root/tk/win/tkWinColor.c
diff options
context:
space:
mode:
Diffstat (limited to 'tk/win/tkWinColor.c')
-rw-r--r--tk/win/tkWinColor.c75
1 files changed, 25 insertions, 50 deletions
diff --git a/tk/win/tkWinColor.c b/tk/win/tkWinColor.c
index 20dd3ed13a0..e05f0c692e0 100644
--- a/tk/win/tkWinColor.c
+++ b/tk/win/tkWinColor.c
@@ -12,8 +12,8 @@
* RCS: @(#) $Id$
*/
-#include <tkColor.h>
-#include <tkWinInt.h>
+#include "tkWinInt.h"
+#include "tkColor.h"
/*
* The following structure is used to keep track of each color that is
@@ -27,12 +27,6 @@ typedef struct WinColor {
} WinColor;
/*
- * colorTable is a hash table used to look up X colors by name.
- */
-
-static Tcl_HashTable colorTable;
-
-/*
* The sysColors array contains the names and index values for the
* Windows indirect system color names. In use, all of the names
* will have the string "System" prepended, but we omit it in the table
@@ -75,7 +69,10 @@ static SystemColorEntry sysColors[] = {
NULL, 0
};
-static int ncolors = 0;
+typedef struct ThreadSpecificData {
+ int ncolors;
+} ThreadSpecificData;
+static Tcl_ThreadDataKey dataKey;
/*
* Forward declarations for functions defined later in this file.
@@ -111,13 +108,15 @@ FindSystemColor(name, colorPtr, indexPtr)
int *indexPtr; /* Out parameter to store color index. */
{
int l, u, r, i;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* Count the number of elements in the color array if we haven't
* done so yet.
*/
- if (ncolors == 0) {
+ if (tsdPtr->ncolors == 0) {
SystemColorEntry *ePtr;
int version;
@@ -130,7 +129,7 @@ FindSystemColor(name, colorPtr, indexPtr)
ePtr->index = COLOR_BTNHIGHLIGHT;
}
}
- ncolors++;
+ tsdPtr->ncolors++;
}
}
@@ -139,7 +138,7 @@ FindSystemColor(name, colorPtr, indexPtr)
*/
l = 0;
- u = ncolors - 1;
+ u = tsdPtr->ncolors - 1;
while (l <= u) {
i = (l + u) / 2;
r = strcasecmp(name, sysColors[i].name);
@@ -157,9 +156,13 @@ FindSystemColor(name, colorPtr, indexPtr)
*indexPtr = sysColors[i].index;
colorPtr->pixel = GetSysColor(sysColors[i].index);
- colorPtr->red = GetRValue(colorPtr->pixel) << 8;
- colorPtr->green = GetGValue(colorPtr->pixel) << 8;
- colorPtr->blue = GetBValue(colorPtr->pixel) << 8;
+ /*
+ * x257 is (value<<8 + value) to get the properly bit shifted
+ * and padded value. [Bug: 4919]
+ */
+ colorPtr->red = GetRValue(colorPtr->pixel) * 257;
+ colorPtr->green = GetGValue(colorPtr->pixel) * 257;
+ colorPtr->blue = GetBValue(colorPtr->pixel) * 257;
colorPtr->flags = DoRed|DoGreen|DoBlue;
colorPtr->pad = 0;
return 1;
@@ -339,7 +342,7 @@ XAllocColor(display, colormap, color)
TkWinColormap *cmap = (TkWinColormap *) colormap;
PALETTEENTRY entry, closeEntry;
HDC dc = GetDC(NULL);
-
+
entry.peRed = (color->red) >> 8;
entry.peGreen = (color->green) >> 8;
entry.peBlue = (color->blue) >> 8;
@@ -374,9 +377,9 @@ XAllocColor(display, colormap, color)
if ((index >= cmap->size) || (newPixel != closePixel)) {
if (cmap->size == sizePalette) {
- color->red = closeEntry.peRed << 8;
- color->green = closeEntry.peGreen << 8;
- color->blue = closeEntry.peBlue << 8;
+ color->red = closeEntry.peRed * 257;
+ color->green = closeEntry.peGreen * 257;
+ color->blue = closeEntry.peBlue * 257;
entry = closeEntry;
if (index >= cmap->size) {
OutputDebugString("XAllocColor: Colormap is bigger than we thought");
@@ -405,9 +408,9 @@ XAllocColor(display, colormap, color)
color->pixel = GetNearestColor(dc,
RGB(entry.peRed, entry.peGreen, entry.peBlue));
- color->red = (GetRValue(color->pixel) << 8);
- color->green = (GetGValue(color->pixel) << 8);
- color->blue = (GetBValue(color->pixel) << 8);
+ color->red = GetRValue(color->pixel) * 257;
+ color->green = GetGValue(color->pixel) * 257;
+ color->blue = GetBValue(color->pixel) * 257;
}
ReleaseDC(NULL, dc);
@@ -613,31 +616,3 @@ TkWinSelectPalette(dc, colormap)
RealizePalette(dc);
return oldPalette;
}
-
-/* CYGNUS LOCAL: The system colors have changed. Update them. */
-
-static void
-ChangeColor(tkColPtr)
- TkColor *tkColPtr;
-{
- WinColor *winColPtr = (WinColor *) tkColPtr;
-
- if (winColPtr->index != -1) {
- unsigned long pixel;
-
- pixel = GetSysColor(winColPtr->index);
- if (pixel != winColPtr->info.color.pixel) {
- winColPtr->info.color.pixel = pixel;
- winColPtr->info.color.red = GetRValue(pixel) << 8;
- winColPtr->info.color.green = GetGValue(pixel) << 8;
- winColPtr->info.color.blue = GetBValue(pixel) << 8;
- TkColorChanged((TkColor *) winColPtr);
- }
- }
-}
-
-void
-TkWinSysColorChange()
-{
- TkMapOverColors(ChangeColor);
-}