summaryrefslogtreecommitdiffstats
path: root/generic/tkColor.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkColor.c')
-rw-r--r--[-rwxr-xr-x]generic/tkColor.c126
1 files changed, 62 insertions, 64 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c
index 848e9ab..76d0baa 100755..100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -40,11 +40,10 @@ static Tcl_ThreadDataKey dataKey;
* Forward declarations for functions defined in this file:
*/
-static void ColorInit _ANSI_ARGS_((TkDisplay *dispPtr));
-static void DupColorObjProc _ANSI_ARGS_((Tcl_Obj *srcObjPtr,
- Tcl_Obj *dupObjPtr));
-static void FreeColorObjProc _ANSI_ARGS_((Tcl_Obj *objPtr));
-static void InitColorObj _ANSI_ARGS_((Tcl_Obj *objPtr));
+static void ColorInit(TkDisplay *dispPtr);
+static void DupColorObjProc(Tcl_Obj *srcObjPtr,Tcl_Obj *dupObjPtr);
+static void FreeColorObjProc(Tcl_Obj *objPtr);
+static void InitColorObj(Tcl_Obj *objPtr);
/*
* The following structure defines the implementation of the "color" Tcl
@@ -85,11 +84,11 @@ Tcl_ObjType tkColorObjType = {
*/
XColor *
-Tk_AllocColorFromObj(interp, tkwin, objPtr)
- Tcl_Interp *interp; /* Used only for error reporting. If NULL,
+Tk_AllocColorFromObj(
+ Tcl_Interp *interp, /* Used only for error reporting. If NULL,
* then no messages are provided. */
- Tk_Window tkwin; /* Window in which the color will be used.*/
- Tcl_Obj *objPtr; /* Object that describes the color; string
+ Tk_Window tkwin, /* Window in which the color will be used.*/
+ Tcl_Obj *objPtr) /* Object that describes the color; string
* value is a color name such as "red" or
* "#ff0000".*/
{
@@ -128,8 +127,8 @@ Tk_AllocColorFromObj(interp, tkwin, objPtr)
*/
if (tkColPtr != NULL) {
- TkColor *firstColorPtr =
- (TkColor *) Tcl_GetHashValue(tkColPtr->hashPtr);
+ TkColor *firstColorPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
+
FreeColorObjProc(objPtr);
for (tkColPtr = firstColorPtr; tkColPtr != NULL;
tkColPtr = tkColPtr->nextPtr) {
@@ -137,7 +136,7 @@ Tk_AllocColorFromObj(interp, tkwin, objPtr)
&& (Tk_Colormap(tkwin) == tkColPtr->colormap)) {
tkColPtr->resourceRefCount++;
tkColPtr->objRefCount++;
- objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) tkColPtr;
+ objPtr->internalRep.twoPtrValue.ptr1 = (void *) tkColPtr;
return (XColor *) tkColPtr;
}
}
@@ -148,7 +147,7 @@ Tk_AllocColorFromObj(interp, tkwin, objPtr)
*/
tkColPtr = (TkColor *) Tk_GetColor(interp, tkwin, Tcl_GetString(objPtr));
- objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) tkColPtr;
+ objPtr->internalRep.twoPtrValue.ptr1 = (void *) tkColPtr;
if (tkColPtr != NULL) {
tkColPtr->objRefCount++;
}
@@ -180,11 +179,11 @@ Tk_AllocColorFromObj(interp, tkwin, objPtr)
*/
XColor *
-Tk_GetColor(interp, tkwin, name)
- Tcl_Interp *interp; /* Place to leave error message if color can't
+Tk_GetColor(
+ Tcl_Interp *interp, /* Place to leave error message if color can't
* be found. */
- Tk_Window tkwin; /* Window in which color will be used. */
- Tk_Uid name; /* Name of color to be allocated (in form
+ Tk_Window tkwin, /* Window in which color will be used. */
+ Tk_Uid name) /* Name of color to be allocated (in form
* suitable for passing to XParseColor). */
{
Tcl_HashEntry *nameHashPtr;
@@ -203,7 +202,7 @@ Tk_GetColor(interp, tkwin, name)
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->colorNameTable, name, &isNew);
if (!isNew) {
- existingColPtr = (TkColor *) Tcl_GetHashValue(nameHashPtr);
+ existingColPtr = Tcl_GetHashValue(nameHashPtr);
for (tkColPtr = existingColPtr; tkColPtr != NULL;
tkColPtr = tkColPtr->nextPtr) {
if ((tkColPtr->screen == Tk_Screen(tkwin))
@@ -234,7 +233,7 @@ Tk_GetColor(interp, tkwin, name)
if (isNew) {
Tcl_DeleteHashEntry(nameHashPtr);
}
- return (XColor *) NULL;
+ return NULL;
}
/*
@@ -281,9 +280,9 @@ Tk_GetColor(interp, tkwin, name)
*/
XColor *
-Tk_GetColorByValue(tkwin, colorPtr)
- Tk_Window tkwin; /* Window where color will be used. */
- XColor *colorPtr; /* Red, green, and blue fields indicate
+Tk_GetColorByValue(
+ Tk_Window tkwin, /* Window where color will be used. */
+ XColor *colorPtr) /* Red, green, and blue fields indicate
* desired color. */
{
ValueKey valueKey;
@@ -312,7 +311,7 @@ Tk_GetColorByValue(tkwin, colorPtr)
valueHashPtr = Tcl_CreateHashEntry(&dispPtr->colorValueTable,
(char *) &valueKey, &isNew);
if (!isNew) {
- tkColPtr = (TkColor *) Tcl_GetHashValue(valueHashPtr);
+ tkColPtr = Tcl_GetHashValue(valueHashPtr);
tkColPtr->resourceRefCount++;
return &tkColPtr->color;
}
@@ -358,13 +357,12 @@ Tk_GetColorByValue(tkwin, colorPtr)
*/
CONST char *
-Tk_NameOfColor(colorPtr)
- XColor *colorPtr; /* Color whose name is desired. */
+Tk_NameOfColor(
+ XColor *colorPtr) /* Color whose name is desired. */
{
register TkColor *tkColPtr = (TkColor *) colorPtr;
- if ((tkColPtr->magic == COLOR_MAGIC) &&
- (tkColPtr->type == TK_COLOR_BY_NAME)) {
+ if (tkColPtr->magic==COLOR_MAGIC && tkColPtr->type==TK_COLOR_BY_NAME) {
return tkColPtr->hashPtr->key.string;
} else {
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -397,10 +395,10 @@ Tk_NameOfColor(colorPtr)
*/
GC
-Tk_GCForColor(colorPtr, drawable)
- XColor *colorPtr; /* Color for which a GC is desired. Must have
+Tk_GCForColor(
+ XColor *colorPtr, /* Color for which a GC is desired. Must have
* been allocated by Tk_GetColor. */
- Drawable drawable; /* Drawable in which the color will be used
+ Drawable drawable) /* Drawable in which the color will be used
* (must have same screen and depth as the one
* for which the color was allocated). */
{
@@ -442,8 +440,8 @@ Tk_GCForColor(colorPtr, drawable)
*/
void
-Tk_FreeColor(colorPtr)
- XColor *colorPtr; /* Color to be released. Must have been
+Tk_FreeColor(
+ XColor *colorPtr) /* Color to be released. Must have been
* allocated by Tk_GetColor or
* Tk_GetColorByValue. */
{
@@ -477,7 +475,7 @@ Tk_FreeColor(colorPtr)
}
TkpFreeColor(tkColPtr);
- prevPtr = (TkColor *) Tcl_GetHashValue(tkColPtr->hashPtr);
+ prevPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
if (prevPtr == tkColPtr) {
if (tkColPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(tkColPtr->hashPtr);
@@ -524,10 +522,10 @@ Tk_FreeColor(colorPtr)
*/
void
-Tk_FreeColorFromObj(tkwin, objPtr)
- Tk_Window tkwin; /* The window this color lives in. Needed
- * for the screen and colormap values. */
- Tcl_Obj *objPtr; /* The Tcl_Obj * to be freed. */
+Tk_FreeColorFromObj(
+ Tk_Window tkwin, /* The window this color lives in. Needed for
+ * the screen and colormap values. */
+ Tcl_Obj *objPtr) /* The Tcl_Obj * to be freed. */
{
Tk_FreeColor(Tk_GetColorFromObj(tkwin, objPtr));
FreeColorObjProc(objPtr);
@@ -553,8 +551,8 @@ Tk_FreeColorFromObj(tkwin, objPtr)
*/
static void
-FreeColorObjProc(objPtr)
- Tcl_Obj *objPtr; /* The object we are releasing. */
+FreeColorObjProc(
+ Tcl_Obj *objPtr) /* The object we are releasing. */
{
TkColor *tkColPtr = (TkColor *) objPtr->internalRep.twoPtrValue.ptr1;
@@ -564,7 +562,7 @@ FreeColorObjProc(objPtr)
&& (tkColPtr->resourceRefCount == 0)) {
ckfree((char *) tkColPtr);
}
- objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) NULL;
+ objPtr->internalRep.twoPtrValue.ptr1 = NULL;
}
}
@@ -587,14 +585,14 @@ FreeColorObjProc(objPtr)
*/
static void
-DupColorObjProc(srcObjPtr, dupObjPtr)
- Tcl_Obj *srcObjPtr; /* The object we are copying from. */
- Tcl_Obj *dupObjPtr; /* The object we are copying to. */
+DupColorObjProc(
+ Tcl_Obj *srcObjPtr, /* The object we are copying from. */
+ Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
TkColor *tkColPtr = (TkColor *) srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
- dupObjPtr->internalRep.twoPtrValue.ptr1 = (VOID *) tkColPtr;
+ dupObjPtr->internalRep.twoPtrValue.ptr1 = (void *) tkColPtr;
if (tkColPtr != NULL) {
tkColPtr->objRefCount++;
@@ -621,10 +619,10 @@ DupColorObjProc(srcObjPtr, dupObjPtr)
*/
XColor *
-Tk_GetColorFromObj(tkwin, objPtr)
- Tk_Window tkwin; /* The window in which the color will be
+Tk_GetColorFromObj(
+ Tk_Window tkwin, /* The window in which the color will be
* used. */
- Tcl_Obj *objPtr; /* String value contains the name of the
+ Tcl_Obj *objPtr) /* String value contains the name of the
* desired color. */
{
TkColor *tkColPtr;
@@ -667,12 +665,12 @@ Tk_GetColorFromObj(tkwin, objPtr)
if (hashPtr == NULL) {
goto error;
}
- for (tkColPtr = (TkColor *) Tcl_GetHashValue(hashPtr);
+ for (tkColPtr = Tcl_GetHashValue(hashPtr);
(tkColPtr != NULL); tkColPtr = tkColPtr->nextPtr) {
if ((Tk_Screen(tkwin) == tkColPtr->screen)
&& (Tk_Colormap(tkwin) == tkColPtr->colormap)) {
FreeColorObjProc(objPtr);
- objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) tkColPtr;
+ objPtr->internalRep.twoPtrValue.ptr1 = (void *) tkColPtr;
tkColPtr->objRefCount++;
return (XColor *) tkColPtr;
}
@@ -705,10 +703,10 @@ Tk_GetColorFromObj(tkwin, objPtr)
*/
static void
-InitColorObj(objPtr)
- Tcl_Obj *objPtr; /* The object to convert. */
+InitColorObj(
+ Tcl_Obj *objPtr) /* The object to convert. */
{
- Tcl_ObjType *typePtr;
+ const Tcl_ObjType *typePtr;
/*
* Free the old internalRep before setting the new one.
@@ -720,7 +718,7 @@ InitColorObj(objPtr)
(*typePtr->freeIntRepProc)(objPtr);
}
objPtr->typePtr = &tkColorObjType;
- objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) NULL;
+ objPtr->internalRep.twoPtrValue.ptr1 = NULL;
}
/*
@@ -740,8 +738,8 @@ InitColorObj(objPtr)
*/
static void
-ColorInit(dispPtr)
- TkDisplay *dispPtr;
+ColorInit(
+ TkDisplay *dispPtr)
{
if (!dispPtr->colorInit) {
dispPtr->colorInit = 1;
@@ -771,10 +769,10 @@ ColorInit(dispPtr)
*/
Tcl_Obj *
-TkDebugColor(tkwin, name)
- Tk_Window tkwin; /* The window in which the color will be used
+TkDebugColor(
+ Tk_Window tkwin, /* The window in which the color will be used
* (not currently used). */
- char *name; /* Name of the desired color. */
+ char *name) /* Name of the desired color. */
{
Tcl_HashEntry *hashPtr;
Tcl_Obj *resultPtr;
@@ -783,7 +781,7 @@ TkDebugColor(tkwin, name)
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, name);
if (hashPtr != NULL) {
- TkColor *tkColPtr = (TkColor *) Tcl_GetHashValue(hashPtr);
+ TkColor *tkColPtr = Tcl_GetHashValue(hashPtr);
if (tkColPtr == NULL) {
Tcl_Panic("TkDebugColor found empty hash table entry");
@@ -832,11 +830,11 @@ CONST char *CONST tkWebColors[20] = {
};
Status
-TkParseColor(display, map, name, color)
- Display * display; /* The display */
- Colormap map; /* Color map */
- CONST char* name; /* String to be parsed */
- XColor * color;
+TkParseColor(
+ Display *display, /* The display */
+ Colormap map, /* Color map */
+ const char *name, /* String to be parsed */
+ XColor *color)
{
char buf[14];
if (*name == '#') {