diff options
author | donal.k.fellows@manchester.ac.uk <dkf> | 2007-06-24 16:09:25 (GMT) |
---|---|---|
committer | donal.k.fellows@manchester.ac.uk <dkf> | 2007-06-24 16:09:25 (GMT) |
commit | ed8ffa9c7fc7e0d856f4110e06392c48e9e84c18 (patch) | |
tree | e52ad058dd90412f8bccbf87afd192b1344a085f /generic | |
parent | f3a660b2937480d214eabf32ee7ec8a7f9e15bc4 (diff) | |
download | tk-ed8ffa9c7fc7e0d856f4110e06392c48e9e84c18.zip tk-ed8ffa9c7fc7e0d856f4110e06392c48e9e84c18.tar.gz tk-ed8ffa9c7fc7e0d856f4110e06392c48e9e84c18.tar.bz2 |
Cleaning up whitespace, comments, declarations. No functional changes.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkBitmap.c | 143 | ||||
-rw-r--r-- | generic/tkCanvas.h | 14 |
2 files changed, 77 insertions, 80 deletions
diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index 60fce0f..ad4f36f 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkBitmap.c,v 1.16 2007/01/03 04:10:55 nijtmans Exp $ + * RCS: @(#) $Id: tkBitmap.c,v 1.17 2007/06/24 16:17:13 dkf Exp $ */ #include "tkPort.h" @@ -57,7 +57,7 @@ typedef struct TkBitmap { * it isn't currently in use. */ int width, height; /* Dimensions of bitmap. */ Display *display; /* Display for which bitmap is valid. */ - int screenNum; /* Screen on which bitmap is valid */ + int screenNum; /* Screen on which bitmap is valid. */ int resourceRefCount; /* Number of active uses of this bitmap (each * active use corresponds to a call to * Tk_AllocBitmapFromObj or Tk_GetBitmap). If @@ -87,14 +87,14 @@ typedef struct TkBitmap { */ typedef struct { - CONST char *source; /* Bitmap bits. */ + const char *source; /* Bitmap bits. */ int width, height; /* Dimensions of bitmap. */ } DataKey; typedef struct ThreadSpecificData { - int initialized; /* 0 means table below needs initializing. */ + int initialized; /* 0 means table below needs initializing. */ Tcl_HashTable predefBitmapTable; - /* Hash table created by Tk_DefineBitmap to + /* Hash table created by Tk_DefineBitmap to * map from a name to a collection of in-core * data about a bitmap. The table is indexed * by the address of the data for the bitmap, @@ -112,8 +112,8 @@ static void DupBitmapObjProc(Tcl_Obj *srcObjPtr, Tcl_Obj *dupObjPtr); static void FreeBitmap(TkBitmap *bitmapPtr); static void FreeBitmapObjProc(Tcl_Obj *objPtr); -static TkBitmap * GetBitmap(Tcl_Interp *interp, - Tk_Window tkwin, CONST char *name); +static TkBitmap * GetBitmap(Tcl_Interp *interp, Tk_Window tkwin, + const char *name); static TkBitmap * GetBitmapFromObj(Tk_Window tkwin, Tcl_Obj *objPtr); static void InitBitmapObj(Tcl_Obj *objPtr); @@ -257,10 +257,11 @@ Tk_GetBitmap( Tcl_Interp *interp, /* Interpreter to use for error reporting, * this may be NULL. */ Tk_Window tkwin, /* Window in which bitmap will be used. */ - CONST char *string) /* Description of bitmap. See manual entry for + const char *string) /* Description of bitmap. See manual entry for * details on legal syntax. */ { TkBitmap *bitmapPtr = GetBitmap(interp, tkwin, string); + if (bitmapPtr == NULL) { return None; } @@ -299,19 +300,17 @@ GetBitmap( Tcl_Interp *interp, /* Interpreter to use for error reporting, * this may be NULL. */ Tk_Window tkwin, /* Window in which bitmap will be used. */ - CONST char *string) /* Description of bitmap. See manual entry for + const char *string) /* Description of bitmap. See manual entry for * details on legal syntax. */ { Tcl_HashEntry *nameHashPtr, *predefHashPtr; TkBitmap *bitmapPtr, *existingBitmapPtr; TkPredefBitmap *predefPtr; - int isNew; Pixmap bitmap; - int width, height; - int dummy2; + int isNew, width, height, dummy2; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!dispPtr->bitmapInit) { BitmapInit(dispPtr); @@ -344,15 +343,15 @@ GetBitmap( Tcl_DString buffer; int result; - if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't specify bitmap with '@' in a", - " safe interpreter", NULL); - goto error; - } + if (Tcl_IsSafe(interp)) { + Tcl_AppendResult(interp, "can't specify bitmap with '@' in a", + " safe interpreter", NULL); + goto error; + } /* - * Note that we need to cast away the CONST from the string because - * Tcl_TranslateFileName is non const, even though it doesn't modify + * Note that we need to cast away the const from the string because + * Tcl_TranslateFileName is non-const, even though it doesn't modify * the string. */ @@ -424,7 +423,7 @@ GetBitmap( bitmapPtr->objRefCount = 0; bitmapPtr->nameHashPtr = nameHashPtr; bitmapPtr->idHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapIdTable, - (char *) bitmap, &isNew); + (char *) bitmap, &isNew); if (!isNew) { Tcl_Panic("bitmap already registered in Tk_GetBitmap"); } @@ -463,9 +462,9 @@ GetBitmap( int Tk_DefineBitmap( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - CONST char *name, /* Name to use for bitmap. Must not already be + const char *name, /* Name to use for bitmap. Must not already be * defined as a bitmap. */ - CONST char *source, /* Address of bits for bitmap. */ + const char *source, /* Address of bits for bitmap. */ int width, /* Width of bitmap. */ int height) /* Height of bitmap. */ { @@ -473,7 +472,7 @@ Tk_DefineBitmap( Tcl_HashEntry *predefHashPtr; TkPredefBitmap *predefPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Initialize the Bitmap module if not initialized already for this @@ -488,10 +487,10 @@ Tk_DefineBitmap( } predefHashPtr = Tcl_CreateHashEntry(&tsdPtr->predefBitmapTable, - name, &isNew); + name, &isNew); if (!isNew) { - Tcl_AppendResult(interp, "bitmap \"", name, - "\" is already defined", NULL); + Tcl_AppendResult(interp, "bitmap \"", name, "\" is already defined", + NULL); return TCL_ERROR; } predefPtr = (TkPredefBitmap *) ckalloc(sizeof(TkPredefBitmap)); @@ -519,7 +518,7 @@ Tk_DefineBitmap( *-------------------------------------------------------------- */ -CONST char * +const char * Tk_NameOfBitmap( Display *display, /* Display for which bitmap was allocated. */ Pixmap bitmap) /* Bitmap whose name is wanted. */ @@ -800,7 +799,7 @@ Pixmap Tk_GetBitmapFromData( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Tk_Window tkwin, /* Window in which bitmap will be used. */ - CONST char *source, /* Bitmap data for bitmap shape. */ + const char *source, /* Bitmap data for bitmap shape. */ int width, int height) /* Dimensions of bitmap. */ { DataKey nameKey; @@ -820,7 +819,7 @@ Tk_GetBitmapFromData( nameKey.width = width; nameKey.height = height; dataHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapDataTable, - (char *) &nameKey, &isNew); + (char *) &nameKey, &isNew); if (!isNew) { name = (char *) Tcl_GetHashValue(dataHashPtr); } else { @@ -862,6 +861,7 @@ Tk_GetBitmapFromObj( Tcl_Obj *objPtr) /* The object from which to get pixels. */ { TkBitmap *bitmapPtr = GetBitmapFromObj(tkwin, objPtr); + return bitmapPtr->bitmap; } @@ -909,7 +909,7 @@ GetBitmapFromObj( FreeBitmapObjProc(objPtr); } else { hashPtr = Tcl_FindHashEntry(&dispPtr->bitmapNameTable, - Tcl_GetString(objPtr)); + Tcl_GetString(objPtr)); if (hashPtr == NULL) { goto error; } @@ -985,7 +985,7 @@ InitBitmapObj( * ThreadSpecificData structure. * * Results: - * None. + * None. * * Side effects: * Read the code. @@ -1001,7 +1001,7 @@ BitmapInit( { Tcl_Interp *dummy; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * First initialize the data in the ThreadSpecificData strucuture, if @@ -1010,32 +1010,32 @@ BitmapInit( if (!tsdPtr->initialized) { tsdPtr->initialized = 1; - dummy = Tcl_CreateInterp(); + dummy = Tcl_CreateInterp(); Tcl_InitHashTable(&tsdPtr->predefBitmapTable, TCL_STRING_KEYS); - Tk_DefineBitmap(dummy, "error", (char *) error_bits, + Tk_DefineBitmap(dummy, "error", (char *) error_bits, error_width, error_height); - Tk_DefineBitmap(dummy, "gray75", (char *) gray75_bits, - gray75_width, gray75_height); - Tk_DefineBitmap(dummy, "gray50", (char *) gray50_bits, - gray50_width, gray50_height); - Tk_DefineBitmap(dummy, "gray25", (char *) gray25_bits, - gray25_width, gray25_height); - Tk_DefineBitmap(dummy, "gray12", (char *) gray12_bits, - gray12_width, gray12_height); - Tk_DefineBitmap(dummy, "hourglass", (char *) hourglass_bits, - hourglass_width, hourglass_height); - Tk_DefineBitmap(dummy, "info", (char *) info_bits, - info_width, info_height); - Tk_DefineBitmap(dummy, "questhead", (char *) questhead_bits, - questhead_width, questhead_height); - Tk_DefineBitmap(dummy, "question", (char *) question_bits, - question_width, question_height); - Tk_DefineBitmap(dummy, "warning", (char *) warning_bits, - warning_width, warning_height); - - TkpDefineNativeBitmaps(); - Tcl_DeleteInterp(dummy); + Tk_DefineBitmap(dummy, "gray75", (char *) gray75_bits, + gray75_width, gray75_height); + Tk_DefineBitmap(dummy, "gray50", (char *) gray50_bits, + gray50_width, gray50_height); + Tk_DefineBitmap(dummy, "gray25", (char *) gray25_bits, + gray25_width, gray25_height); + Tk_DefineBitmap(dummy, "gray12", (char *) gray12_bits, + gray12_width, gray12_height); + Tk_DefineBitmap(dummy, "hourglass", (char *) hourglass_bits, + hourglass_width, hourglass_height); + Tk_DefineBitmap(dummy, "info", (char *) info_bits, + info_width, info_height); + Tk_DefineBitmap(dummy, "questhead", (char *) questhead_bits, + questhead_width, questhead_height); + Tk_DefineBitmap(dummy, "question", (char *) question_bits, + question_width, question_height); + Tk_DefineBitmap(dummy, "warning", (char *) warning_bits, + warning_width, warning_height); + + TkpDefineNativeBitmaps(); + Tcl_DeleteInterp(dummy); } /* @@ -1044,7 +1044,7 @@ BitmapInit( */ if (dispPtr != NULL) { - dispPtr->bitmapInit = 1; + dispPtr->bitmapInit = 1; Tcl_InitHashTable(&dispPtr->bitmapNameTable, TCL_STRING_KEYS); Tcl_InitHashTable(&dispPtr->bitmapDataTable, sizeof(DataKey) / sizeof(int)); @@ -1081,14 +1081,12 @@ BitmapInit( int TkReadBitmapFile( - Display* display, + Display *display, Drawable d, - CONST char* filename, - unsigned int* width_return, - unsigned int* height_return, - Pixmap* bitmap_return, - int* x_hot_return, - int* y_hot_return) + const char *filename, + unsigned int *width_return, *height_return, + Pixmap *bitmap_return, + int *x_hot_return, *y_hot_return) { char *data; @@ -1101,7 +1099,6 @@ TkReadBitmapFile( *bitmap_return = XCreateBitmapFromData(display, d, data, *width_return, *height_return); - ckfree(data); return BitmapSuccess; } @@ -1160,15 +1157,15 @@ TkDebugBitmap( * * TkGetBitmapPredefTable -- * - * This function is used by tkMacBitmap.c to access the thread-specific - * predefBitmap table that maps from the names of the predefined bitmaps - * to data associated with those bitmaps. It is required because the - * table is allocated in thread-local storage and is not visible outside - * this file. + * This function is used by tkMacBitmap.c to access the thread-specific + * predefBitmap table that maps from the names of the predefined bitmaps + * to data associated with those bitmaps. It is required because the + * table is allocated in thread-local storage and is not visible outside + * this file. * Results: - * Returns a pointer to the predefined bitmap hash table for the current - * thread. + * Returns a pointer to the predefined bitmap hash table for the current + * thread. * * Side effects: * None. @@ -1180,7 +1177,7 @@ Tcl_HashTable * TkGetBitmapPredefTable(void) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); return &tsdPtr->predefBitmapTable; } diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index 6fbb5e0..cdda4d4 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvas.h,v 1.10 2007/06/24 16:07:34 dkf Exp $
+ * RCS: @(#) $Id: tkCanvas.h,v 1.11 2007/06/24 16:09:25 dkf Exp $
*/
#ifndef _TKCANVAS
@@ -26,13 +26,13 @@ typedef struct TagSearchExpr_s TagSearchExpr; struct TagSearchExpr_s {
TagSearchExpr *next; /* For linked lists of expressions - used in
* bindings. */
- Tk_Uid uid; /* The uid of the whole expression. */
- Tk_Uid *uids; /* Expresion compiled to an array of uids. */
- int allocated; /* Available space for array of uids. */
- int length; /* Length of expression. */
- int index; /* Current position in expression
+ Tk_Uid uid; /* The uid of the whole expression. */
+ Tk_Uid *uids; /* Expresion compiled to an array of uids. */
+ int allocated; /* Available space for array of uids. */
+ int length; /* Length of expression. */
+ int index; /* Current position in expression
* evaluation. */
- int match; /* This expression matches event's item's
+ int match; /* This expression matches event's item's
* tags. */
};
#endif /* not USE_OLD_TAG_SEARCH */
|