OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / generic / tkColor.h
1 /*
2  * tkColor.h --
3  *
4  *      Declarations of data types and functions used by the Tk color module.
5  *
6  * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
7  *
8  * See the file "license.terms" for information on usage and redistribution of
9  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
10  */
11
12 #ifndef _TKCOLOR
13 #define _TKCOLOR
14
15 #include "tkInt.h"
16
17 /*
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.
21  */
22
23 #define TK_COLOR_BY_NAME        1
24 #define TK_COLOR_BY_VALUE       2
25
26 #define COLOR_MAGIC ((unsigned int) 0x46140277)
27
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
32                                  * COLOR_MAGIC. */
33     GC gc;                      /* Simple gc with this color as foreground
34                                  * color and all other fields defaulted. May
35                                  * be NULL. */
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
39                                  * allocated. */
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
50                                  * both 0. */
51     int objRefCount;            /* The number of Tcl objects that reference
52                                  * this structure. */
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
62                                  * is always NULL. */
63 } TkColor;
64
65 /*
66  * Common APIs exported from all platform-specific implementations.
67  */
68
69 #ifndef TkpFreeColor
70 MODULE_SCOPE void       TkpFreeColor(TkColor *tkColPtr);
71 #endif
72 MODULE_SCOPE TkColor *  TkpGetColor(Tk_Window tkwin, Tk_Uid name);
73 MODULE_SCOPE TkColor *  TkpGetColorByValue(Tk_Window tkwin, XColor *colorPtr);
74
75 #endif /* _TKCOLOR */