4 * Declarations of data types and functions used by the Tk color module.
6 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
8 * See the file "license.terms" for information on usage and redistribution of
9 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
18 * One of the following data structures is used to keep track of each color
19 * that is being used by the application; typically there is a colormap entry
20 * allocated for each of these colors.
23 #define TK_COLOR_BY_NAME 1
24 #define TK_COLOR_BY_VALUE 2
26 #define COLOR_MAGIC ((unsigned int) 0x46140277)
28 typedef struct TkColor {
29 XColor color; /* Information about this color. */
30 unsigned int magic; /* Used for quick integrity check on this
31 * structure. Must always have the value
33 GC gc; /* Simple gc with this color as foreground
34 * color and all other fields defaulted. May
36 Screen *screen; /* Screen where this color is valid. Used to
37 * delete it, and to find its display. */
38 Colormap colormap; /* Colormap from which this entry was
40 Visual *visual; /* Visual associated with colormap. */
41 int resourceRefCount; /* Number of active uses of this color (each
42 * active use corresponds to a call to
43 * Tk_AllocColorFromObj or Tk_GetColor). If
44 * this count is 0, then this TkColor
45 * structure is no longer valid and it isn't
46 * present in a hash table: it is being kept
47 * around only because there are objects
48 * referring to it. The structure is freed
49 * when resourceRefCount and objRefCount are
51 int objRefCount; /* The number of Tcl objects that reference
53 int type; /* TK_COLOR_BY_NAME or TK_COLOR_BY_VALUE. */
54 Tcl_HashEntry *hashPtr; /* Pointer to hash table entry for this
55 * structure. (for use in deleting entry). */
56 struct TkColor *nextPtr; /* Points to the next TkColor structure with
57 * the same color name. Colors with the same
58 * name but different screens or colormaps are
59 * chained together off a single entry in
60 * nameTable. For colors in valueTable (those
61 * allocated by Tk_GetColorByValue) this field
66 * Common APIs exported from all platform-specific implementations.
70 MODULE_SCOPE void TkpFreeColor(TkColor *tkColPtr);
72 MODULE_SCOPE TkColor * TkpGetColor(Tk_Window tkwin, Tk_Uid name);
73 MODULE_SCOPE TkColor * TkpGetColorByValue(Tk_Window tkwin, XColor *colorPtr);