aboutsummaryrefslogtreecommitdiff
path: root/generic/Color.c
diff options
context:
space:
mode:
authorlecoanet2000-02-02 14:01:15 +0000
committerlecoanet2000-02-02 14:01:15 +0000
commit64089dca388f5a9a8235a94b4372763875132219 (patch)
tree0455fa06d471a568cbece8fc27cde0216d4def23 /generic/Color.c
parent2b91521b4c124546e59638f2e990dcbc75903d85 (diff)
downloadtkzinc-64089dca388f5a9a8235a94b4372763875132219.zip
tkzinc-64089dca388f5a9a8235a94b4372763875132219.tar.gz
tkzinc-64089dca388f5a9a8235a94b4372763875132219.tar.bz2
tkzinc-64089dca388f5a9a8235a94b4372763875132219.tar.xz
Passage en Zinc
Diffstat (limited to 'generic/Color.c')
-rw-r--r--generic/Color.c182
1 files changed, 91 insertions, 91 deletions
diff --git a/generic/Color.c b/generic/Color.c
index 4cbaa6c..129d990 100644
--- a/generic/Color.c
+++ b/generic/Color.c
@@ -81,7 +81,7 @@ static StressedDpy *stressed_display_list = NULL;
#define COLOR_MAGIC ((unsigned int) 0x46140277)
-typedef struct TkColor {
+typedef struct ZnColorInfo {
XColor color; /* Information about this color. */
unsigned int magic; /* Used for quick integrity check on this
* structure. Must always have the
@@ -96,7 +96,7 @@ typedef struct TkColor {
* (needed when deleting structure). */
Tcl_HashEntry *hash; /* Pointer to hash table entry for this
* structure. (for use in deleting entry). */
-} TkColor;
+} ZnColorInfo;
/*
@@ -112,7 +112,7 @@ typedef struct TkColor {
*/
/*
- * Hash table for name -> TkColor mapping, and key structure used to
+ * Hash table for name -> ZnColorInfo mapping, and key structure used to
* index into that table:
*/
static Tcl_HashTable name_table;
@@ -126,7 +126,7 @@ typedef struct {
/*
- * Hash table for value -> TkColor mapping, and key structure used to
+ * Hash table for value -> ZnColorInfo mapping, and key structure used to
* index into that table:
*/
static Tcl_HashTable value_table;
@@ -149,7 +149,7 @@ typedef struct _ColorGradient {
* allocated. */
int ref_count;
Tcl_HashEntry *hash;
- RadarBool realized;
+ ZnBool realized;
int num_colors; /* Number of steps in the gradient. */
XColor *colors[1]; /* Colors of the gradient. */
} ColorGradient;
@@ -210,7 +210,7 @@ GetStressedDisplay(Display *dpy)
/*
* Not found, allocate a new one.
*/
- cur = (StressedDpy *) RadarMalloc(sizeof(StressedDpy));
+ cur = (StressedDpy *) ZnMalloc(sizeof(StressedDpy));
cur->dpy = dpy;
cur->stress = NULL;
cur->next = stressed_display_list;
@@ -261,8 +261,8 @@ DeleteStressedCmap(Display *display,
else {
prev->next = stress->next;
}
- RadarFree(stress->color);
- RadarFree(stress);
+ ZnFree(stress->color);
+ ZnFree(stress);
return;
}
}
@@ -312,18 +312,18 @@ FindClosestColor(Tk_Window tkwin, /* Window where color will
*/
for (stress = dpy->stress; ; stress = stress->next) {
if (stress == NULL) {
- stress = (StressedCmap *) RadarMalloc(sizeof(StressedCmap));
+ stress = (StressedCmap *) ZnMalloc(sizeof(StressedCmap));
stress->colormap = colormap;
template.visualid = XVisualIDFromVisual(Tk_Visual(tkwin));
vis_info = XGetVisualInfo(Tk_Display(tkwin), VisualIDMask,
&template, &num_found);
if (num_found < 1) {
- RadarWarning("FindClosestColor (Radar) couldn't lookup visual");
+ ZnWarning("FindClosestColor (Zinc) couldn't lookup visual");
abort();
}
stress->num_colors = vis_info->colormap_size;
XFree((char *) vis_info);
- stress->color = (XColor *) RadarMalloc((unsigned)
+ stress->color = (XColor *) ZnMalloc((unsigned)
(stress->num_colors*sizeof(XColor)));
for (i = 0; i < stress->num_colors; i++) {
stress->color[i].pixel = (unsigned long) i;
@@ -347,7 +347,7 @@ FindClosestColor(Tk_Window tkwin, /* Window where color will
*/
while (1) {
if (stress->num_colors == 0) {
- RadarWarning("FindClosestColor (Radar) ran out of colors");
+ ZnWarning("FindClosestColor (Zinc) ran out of colors");
abort();
}
closest_dist = 1e30;
@@ -403,7 +403,7 @@ FindClosestColor(Tk_Window tkwin, /* Window where color will
*----------------------------------------------------------------------
*/
#if 0
-static RadarBool
+static ZnBool
CmapStressed(Tk_Window tkwin,
Colormap colormap)
{
@@ -448,7 +448,7 @@ ColorInit()
/*
*----------------------------------------------------------------------
*
- * RadarGetColor --
+ * ZnGetColor --
*
* Given a string name for a color, map the name to a corresponding
* XColor structure.
@@ -463,16 +463,16 @@ ColorInit()
* Side effects:
* The color is added to an internal database with a reference count.
* For each call to this procedure, there should eventually be a call
- * to RadarFreeColor so that the database is cleaned up when colors
+ * to ZnFreeColor so that the database is cleaned up when colors
* aren't in use anymore.
*
*----------------------------------------------------------------------
*/
XColor *
-RadarGetColor(Tcl_Interp *interp,
- Tk_Window tkwin, /* Window in which color will be used. */
- Tk_Uid name) /* Name of color to allocated (in form
- * suitable for passing to XParseColor). */
+ZnGetColor(Tcl_Interp *interp,
+ Tk_Window tkwin, /* Window in which color will be used. */
+ Tk_Uid name) /* Name of color to allocated (in form
+ * suitable for passing to XParseColor). */
{
NameKey name_key;
Tcl_HashEntry *name_hash;
@@ -480,13 +480,13 @@ RadarGetColor(Tcl_Interp *interp,
Display *dpy = Tk_Display(tkwin);
Colormap colormap = Tk_Colormap(tkwin);
XColor color, screen;
- TkColor *tk_col;
+ ZnColorInfo *tk_col;
if (!initialized) {
ColorInit();
}
- /*printf("RadarGetColor color: %s\n", name);*/
+ /*printf("ZnGetColor color: %s\n", name);*/
/*
* First, check to see if there's already a mapping for this color
* name.
@@ -496,9 +496,9 @@ RadarGetColor(Tcl_Interp *interp,
name_key.display = Tk_Display(tkwin);
name_hash = Tcl_CreateHashEntry(&name_table, (char *) &name_key, &new);
if (!new) {
- tk_col = (TkColor *) Tcl_GetHashValue(name_hash);
+ tk_col = (ZnColorInfo *) Tcl_GetHashValue(name_hash);
tk_col->ref_count++;
- /*printf("RadarGetColor cache hit for: %d %d %d\n",
+ /*printf("ZnGetColor cache hit for: %d %d %d\n",
tk_col->color.red, tk_col->color.green, tk_col->color.blue);*/
return &tk_col->color;
}
@@ -510,7 +510,7 @@ RadarGetColor(Tcl_Interp *interp,
*/
if (*name != '#') {
if (XAllocNamedColor(dpy, colormap, name, &screen, &color) != 0) {
- /*printf("RadarGetColor XAllocNamedColor gives: %d %d %d\n",
+ /*printf("ZnGetColor XAllocNamedColor gives: %d %d %d\n",
color.red, color.green, color.blue);*/
DeleteStressedCmap(dpy, colormap);
}
@@ -549,11 +549,11 @@ RadarGetColor(Tcl_Interp *interp,
}
}
- tk_col = (TkColor *) RadarMalloc(sizeof(TkColor));
+ tk_col = (ZnColorInfo *) ZnMalloc(sizeof(ZnColorInfo));
tk_col->color = color;
/*
- * Now create a new TkColor structure and add it to nameTable.
+ * Now create a new ZnColorInfo structure and add it to nameTable.
*/
tk_col->magic = COLOR_MAGIC;
tk_col->screen = Tk_Screen(tkwin);
@@ -564,7 +564,7 @@ RadarGetColor(Tcl_Interp *interp,
tk_col->hash = name_hash;
Tcl_SetHashValue(name_hash, tk_col);
- /*printf("RadarGetColor created: %d %d %d\n",
+ /*printf("ZnGetColor created: %d %d %d\n",
tk_col->color.red, tk_col->color.green, tk_col->color.blue);*/
return &tk_col->color;
}
@@ -573,7 +573,7 @@ RadarGetColor(Tcl_Interp *interp,
/*
*----------------------------------------------------------------------
*
- * RadarGetColorByValue --
+ * ZnGetColorByValue --
*
* Given a desired set of red-green-blue intensities for a color,
* locate a pixel value to use to draw that color in a given
@@ -588,19 +588,19 @@ RadarGetColor(Tcl_Interp *interp,
* Side effects:
* The color is added to an internal database with a reference count.
* For each call to this procedure, there should eventually be a call
- * to RadarFreeColor, so that the database is cleaned up when colors
+ * to ZnFreeColor, so that the database is cleaned up when colors
* aren't in use anymore.
*
*----------------------------------------------------------------------
*/
XColor *
-RadarGetColorByValue(Tk_Window tkwin,
- XColor *color)
+ZnGetColorByValue(Tk_Window tkwin,
+ XColor *color)
{
ValueKey value_key;
Tcl_HashEntry *value_hash;
int new;
- TkColor *tk_col;
+ ZnColorInfo *tk_col;
Display *dpy = Tk_Display(tkwin);
Colormap colormap = Tk_Colormap(tkwin);
@@ -619,7 +619,7 @@ RadarGetColorByValue(Tk_Window tkwin,
value_key.display = Tk_Display(tkwin);
value_hash = Tcl_CreateHashEntry(&value_table, (char *) &value_key, &new);
if (!new) {
- tk_col = (TkColor *) Tcl_GetHashValue(value_hash);
+ tk_col = (ZnColorInfo *) Tcl_GetHashValue(value_hash);
tk_col->ref_count++;
return &tk_col->color;
}
@@ -628,7 +628,7 @@ RadarGetColorByValue(Tk_Window tkwin,
* The name isn't currently known. Find a pixel value
* to use to draw that color in a given window.
*/
- tk_col = (TkColor *) RadarMalloc(sizeof(TkColor));
+ tk_col = (ZnColorInfo *) ZnMalloc(sizeof(ZnColorInfo));
tk_col->color.red = color->red;
tk_col->color.green = color->green;
tk_col->color.blue = color->blue;
@@ -655,7 +655,7 @@ RadarGetColorByValue(Tk_Window tkwin,
/*
*--------------------------------------------------------------
*
- * RadarNameOfColor --
+ * ZnNameOfColor --
*
* Given a color, return a textual string identifying
* the color.
@@ -674,9 +674,9 @@ RadarGetColorByValue(Tk_Window tkwin,
*--------------------------------------------------------------
*/
char *
-RadarNameOfColor(XColor *color)
+ZnNameOfColor(XColor *color)
{
- register TkColor *tk_col = (TkColor *) color;
+ register ZnColorInfo *tk_col = (ZnColorInfo *) color;
static char string[20];
if ((tk_col->magic == COLOR_MAGIC) && (tk_col->table == &name_table)) {
@@ -690,10 +690,10 @@ RadarNameOfColor(XColor *color)
/*
*----------------------------------------------------------------------
*
- * RadarFreeColor --
+ * ZnFreeColor --
*
* This procedure is called to release a color allocated by
- * RadarGetColor or RadarGetColorByValue.
+ * ZnGetColor or ZnGetColorByValue.
*
* Results:
* None.
@@ -706,27 +706,27 @@ RadarNameOfColor(XColor *color)
*----------------------------------------------------------------------
*/
void
-RadarFreeColor(XColor *color) /* Color to be released. Must have been
- * allocated by RadarGetColor or
- * RadarGetColorByValue. */
+ZnFreeColor(XColor *color) /* Color to be released. Must have been
+ * allocated by ZnGetColor or
+ * ZnGetColorByValue. */
{
- TkColor *tk_col = (TkColor *) color;
+ ZnColorInfo *tk_col = (ZnColorInfo *) color;
Visual *visual;
Screen *screen = tk_col->screen;
Tk_ErrorHandler handler;
/*
* Do a quick sanity check to make sure this color was really
- * allocated by RadarGetColor.
+ * allocated by ZnGetColor.
*/
if (tk_col->magic != COLOR_MAGIC) {
- RadarWarning("RadarFreeColor called with bogus color");
+ ZnWarning("ZnFreeColor called with bogus color");
abort();
}
tk_col->ref_count--;
if (tk_col->ref_count == 0) {
- /*printf("RadarFreeColor freeing %s\n", RadarNameOfColor(color));*/
+ /*printf("ZnFreeColor freeing %s\n", ZnNameOfColor(color));*/
/*
* Careful! Don't free black or white, since this will
* make some servers very unhappy. Also, there is a bug in
@@ -752,7 +752,7 @@ RadarFreeColor(XColor *color) /* Color to be released. Must have been
Tcl_DeleteHashEntry(tk_col->hash);
tk_col->magic = 0;
- RadarFree(tk_col);
+ ZnFree(tk_col);
}
}
@@ -766,7 +766,7 @@ RadarFreeColor(XColor *color) /* Color to be released. Must have been
* a gradient. The first and last colors are always allocated
* during the gradient's creation. For 3D gradients the center
* color is also allocated.
- * It's called lazily by RadarColorGradientPixel, so that the
+ * It's called lazily by ZnColorGradientPixel, so that the
* colors aren't allocated until something is actually drawn
* with them.
*
@@ -805,7 +805,7 @@ RealizeColorGradient(ColorGradient *grad,
color.red = (int) base->red + red_range * i / (num_colors-2);
color.green = (int) base->green + green_range * i / (num_colors-2);
color.blue = (int) base->blue + blue_range * i / (num_colors-2);
- grad->colors[i] = RadarGetColorByValue(tkwin, &color);
+ grad->colors[i] = ZnGetColorByValue(tkwin, &color);
}
red_range = (int) base->red - (int) last->red;
green_range = (int) base->green - (int) last->green;
@@ -814,7 +814,7 @@ RealizeColorGradient(ColorGradient *grad,
color.red = (int) base->red + red_range * i / (num_colors-2);
color.green = (int) base->green + green_range * i / (num_colors-2);
color.blue = (int) base->blue + blue_range * i / (num_colors-2);
- grad->colors[i] = RadarGetColorByValue(tkwin, &color);
+ grad->colors[i] = ZnGetColorByValue(tkwin, &color);
}
}
else {
@@ -825,7 +825,7 @@ RealizeColorGradient(ColorGradient *grad,
color.red =(int) first->red + red_range * i / (num_colors-2);
color.green = (int) first->green + green_range * i / (num_colors-2);
color.blue = (int) first->blue + blue_range * i / (num_colors-2);
- grad->colors[i] = RadarGetColorByValue(tkwin, &color);
+ grad->colors[i] = ZnGetColorByValue(tkwin, &color);
}
}
}
@@ -834,12 +834,12 @@ RealizeColorGradient(ColorGradient *grad,
/*
*----------------------------------------------------------------------
*
- * RadarColorGradientSpan --
+ * ZnColorGradientSpan --
*
*----------------------------------------------------------------------
*/
int
-RadarColorGradientSpan(RadarColorGradient gradient)
+ZnColorGradientSpan(ZnColorGradient gradient)
{
return ((ColorGradient *) gradient)->num_colors;
}
@@ -848,14 +848,14 @@ RadarColorGradientSpan(RadarColorGradient gradient)
/*
*----------------------------------------------------------------------
*
- * RadarColorGradientPixel --
+ * ZnColorGradientPixel --
*
*----------------------------------------------------------------------
*/
int
-RadarColorGradientPixel(RadarColorGradient gradient,
- Tk_Window tkwin,
- int color_index)
+ZnColorGradientPixel(ZnColorGradient gradient,
+ Tk_Window tkwin,
+ int color_index)
{
ColorGradient *grad = (ColorGradient *) gradient;
@@ -868,14 +868,14 @@ RadarColorGradientPixel(RadarColorGradient gradient,
if (!grad->realized) {
RealizeColorGradient(grad, tkwin);
}
- return RadarPixel(grad->colors[color_index]);
+ return ZnPixel(grad->colors[color_index]);
}
/*
*--------------------------------------------------------------
*
- * RadarGetReliefGradient --
+ * ZnGetReliefGradient --
*
* Create a data structure containing a range of colors
* used to display a 3D border. Name contains the base
@@ -889,7 +889,7 @@ RadarColorGradientPixel(RadarColorGradient gradient,
* to the drawing routines. This function allocate
* the base color and the two end colors in an attempt
* to use only actually needed resources. The function
- * RadarColorGradientPixel asserts that all the colors
+ * ZnColorGradientPixel asserts that all the colors
* get allocated when needed.
* If an error prevented the gradient from being created
* then NULL is returned and an error message will be
@@ -898,14 +898,14 @@ RadarColorGradientPixel(RadarColorGradient gradient,
* Side effects:
* Data structures, etc. are allocated.
* It is the caller's responsibility to eventually call
- * RadarFreeColorGradient to release the resources.
+ * ZnFreeColorGradient to release the resources.
*
*--------------------------------------------------------------
*/
-RadarColorGradient
-RadarGetReliefGradient(Tcl_Interp *interp,
- Tk_Window tkwin,
- Tk_Uid name)
+ZnColorGradient
+ZnGetReliefGradient(Tcl_Interp *interp,
+ Tk_Window tkwin,
+ Tk_Uid name)
{
GradientKey key;
Tcl_HashEntry *hash;
@@ -934,14 +934,14 @@ RadarGetReliefGradient(Tcl_Interp *interp,
/*
* No satisfactory gradient exists yet. Initialize a new one.
*/
- base = RadarGetColor(interp, tkwin, name);
+ base = ZnGetColor(interp, tkwin, name);
if (base == NULL) {
Tcl_AppendResult(interp, " in border gradient", NULL);
Tcl_DeleteHashEntry(hash);
return NULL;
}
- grad = (ColorGradient *) RadarMalloc(sizeof(ColorGradient) +
+ grad = (ColorGradient *) ZnMalloc(sizeof(ColorGradient) +
sizeof(XColor *)*(BORDER_STEPS-1));
grad->screen = Tk_Screen(tkwin);
grad->visual = Tk_Visual(tkwin);
@@ -986,7 +986,7 @@ RadarGetReliefGradient(Tcl_Interp *interp,
tmp1 = (60 * (int) base->blue)/100;
tmp2 = (MAX_INTENSITY + (int) base->blue)/2;
color.blue = MIN(tmp1, tmp2);
- grad->colors[0] = RadarGetColorByValue(tkwin, &color);
+ grad->colors[0] = ZnGetColorByValue(tkwin, &color);
tmp1 = (14 * (int) base->red)/10;
if (tmp1 > MAX_INTENSITY) {
@@ -1006,7 +1006,7 @@ RadarGetReliefGradient(Tcl_Interp *interp,
}
tmp2 = (MAX_INTENSITY + (int) base->blue)/2;
color.blue = MAX(tmp1, tmp2);
- grad->colors[BORDER_STEPS-1] = RadarGetColorByValue(tkwin, &color);
+ grad->colors[BORDER_STEPS-1] = ZnGetColorByValue(tkwin, &color);
/*
* Now init the in between colors to let RealizeColorGradient know
@@ -1025,14 +1025,14 @@ RadarGetReliefGradient(Tcl_Interp *interp,
* Delay the allocation of colors until they are actually
* needed for drawing.
*/
- return (RadarColorGradient) grad;
+ return (ZnColorGradient) grad;
}
/*
*--------------------------------------------------------------
*
- * RadarGetColorGradient --
+ * ZnGetColorGradient --
*
* Create a data structure containing a range of colors
* used to display a gradient. Name contains the gradient
@@ -1045,7 +1045,7 @@ RadarGetReliefGradient(Tcl_Interp *interp,
* to the drawing routines. This function allocate
* the two end colors in an attempt to use only
* actually needed resources. The function
- * RadarColorGradientPixel asserts that all the colors
+ * ZnColorGradientPixel asserts that all the colors
* get allocated when needed.
* If an error prevented the gradient from being created
* then NULL is returned and an error message will be
@@ -1054,12 +1054,12 @@ RadarGetReliefGradient(Tcl_Interp *interp,
* Side effects:
* Data structures, etc. are allocated.
* It is the caller's responsibility to eventually call
- * RadarFreeColorGradient to release the resources.
+ * ZnFreeColorGradient to release the resources.
*
*--------------------------------------------------------------
*/
-RadarColorGradient
-RadarGetColorGradientByValue(RadarColorGradient gradient)
+ZnColorGradient
+ZnGetColorGradientByValue(ZnColorGradient gradient)
{
ColorGradient *grad;
@@ -1069,10 +1069,10 @@ RadarGetColorGradientByValue(RadarColorGradient gradient)
}
-RadarColorGradient
-RadarGetColorGradient(Tcl_Interp *interp,
- Tk_Window tkwin,
- Tk_Uid name)
+ZnColorGradient
+ZnGetColorGradient(Tcl_Interp *interp,
+ Tk_Window tkwin,
+ Tk_Uid name)
{
GradientKey key;
Tcl_HashEntry *hash;
@@ -1110,19 +1110,19 @@ RadarGetColorGradient(Tcl_Interp *interp,
Tcl_DeleteHashEntry(hash);
return NULL;
}
- first = RadarGetColor(interp, tkwin, name_first);
+ first = ZnGetColor(interp, tkwin, name_first);
if (first == NULL) {
grad_err2:
Tcl_AppendResult(interp, " in gradient", NULL);
goto grad_err;
}
- last = RadarGetColor(interp, tkwin, name_last);
+ last = ZnGetColor(interp, tkwin, name_last);
if (last == NULL) {
- RadarFreeColor(first);
+ ZnFreeColor(first);
goto grad_err2;
}
- grad = (ColorGradient *) RadarMalloc(sizeof(ColorGradient) +
+ grad = (ColorGradient *) ZnMalloc(sizeof(ColorGradient) +
sizeof(XColor *)*(steps-1));
grad->screen = Tk_Screen(tkwin);
grad->visual = Tk_Visual(tkwin);
@@ -1144,18 +1144,18 @@ RadarGetColorGradient(Tcl_Interp *interp,
* Delay the allocation of colors until they are actually
* needed for drawing.
*/
- return (RadarColorGradient) grad;
+ return (ZnColorGradient) grad;
}
/*
*--------------------------------------------------------------
*
- * RadarNameOfColorGradient --
+ * ZnNameOfColorGradient --
*
* Given a gradient, return a textual string identifying
* the gradient. This can be either a single color (for
- * gradients allocated by RadarGetReliefGradient) or a
+ * gradients allocated by ZnGetReliefGradient) or a
* full gradient spec: color1:color2:steps.
*
* Results:
@@ -1168,7 +1168,7 @@ RadarGetColorGradient(Tcl_Interp *interp,
*--------------------------------------------------------------
*/
char *
-RadarNameOfColorGradient(RadarColorGradient gradient)
+ZnNameOfColorGradient(ZnColorGradient gradient)
{
ColorGradient *grad = (ColorGradient *) gradient;
@@ -1179,7 +1179,7 @@ RadarNameOfColorGradient(RadarColorGradient gradient)
/*
*--------------------------------------------------------------
*
- * RadarFreeColorGradient --
+ * ZnFreeColorGradient --
*
* This procedure is called when a gradient is no longer
* needed. It frees the resources associated with the
@@ -1195,7 +1195,7 @@ RadarNameOfColorGradient(RadarColorGradient gradient)
*--------------------------------------------------------------
*/
void
-RadarFreeColorGradient(RadarColorGradient gradient)
+ZnFreeColorGradient(ZnColorGradient gradient)
{
ColorGradient *grad = (ColorGradient *) gradient;
int i;
@@ -1204,10 +1204,10 @@ RadarFreeColorGradient(RadarColorGradient gradient)
if (grad->ref_count == 0) {
for (i = 0; i < grad->num_colors; i++) {
if (grad->colors[i] != NULL) {
- RadarFreeColor(grad->colors[i]);
+ ZnFreeColor(grad->colors[i]);
}
}
Tcl_DeleteHashEntry(grad->hash);
- RadarFree(grad);
+ ZnFree(grad);
}
}