summaryrefslogtreecommitdiffstats
path: root/generic/tkGC.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkGC.c')
-rw-r--r--generic/tkGC.c148
1 files changed, 78 insertions, 70 deletions
diff --git a/generic/tkGC.c b/generic/tkGC.c
index 46a3a56..800e4d3 100644
--- a/generic/tkGC.c
+++ b/generic/tkGC.c
@@ -1,24 +1,23 @@
-/*
+/*
* tkGC.c --
*
- * This file maintains a database of read-only graphics contexts
- * for the Tk toolkit, in order to allow GC's to be shared.
+ * This file maintains a database of read-only graphics contexts for the
+ * Tk toolkit, in order to allow GC's to be shared.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "tkPort.h"
#include "tkInt.h"
/*
- * One of the following data structures exists for each GC that is
- * currently active. The structure is indexed with two hash tables,
- * one based on the values in the graphics context and the other
- * based on the display and GC identifier.
+ * One of the following data structures exists for each GC that is currently
+ * active. The structure is indexed with two hash tables, one based on the
+ * values in the graphics context and the other based on the display and GC
+ * identifier.
*/
typedef struct {
@@ -37,48 +36,48 @@ typedef struct {
} ValueKey;
/*
- * Forward declarations for procedures defined in this file:
+ * Forward declarations for functions defined in this file:
*/
-static void GCInit _ANSI_ARGS_((TkDisplay *dispPtr));
+static void GCInit(TkDisplay *dispPtr);
/*
*----------------------------------------------------------------------
*
* Tk_GetGC --
*
- * Given a desired set of values for a graphics context, find
- * a read-only graphics context with the desired values.
+ * Given a desired set of values for a graphics context, find a read-only
+ * graphics context with the desired values.
*
* Results:
- * The return value is the X identifer for the desired graphics
- * context. The caller should never modify this GC, and should
- * call Tk_FreeGC when the GC is no longer needed.
+ * The return value is the X identifer for the desired graphics context.
+ * The caller should never modify this GC, and should call Tk_FreeGC when
+ * the GC is no longer needed.
*
* Side effects:
- * The GC is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeGC, so that the database can be cleaned up when GC's
- * aren't needed anymore.
+ * The GC is added to an internal database with a reference count. For
+ * each call to this function, there should eventually be a call to
+ * Tk_FreeGC, so that the database can be cleaned up when GC's aren't
+ * needed anymore.
*
*----------------------------------------------------------------------
*/
GC
-Tk_GetGC(tkwin, valueMask, valuePtr)
- Tk_Window tkwin; /* Window in which GC will be used. */
- register unsigned long valueMask;
- /* 1 bits correspond to values specified
- * in *valuesPtr; other values are set
- * from defaults. */
- register XGCValues *valuePtr;
- /* Values are specified here for bits set
- * in valueMask. */
+Tk_GetGC(
+ Tk_Window tkwin, /* Window in which GC will be used. */
+ register unsigned long valueMask,
+ /* 1 bits correspond to values specified in
+ * *valuesPtr; other values are set from
+ * defaults. */
+ register XGCValues *valuePtr)
+ /* Values are specified here for bits set in
+ * valueMask. */
{
ValueKey valueKey;
Tcl_HashEntry *valueHashPtr, *idHashPtr;
register TkGC *gcPtr;
- int new;
+ int isNew;
Drawable d, freeDrawable;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -87,15 +86,15 @@ Tk_GetGC(tkwin, valueMask, valuePtr)
}
/*
- * Must zero valueKey at start to clear out pad bytes that may be
- * part of structure on some systems.
+ * Must zero valueKey at start to clear out pad bytes that may be part of
+ * structure on some systems.
*/
- memset((VOID *) &valueKey, 0, sizeof(valueKey));
+ memset(&valueKey, 0, sizeof(valueKey));
/*
- * First, check to see if there's already a GC that will work
- * for this request (exact matches only, sorry).
+ * First, check to see if there's already a GC that will work for this
+ * request (exact matches only, sorry).
*/
if (valueMask & GCFunction) {
@@ -216,24 +215,24 @@ Tk_GetGC(tkwin, valueMask, valuePtr)
valueKey.display = Tk_Display(tkwin);
valueKey.screenNum = Tk_ScreenNumber(tkwin);
valueKey.depth = Tk_Depth(tkwin);
- valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable,
- (char *) &valueKey, &new);
- if (!new) {
+ valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable,
+ (char *) &valueKey, &isNew);
+ if (!isNew) {
gcPtr = (TkGC *) Tcl_GetHashValue(valueHashPtr);
gcPtr->refCount++;
return gcPtr->gc;
}
/*
- * No GC is currently available for this set of values. Allocate a
- * new GC and add a new structure to the database.
+ * No GC is currently available for this set of values. Allocate a new GC
+ * and add a new structure to the database.
*/
gcPtr = (TkGC *) ckalloc(sizeof(TkGC));
/*
- * Find or make a drawable to use to specify the screen and depth
- * of the GC. We may have to make a small pixmap, to avoid doing
+ * Find or make a drawable to use to specify the screen and depth of the
+ * GC. We may have to make a small pixmap, to avoid doing
* Tk_MakeWindowExist on the window.
*/
@@ -254,10 +253,10 @@ Tk_GetGC(tkwin, valueMask, valuePtr)
gcPtr->display = valueKey.display;
gcPtr->refCount = 1;
gcPtr->valueHashPtr = valueHashPtr;
- idHashPtr = Tcl_CreateHashEntry(&dispPtr->gcIdTable,
- (char *) gcPtr->gc, &new);
- if (!new) {
- panic("GC already registered in Tk_GetGC");
+ idHashPtr = Tcl_CreateHashEntry(&dispPtr->gcIdTable,
+ (char *) gcPtr->gc, &isNew);
+ if (!isNew) {
+ Tcl_Panic("GC already registered in Tk_GetGC");
}
Tcl_SetHashValue(valueHashPtr, gcPtr);
Tcl_SetHashValue(idHashPtr, gcPtr);
@@ -273,43 +272,44 @@ Tk_GetGC(tkwin, valueMask, valuePtr)
*
* Tk_FreeGC --
*
- * This procedure is called to release a graphics context allocated by
+ * This function is called to release a graphics context allocated by
* Tk_GetGC.
*
* Results:
* None.
*
* Side effects:
- * The reference count associated with gc is decremented, and
- * gc is officially deallocated if no-one is using it anymore.
+ * The reference count associated with gc is decremented, and gc is
+ * officially deallocated if no-one is using it anymore.
*
*----------------------------------------------------------------------
*/
void
-Tk_FreeGC(display, gc)
- Display *display; /* Display for which gc was allocated. */
- GC gc; /* Graphics context to be released. */
+Tk_FreeGC(
+ Display *display, /* Display for which gc was allocated. */
+ GC gc) /* Graphics context to be released. */
{
Tcl_HashEntry *idHashPtr;
register TkGC *gcPtr;
TkDisplay *dispPtr = TkGetDisplay(display);
if (!dispPtr->gcInit) {
- panic("Tk_FreeGC called before Tk_GetGC");
+ Tcl_Panic("Tk_FreeGC called before Tk_GetGC");
}
if (dispPtr->gcInit < 0) {
/*
- * The GCCleanup has been called, and remaining GCs have been
- * freed. This may still get called by other things shutting
- * down, but the GCs should no longer be in use.
+ * The GCCleanup has been called, and remaining GCs have been freed.
+ * This may still get called by other things shutting down, but the
+ * GCs should no longer be in use.
*/
+
return;
}
idHashPtr = Tcl_FindHashEntry(&dispPtr->gcIdTable, (char *) gc);
if (idHashPtr == NULL) {
- panic("Tk_FreeGC received unknown gc argument");
+ Tcl_Panic("Tk_FreeGC received unknown gc argument");
}
gcPtr = (TkGC *) Tcl_GetHashValue(idHashPtr);
gcPtr->refCount--;
@@ -327,9 +327,8 @@ Tk_FreeGC(display, gc)
*
* TkGCCleanup --
*
- * Frees the structures used for GC management.
- * We need to have it called near the end, when other cleanup that
- * calls Tk_FreeGC is all done.
+ * Frees the structures used for GC management. We need to have it called
+ * near the end, when other cleanup that calls Tk_FreeGC is all done.
*
* Results:
* None.
@@ -341,22 +340,23 @@ Tk_FreeGC(display, gc)
*/
void
-TkGCCleanup(dispPtr)
- TkDisplay *dispPtr; /* display to clean up resources in */
+TkGCCleanup(
+ TkDisplay *dispPtr) /* display to clean up resources in */
{
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
TkGC *gcPtr;
for (entryPtr = Tcl_FirstHashEntry(&dispPtr->gcIdTable, &search);
- entryPtr != NULL;
- entryPtr = Tcl_NextHashEntry(&search)) {
+ entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) {
gcPtr = (TkGC *) Tcl_GetHashValue(entryPtr);
+
/*
- * This call is not needed, as it is only used on Unix to restore
- * the Id to the stack pool, and we don't want to use them anymore.
+ * This call is not needed, as it is only used on Unix to restore the
+ * Id to the stack pool, and we don't want to use them anymore.
* Tk_FreeXId(gcPtr->display, (XID) XGContextFromGC(gcPtr->gc));
*/
+
XFreeGC(gcPtr->display, gcPtr->gc);
Tcl_DeleteHashEntry(gcPtr->valueHashPtr);
Tcl_DeleteHashEntry(entryPtr);
@@ -384,13 +384,21 @@ TkGCCleanup(dispPtr)
*/
static void
-GCInit(dispPtr)
- TkDisplay *dispPtr;
+GCInit(
+ TkDisplay *dispPtr)
{
if (dispPtr->gcInit < 0) {
- panic("called GCInit after GCCleanup");
+ Tcl_Panic("called GCInit after GCCleanup");
}
dispPtr->gcInit = 1;
Tcl_InitHashTable(&dispPtr->gcValueTable, sizeof(ValueKey)/sizeof(int));
Tcl_InitHashTable(&dispPtr->gcIdTable, TCL_ONE_WORD_KEYS);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */