diff options
author | dgp <dgp@users.sourceforge.net> | 2007-06-25 19:12:12 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-06-25 19:12:12 (GMT) |
commit | a7f7c5e1a86b94cff3e98fa4ce842fbfdbf8cd6e (patch) | |
tree | 12856217612ac1c48e30bde71f2b37b20463cca7 /generic | |
parent | aef9147803123cbd2e4a67306397248b60b4435d (diff) | |
download | tk-a7f7c5e1a86b94cff3e98fa4ce842fbfdbf8cd6e.zip tk-a7f7c5e1a86b94cff3e98fa4ce842fbfdbf8cd6e.tar.gz tk-a7f7c5e1a86b94cff3e98fa4ce842fbfdbf8cd6e.tar.bz2 |
merge updates from HEAD
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkArgv.c | 83 | ||||
-rw-r--r-- | generic/tkBitmap.c | 145 | ||||
-rw-r--r-- | generic/tkButton.h | 17 | ||||
-rw-r--r-- | generic/tkCanvas.h | 30 | ||||
-rw-r--r-- | generic/tkColor.h | 8 | ||||
-rw-r--r-- | generic/tkFont.c | 36 | ||||
-rw-r--r-- | generic/tkImgPPM.c | 37 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 332 | ||||
-rw-r--r-- | generic/tkInt.h | 34 | ||||
-rw-r--r-- | generic/tkMenu.c | 155 | ||||
-rw-r--r-- | generic/tkMenu.h | 41 | ||||
-rw-r--r-- | generic/tkMenubutton.c | 84 | ||||
-rw-r--r-- | generic/tkMenubutton.h | 37 | ||||
-rw-r--r-- | generic/tkOption.c | 60 | ||||
-rw-r--r-- | generic/tkPlace.c | 73 | ||||
-rw-r--r-- | generic/tkScale.c | 87 | ||||
-rw-r--r-- | generic/tkSelect.h | 6 | ||||
-rw-r--r-- | generic/tkText.h | 156 | ||||
-rw-r--r-- | generic/tkUndo.h | 29 |
19 files changed, 700 insertions, 750 deletions
diff --git a/generic/tkArgv.c b/generic/tkArgv.c index c1eb479..69def03 100644 --- a/generic/tkArgv.c +++ b/generic/tkArgv.c @@ -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: tkArgv.c,v 1.5 2005/11/04 11:52:50 dkf Exp $ + * RCS: @(#) $Id: tkArgv.c,v 1.5.2.1 2007/06/25 19:12:12 dgp Exp $ */ #include "tkPort.h" @@ -121,36 +121,35 @@ Tk_ParseArgv( } for (; (infoPtr != NULL) && (infoPtr->type != TK_ARGV_END); infoPtr++) { - if (infoPtr->key == NULL) { - continue; - } - if ((infoPtr->key[1] != c) - || (strncmp(infoPtr->key, curArg, length) != 0)) { - continue; - } - if ((tkwin == NULL) - && ((infoPtr->type == TK_ARGV_CONST_OPTION) - || (infoPtr->type == TK_ARGV_OPTION_VALUE) - || (infoPtr->type == TK_ARGV_OPTION_NAME_VALUE))) { - continue; - } - if (infoPtr->key[length] == 0) { - matchPtr = infoPtr; - goto gotMatch; - } - if (flags & TK_ARGV_NO_ABBREV) { - continue; - } - if (matchPtr != NULL) { - Tcl_AppendResult(interp, "ambiguous option \"", curArg, - "\"", NULL); - return TCL_ERROR; - } - matchPtr = infoPtr; + if (infoPtr->key == NULL) { + continue; + } + if ((infoPtr->key[1] != c) + || (strncmp(infoPtr->key, curArg, length) != 0)) { + continue; + } + if ((tkwin == NULL) + && ((infoPtr->type == TK_ARGV_CONST_OPTION) + || (infoPtr->type == TK_ARGV_OPTION_VALUE) + || (infoPtr->type == TK_ARGV_OPTION_NAME_VALUE))) { + continue; + } + if (infoPtr->key[length] == 0) { + matchPtr = infoPtr; + goto gotMatch; + } + if (flags & TK_ARGV_NO_ABBREV) { + continue; + } + if (matchPtr != NULL) { + Tcl_AppendResult(interp, "ambiguous option \"", curArg, + "\"", NULL); + return TCL_ERROR; + } + matchPtr = infoPtr; } } if (matchPtr == NULL) { - /* * Unrecognized argument. Just copy it down, unless the caller * prefers an error to be registered. @@ -185,8 +184,8 @@ Tk_ParseArgv( *((int *) infoPtr->dst) = strtol(argv[srcIndex], &endPtr, 0); if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) { Tcl_AppendResult(interp,"expected integer argument for \"", - infoPtr->key, "\" but got \"", argv[srcIndex],"\"", - NULL); + infoPtr->key, "\" but got \"", argv[srcIndex], + "\"", NULL); return TCL_ERROR; } srcIndex++; @@ -196,20 +195,18 @@ Tk_ParseArgv( case TK_ARGV_STRING: if (argc == 0) { goto missingArg; - } else { - *((CONST char **)infoPtr->dst) = argv[srcIndex]; - srcIndex++; - argc--; } + *((CONST char **)infoPtr->dst) = argv[srcIndex]; + srcIndex++; + argc--; break; case TK_ARGV_UID: if (argc == 0) { goto missingArg; - } else { - *((Tk_Uid *)infoPtr->dst) = Tk_GetUid(argv[srcIndex]); - srcIndex++; - argc--; } + *((Tk_Uid *)infoPtr->dst) = Tk_GetUid(argv[srcIndex]); + srcIndex++; + argc--; break; case TK_ARGV_REST: *((int *) infoPtr->dst) = dstIndex; @@ -233,21 +230,19 @@ Tk_ParseArgv( break; case TK_ARGV_FUNC: { typedef int (ArgvFunc)(char *, char *, CONST char *); - ArgvFunc *handlerProc; + ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src; - handlerProc = (ArgvFunc *) infoPtr->src; if ((*handlerProc)(infoPtr->dst, infoPtr->key, argv[srcIndex])) { - srcIndex += 1; - argc -= 1; + srcIndex++; + argc--; } break; } case TK_ARGV_GENFUNC: { typedef int (ArgvGenFunc)(char *, Tcl_Interp *, char *, int, CONST char **); - ArgvGenFunc *handlerProc; + ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src; - handlerProc = (ArgvGenFunc *) infoPtr->src; argc = (*handlerProc)(infoPtr->dst, interp, infoPtr->key, argc, argv+srcIndex); if (argc < 0) { diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index 60fce0f..c609dd9 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.16.2.1 2007/06/25 19:12:12 dgp 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,14 @@ 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, + unsigned int *height_return, + Pixmap *bitmap_return, + int *x_hot_return, + int *y_hot_return) { char *data; @@ -1101,7 +1101,6 @@ TkReadBitmapFile( *bitmap_return = XCreateBitmapFromData(display, d, data, *width_return, *height_return); - ckfree(data); return BitmapSuccess; } @@ -1160,15 +1159,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 +1179,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/tkButton.h b/generic/tkButton.h index def38c2..5755cae 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkButton.h,v 1.13 2005/11/27 02:36:13 das Exp $ + * RCS: @(#) $Id: tkButton.h,v 1.13.2.1 2007/06/25 19:12:12 dgp Exp $ */ #ifndef _TKBUTTON @@ -132,13 +132,13 @@ typedef struct { * effect for the border, such as * TK_RELIEF_RAISED, to be used when a * checkbutton or radiobutton without - * indicator is off */ + * indicator is off. */ Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option: * specifies width in pixels of highlight to * draw around widget when it has the focus. * <= 0 means don't draw a highlight. */ int highlightWidth; /* Integer value corresponding to - * highlightWidthPtr. Always >= 0. */ + * highlightWidthPtr. Always >= 0. */ Tk_3DBorder highlightBorder;/* Value of -highlightbackground option: * specifies background with which to draw 3-D * default ring and focus highlight area when @@ -160,7 +160,7 @@ typedef struct { XColor *disabledFg; /* Value of -disabledforeground option: * foreground color when disabled. NULL means * use normalFg with a 50% stipple instead. */ - GC normalTextGC; /* GC for drawing text in normal mode. Also + GC normalTextGC; /* GC for drawing text in normal mode. Also * used to copy from off-screen pixmap onto * screen. */ GC activeTextGC; /* GC for drawing text in active mode (NULL @@ -203,7 +203,8 @@ typedef struct { * 0 means don't draw it. */ Tk_3DBorder selectBorder; /* Value of -selectcolor option: specifies * color for drawing indicator background, or - * perhaps widget background, when selected */ + * perhaps widget background, when + * selected. */ int textWidth; /* Width needed to display text as requested, * in pixels. */ int textHeight; /* Height needed to display text as requested, @@ -233,9 +234,9 @@ typedef struct { * to store in variable when this button isn't * selected. Used only by checkbuttons. */ Tcl_Obj *tristateValuePtr; /* Value of -tristatevalue option: specifies - * value to display Tristate or Multivalue - * mode when variable matches this value. - * Used by check- buttons. */ + * value to display Tristate or Multivalue + * mode when variable matches this value. + * Used by check- buttons. */ /* * Miscellaneous information: diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index de1aaf2..4c037cf 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.9 2005/11/27 02:36:13 das Exp $ + * RCS: @(#) $Id: tkCanvas.h,v 1.9.2.1 2007/06/25 19:12:12 dgp Exp $ */ #ifndef _TKCANVAS @@ -24,14 +24,16 @@ 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 evaluation */ - int match; /* this expression matches event's item's tags*/ + 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 + * evaluation. */ + int match; /* This expression matches event's item's + * tags. */ }; #endif /* not USE_OLD_TAG_SEARCH */ @@ -157,10 +159,10 @@ typedef struct TkCanvas { char *xScrollCmd; /* Command prefix for communicating with * horizontal scrollbar. NULL means no - * horizontal scrollbar. Malloc'ed*/ + * horizontal scrollbar. Malloc'ed. */ char *yScrollCmd; /* Command prefix for communicating with * vertical scrollbar. NULL means no vertical - * scrollbar. Malloc'ed*/ + * scrollbar. Malloc'ed. */ int scrollX1, scrollY1, scrollX2, scrollY2; /* These four coordinates define the region * that is the 100% area for scrolling (i.e. @@ -226,13 +228,13 @@ typedef struct TkCanvas { */ void *reserved1; - Tk_State canvas_state; /* state of canvas */ + Tk_State canvas_state; /* State of canvas. */ void *reserved2; void *reserved3; Tk_TSOffset tsoffset; #ifndef USE_OLD_TAG_SEARCH - TagSearchExpr *bindTagExprs; /* Linked list of tag expressions used in - * bindings. */ + TagSearchExpr *bindTagExprs;/* Linked list of tag expressions used in + * bindings. */ #endif } TkCanvas; diff --git a/generic/tkColor.h b/generic/tkColor.h index 71e02ee..4c0dd7d 100644 --- a/generic/tkColor.h +++ b/generic/tkColor.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkColor.h,v 1.8 2005/11/27 02:36:13 das Exp $ + * RCS: @(#) $Id: tkColor.h,v 1.8.2.1 2007/06/25 19:12:13 dgp Exp $ */ #ifndef _TKCOLOR @@ -35,7 +35,7 @@ typedef struct TkColor { XColor color; /* Information about this color. */ unsigned int magic; /* Used for quick integrity check on this - * structure. Must always have the value + * structure. Must always have the value * COLOR_MAGIC. */ GC gc; /* Simple gc with this color as foreground * color and all other fields defaulted. May @@ -44,7 +44,7 @@ typedef struct TkColor { * delete it, and to find its display. */ Colormap colormap; /* Colormap from which this entry was * allocated. */ - Visual *visual; /* Visual associated with colormap. */ + Visual *visual; /* Visual associated with colormap. */ int resourceRefCount; /* Number of active uses of this color (each * active use corresponds to a call to * Tk_AllocColorFromObj or Tk_GetColor). If @@ -57,7 +57,7 @@ typedef struct TkColor { * both 0. */ int objRefCount; /* The number of Tcl objects that reference * this structure. */ - int type; /* TK_COLOR_BY_NAME or TK_COLOR_BY_VALUE */ + int type; /* TK_COLOR_BY_NAME or TK_COLOR_BY_VALUE. */ Tcl_HashEntry *hashPtr; /* Pointer to hash table entry for this * structure. (for use in deleting entry). */ struct TkColor *nextPtr; /* Points to the next TkColor structure with diff --git a/generic/tkFont.c b/generic/tkFont.c index 3940267..9867b86 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -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: tkFont.c,v 1.35.2.1 2007/06/01 04:01:31 dgp Exp $ + * RCS: @(#) $Id: tkFont.c,v 1.35.2.2 2007/06/25 19:12:13 dgp Exp $ */ #include "tkPort.h" @@ -994,8 +994,8 @@ TkCreateNamedFont( * * TkDeleteNamedFont -- * - * Delete the named font. If there are still widgets using this - * font, then it isn't deleted right away. + * Delete the named font. If there are still widgets using this font, + * then it isn't deleted right away. * *--------------------------------------------------------------------------- */ @@ -1009,13 +1009,13 @@ TkDeleteNamedFont( TkFontInfo *fiPtr; NamedFont *nfPtr; Tcl_HashEntry *namedHashPtr; - + fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, name); if (namedHashPtr == NULL) { Tcl_AppendResult(interp, "named font \"", name, - "\" doesn't exist", (char *) NULL); + "\" doesn't exist", NULL); return TCL_ERROR; } nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr); @@ -1749,14 +1749,12 @@ Tk_PostscriptFontName( slantString = NULL; if (fontPtr->fa.slant == TK_FS_ROMAN) { ; + } else if ((strcmp(family, "Helvetica") == 0) + || (strcmp(family, "Courier") == 0) + || (strcmp(family, "AvantGarde") == 0)) { + slantString = "Oblique"; } else { - if ((strcmp(family, "Helvetica") == 0) - || (strcmp(family, "Courier") == 0) - || (strcmp(family, "AvantGarde") == 0)) { - slantString = "Oblique"; - } else { - slantString = "Italic"; - } + slantString = "Italic"; } /* @@ -1856,10 +1854,6 @@ Tk_UnderlineChars( int lastByte) /* Index of first byte after the last * character. */ { - TkFont *fontPtr; - - fontPtr = (TkFont *) tkfont; - TkUnderlineCharsInContext(display, drawable, gc, tkfont, string, lastByte, x, y, firstByte, lastByte); } @@ -2777,10 +2771,10 @@ Tk_IntersectTextLayout( chunkPtr = layoutPtr->chunks; fontPtr = (TkFont *) layoutPtr->tkfont; - left = x; - top = y; - right = x + width; - bottom = y + height; + left = x; + top = y; + right = x + width; + bottom = y + height; result = 0; for (i = 0; i < layoutPtr->numChunks; i++) { @@ -2827,7 +2821,7 @@ Tk_IntersectTextLayout( * lines in the text layout will be rendered by the user supplied * Postscript function. The function should be of the form: * - * justify x y string function -- + * justify x y string function -- * * Justify is -1, 0, or 1, depending on whether the following string * should be left, center, or right justified, x and y is the location diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index b1b4ad4..c40c40c 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -10,10 +10,10 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * Author: Paul Mackerras (paulus@cs.anu.edu.au), - * Department of Computer Science, - * Australian National University. + * Department of Computer Science, + * Australian National University. * - * RCS: @(#) $Id: tkImgPPM.c,v 1.16 2005/11/17 16:21:55 dkf Exp $ + * RCS: @(#) $Id: tkImgPPM.c,v 1.16.2.1 2007/06/25 19:12:13 dgp Exp $ */ #include "tkInt.h" @@ -179,13 +179,13 @@ FileReadPPM( } if (type == PGM) { - block.pixelSize = 1; - block.offset[0] = 0; + block.pixelSize = 1; + block.offset[0] = 0; block.offset[1] = 0; block.offset[2] = 0; } else { - block.pixelSize = 3; - block.offset[0] = 0; + block.pixelSize = 3; + block.offset[0] = 0; block.offset[1] = 1; block.offset[2] = 2; } @@ -273,8 +273,7 @@ FileWritePPM( Tk_PhotoImageBlock *blockPtr) { Tcl_Channel chan; - int w, h; - int greenOffset, blueOffset, nBytes; + int w, h, greenOffset, blueOffset, nBytes; unsigned char *pixelPtr, *pixLinePtr; char header[16 + TCL_INTEGER_SPACE * 2]; @@ -516,13 +515,13 @@ StringReadPPM( } if (type == PGM) { - block.pixelSize = 1; - block.offset[0] = 0; + block.pixelSize = 1; + block.offset[0] = 0; block.offset[1] = 0; block.offset[2] = 0; } else { - block.pixelSize = 3; - block.offset[0] = 0; + block.pixelSize = 3; + block.offset[0] = 0; block.offset[1] = 1; block.offset[2] = 2; } @@ -626,10 +625,8 @@ ReadPPMFileHeader( * is stored here. */ { #define BUFFER_SIZE 1000 - char buffer[BUFFER_SIZE]; - int i, numFields; - int type = 0; - char c; + char buffer[BUFFER_SIZE], c; + int i, numFields, type = 0; /* * Read 4 space-separated fields from the file, ignoring comments (any @@ -735,10 +732,8 @@ ReadPPMStringHeader( int *dataSizePtr) { #define BUFFER_SIZE 1000 - char buffer[BUFFER_SIZE]; - int i, numFields, dataSize; - int type = 0; - char c; + char buffer[BUFFER_SIZE], c; + int i, numFields, dataSize, type = 0; unsigned char *dataBuffer; dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize); diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index e9e5b0c..944a9de 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.69 2007/05/14 20:58:27 dgp Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.69.2.1 2007/06/25 19:12:13 dgp Exp $ */ #include "tkInt.h" @@ -79,7 +79,7 @@ typedef unsigned int pixel; */ typedef struct { - Display *display; /* Qualifies the colormap resource ID */ + Display *display; /* Qualifies the colormap resource ID. */ Colormap colormap; /* Colormap that the windows are using. */ double gamma; /* Gamma exponent value for images. */ Tk_Uid palette; /* Specifies how many shades of each primary @@ -106,8 +106,8 @@ typedef struct ColorTable { pixel redValues[256]; /* Maps 8-bit values of red intensity to a * pixel value or index in pixelMap. */ - pixel greenValues[256]; /* Ditto for green intensity */ - pixel blueValues[256]; /* Ditto for blue intensity */ + pixel greenValues[256]; /* Ditto for green intensity. */ + pixel blueValues[256]; /* Ditto for blue intensity. */ unsigned long *pixelMap; /* Actual pixel values allocated. */ unsigned char colorQuant[3][256]; @@ -240,7 +240,8 @@ struct SubcommandOptions { int subsampleX, subsampleY; /* Values specified for -subsample option. */ Tcl_Obj *format; /* Value specified for -format option. */ XColor *background; /* Value specified for -background option. */ - int compositingRule; /* Value specified for -compositingrule opt */ + int compositingRule; /* Value specified for -compositingrule + * option. */ }; /* @@ -329,7 +330,7 @@ Tk_ImageType tkPhotoImageType = { ImgPhotoFree, /* freeProc */ ImgPhotoDelete, /* deleteProc */ ImgPhotoPostscript, /* postscriptProc */ - NULL /* nextPtr */ + NULL /* nextPtr */ }; typedef struct ThreadSpecificData { @@ -405,8 +406,8 @@ static int ImgPhotoConfigureMaster(Tcl_Interp *interp, PhotoMaster *masterPtr, int objc, Tcl_Obj *const objv[], int flags); static void ImgPhotoConfigureInstance(PhotoInstance *instancePtr); -static int ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr); -static void ImgPhotoBlendComplexAlpha(XImage *bgImg, +static int ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr); +static void ImgPhotoBlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr, int xOffset, int yOffset, int width, int height); static int ImgPhotoSetSize(PhotoMaster *masterPtr, int width, @@ -468,7 +469,7 @@ PhotoFormatThreadExitProc( { Tk_PhotoImageFormat *freePtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); while (tsdPtr->oldFormatList != NULL) { freePtr = tsdPtr->oldFormatList; @@ -513,7 +514,7 @@ Tk_CreateOldPhotoImageFormat( { Tk_PhotoImageFormat *copyPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; @@ -537,7 +538,7 @@ Tk_CreatePhotoImageFormat( { Tk_PhotoImageFormat *copyPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; @@ -642,7 +643,6 @@ ImgPhotoCmd( int objc, /* Number of arguments. */ Tcl_Obj *CONST objv[]) /* Argument objects. */ { - int oldformat = 0; static const char *photoOptions[] = { "blank", "cget", "configure", "copy", "data", "get", "put", "read", "redither", "transparency", "write", NULL @@ -654,22 +654,18 @@ ImgPhotoCmd( }; PhotoMaster *masterPtr = (PhotoMaster *) clientData; - int result, index; - int x, y, width, height; - int dataWidth, dataHeight; + int result, index, x, y, width, height, dataWidth, dataHeight, listObjc; struct SubcommandOptions options; - int listObjc; Tcl_Obj **listObjv, **srcObjv; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_Window tkwin; Tk_PhotoImageFormat *imageFormat; - int imageWidth, imageHeight; - int matched, length; + int imageWidth, imageHeight, matched, length, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); @@ -1239,15 +1235,15 @@ ImgPhotoCmd( return TCL_ERROR; } - /* - * Prevent file system access in safe interpreters. - */ + /* + * Prevent file system access in safe interpreters. + */ - if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't get image from a file in a", + if (Tcl_IsSafe(interp)) { + Tcl_AppendResult(interp, "can't get image from a file in a", " safe interpreter", NULL); - return TCL_ERROR; - } + return TCL_ERROR; + } /* * Open the image file and look for a handler for it. @@ -1258,16 +1254,16 @@ ImgPhotoCmd( if (chan == NULL) { return TCL_ERROR; } - if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") + if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { Tcl_Close(NULL, chan); - return TCL_ERROR; - } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") + return TCL_ERROR; + } + if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) { Tcl_Close(NULL, chan); - return TCL_ERROR; - } + return TCL_ERROR; + } if (MatchFileFormat(interp, chan, Tcl_GetString(options.name), options.format, &imageFormat, @@ -1489,15 +1485,15 @@ ImgPhotoCmd( char *data; Tcl_Obj *format; - /* - * Prevent file system access in safe interpreters. - */ + /* + * Prevent file system access in safe interpreters. + */ - if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't write image to a file in a", + if (Tcl_IsSafe(interp)) { + Tcl_AppendResult(interp, "can't write image to a file in a", " safe interpreter", NULL); - return TCL_ERROR; - } + return TCL_ERROR; + } /* * photo write command - first parse and check any options given. @@ -1638,11 +1634,9 @@ ParseSubcommandOptions( int objc, /* Number of arguments in objv[]. */ Tcl_Obj *const objv[]) /* Arguments to be parsed. */ { - int index, c, bit, currentBit; - int length; + int index, c, bit, currentBit, length; + int values[4], numValues, maxValues, argIndex; char *option, **listPtr; - int values[4]; - int numValues, maxValues, argIndex; for (index = *optIndexPtr; index < objc; *optIndexPtr = ++index) { /* @@ -1775,7 +1769,7 @@ ParseSubcommandOptions( if (argIndex >= objc) { break; } - val = Tcl_GetString(objv[argIndex]); + val = Tcl_GetString(objv[argIndex]); if ((argIndex < objc) && (isdigit(UCHAR(val[0])) || ((val[0] == '-') && isdigit(UCHAR(val[1]))))) { if (Tcl_GetInt(interp, val, &values[numValues]) @@ -1910,15 +1904,12 @@ ImgPhotoConfigureMaster( PhotoInstance *instancePtr; const char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL; - int length, i, j; + Tcl_Obj *tempdata, *tempformat; + int length, i, j, result, imageWidth, imageHeight, oldformat; double oldGamma; - int result; Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; - int imageWidth, imageHeight; const char **args; - int oldformat; - Tcl_Obj *tempdata, *tempformat; args = (const char **) ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { @@ -2045,16 +2036,16 @@ ImgPhotoConfigureMaster( && ((masterPtr->fileString != oldFileString) || (masterPtr->format != oldFormat))) { - /* - * Prevent file system access in a safe interpreter. - */ + /* + * Prevent file system access in a safe interpreter. + */ - if (Tcl_IsSafe(interp)) { + if (Tcl_IsSafe(interp)) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, + Tcl_AppendResult(interp, "can't get image from a file in a safe interpreter", NULL); goto errorExit; - } + } chan = Tcl_OpenFileChannel(interp, masterPtr->fileString, "r", 0); if (chan == NULL) { @@ -2065,7 +2056,7 @@ ImgPhotoConfigureMaster( * -translation binary also sets -encoding binary */ - if ((Tcl_SetChannelOption(interp, chan, + if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) || (MatchFileFormat(interp, chan, masterPtr->fileString, masterPtr->format, &imageFormat, &imageWidth, @@ -2260,7 +2251,7 @@ ImgPhotoConfigureInstance( if ((instancePtr->imagePtr == NULL) || (instancePtr->imagePtr->bits_per_pixel != bitsPerPixel)) { if (instancePtr->imagePtr != NULL) { - XFree((char *) instancePtr->imagePtr); + XDestroyImage(instancePtr->imagePtr); } imagePtr = XCreateImage(instancePtr->display, instancePtr->visualInfo.visual, (unsigned) bitsPerPixel, @@ -2269,25 +2260,18 @@ ImgPhotoConfigureInstance( instancePtr->imagePtr = imagePtr; /* - * Determine the endianness of this machine. We create images - * using the local host's endianness, rather than the endianness - * of the server; otherwise we would have to byte-swap any 16 or - * 32 bit values that we store in the image in those situations - * where the server's endianness is different from ours. - * - * FIXME: use autoconf to figure this out. + * We create images using the local host's endianness, rather than + * the endianness of the server; otherwise we would have to + * byte-swap any 16 or 32 bit values that we store in the image + * if the server's endianness is different from ours. */ if (imagePtr != NULL) { - union { - int i; - char c[sizeof(int)]; - } kludge; - - imagePtr->bitmap_unit = sizeof(pixel) * NBBY; - kludge.i = 0; - kludge.c[0] = 1; - imagePtr->byte_order = (kludge.i == 1) ? LSBFirst : MSBFirst; +#ifdef WORDS_BIGENDIAN + imagePtr->byte_order = MSBFirst; +#else + imagePtr->byte_order = LSBFirst; +#endif _XInitImageFuncPtrs(imagePtr); } } @@ -2348,10 +2332,9 @@ ImgPhotoGet( PhotoMaster *masterPtr = (PhotoMaster *) masterData; PhotoInstance *instancePtr; Colormap colormap; - int mono, nRed, nGreen, nBlue; + int mono, nRed, nGreen, nBlue, numVisuals; XVisualInfo visualInfo, *visInfoPtr; char buf[TCL_INTEGER_SPACE * 3]; - int numVisuals; XColor *white, *black; XGCValues gcValues; @@ -2543,7 +2526,7 @@ ToggleComplexAlphaIfNeeded( */ mPtr->flags &= ~COMPLEX_ALPHA; - c += 3; /* start at first alpha byte */ + c += 3; /* Start at first alpha byte. */ for (; c < end; c += 4) { if (*c && *c != 255) { mPtr->flags |= COMPLEX_ALPHA; @@ -2572,16 +2555,15 @@ ToggleComplexAlphaIfNeeded( * Side effects: * Background image passed in gets drawn over with image data. * - *---------------------------------------------------------------------- - */ - -/* - * This should work on all platforms that set mask and shift data properly - * from the visualInfo. RGB is really only a 24+ bpp version whereas RGB15 is - * the correct version and works for 15bpp+, but it slower, so it's only used - * for 15bpp+. + * Notes: + * This should work on all platforms that set mask and shift data + * properly from the visualInfo. RGB is really only a 24+ bpp version + * whereas RGB15 is the correct version and works for 15bpp+, but it + * slower, so it's only used for 15bpp+. + * + * Note that Win32 pre-defines those operations that we really need. * - * Note that Win32 pre-defines those operations that we really need. + *---------------------------------------------------------------------- */ #ifndef __WIN32__ @@ -2600,16 +2582,16 @@ ToggleComplexAlphaIfNeeded( static void ImgPhotoBlendComplexAlpha( - XImage *bgImg, /* background image to draw on */ - PhotoInstance *iPtr, /* image instance to draw */ - int xOffset, int yOffset, /* X & Y offset into image instance to draw */ - int width, int height) /* width & height of image to draw */ + XImage *bgImg, /* Background image to draw on. */ + PhotoInstance *iPtr, /* Image instance to draw. */ + int xOffset, int yOffset, /* X & Y offset into image instance to + * draw. */ + int width, int height) /* Width & height of image to draw. */ { int x, y, line; unsigned long pixel; - unsigned char r, g, b, alpha, unalpha; + unsigned char r, g, b, alpha, unalpha, *masterPtr; unsigned char *alphaAr = iPtr->masterPtr->pix32; - unsigned char *masterPtr; /* * This blending is an integer version of the Source-Over compositing rule @@ -2695,7 +2677,7 @@ ImgPhotoBlendComplexAlpha( ra = GetRValue(pixel) << red_mlen; ga = GetGValue(pixel) << green_mlen; ba = GetBValue(pixel) << blue_mlen; - unalpha = 255 - alpha; /* calculate once */ + unalpha = 255 - alpha; /* Calculate once. */ r = ALPHA_BLEND(ra, r, alpha, unalpha); g = ALPHA_BLEND(ga, g, alpha, unalpha); b = ALPHA_BLEND(ba, b, alpha, unalpha); @@ -2738,7 +2720,7 @@ ImgPhotoBlendComplexAlpha( ra = GetRValue(pixel); ga = GetGValue(pixel); ba = GetBValue(pixel); - unalpha = 255 - alpha; /* calculate once */ + unalpha = 255 - alpha; /* Calculate once. */ r = ALPHA_BLEND(ra, r, alpha, unalpha); g = ALPHA_BLEND(ga, g, alpha, unalpha); b = ALPHA_BLEND(ba, b, alpha, unalpha); @@ -3187,8 +3169,7 @@ ImgPhotoInstanceSetSize( PhotoInstance *instancePtr) /* Instance whose size is to be changed. */ { PhotoMaster *masterPtr; - schar *newError; - schar *errSrcPtr, *errDestPtr; + schar *newError, *errSrcPtr, *errDestPtr; int h, offset; XRectangle validBox; Pixmap newPixmap; @@ -3205,9 +3186,9 @@ ImgPhotoInstanceSetSize( (masterPtr->width > 0) ? masterPtr->width: 1, (masterPtr->height > 0) ? masterPtr->height: 1, instancePtr->visualInfo.depth); - if (!newPixmap) { - Tcl_Panic("Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize.\n"); - } + if (!newPixmap) { + Tcl_Panic("Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize.\n"); + } /* * The following is a gross hack needed to properly support colormaps @@ -3468,7 +3449,6 @@ GetColorTable( */ colorPtr = (ColorTable *) Tcl_GetHashValue(entry); - } else { /* * No color table currently available; need to make one. @@ -3543,6 +3523,7 @@ FreeColorTable( if (colorPtr->refCount > 0) { return; } + if (force) { if ((colorPtr->flags & DISPOSE_PENDING) != 0) { Tcl_CancelIdleCall(DisposeColorTable, (ClientData) colorPtr); @@ -3860,10 +3841,9 @@ DisposeColorTable( ClientData clientData) /* Pointer to the ColorTable whose * colors are to be released. */ { - ColorTable *colorPtr; + ColorTable *colorPtr = (ColorTable *) clientData; Tcl_HashEntry *entry; - colorPtr = (ColorTable *) clientData; if (colorPtr->pixelMap != NULL) { if (colorPtr->numColors > 0) { XFreeColors(colorPtr->id.display, colorPtr->id.colormap, @@ -3912,14 +3892,13 @@ ReclaimColors( Tcl_HashSearch srch; Tcl_HashEntry *entry; ColorTable *colorPtr; - int nAvail; + int nAvail = 0; /* * First scan through the color hash table to get an upper bound on how * many colors we might be able to free. */ - nAvail = 0; entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch); while (entry != NULL) { colorPtr = (ColorTable *) Tcl_GetHashValue(entry); @@ -3971,7 +3950,7 @@ ReclaimColors( entry = Tcl_NextHashEntry(&srch); } - return 1; /* we freed some colors */ + return 1; /* We freed some colors. */ } /* @@ -4006,7 +3985,7 @@ DisposeInstance( Tk_FreeGC(instancePtr->display, instancePtr->gc); } if (instancePtr->imagePtr != NULL) { - XFree((char *) instancePtr->imagePtr); + XDestroyImage(instancePtr->imagePtr); } if (instancePtr->error != NULL) { ckfree((char *) instancePtr->error); @@ -4020,7 +3999,7 @@ DisposeInstance( } else { for (prevPtr = instancePtr->masterPtr->instancePtr; prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) { - /* Empty loop body */ + /* Empty loop body. */ } prevPtr->nextPtr = instancePtr->nextPtr; } @@ -4062,13 +4041,12 @@ MatchFileFormat( int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here. */ - int *oldformat) /* returns 1 if the old image API is used */ + int *oldformat) /* Returns 1 if the old image API is used. */ { - int matched; - int useoldformat = 0; + int matched = 0, useoldformat = 0; Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char *formatString = NULL; if (formatObj) { @@ -4080,9 +4058,8 @@ MatchFileFormat( * handle the image. */ - matched = 0; for (formatPtr = tsdPtr->formatList; formatPtr != NULL; - formatPtr = formatPtr->nextPtr) { + formatPtr = formatPtr->nextPtr) { if (formatObj != NULL) { if (strncasecmp(formatString, formatPtr->name, strlen(formatPtr->name)) != 0) { @@ -4193,13 +4170,12 @@ MatchStringFormat( int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here. */ - int *oldformat) /* returns 1 if the old image API is used */ + int *oldformat) /* Returns 1 if the old image API is used. */ { - int matched; - int useoldformat = 0; + int matched = 0, useoldformat = 0; Tk_PhotoImageFormat *formatPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); char *formatString = NULL; if (formatObj) { @@ -4211,7 +4187,6 @@ MatchStringFormat( * handle the image. */ - matched = 0; for (formatPtr = tsdPtr->formatList; formatPtr != NULL; formatPtr = formatPtr->nextPtr) { if (formatObj != NULL) { @@ -4347,13 +4322,9 @@ Tk_PhotoPutBlock( * transparent pixels. */ { register PhotoMaster *masterPtr; - int xEnd, yEnd; - int greenOffset, blueOffset, alphaOffset; - int wLeft, hLeft; - int wCopy, hCopy; - unsigned char *srcPtr, *srcLinePtr; - unsigned char *destPtr, *destLinePtr; - int pitch; + int xEnd, yEnd, greenOffset, blueOffset, alphaOffset; + int wLeft, hLeft, wCopy, hCopy, pitch; + unsigned char *srcPtr, *srcLinePtr, *destPtr, *destLinePtr; int sourceIsSimplePhoto = compRule & SOURCE_IS_SIMPLE_ALPHA_PHOTO; XRectangle rect; @@ -4622,6 +4593,7 @@ Tk_PhotoPutBlock( * builds up large simple-alpha images by single pixels. We don't * negate COMPLEX_ALPHA in this case. [Bug 1409140] */ + if (!(masterPtr->flags & COMPLEX_ALPHA)) { unsigned char newAlpha; @@ -4639,6 +4611,7 @@ Tk_PhotoPutBlock( * Toggle to only checking the changed pixels requires knowing where * the alpha pixels are. */ + ToggleComplexAlphaIfNeeded(masterPtr); } @@ -4695,17 +4668,11 @@ Tk_PhotoPutZoomedBlock( int compRule) /* Compositing rule to use when processing * transparent pixels. */ { - register PhotoMaster *masterPtr; - int xEnd, yEnd; - int greenOffset, blueOffset, alphaOffset; - int wLeft, hLeft; - int wCopy, hCopy; - int blockWid, blockHt; - unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr; - unsigned char *destPtr, *destLinePtr; - int pitch; - int xRepeat, yRepeat; - int blockXSkip, blockYSkip, sourceIsSimplePhoto; + register PhotoMaster *masterPtr = (PhotoMaster *) handle; + int xEnd, yEnd, greenOffset, blueOffset, alphaOffset; + int wLeft, hLeft, wCopy, hCopy, blockWid, blockHt; + unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr, *destPtr, *destLinePtr; + int pitch, xRepeat, yRepeat, blockXSkip, blockYSkip, sourceIsSimplePhoto; XRectangle rect; if (zoomX==1 && zoomY==1 && subsampleX==1 && subsampleY==1) { @@ -4715,7 +4682,6 @@ Tk_PhotoPutZoomedBlock( sourceIsSimplePhoto = compRule & SOURCE_IS_SIMPLE_ALPHA_PHOTO; compRule &= ~SOURCE_IS_SIMPLE_ALPHA_PHOTO; - masterPtr = (PhotoMaster *) handle; if (zoomX <= 0 || zoomY <= 0) { return TCL_OK; @@ -4826,7 +4792,7 @@ Tk_PhotoPutZoomedBlock( srcPtr = srcLinePtr; for (; wCopy > 0; wCopy -= zoomX) { for (xRepeat = MIN(wCopy, zoomX); xRepeat > 0; xRepeat--) { - int alpha = srcPtr[alphaOffset];/* source alpha */ + int alpha = srcPtr[alphaOffset];/* Source alpha. */ /* * Common case (solid pixels) first @@ -4853,7 +4819,8 @@ Tk_PhotoPutZoomedBlock( *destPtr++ = srcPtr[blueOffset]; *destPtr++ = alpha; } else if (alpha) { - int Alpha = destPtr[3]; /* destination alpha */ + int Alpha = destPtr[3]; /* Destination + * alpha. */ destPtr[0] = PD_SRC_OVER(srcPtr[0], alpha, destPtr[0], Alpha); @@ -5064,23 +5031,14 @@ DitherInstance( * block to be dithered. */ int width, int height) /* Dimensions of the block to be dithered. */ { - PhotoMaster *masterPtr; - ColorTable *colorPtr; + PhotoMaster *masterPtr = instancePtr->masterPtr; + ColorTable *colorPtr = instancePtr->colorTablePtr; XImage *imagePtr; - int nLines, bigEndian; - int i, c, x, y; - int xEnd, yEnd; + int nLines, bigEndian, i, c, x, y, xEnd, doDithering = 1; int bitsPerPixel, bytesPerLine, lineLength; - unsigned char *srcLinePtr, *srcPtr; - schar *errLinePtr, *errPtr; - unsigned char *destBytePtr, *dstLinePtr; - pixel *destLongPtr; + unsigned char *srcLinePtr; + schar *errLinePtr; pixel firstBit, word, mask; - int col[3]; - int doDithering = 1; - - colorPtr = instancePtr->colorTablePtr; - masterPtr = instancePtr->masterPtr; /* * Turn dithering off in certain cases where it is not needed (TrueColor, @@ -5114,7 +5072,7 @@ DitherInstance( imagePtr = instancePtr->imagePtr; if (imagePtr == NULL) { - return; /* we must be really tight on memory */ + return; /* We must be really tight on memory. */ } bitsPerPixel = imagePtr->bits_per_pixel; bytesPerLine = ((bitsPerPixel * width + 31) >> 3) & ~3; @@ -5137,16 +5095,19 @@ DitherInstance( */ for (; height > 0; height -= nLines) { + unsigned char *dstLinePtr = (unsigned char *) imagePtr->data; + int yEnd; + if (nLines > height) { nLines = height; } - dstLinePtr = (unsigned char *) imagePtr->data; yEnd = yStart + nLines; for (y = yStart; y < yEnd; ++y) { - srcPtr = srcLinePtr; - errPtr = errLinePtr; - destBytePtr = dstLinePtr; - destLongPtr = (pixel *) dstLinePtr; + unsigned char *srcPtr = srcLinePtr; + schar *errPtr = errLinePtr; + unsigned char *destBytePtr = dstLinePtr; + pixel *destLongPtr = (pixel *) dstLinePtr; + if (colorPtr->flags & COLOR_WINDOW) { /* * Color window. We dither the three components independently, @@ -5156,6 +5117,8 @@ DitherInstance( */ for (x = xStart; x < xEnd; ++x) { + int col[3]; + if (doDithering) { for (i = 0; i < 3; ++i) { /* @@ -5404,10 +5367,9 @@ void Tk_PhotoBlank( Tk_PhotoHandle handle) /* Handle for the image to be blanked. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; PhotoInstance *instancePtr; - masterPtr = (PhotoMaster *) handle; masterPtr->ditherX = masterPtr->ditherY = 0; masterPtr->flags = 0; @@ -5471,9 +5433,7 @@ Tk_PhotoExpand( Tk_PhotoHandle handle, /* Handle for the image to be expanded. */ int width, int height) /* Desired minimum dimensions of the image. */ { - PhotoMaster *masterPtr; - - masterPtr = (PhotoMaster *) handle; + PhotoMaster *masterPtr = (PhotoMaster *) handle; if (width <= masterPtr->width) { width = masterPtr->width; @@ -5520,9 +5480,8 @@ Tk_PhotoGetSize( /* The dimensions of the image are returned * here. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; - masterPtr = (PhotoMaster *) handle; *widthPtr = masterPtr->width; *heightPtr = masterPtr->height; } @@ -5553,9 +5512,7 @@ Tk_PhotoSetSize( * set. */ int width, int height) /* New dimensions for the image. */ { - PhotoMaster *masterPtr; - - masterPtr = (PhotoMaster *) handle; + PhotoMaster *masterPtr = (PhotoMaster *) handle; masterPtr->userWidth = width; masterPtr->userHeight = height; @@ -5597,9 +5554,8 @@ TkPhotoGetValidRegion( Tk_PhotoHandle handle) /* Handle for the image whose valid region is * to obtained. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; - masterPtr = (PhotoMaster *) handle; return masterPtr->validRegion; } @@ -5728,9 +5684,10 @@ ImgGetPhoto( */ } else if (optPtr->options & OPT_BACKGROUND) { if (newPixelSize > 2) { - int red = optPtr->background->red>>8; - int green = optPtr->background->green>>8; - int blue = optPtr->background->blue>>8; + int red = optPtr->background->red>>8; + int green = optPtr->background->green>>8; + int blue = optPtr->background->blue>>8; + for (y = blockPtr->height; y > 0; y--) { for (x = blockPtr->width; x > 0; x--) { destPtr[0] += (unsigned char) (((255 - *srcPtr) * @@ -5812,7 +5769,7 @@ ImgStringWrite( Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr) { - int row,col; + int row, col; char *line, *linePtr; unsigned char *pixelPtr; int greenOffset, blueOffset; @@ -5870,9 +5827,8 @@ Tk_PhotoGetImage( /* Information about the address and layout of * the image data is returned here. */ { - PhotoMaster *masterPtr; + PhotoMaster *masterPtr = (PhotoMaster *) handle; - masterPtr = (PhotoMaster *) handle; blockPtr->pixelPtr = masterPtr->pix32; blockPtr->width = masterPtr->width; blockPtr->height = masterPtr->height; @@ -5969,9 +5925,10 @@ PhotoOptionCleanupProc( Tcl_Interp *interp) /* Interpreter that is being deleted. */ { OptionAssocData *list = (OptionAssocData *) clientData; - OptionAssocData *ptr; while (list != NULL) { + register OptionAssocData *ptr; + list = (ptr = list)->nextPtr; ckfree((char *) ptr); } @@ -5996,14 +5953,13 @@ PhotoOptionCleanupProc( MODULE_SCOPE void Tk_CreatePhotoOption( - Tcl_Interp *interp, /* Interpreter */ - CONST char *name, /* Option name */ - Tcl_ObjCmdProc *proc) /* Function to execute command */ + Tcl_Interp *interp, /* Interpreter. */ + CONST char *name, /* Option name. */ + Tcl_ObjCmdProc *proc) /* Function to execute command. */ { OptionAssocData *typePtr2, *prevPtr, *ptr; - OptionAssocData *list; - - list = (OptionAssocData *) Tcl_GetAssocData(interp, "photoOption", NULL); + OptionAssocData *list = (OptionAssocData *) + Tcl_GetAssocData(interp, "photoOption", NULL); /* * If there's already a photo option with the given name, remove it. @@ -6048,12 +6004,12 @@ Tk_CreatePhotoOption( static int ImgPhotoPostscript( - ClientData clientData, /* Handle for the photo image */ - Tcl_Interp *interp, /* Interpreter */ + ClientData clientData, /* Handle for the photo image. */ + Tcl_Interp *interp, /* Interpreter. */ Tk_Window tkwin, /* (unused) */ - Tk_PostscriptInfo psInfo, /* postscript info */ - int x, int y, /* First pixel to output */ - int width, int height, /* Width and height of area */ + Tk_PostscriptInfo psInfo, /* Postscript info. */ + int x, int y, /* First pixel to output. */ + int width, int height, /* Width and height of area. */ int prepass) /* (unused) */ { Tk_PhotoImageBlock block; diff --git a/generic/tkInt.h b/generic/tkInt.h index 627ec58..ee44aab 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -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: tkInt.h,v 1.77 2007/01/18 23:56:43 nijtmans Exp $ + * RCS: $Id: tkInt.h,v 1.77.2.1 2007/06/25 19:12:13 dgp Exp $ */ #ifndef _TKINT @@ -192,7 +192,8 @@ typedef struct TkDisplay { * corresponding to the "Meta" key. If no such * modifier, then this is zero. */ enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage; - /* Indicates how to interpret lock modifier */ + /* Indicates how to interpret lock + * modifier. */ int numModKeyCodes; /* Number of entries in modKeyCodes array * below. */ KeyCode *modKeyCodes; /* Pointer to an array giving keycodes for all @@ -503,7 +504,7 @@ typedef struct TkDisplay { */ #ifdef TK_USE_INPUT_METHODS - XIM inputMethod; /* Input method for this display */ + XIM inputMethod; /* Input method for this display. */ #if TK_XIM_SPOT XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */ #endif @@ -511,14 +512,16 @@ typedef struct TkDisplay { Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ int refCount; /* Reference count of how many Tk applications - * are using this display. Used to clean up - * the display when we no longer have any Tk - * applications using it. */ + * are using this display. Used to clean up + * the display when we no longer have any Tk + * applications using it. */ + /* * The following field were all added for Tk8.3 */ + int mouseButtonState; /* Current mouse button state for this - * display */ + * display. */ Window mouseButtonWindow; /* Window the button state was set in, added * in Tk 8.4. */ Window warpWindow; @@ -534,8 +537,8 @@ typedef struct TkDisplay { TkCaret caret; /* Information about the caret for this * display. This is not a pointer. */ - int iconDataSize; /* Size of default iconphoto image data */ - unsigned char *iconDataPtr; /* Default iconphoto image data, if set */ + int iconDataSize; /* Size of default iconphoto image data. */ + unsigned char *iconDataPtr; /* Default iconphoto image data, if set. */ } TkDisplay; /* @@ -620,7 +623,7 @@ typedef struct TkMainInfo { Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow * structs for all windows related to this * main window. Managed by tkWindow.c. */ - long deletionEpoch; /* Incremented by window deletions */ + long deletionEpoch; /* Incremented by window deletions. */ Tk_BindingTable bindingTable; /* Used in conjunction with "bind" command to * bind events to Tcl commands. */ @@ -854,7 +857,7 @@ typedef struct TkStateMap { */ typedef struct TkpClipMask { - int type; /* One of TKP_CLIP_PIXMAP or TKP_CLIP_REGION */ + int type; /* TKP_CLIP_PIXMAP or TKP_CLIP_REGION. */ union { Pixmap pixmap; TkRegion region; @@ -1171,19 +1174,18 @@ MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp, MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin); MODULE_SCOPE void TkpDrawCharsInContext(Display * display, Drawable drawable, GC gc, Tk_Font tkfont, - const char * source, int numBytes, int rangeStart, + const char *source, int numBytes, int rangeStart, int rangeLength, int x, int y); MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont, - const char * source, int numBytes, int rangeStart, + const char *source, int numBytes, int rangeStart, int rangeLength, int maxLength, int flags, - int * lengthPtr); + int *lengthPtr); MODULE_SCOPE void TkUnderlineCharsInContext(Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *string, int numBytes, int x, int y, int firstByte, int lastByte); MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont, - Tcl_UniChar c, - struct TkFontAttributes *faPtr); + Tcl_UniChar c, struct TkFontAttributes *faPtr); /* * Unsupported commands. diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 0545412..b603b43 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.c,v 1.38 2007/01/03 05:06:26 nijtmans Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.38.2.1 2007/06/25 19:12:13 dgp Exp $ */ /* @@ -53,7 +53,7 @@ * Clones are rather tricky when a menu with cascade entries is cloned (such * as a menubar). Not only does the menu have to be cloned, but each cascade * entry's corresponding menu must also be cloned. This maintains the pathname - * parent-child hierarchy necessary for menubars and toplevels to work. This + * parent-child hierarchy necessary for menubars and toplevels to work. This * leads to several special cases: * * 1. When a new menu is created, and it is pointed to by cascade entries in @@ -61,8 +61,8 @@ * structure. * 2. When a cascade item is added to a menu that has been cloned, and the * menu that the cascade item points to exists, that menu has to be cloned. - * 3. When the menu that a cascade entry points to is changed, the old - * cloned cascade menu has to be discarded, and the new one has to be cloned. + * 3. When the menu that a cascade entry points to is changed, the old cloned + * cascade menu has to be discarded, and the new one has to be cloned. */ #if 0 @@ -80,9 +80,9 @@ #define MENU_HASH_KEY "tkMenus" typedef struct ThreadSpecificData { - int menusInitialized; /* Flag indicates whether thread-specific - * elements of the Windows Menu module - * have been initialized. */ + int menusInitialized; /* Flag indicates whether thread-specific + * elements of the Windows Menu module have + * been initialized. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -137,7 +137,7 @@ static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { DEF_MENU_ENTRY_COMMAND, Tk_Offset(TkMenuEntry, commandPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", - DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0, + DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0, (ClientData) compoundStrings, 0}, {TK_OPTION_FONT, "-font", NULL, NULL, DEF_MENU_ENTRY_FONT, @@ -251,8 +251,8 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = { Tk_Offset(TkMenu, activeBorderPtr), -1, 0, (ClientData) DEF_MENU_ACTIVE_BG_MONO}, {TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth", - "BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH, - Tk_Offset(TkMenu, activeBorderWidthPtr), -1}, + "BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH, + Tk_Offset(TkMenu, activeBorderWidthPtr), -1}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_MENU_ACTIVE_FG_COLOR, Tk_Offset(TkMenu, activeFgPtr), -1, 0, @@ -297,7 +297,7 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = { "TearOffCommand", DEF_MENU_TEAROFF_CMD, Tk_Offset(TkMenu, tearoffCommandPtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING, "-title", "title", "Title", - DEF_MENU_TITLE, Tk_Offset(TkMenu, titlePtr), -1, + DEF_MENU_TITLE, Tk_Offset(TkMenu, titlePtr), -1, TK_OPTION_NULL_OK}, {TK_OPTION_STRING_TABLE, "-type", "type", "Type", DEF_MENU_TYPE, Tk_Offset(TkMenu, menuTypePtr), -1, TK_OPTION_NULL_OK, @@ -454,8 +454,7 @@ MenuCmd( Tk_Window newWin; register TkMenu *menuPtr; TkMenuReferences *menuRefPtr; - int i, index; - int toplevel; + int i, index, toplevel; char *windowName; static CONST char *typeStringList[] = {"-type", NULL}; TkMenuOptionTables *optionTablesPtr = (TkMenuOptionTables *) clientData; @@ -552,12 +551,11 @@ MenuCmd( */ if (menuRefPtr->parentEntryPtr != NULL) { - TkMenuEntry *cascadeListPtr = menuRefPtr->parentEntryPtr; - TkMenuEntry *nextCascadePtr; - Tcl_Obj *newMenuName; - Tcl_Obj *newObjv[2]; + TkMenuEntry *cascadeListPtr = menuRefPtr->parentEntryPtr; + TkMenuEntry *nextCascadePtr; + Tcl_Obj *newMenuName, *newObjv[2]; - while (cascadeListPtr != NULL) { + while (cascadeListPtr != NULL) { nextCascadePtr = cascadeListPtr->nextCascadePtr; /* @@ -587,27 +585,27 @@ MenuCmd( Tcl_IncrRefCount(normalPtr); Tcl_IncrRefCount(windowNamePtr); - newMenuName = TkNewMenuName(menuPtr->interp, + newMenuName = TkNewMenuName(menuPtr->interp, windowNamePtr, menuPtr); Tcl_IncrRefCount(newMenuName); - CloneMenu(menuPtr, newMenuName, normalPtr); + CloneMenu(menuPtr, newMenuName, normalPtr); - /* - * Now we can set the new menu instance to be the cascade - * entry of the parent's instance. - */ + /* + * Now we can set the new menu instance to be the cascade + * entry of the parent's instance. + */ newObjv[0] = Tcl_NewStringObj("-menu", -1); newObjv[1] = newMenuName; Tcl_IncrRefCount(newObjv[0]); - ConfigureMenuEntry(cascadeListPtr, 2, newObjv); + ConfigureMenuEntry(cascadeListPtr, 2, newObjv); Tcl_DecrRefCount(normalPtr); Tcl_DecrRefCount(newObjv[0]); Tcl_DecrRefCount(newObjv[1]); Tcl_DecrRefCount(windowNamePtr); - } - cascadeListPtr = nextCascadePtr; - } + } + cascadeListPtr = nextCascadePtr; + } } /* @@ -620,8 +618,8 @@ MenuCmd( TkMenuTopLevelList *topLevelListPtr = menuRefPtr->topLevelListPtr; TkMenuTopLevelList *nextPtr; Tk_Window listtkwin; - while (topLevelListPtr != NULL) { + while (topLevelListPtr != NULL) { /* * Need to get the next pointer first. TkSetWindowMenuBar changes * the list, so that the next pointer is different after calling @@ -1022,7 +1020,7 @@ TkInvokeMenu( Tcl_Interp *interp, /* The interp that the menu lives in. */ TkMenu *menuPtr, /* The menu we are invoking. */ int index) /* The zero based index of the item we are - * invoking */ + * invoking. */ { int result = TCL_OK; TkMenuEntry *mePtr; @@ -1177,18 +1175,18 @@ DestroyMenuInstance( } if (menuPtr->masterMenuPtr != menuPtr) { - for (menuInstancePtr = menuPtr->masterMenuPtr; - menuInstancePtr != NULL; - menuInstancePtr = menuInstancePtr->nextInstancePtr) { - if (menuInstancePtr->nextInstancePtr == menuPtr) { - menuInstancePtr->nextInstancePtr = - menuInstancePtr->nextInstancePtr->nextInstancePtr; - break; - } - } - } else if (menuPtr->nextInstancePtr != NULL) { - Tcl_Panic("Attempting to delete master menu when there are still clones."); - } + for (menuInstancePtr = menuPtr->masterMenuPtr; + menuInstancePtr != NULL; + menuInstancePtr = menuInstancePtr->nextInstancePtr) { + if (menuInstancePtr->nextInstancePtr == menuPtr) { + menuInstancePtr->nextInstancePtr = + menuInstancePtr->nextInstancePtr->nextInstancePtr; + break; + } + } + } else if (menuPtr->nextInstancePtr != NULL) { + Tcl_Panic("Attempting to delete master menu when there are still clones."); + } /* * Free up all the stuff that requires special handling, then let @@ -1329,7 +1327,7 @@ UnhookCascadeEntry( menuRefPtr = mePtr->childMenuRefPtr; if (menuRefPtr == NULL) { - return; + return; } cascadeEntryPtr = menuRefPtr->parentEntryPtr; @@ -1366,15 +1364,15 @@ UnhookCascadeEntry( for (prevCascadePtr = cascadeEntryPtr, cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr; cascadeEntryPtr != NULL; - prevCascadePtr = cascadeEntryPtr, + prevCascadePtr = cascadeEntryPtr, cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) { if (cascadeEntryPtr == mePtr){ prevCascadePtr->nextCascadePtr = - cascadeEntryPtr->nextCascadePtr; + cascadeEntryPtr->nextCascadePtr; cascadeEntryPtr->nextCascadePtr = NULL; break; } - } + } mePtr->nextCascadePtr = NULL; } mePtr->childMenuRefPtr = NULL; @@ -1447,9 +1445,9 @@ DestroyMenuEntry( } UnhookCascadeEntry(mePtr); if (menuRefPtr != NULL) { - if (menuRefPtr->menuPtr == destroyThis) { - menuRefPtr->menuPtr = NULL; - } + if (menuRefPtr->menuPtr == destroyThis) { + menuRefPtr->menuPtr = NULL; + } if (destroyThis != NULL) { TkDestroyMenu(destroyThis); } @@ -1489,10 +1487,10 @@ DestroyMenuEntry( * all its graphics contexts and determine its new geometry. * * Results: - * None. + * None. * * Side effects: - * Menu will be relayed out and redisplayed. + * Menu will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ @@ -1535,8 +1533,8 @@ MenuWorldChanged( static int ConfigureMenu( Tcl_Interp *interp, /* Used for error reporting. */ - register TkMenu *menuPtr, /* Information about widget; may or may - * not already have values for some fields. */ + register TkMenu *menuPtr, /* Information about widget; may or may not + * already have values for some fields. */ int objc, /* Number of valid entries in argv. */ Tcl_Obj *CONST objv[]) /* Arguments. */ { @@ -2142,7 +2140,7 @@ TkGetMenuIndex( } if (isdigit(UCHAR(string[0]))) { - if (Tcl_GetInt(interp, string, &i) == TCL_OK) { + if (Tcl_GetInt(interp, string, &i) == TCL_OK) { if (i >= menuPtr->numEntries) { if (lastOK) { i = menuPtr->numEntries; @@ -2256,7 +2254,7 @@ MenuNewEntry( for (i = 0; i < index; i++) { newEntries[i] = menuPtr->entries[i]; } - for ( ; i < menuPtr->numEntries; i++) { + for (; i < menuPtr->numEntries; i++) { newEntries[i+1] = menuPtr->entries[i]; newEntries[i+1]->index = i + 1; } @@ -2418,14 +2416,13 @@ MenuAddOrInsert( if ((mePtr->namePtr != NULL) && (mePtr->childMenuRefPtr != NULL) && (mePtr->childMenuRefPtr->menuPtr != NULL)) { - TkMenu *cascadeMenuPtr = + TkMenu *cascadeMenuPtr = mePtr->childMenuRefPtr->menuPtr->masterMenuPtr; - Tcl_Obj *newCascadePtr; + Tcl_Obj *newCascadePtr, *newObjv[2]; Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1); Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(menuListPtr->tkwin), -1); Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", -1); - Tcl_Obj *newObjv[2]; TkMenuReferences *menuRefPtr; Tcl_IncrRefCount(windowNamePtr); @@ -2444,8 +2441,8 @@ MenuAddOrInsert( newObjv[1] = newCascadePtr; Tcl_IncrRefCount(menuNamePtr); Tcl_IncrRefCount(newCascadePtr); - ConfigureMenuEntry(mePtr, 2, newObjv); - Tcl_DecrRefCount(newCascadePtr); + ConfigureMenuEntry(mePtr, 2, newObjv); + Tcl_DecrRefCount(newCascadePtr); Tcl_DecrRefCount(menuNamePtr); Tcl_DecrRefCount(windowNamePtr); Tcl_DecrRefCount(normalPtr); @@ -2659,8 +2656,8 @@ TkPostCommand( static int CloneMenu( - TkMenu *menuPtr, /* The menu we are going to clone */ - Tcl_Obj *newMenuNamePtr, /* The name to give the new menu */ + TkMenu *menuPtr, /* The menu we are going to clone. */ + Tcl_Obj *newMenuNamePtr, /* The name to give the new menu. */ Tcl_Obj *newMenuTypePtr) /* What kind of menu is this, a normal menu a * menubar, or a tearoff? */ { @@ -2917,10 +2914,10 @@ MenuDoYPosition( static int GetIndexFromCoords( - Tcl_Interp *interp, /* interp of menu */ - TkMenu *menuPtr, /* the menu we are searching */ - char *string, /* The @string we are parsing */ - int *indexPtr) /* The index of the item that matches */ + Tcl_Interp *interp, /* Interpreter of menu. */ + TkMenu *menuPtr, /* The menu we are searching. */ + char *string, /* The @string we are parsing. */ + int *indexPtr) /* The index of the item that matches. */ { int x, y, i; char *p, *end; @@ -2983,7 +2980,7 @@ GetIndexFromCoords( static void RecursivelyDeleteMenu( - TkMenu *menuPtr) /* The menubar instance we are deleting */ + TkMenu *menuPtr) /* The menubar instance we are deleting. */ { int i; TkMenuEntry *mePtr; @@ -3109,7 +3106,7 @@ TkNewMenuName( void TkSetWindowMenuBar( Tcl_Interp *interp, /* The interpreter the toplevel lives in. */ - Tk_Window tkwin, /* The toplevel window */ + Tk_Window tkwin, /* The toplevel window. */ char *oldMenuName, /* The name of the menubar previously set in * this toplevel. NULL means no menu was set * previously. */ @@ -3159,7 +3156,7 @@ TkSetWindowMenuBar( prevTopLevelPtr = NULL; while ((topLevelListPtr != NULL) - && (topLevelListPtr->tkwin != tkwin)) { + && (topLevelListPtr->tkwin != tkwin)) { prevTopLevelPtr = topLevelListPtr; topLevelListPtr = topLevelListPtr->nextPtr; } @@ -3271,8 +3268,8 @@ TkSetWindowMenuBar( static void DestroyMenuHashTable( - ClientData clientData, /* The menu hash table we are destroying */ - Tcl_Interp *interp) /* The interpreter we are destroying */ + ClientData clientData, /* The menu hash table we are destroying. */ + Tcl_Interp *interp) /* The interpreter we are destroying. */ { Tcl_DeleteHashTable((Tcl_HashTable *) clientData); ckfree((char *) clientData); @@ -3337,7 +3334,7 @@ TkGetMenuHashTable( TkMenuReferences * TkCreateMenuReferences( Tcl_Interp *interp, - char *pathName) /* The path of the menu widget */ + char *pathName) /* The path of the menu widget. */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr; @@ -3381,7 +3378,7 @@ TkCreateMenuReferences( TkMenuReferences * TkFindMenuReferences( Tcl_Interp *interp, /* The interp the menu is living in. */ - char *pathName) /* The path of the menu widget */ + char *pathName) /* The path of the menu widget. */ { Tcl_HashEntry *hashEntryPtr; TkMenuReferences *menuRefPtr = NULL; @@ -3418,7 +3415,7 @@ TkFindMenuReferences( TkMenuReferences * TkFindMenuReferencesObj( Tcl_Interp *interp, /* The interp the menu is living in. */ - Tcl_Obj *objPtr) /* The path of the menu widget */ + Tcl_Obj *objPtr) /* The path of the menu widget. */ { char *pathName = Tcl_GetString(objPtr); return TkFindMenuReferences(interp, pathName); @@ -3445,7 +3442,7 @@ TkFindMenuReferencesObj( int TkFreeMenuReferences( TkMenuReferences *menuRefPtr) - /* The menu reference to free */ + /* The menu reference to free. */ { if ((menuRefPtr->menuPtr == NULL) && (menuRefPtr->parentEntryPtr == NULL) @@ -3516,14 +3513,14 @@ DeleteMenuCloneEntries( * * TkMenuCleanup -- * - * Resets menusInitialized to allow Tk to be finalized and reused without - * the DLL being unloaded. + * Resets menusInitialized to allow Tk to be finalized and reused without + * the DLL being unloaded. * * Results: - * None. + * None. * * Side effects: - * None. + * None. * *---------------------------------------------------------------------- */ diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 0c726a0..ff7f351 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.h,v 1.12 2007/01/05 00:00:51 nijtmans Exp $ + * RCS: @(#) $Id: tkMenu.h,v 1.12.2.1 2007/06/25 19:12:13 dgp Exp $ */ #ifndef _TKMENU @@ -139,7 +139,7 @@ typedef struct TkMenuEntry { * Malloc'ed. */ Tcl_Obj *namePtr; /* Name of variable (for check buttons and * radio buttons) or menu (for cascade - * entries). Malloc'ed.*/ + * entries). Malloc'ed. */ Tcl_Obj *onValuePtr; /* Value to store in variable when selected * (only for radio and check buttons). * Malloc'ed. */ @@ -155,19 +155,19 @@ typedef struct TkMenuEntry { * horizontal dimension. Not used except in * menubars. The width of norma menus is * dependent on the rest of the menu. */ - int x; /* X-coordinate of leftmost pixel in entry */ + int x; /* X-coordinate of leftmost pixel in entry. */ int height; /* Number of pixels occupied by entry in * vertical dimension, including raised border * drawn around entry when active. */ int y; /* Y-coordinate of topmost pixel in entry. */ - GC textGC; /* GC for drawing text in entry. NULL means + GC textGC; /* GC for drawing text in entry. NULL means * use overall textGC for menu. */ GC activeGC; /* GC for drawing text in entry when active. * NULL means use overall activeGC for * menu. */ GC disabledGC; /* Used to produce disabled effect for entry. * NULL means use overall disabledGC from menu - * structure. See comments for disabledFg in + * structure. See comments for disabledFg in * menu structure for more information. */ GC indicatorGC; /* For drawing indicators. None means use GC * from menu. */ @@ -313,8 +313,8 @@ typedef struct TkMenu { * Information about geometry of menu. */ - int totalWidth; /* Width of entire menu */ - int totalHeight; /* Height of entire menu */ + int totalWidth; /* Width of entire menu. */ + int totalHeight; /* Height of entire menu. */ /* * Miscellaneous information: @@ -335,16 +335,16 @@ typedef struct TkMenu { * whenever the menu is torn-off. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal - * scripts. Malloc'ed, but may be NULL. */ + * scripts. Malloc'ed, but may be NULL. */ Tcl_Obj *cursorPtr; /* Current cursor for window, or None. */ Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy * trees when preprocessing postcommands on * some platforms. See PostMenu for more * details. */ int postCommandGeneration; /* Need to do pre-invocation post command - * traversal */ + * traversal. */ int menuFlags; /* Flags for use by X; see below for - definition */ + * definition. */ TkMenuEntry *postedCascade; /* Points to menu entry for cascaded submenu * that is currently posted or NULL if no * submenu posted. */ @@ -373,8 +373,8 @@ typedef struct TkMenu { * have this menu specified as a cascade. */ TkMenuPlatformData platformData; /* The data for the specific type of menu. - * Depends on platform and menu type what kind - * of options are in this structure. */ + * Depends on platform and menu type what kind + * of options are in this structure. */ Tk_OptionSpec *extensionPtr;/* Needed by the configuration package for * this widget to be extended. */ Tk_SavedOptions *errorStructPtr; @@ -391,7 +391,7 @@ typedef struct TkMenu { typedef struct TkMenuTopLevelList { struct TkMenuTopLevelList *nextPtr; - /* The next window in the list */ + /* The next window in the list. */ Tk_Window tkwin; /* The window that has this menu as its * menubar. */ } TkMenuTopLevelList; @@ -451,14 +451,14 @@ typedef struct TkMenuOptionTables { * when TkDestroyMenu was called again on this * menu (via a destroy binding or somesuch). * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of - * destroying this menu's Tk_Window. + * destroying this menu's Tk_Window. * MENU_PLATFORM_FLAG1... Reserved for use by the platform-specific menu * code. */ -#define REDRAW_PENDING 1 -#define RESIZE_PENDING 2 -#define MENU_DELETION_PENDING 4 +#define REDRAW_PENDING 1 +#define RESIZE_PENDING 2 +#define MENU_DELETION_PENDING 4 #define MENU_WIN_DESTRUCTION_PENDING 8 #define MENU_PLATFORM_FLAG1 (1 << 30) #define MENU_PLATFORM_FLAG2 (1 << 29) @@ -482,9 +482,9 @@ typedef struct TkMenuOptionTables { * Various geometry definitions: */ -#define CASCADE_ARROW_HEIGHT 10 -#define CASCADE_ARROW_WIDTH 8 -#define DECORATION_BORDER_WIDTH 2 +#define CASCADE_ARROW_HEIGHT 10 +#define CASCADE_ARROW_WIDTH 8 +#define DECORATION_BORDER_WIDTH 2 /* * Menu-related functions that are shared among Tk modules but not exported to @@ -560,4 +560,3 @@ MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr); # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKMENU */ - diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 9fa7c4f..d71dcfa 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -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: tkMenubutton.c,v 1.15 2007/01/03 05:06:26 nijtmans Exp $ + * RCS: @(#) $Id: tkMenubutton.c,v 1.15.2.1 2007/06/25 19:12:13 dgp Exp $ */ #include "tkMenubutton.h" @@ -50,19 +50,19 @@ static char *compoundStrings[] = { static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground", - DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1, - Tk_Offset(TkMenuButton, activeBorder), 0, - (ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0}, + DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1, + Tk_Offset(TkMenuButton, activeBorder), 0, + (ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_MENUBUTTON_ACTIVE_FG_COLOR, -1, - Tk_Offset(TkMenuButton, activeFg), - 0, (ClientData) DEF_MENUBUTTON_ACTIVE_FG_MONO, 0}, + Tk_Offset(TkMenuButton, activeFg), + 0, (ClientData) DEF_MENUBUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MENUBUTTON_ANCHOR, -1, - Tk_Offset(TkMenuButton, anchor), 0, 0, 0}, + Tk_Offset(TkMenuButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_MENUBUTTON_BG_COLOR, -1, Tk_Offset(TkMenuButton, normalBorder), - 0, (ClientData) DEF_MENUBUTTON_BG_MONO, 0}, + 0, (ClientData) DEF_MENUBUTTON_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0, @@ -72,12 +72,12 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_MENUBUTTON_BORDER_WIDTH, -1, - Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0}, + Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MENUBUTTON_CURSOR, -1, Tk_Offset(TkMenuButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction", - DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction), + DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction), 0, (ClientData) directionStrings, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR, @@ -91,13 +91,13 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_FG, -1, Tk_Offset(TkMenuButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", DEF_MENUBUTTON_HEIGHT, -1, Tk_Offset(TkMenuButton, heightString), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR, -1, Tk_Offset(TkMenuButton, highlightBgColorPtr), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_MENUBUTTON_HIGHLIGHT, -1, - Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0}, + Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH, -1, Tk_Offset(TkMenuButton, highlightWidth), 0, 0, 0}, @@ -106,7 +106,7 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn", DEF_MENUBUTTON_INDICATOR, -1, Tk_Offset(TkMenuButton, indicatorOn), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkMenuButton, justify), 0, 0, 0}, {TK_OPTION_STRING, "-menu", "menu", "Menu", @@ -120,30 +120,30 @@ static const Tk_OptionSpec optionSpecs[] = { 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENUBUTTON_RELIEF, -1, Tk_Offset(TkMenuButton, relief), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", - DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound), 0, - (ClientData) compoundStrings, 0}, + DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_MENUBUTTON_STATE, -1, Tk_Offset(TkMenuButton, state), 0, (ClientData) stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_MENUBUTTON_TAKE_FOCUS, -1, - Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0}, + Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_MENUBUTTON_TEXT, -1, Tk_Offset(TkMenuButton, text), 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_MENUBUTTON_TEXT_VARIABLE, -1, - Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0}, + Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INT, "-underline", "underline", "Underline", DEF_MENUBUTTON_UNDERLINE, -1, Tk_Offset(TkMenuButton, underline), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_MENUBUTTON_WIDTH, -1, Tk_Offset(TkMenuButton, widthString), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", DEF_MENUBUTTON_WRAP_LENGTH, -1, Tk_Offset(TkMenuButton, wrapLength), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0} }; @@ -179,7 +179,7 @@ static int MenuButtonWidgetObjCmd(ClientData clientData, Tcl_Obj *CONST objv[]); static int ConfigureMenuButton(Tcl_Interp *interp, TkMenuButton *mbPtr, int objc, - Tcl_Obj *CONST objv[]); + Tcl_Obj *CONST objv[]); static void DestroyMenuButton(char *memPtr); /* @@ -246,8 +246,8 @@ Tk_MenubuttonObjCmd( mbPtr->display = Tk_Display (tkwin); mbPtr->interp = interp; mbPtr->widgetCmd = Tcl_CreateObjCommand(interp, - Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, - (ClientData) mbPtr, MenuButtonCmdDeletedProc); + Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, + (ClientData) mbPtr, MenuButtonCmdDeletedProc); mbPtr->optionTable = optionTable; mbPtr->menuName = NULL; mbPtr->text = NULL; @@ -342,13 +342,13 @@ MenuButtonWidgetObjCmd( Tcl_Obj *objPtr; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, "option", 0, &index); if (result != TCL_OK) { - return result; + return result; } Tcl_Preserve((ClientData) mbPtr); @@ -418,7 +418,7 @@ DestroyMenuButton( TkpDestroyMenuButton(mbPtr); if (mbPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(TkpDisplayMenuButton, (ClientData) mbPtr); + Tcl_CancelIdleCall(TkpDisplayMenuButton, (ClientData) mbPtr); } /* @@ -451,7 +451,7 @@ DestroyMenuButton( Tk_FreeBitmap(mbPtr->display, mbPtr->gray); } if (mbPtr->textLayout != NULL) { - Tk_FreeTextLayout(mbPtr->textLayout); + Tk_FreeTextLayout(mbPtr->textLayout); } Tk_FreeConfigOptions((char *) mbPtr, mbPtr->optionTable, mbPtr->tkwin); mbPtr->tkwin = NULL; @@ -483,7 +483,7 @@ static int ConfigureMenuButton( Tcl_Interp *interp, /* Used for error reporting. */ register TkMenuButton *mbPtr, - /* Information about widget; may or may not + /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of valid entries in objv. */ Tcl_Obj *CONST objv[]) /* Arguments. */ @@ -566,7 +566,7 @@ ConfigureMenuButton( mbPtr->imageString, MenuButtonImageProc, (ClientData) mbPtr); if (image == NULL) { - return TCL_ERROR; + return TCL_ERROR; } } else { image = NULL; @@ -582,25 +582,25 @@ ConfigureMenuButton( if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) { if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString, - &mbPtr->width) != TCL_OK) { + &mbPtr->width) != TCL_OK) { widthError: - Tcl_AddErrorInfo(interp, "\n (processing -width option)"); + Tcl_AddErrorInfo(interp, "\n (processing -width option)"); continue; } if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString, &mbPtr->height) != TCL_OK) { heightError: - Tcl_AddErrorInfo(interp, "\n (processing -height option)"); + Tcl_AddErrorInfo(interp, "\n (processing -height option)"); continue; } } else { if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width) != TCL_OK) { - goto widthError; + goto widthError; } if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height) != TCL_OK) { - goto heightError; + goto heightError; } } break; @@ -641,7 +641,7 @@ ConfigureMenuButton( if (error) { Tcl_SetObjResult(interp, errorResult); Tcl_DecrRefCount(errorResult); - return TCL_ERROR; + return TCL_ERROR; } return TCL_OK; } @@ -651,15 +651,15 @@ ConfigureMenuButton( * * TkMenuButtonWorldChanged -- * - * This function is called when the world has changed in some way and the - * widget needs to recompute all its graphics contexts and determine its - * new geometry. + * This function is called when the world has changed in some way and the + * widget needs to recompute all its graphics contexts and determine its + * new geometry. * * Results: - * None. + * None. * * Side effects: - * TkMenuButton will be relayed out and redisplayed. + * TkMenuButton will be relayed out and redisplayed. * *--------------------------------------------------------------------------- */ @@ -785,7 +785,7 @@ MenuButtonEventProc( goto redraw; } else if (eventPtr->type == DestroyNotify) { - DestroyMenuButton((char *) mbPtr); + DestroyMenuButton((char *) mbPtr); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { mbPtr->flags |= GOT_FOCUS; diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index 087db07..a270caf 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenubutton.h,v 1.11 2005/11/27 02:36:14 das Exp $ + * RCS: @(#) $Id: tkMenubutton.h,v 1.11.2.1 2007/06/25 19:12:13 dgp Exp $ */ #ifndef _TKMENUBUTTON @@ -88,7 +88,7 @@ typedef struct { * Information used when displaying widget: */ - enum state state; /* State of button for display purposes: + enum state state; /* State of button for display purposes: * normal, active, or disabled. */ Tk_3DBorder normalBorder; /* Structure used to draw 3-D border and * background when window isn't active. NULL @@ -111,8 +111,8 @@ typedef struct { * borders. */ Tk_Font tkfont; /* Information about text font, or NULL. */ XColor *normalFg; /* Foreground color in normal mode. */ - XColor *activeFg; /* Foreground color in active mode. NULL - * means use normalFg instead. */ + XColor *activeFg; /* Foreground color in active mode. NULL means + * use normalFg instead. */ XColor *disabledFg; /* Foreground color when disabled. NULL means * use normalFg with a 50% stipple instead. */ GC normalTextGC; /* GC for drawing text in normal mode. */ @@ -120,19 +120,22 @@ typedef struct { * means use normalTextGC). */ Pixmap gray; /* Pixmap for displaying disabled text/icon if * disabledFg is NULL. */ - GC disabledGC; /* Used to produce disabled effect for text */ + GC disabledGC; /* Used to produce disabled effect for + * text. */ GC stippleGC; /* Used to produce disabled stipple effect for * images when disabled. */ int leftBearing; /* Distance from text origin to leftmost drawn * pixel (positive means to right). */ - int rightBearing; /* Amount text sticks right from its origin */ - char *widthString; /* Value of -width option. Malloc'ed. */ - char *heightString; /* Value of -height option. Malloc'ed. */ + int rightBearing; /* Amount text sticks right from its + * origin. */ + char *widthString; /* Value of -width option. Malloc'ed. */ + char *heightString; /* Value of -height option. Malloc'ed. */ int width, height; /* If > 0, these specify dimensions to request * for window, in characters for text and in * pixels for bitmaps. In this case the actual * size of the text string or bitmap is - * ignored in computing desired window size */ + * ignored in computing desired window + * size. */ int wrapLength; /* Line length (in pixels) at which to wrap * onto next line. <= 0 means don't wrap * except at newlines. */ @@ -140,7 +143,8 @@ typedef struct { * on each side). */ Tk_Anchor anchor; /* Where text/bitmap should be displayed * inside window region. */ - Tk_Justify justify; /* Justification to use for multi-line text */ + Tk_Justify justify; /* Justification to use for multi-line + * text. */ int textWidth; /* Width needed to display text as requested, * in pixels. */ int textHeight; /* Height needed to display text as requested, @@ -150,7 +154,8 @@ typedef struct { * don't display. */ int indicatorHeight; /* Height of indicator in pixels. This same * amount of extra space is also left on each - * side of the indicator. 0 if no indicator */ + * side of the indicator. 0 if no + * indicator. */ int indicatorWidth; /* Width of indicator in pixels, including * indicatorHeight in padding on each side. 0 * if no indicator. */ @@ -159,10 +164,9 @@ typedef struct { * Miscellaneous information: */ - int compound; /* Value of -compound option; specifies - * whether the menubutton should show both an - * image and text, and, if so, how. */ - + int compound; /* Value of -compound option; specifies + * whether the menubutton should show both an + * image and text, and, if so, how. */ enum direction direction; /* Direction for where to pop the menu. Valid * directions are "above", "below", "left", * "right", and "flush". "flush" means that @@ -177,7 +181,8 @@ typedef struct { char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ - int flags; /* Various flags; see below for definitions */ + int flags; /* Various flags; see below for + * definitions. */ } TkMenuButton; /* diff --git a/generic/tkOption.c b/generic/tkOption.c index b930f8c..c8c1414 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.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: tkOption.c,v 1.20 2007/05/03 15:21:32 dkf Exp $ + * RCS: @(#) $Id: tkOption.c,v 1.20.2.1 2007/06/25 19:12:13 dgp Exp $ */ #include "tkPort.h" @@ -180,7 +180,7 @@ typedef struct StackLevel { } StackLevel; typedef struct ThreadSpecificData { - int initialized; /* 0 means the ThreadSpecific Data structure + int initialized; /* 0 means the ThreadSpecific Data structure * for the current thread needs to be * initialized. */ ElArray *stacks[NUM_STACKS]; @@ -193,9 +193,9 @@ typedef struct ThreadSpecificData { * This array grows dynamically to become as large as needed. */ - StackLevel *levels; /* Array describing current stack. */ - int numLevels; /* Total space allocated. */ - int curLevel; /* Highest level currently in use. Note: + StackLevel *levels; /* Array describing current stack. */ + int numLevels; /* Total space allocated. */ + int curLevel; /* Highest level currently in use. Note: * curLevel is never 0! (I don't remember why * anymore...) */ int serial; /* A serial number for all options entered @@ -204,9 +204,8 @@ typedef struct ThreadSpecificData { * used in computing option priorities, so * that the most recent entry wins when * choosing between options at the same - * priority level. - */ - Element defaultMatch; /* Special "no match" Element to use as + * priority level. */ + Element defaultMatch; /* Special "no match" Element to use as * default for searches.*/ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -267,7 +266,7 @@ Tk_AddOption( #define TMP_SIZE 100 char tmp[TMP_SIZE+1]; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->mainPtr->optionRootPtr == NULL) { OptionInit(winPtr->mainPtr); @@ -339,7 +338,8 @@ Tk_AddOption( if (count == 0) { newEl.child.arrayPtr = NewArray(5); *arrayPtrPtr = ExtendArray(*arrayPtrPtr, &newEl); - arrayPtrPtr = &((*arrayPtrPtr)->nextToUse[-1].child.arrayPtr); + arrayPtrPtr = &((*arrayPtrPtr) + ->nextToUse[-1].child.arrayPtr); break; } if ((elPtr->nameUid == newEl.nameUid) @@ -414,7 +414,7 @@ Tk_GetOption( StackLevel *levelPtr; int stackDepth[NUM_STACKS]; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Note: no need to call OptionInit here: it will be done by the @@ -619,7 +619,7 @@ Tk_OptionObjCmd( Tk_Window tkwin = (Tk_Window) clientData; int index, result; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static CONST char *optionCmds[] = { "add", "clear", "get", "readfile", NULL @@ -744,14 +744,14 @@ TkOptionDeadWindow( register TkWindow *winPtr) /* Window to be cleaned up. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * If this window is in the option stacks, then clear the stacks. * * XXX: OptionThreadExitProc will be invoked before DeleteWindowsExitProc * XXX: if it is thread-specific (which it should be), invalidating the - * XXX: tsd. Tk shutdown needs to be verified to handle this correctly. + * XXX: tsd. Tk shutdown needs to be verified to handle this correctly. */ if (tsdPtr->initialized && (winPtr->optionLevel != -1)) { @@ -800,7 +800,7 @@ TkOptionClassChanged( int i, j, *basePtr; ElArray *arrayPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->optionLevel == -1) { return; @@ -880,7 +880,7 @@ ParsePriority( priority = strtoul(string, &end, 0); if ((end == string) || (*end != 0) || (priority < 0) || (priority > 100)) { - Tcl_AppendResult(interp, "bad priority level \"", string, + Tcl_AppendResult(interp, "bad priority level \"", string, "\": must be widgetDefault, startupFile, userDefault, ", "interactive, or a number between 0 and 100", NULL); return -1; @@ -1084,9 +1084,9 @@ ReadOptionFile( */ if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't read options from a file in a", - " safe interpreter", NULL); - return TCL_ERROR; + Tcl_AppendResult(interp, "can't read options from a file in a", + " safe interpreter", NULL); + return TCL_ERROR; } realName = Tcl_TranslateFileName(interp, fileName, &newName); @@ -1096,7 +1096,7 @@ ReadOptionFile( chan = Tcl_OpenFileChannel(interp, realName, "r", 0); Tcl_DStringFree(&newName); if (chan == NULL) { - Tcl_ResetResult(interp); + Tcl_ResetResult(interp); Tcl_AppendResult(interp, "couldn't open \"", fileName, "\": ", Tcl_PosixError(interp), NULL); return TCL_ERROR; @@ -1237,7 +1237,7 @@ SetupStacks( register StackLevel *levelPtr; register ElArray *arrayPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * The following array defines the order in which the current stacks are @@ -1399,15 +1399,15 @@ ExtendStacks( register int count; register Element *elPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (elPtr = arrayPtr->els, count = arrayPtr->numUsed; count > 0; elPtr++, count--) { if (!(elPtr->flags & (NODE|WILDCARD)) && !leaf) { continue; } - tsdPtr->stacks[elPtr->flags] = ExtendArray( - tsdPtr->stacks[elPtr->flags], elPtr); + tsdPtr->stacks[elPtr->flags] = + ExtendArray(tsdPtr->stacks[elPtr->flags], elPtr); } } @@ -1432,7 +1432,7 @@ OptionThreadExitProc( ClientData clientData) /* not used */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->initialized) { int i; @@ -1470,7 +1470,7 @@ OptionInit( int i; Tcl_Interp *interp; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Element *defaultMatchPtr = &tsdPtr->defaultMatch; /* @@ -1478,14 +1478,14 @@ OptionInit( */ if (tsdPtr->initialized == 0) { - tsdPtr->initialized = 1; - tsdPtr->cachedWindow = NULL; + tsdPtr->initialized = 1; + tsdPtr->cachedWindow = NULL; tsdPtr->numLevels = 5; tsdPtr->curLevel = -1; tsdPtr->serial = 0; - tsdPtr->levels = (StackLevel *) ckalloc((unsigned) - (5*sizeof(StackLevel))); + tsdPtr->levels = (StackLevel *) + ckalloc((unsigned) (5*sizeof(StackLevel))); for (i = 0; i < NUM_STACKS; i++) { tsdPtr->stacks[i] = NewArray(10); tsdPtr->levels[0].bases[i] = 0; diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 9effd23..e23cf68 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -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: tkPlace.c,v 1.20 2007/01/05 00:00:50 nijtmans Exp $ + * RCS: @(#) $Id: tkPlace.c,v 1.20.2.1 2007/06/25 19:12:13 dgp Exp $ */ #include "tkPort.h" @@ -58,12 +58,14 @@ typedef struct Slave { int x, y; /* X and Y pixel coordinates for tkwin. */ Tcl_Obj *xPtr, *yPtr; /* Tcl_Obj rep's of x, y coords, to keep pixel - * spec. information */ + * spec. information. */ double relX, relY; /* X and Y coordinates relative to size of * master. */ int width, height; /* Absolute dimensions for tkwin. */ - Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel spec */ - Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel spec */ + Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel + * spec. */ + Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel + * spec. */ double relWidth, relHeight; /* Dimensions for tkwin relative to size of * master. */ Tcl_Obj *relWidthPtr; @@ -154,9 +156,9 @@ static void PlaceLostSlaveProc(ClientData clientData, Tk_Window tkwin); static const Tk_GeomMgr placerType = { - "place", /* name */ - PlaceRequestProc, /* requestProc */ - PlaceLostSlaveProc, /* lostSlaveProc */ + "place", /* name */ + PlaceRequestProc, /* requestProc */ + PlaceLostSlaveProc, /* lostSlaveProc */ }; /* @@ -170,7 +172,7 @@ static int ConfigureSlave(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *CONST objv[]); static int PlaceInfoCommand(Tcl_Interp *interp, Tk_Window tkwin); static Slave * CreateSlave(Tk_Window tkwin, Tk_OptionTable table); -static void FreeSlave(Slave *slavePtr); +static void FreeSlave(Slave *slavePtr); static Slave * FindSlave(Tk_Window tkwin); static Master * CreateMaster(Tk_Window tkwin); static Master * FindMaster(Tk_Window tkwin); @@ -380,20 +382,25 @@ CreateSlave( TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &isNew); - if (isNew) { - slavePtr = (Slave *) ckalloc(sizeof(Slave)); - memset(slavePtr, 0, sizeof(Slave)); - slavePtr->tkwin = tkwin; - slavePtr->inTkwin = None; - slavePtr->anchor = TK_ANCHOR_NW; - slavePtr->borderMode = BM_INSIDE; - slavePtr->optionTable = table; - Tcl_SetHashValue(hPtr, slavePtr); - Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, - (ClientData) slavePtr); - } else { - slavePtr = (Slave *) Tcl_GetHashValue(hPtr); + if (!isNew) { + return (Slave *) Tcl_GetHashValue(hPtr); } + + /* + * No preexisting slave structure for that window, so make a new one and + * populate it with some default values. + */ + + slavePtr = (Slave *) ckalloc(sizeof(Slave)); + memset(slavePtr, 0, sizeof(Slave)); + slavePtr->tkwin = tkwin; + slavePtr->inTkwin = None; + slavePtr->anchor = TK_ANCHOR_NW; + slavePtr->borderMode = BM_INSIDE; + slavePtr->optionTable = table; + Tcl_SetHashValue(hPtr, slavePtr); + Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, + (ClientData) slavePtr); return slavePtr; } @@ -446,7 +453,7 @@ FindSlave( { Tcl_HashEntry *hPtr; register Slave *slavePtr; - TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin); if (hPtr == NULL) { @@ -524,7 +531,7 @@ CreateMaster( Tcl_HashEntry *hPtr; register Master *masterPtr; int isNew; - TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *) tkwin, &isNew); if (isNew) { @@ -566,7 +573,7 @@ FindMaster( { Tcl_HashEntry *hPtr; register Master *masterPtr; - TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin); if (hPtr == NULL) { @@ -703,8 +710,8 @@ ConfigureSlave( */ if (masterWin == NULL) { - masterWin = Tk_Parent(slavePtr->tkwin); - slavePtr->inTkwin = masterWin; + masterWin = Tk_Parent(slavePtr->tkwin); + slavePtr->inTkwin = masterWin; } /* @@ -860,13 +867,13 @@ RecomputePlacement( if (slavePtr->borderMode == BM_INSIDE) { masterX = Tk_InternalBorderLeft(masterPtr->tkwin); masterY = Tk_InternalBorderTop(masterPtr->tkwin); - masterWidth -= masterX + Tk_InternalBorderRight(masterPtr->tkwin); - masterHeight -= masterY + + masterWidth -= masterX + Tk_InternalBorderRight(masterPtr->tkwin); + masterHeight -= masterY + Tk_InternalBorderBottom(masterPtr->tkwin); } else if (slavePtr->borderMode == BM_OUTSIDE) { masterX = masterY = -Tk_Changes(masterPtr->tkwin)->border_width; - masterWidth -= 2 * masterX; - masterHeight -= 2 * masterY; + masterWidth -= 2 * masterX; + masterHeight -= 2 * masterY; } /* @@ -1104,7 +1111,7 @@ SlaveStructureProc( XEvent *eventPtr) /* Describes what just happened. */ { register Slave *slavePtr = (Slave *) clientData; - TkDisplay * dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; if (eventPtr->type == DestroyNotify) { if (slavePtr->masterPtr != NULL) { @@ -1182,7 +1189,7 @@ PlaceLostSlaveProc( Tk_Window tkwin) /* Tk's handle for the slave window. */ { register Slave *slavePtr = (Slave *) clientData; - TkDisplay * dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; + TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr; if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); @@ -1190,7 +1197,7 @@ PlaceLostSlaveProc( Tk_UnmapWindow(tkwin); UnlinkSlave(slavePtr); Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable, - (char *) tkwin)); + (char *) tkwin)); Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, (ClientData) slavePtr); FreeSlave(slavePtr); diff --git a/generic/tkScale.c b/generic/tkScale.c index 2e371b6..36ca7e5 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScale.c,v 1.24 2007/01/03 05:06:26 nijtmans Exp $ + * RCS: @(#) $Id: tkScale.c,v 1.24.2.1 2007/06/25 19:12:13 dgp Exp $ */ #include "tkPort.h" @@ -50,15 +50,15 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_BG_COLOR, -1, Tk_Offset(TkScale, bgBorder), 0, (ClientData) DEF_SCALE_BG_MONO, 0}, {TK_OPTION_DOUBLE, "-bigincrement", "bigIncrement", "BigIncrement", - DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement), - 0, 0, 0}, + DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement), + 0, 0, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0, (ClientData) "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_SCALE_BORDER_WIDTH, -1, Tk_Offset(TkScale, borderWidth), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_SCALE_COMMAND, -1, Tk_Offset(TkScale, command), TK_OPTION_NULL_OK, 0, 0}, @@ -67,20 +67,20 @@ static const Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INT, "-digits", "digits", "Digits", DEF_SCALE_DIGITS, -1, Tk_Offset(TkScale, digits), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, -1, 0, (ClientData) "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_SCALE_FONT, -1, Tk_Offset(TkScale, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_SCALE_FG_COLOR, -1, Tk_Offset(TkScale, textColorPtr), 0, - (ClientData) DEF_SCALE_FG_MONO, 0}, + (ClientData) DEF_SCALE_FG_MONO, 0}, {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, -1, - Tk_Offset(TkScale, fromValue), 0, 0, 0}, + Tk_Offset(TkScale, fromValue), 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_SCALE_HIGHLIGHT_BG_COLOR, -1, Tk_Offset(TkScale, highlightBorder), - 0, (ClientData) DEF_SCALE_HIGHLIGHT_BG_MONO, 0}, + 0, (ClientData) DEF_SCALE_HIGHLIGHT_BG_MONO, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_SCALE_HIGHLIGHT, -1, Tk_Offset(TkScale, highlightColorPtr), 0, 0, 0}, @@ -93,42 +93,42 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_PIXELS, "-length", "length", "Length", DEF_SCALE_LENGTH, -1, Tk_Offset(TkScale, length), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", - DEF_SCALE_ORIENT, -1, Tk_Offset(TkScale, orient), - 0, (ClientData) orientStrings, 0}, + DEF_SCALE_ORIENT, -1, Tk_Offset(TkScale, orient), + 0, (ClientData) orientStrings, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_SCALE_RELIEF, -1, Tk_Offset(TkScale, relief), 0, 0, 0}, {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", - DEF_SCALE_REPEAT_DELAY, -1, Tk_Offset(TkScale, repeatDelay), - 0, 0, 0}, + DEF_SCALE_REPEAT_DELAY, -1, Tk_Offset(TkScale, repeatDelay), + 0, 0, 0}, {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", - DEF_SCALE_REPEAT_INTERVAL, -1, Tk_Offset(TkScale, repeatInterval), - 0, 0, 0}, + DEF_SCALE_REPEAT_INTERVAL, -1, Tk_Offset(TkScale, repeatInterval), + 0, 0, 0}, {TK_OPTION_DOUBLE, "-resolution", "resolution", "Resolution", - DEF_SCALE_RESOLUTION, -1, Tk_Offset(TkScale, resolution), - 0, 0, 0}, + DEF_SCALE_RESOLUTION, -1, Tk_Offset(TkScale, resolution), + 0, 0, 0}, {TK_OPTION_BOOLEAN, "-showvalue", "showValue", "ShowValue", - DEF_SCALE_SHOW_VALUE, -1, Tk_Offset(TkScale, showValue), - 0, 0, 0}, + DEF_SCALE_SHOW_VALUE, -1, Tk_Offset(TkScale, showValue), + 0, 0, 0}, {TK_OPTION_PIXELS, "-sliderlength", "sliderLength", "SliderLength", - DEF_SCALE_SLIDER_LENGTH, -1, Tk_Offset(TkScale, sliderLength), - 0, 0, 0}, + DEF_SCALE_SLIDER_LENGTH, -1, Tk_Offset(TkScale, sliderLength), + 0, 0, 0}, {TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief", DEF_SCALE_SLIDER_RELIEF, -1, Tk_Offset(TkScale, sliderRelief), - 0, 0, 0}, + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", - DEF_SCALE_STATE, -1, Tk_Offset(TkScale, state), - 0, (ClientData) stateStrings, 0}, + DEF_SCALE_STATE, -1, Tk_Offset(TkScale, state), + 0, (ClientData) stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_SCALE_TAKE_FOCUS, Tk_Offset(TkScale, takeFocusPtr), -1, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-tickinterval", "tickInterval", "TickInterval", - DEF_SCALE_TICK_INTERVAL, -1, Tk_Offset(TkScale, tickInterval), - 0, 0, 0}, + DEF_SCALE_TICK_INTERVAL, -1, Tk_Offset(TkScale, tickInterval), + 0, 0, 0}, {TK_OPTION_DOUBLE, "-to", "to", "To", - DEF_SCALE_TO, -1, Tk_Offset(TkScale, toValue), 0, 0, 0}, + DEF_SCALE_TO, -1, Tk_Offset(TkScale, toValue), 0, 0, 0}, {TK_OPTION_COLOR, "-troughcolor", "troughColor", "Background", - DEF_SCALE_TROUGH_COLOR, -1, Tk_Offset(TkScale, troughColorPtr), - 0, (ClientData) DEF_SCALE_TROUGH_MONO, 0}, + DEF_SCALE_TROUGH_COLOR, -1, Tk_Offset(TkScale, troughColorPtr), + 0, (ClientData) DEF_SCALE_TROUGH_MONO, 0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", DEF_SCALE_VARIABLE, Tk_Offset(TkScale, varNamePtr), -1, TK_OPTION_NULL_OK, 0, 0}, @@ -217,7 +217,7 @@ Tk_ScaleObjCmd( } tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), - Tcl_GetString(objv[1]), NULL); + Tcl_GetString(objv[1]), NULL); if (tkwin == NULL) { return TCL_ERROR; } @@ -338,11 +338,11 @@ ScaleWidgetObjCmd( int index, result; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, - "option", 0, &index); + "option", 0, &index); if (result != TCL_OK) { return result; } @@ -620,10 +620,10 @@ ConfigureScale( */ scalePtr->fromValue = TkRoundToResolution(scalePtr, - scalePtr->fromValue); + scalePtr->fromValue); scalePtr->toValue = TkRoundToResolution(scalePtr, scalePtr->toValue); scalePtr->tickInterval = TkRoundToResolution(scalePtr, - scalePtr->tickInterval); + scalePtr->tickInterval); /* * Make sure that the tick interval has the right sign so that @@ -648,7 +648,7 @@ ConfigureScale( break; } if (!error) { - Tk_FreeSavedOptions(&savedOptions); + Tk_FreeSavedOptions(&savedOptions); } /* @@ -678,27 +678,26 @@ ConfigureScale( valuePtr, &varValue) != TCL_OK)) { ScaleSetVariable(scalePtr); } else { - char varString[TCL_DOUBLE_SPACE]; - char scaleString[TCL_DOUBLE_SPACE]; + char varString[TCL_DOUBLE_SPACE], scaleString[TCL_DOUBLE_SPACE]; + sprintf(varString, scalePtr->format, varValue); sprintf(scaleString, scalePtr->format, scalePtr->value); if (strcmp(varString, scaleString)) { ScaleSetVariable(scalePtr); } } - Tcl_TraceVar(interp, Tcl_GetString(scalePtr->varNamePtr), - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ScaleVarProc, (ClientData) scalePtr); + Tcl_TraceVar(interp, Tcl_GetString(scalePtr->varNamePtr), + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + ScaleVarProc, (ClientData) scalePtr); } ScaleWorldChanged((ClientData) scalePtr); if (error) { - Tcl_SetObjResult(interp, errorResult); + Tcl_SetObjResult(interp, errorResult); Tcl_DecrRefCount(errorResult); return TCL_ERROR; - } else { - return TCL_OK; } + return TCL_OK; } /* @@ -1212,10 +1211,10 @@ ScaleVarProc( } resultStr = NULL; valuePtr = Tcl_ObjGetVar2(interp, scalePtr->varNamePtr, NULL, - TCL_GLOBAL_ONLY); + TCL_GLOBAL_ONLY); result = Tcl_GetDoubleFromObj(interp, valuePtr, &value); if (result != TCL_OK) { - resultStr = "can't assign non-numeric value to scale variable"; + resultStr = "can't assign non-numeric value to scale variable"; ScaleSetVariable(scalePtr); } else { scalePtr->value = TkRoundToResolution(scalePtr, value); diff --git a/generic/tkSelect.h b/generic/tkSelect.h index 784dedf..115f6e0 100644 --- a/generic/tkSelect.h +++ b/generic/tkSelect.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkSelect.h,v 1.6 2005/11/27 02:36:14 das Exp $ + * RCS: @(#) $Id: tkSelect.h,v 1.6.2.1 2007/06/25 19:12:13 dgp Exp $ */ #ifndef _TKSELECT @@ -37,7 +37,7 @@ typedef struct TkSelectionInfo { ClientData clearData; /* Info to pass to clearProc. */ struct TkSelectionInfo *nextPtr; /* Next in list of current selections on this - * display. NULL means end of list */ + * display. NULL means end of list. */ } TkSelectionInfo; /* @@ -47,7 +47,7 @@ typedef struct TkSelectionInfo { */ typedef struct TkSelHandler { - Atom selection; /* Selection name, e.g. XA_PRIMARY */ + Atom selection; /* Selection name, e.g. XA_PRIMARY. */ Atom target; /* Target type for selection conversion, such * as TARGETS or STRING. */ Atom format; /* Format in which selection info will be diff --git a/generic/tkText.h b/generic/tkText.h index 5ac25aa..2974009 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.h,v 1.31 2007/01/18 23:20:37 nijtmans Exp $ + * RCS: @(#) $Id: tkText.h,v 1.31.2.1 2007/06/25 19:12:13 dgp Exp $ */ #ifndef _TKTEXT @@ -120,7 +120,7 @@ typedef struct TkTextEmbWindow { * temporary value, copied from 'clients', to * make option table updating easier. NULL * means that the window hasn't been created - * yet. */ + * yet. */ TkTextLine *linePtr; /* Line structure that contains this * window. */ char *create; /* Script to create window on-demand. NULL @@ -149,12 +149,12 @@ typedef struct TkTextEmbImage { * text widget. This is used when the image * changes or is deleted. */ TkTextLine *linePtr; /* Line structure that contains this image. */ - char *imageString; /* Name of the image for this segment */ + char *imageString; /* Name of the image for this segment. */ char *imageName; /* Name used by text widget to identify this - * image. May be unique-ified */ + * image. May be unique-ified. */ char *name; /* Name used in the hash table. Used by * "image names" to identify this instance of - * the image */ + * the image. */ Tk_Image image; /* Image for this segment. NULL means that the * image hasn't been created yet. */ int align; /* How to align image in vertical space. See @@ -172,7 +172,8 @@ typedef struct TkTextEmbImage { */ typedef struct TkTextSegment { - const struct Tk_SegType *typePtr; /* Pointer to record describing segment's + const struct Tk_SegType *typePtr; + /* Pointer to record describing segment's * type. */ struct TkTextSegment *nextPtr; /* Next in list of segments for this line, or @@ -305,9 +306,10 @@ typedef struct TkTextTag { * freed explicitly. For 'sel' tags this is * just a static string, so again need not be * freed. */ - const struct TkText*textPtr;/* If non-NULL, then this tag only applies to - * the given text widget (when there are peer - * widgets). */ + const struct TkText *textPtr; + /* If non-NULL, then this tag only applies to + * the given text widget (when there are peer + * widgets). */ int priority; /* Priority of this tag within widget. 0 means * lowest priority. Exactly one tag has each * integer value between 0 and numTags-1. */ @@ -317,7 +319,7 @@ typedef struct TkTextTag { * there is no information about the tag. One * or more children of the node do contain * information about the tag. */ - int toggleCount; /* Total number of tag toggles */ + int toggleCount; /* Total number of tag toggles. */ /* * Information for displaying text with this tag. The information belows @@ -330,7 +332,7 @@ typedef struct TkTextTag { Tk_3DBorder border; /* Used for drawing background. NULL means no * value specified here. */ int borderWidth; /* Width of 3-D border for background. */ - Tcl_Obj* borderWidthPtr; /* Width of 3-D border for background. */ + Tcl_Obj *borderWidthPtr; /* Width of 3-D border for background. */ char *reliefString; /* -relief option string (malloc-ed). NULL * means option not specified. */ int relief; /* 3-D relief for background. */ @@ -393,8 +395,8 @@ typedef struct TkTextTag { struct TkTextTabArray *tabArrayPtr; /* Info about tabs for tag (malloc-ed) or * NULL. Corresponds to tabString. */ - int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if - * not specified). */ + int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if + * not specified). */ char *underlineString; /* -underline option string (malloc-ed). NULL * means option not specified. */ int underline; /* Non-zero means draw underline underneath @@ -414,10 +416,10 @@ typedef struct TkTextTag { * (so need to redisplay if tag changes). */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - int affectsDisplayGeometry; /* Non-zero means that this tag affects the - * size with which information is displayed on - * the screen (so need to recalculate line - * dimensions if tag changes). */ + int affectsDisplayGeometry; /* Non-zero means that this tag affects the + * size with which information is displayed on + * the screen (so need to recalculate line + * dimensions if tag changes). */ } TkTextTag; #define TK_TAG_AFFECTS_DISPLAY 0x1 @@ -518,8 +520,7 @@ typedef enum { */ typedef struct TkSharedText { - int refCount; /* Reference count this shared object */ - + int refCount; /* Reference count this shared object. */ TkTextBTree tree; /* B-tree representation of text and tags for * widget. */ Tcl_HashTable tagTable; /* Hash table that maps from tag names to @@ -548,33 +549,33 @@ typedef struct TkSharedText { * exist, so the table hasn't been created. * Each "object" used for this table is the * name of a tag. */ - int stateEpoch; /* This is incremented each time the B-tree's - * contents change structurally, and means - * that any cached TkTextIndex objects are no - * longer valid. */ + int stateEpoch; /* This is incremented each time the B-tree's + * contents change structurally, and means + * that any cached TkTextIndex objects are no + * longer valid. */ /* * Information related to the undo/redo functonality */ - TkUndoRedoStack *undoStack; /* The undo/redo stack */ + TkUndoRedoStack *undoStack; /* The undo/redo stack. */ int undo; /* Non-zero means the undo/redo behaviour is - * enabled */ + * enabled. */ int maxUndo; /* The maximum depth of the undo stack * expressed as the maximum number of compound - * statements */ + * statements. */ int autoSeparators; /* Non-zero means the separators will be - * inserted automatically */ + * inserted automatically. */ int modifiedSet; /* Flag indicating that the 'dirtynesss' of * the text widget has been expplicitly set. */ int isDirty; /* Flag indicating the 'dirtynesss' of the * text widget. If the flag is not zero, * unsaved modifications have been applied to - * the text widget */ + * the text widget. */ int isDirtyIncrement; /* Amount with which the isDirty flag is - * incremented every edit action */ + * incremented every edit action. */ TkTextEditMode lastEditMode;/* Keeps track of what the last edit mode - * was */ + * was. */ /* * Keep track of all the peers @@ -595,14 +596,13 @@ typedef struct TkText { */ TkSharedText *sharedTextPtr;/* Shared section of all peers. */ - struct TkText *next; /* Next in list of linked peers. */ - TkTextLine *start; /* First B-tree line to show, or NULL to start - * at the beginning. */ - TkTextLine *end; /* Last B-tree line to show, or NULL for up to - * the end. */ - int pixelReference; /* Counter into the current tree reference - * index corresponding to this widget */ - + struct TkText *next; /* Next in list of linked peers. */ + TkTextLine *start; /* First B-tree line to show, or NULL to start + * at the beginning. */ + TkTextLine *end; /* Last B-tree line to show, or NULL for up to + * the end. */ + int pixelReference; /* Counter into the current tree reference + * index corresponding to this widget. */ int abortSelections; /* Set to 1 whenever the text is modified in a * way that interferes with selection * retrieval: used to abort incremental @@ -624,6 +624,7 @@ typedef struct TkText { Tcl_Command widgetCmd; /* Token for text's widget command. */ int state; /* Either STATE_NORMAL or STATE_DISABLED. A * text widget is read-only when disabled. */ + /* * Default information for displaying (may be overridden by tags applied * to ranges of characters). @@ -656,12 +657,12 @@ typedef struct TkText { * for the same text line. */ int spacing3; /* Default extra spacing below last display * line for each text line. */ - Tcl_Obj *tabOptionPtr; /* Value of -tabs option string */ + Tcl_Obj *tabOptionPtr; /* Value of -tabs option string. */ TkTextTabArray *tabArrayPtr; /* Information about tab stops (malloc'ed). * NULL means perform default tabbing * behavior. */ - int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ + int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ /* * Additional information used for displaying: @@ -693,9 +694,9 @@ typedef struct TkText { Tk_3DBorder inactiveSelBorder; /* Border and background for selected * characters when they don't have the - * focus. */ + * focus. */ int selBorderWidth; /* Width of border around selection. */ - Tcl_Obj* selBorderWidthPtr; /* Width of border around selection. */ + Tcl_Obj *selBorderWidthPtr; /* Width of border around selection. */ XColor *selFgColorPtr; /* Foreground color for selected text. This is * a copy of information in *selTagPtr, so it * shouldn't be explicitly freed. */ @@ -752,28 +753,25 @@ typedef struct TkText { * vertical scrollbar when view changes. */ int flags; /* Miscellaneous flags; see below for * definitions. */ - Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ + int refCount; /* Number of cached TkTextIndex objects + * refering to us. */ + int insertCursorType; /* 0 = standard insertion cursor, 1 = block + * cursor. */ - int refCount; /* Number of cached TkTextIndex objects - * refering to us */ - int insertCursorType; /* 0 = standard insertion cursor, 1 = block - * cursor. */ /* * Copies of information from the shared section relating to the undo/redo * functonality */ int undo; /* Non-zero means the undo/redo behaviour is - * enabled */ - + * enabled. */ int maxUndo; /* The maximum depth of the undo stack * expressed as the maximum number of compound - * statements */ - + * statements. */ int autoSeparators; /* Non-zero means the separators will be - * inserted automatically */ + * inserted automatically. */ } TkText; /* @@ -790,10 +788,10 @@ typedef struct TkText { * duration of button presses. * UPDATE_SCROLLBARS: Non-zero means scrollbar(s) should be updated * during next redisplay operation. - * NEED_REPICK This appears unused and should probably be - * ignored - * OPTIONS_FREED The widget's options have been freed - * DESTROYED The widget is going away + * NEED_REPICK This appears unused and should probably be + * ignored. + * OPTIONS_FREED The widget's options have been freed. + * DESTROYED The widget is going away. */ #define GOT_SELECTION 1 @@ -879,62 +877,62 @@ typedef int TkTextCountType; #define LOTSA_TAGS 1000 typedef struct TkTextElideInfo { - int numTags; /* Total tags in widget */ - int elide; /* Is the state currently elided */ - int elidePriority; /* Tag priority controlling elide state */ - TkTextSegment *segPtr; /* Segment to look at next */ - int segOffset; /* Offset of segment within line */ + int numTags; /* Total tags in widget. */ + int elide; /* Is the state currently elided. */ + int elidePriority; /* Tag priority controlling elide state. */ + TkTextSegment *segPtr; /* Segment to look at next. */ + int segOffset; /* Offset of segment within line. */ int deftagCnts[LOTSA_TAGS]; TkTextTag *deftagPtrs[LOTSA_TAGS]; - int *tagCnts; /* 0 or 1 depending if the tag with that - * priority is on or off */ - TkTextTag **tagPtrs; /* Only filled with a tagPtr if the - * corresponding tagCnt is 1 */ + int *tagCnts; /* 0 or 1 depending if the tag with that + * priority is on or off. */ + TkTextTag **tagPtrs; /* Only filled with a tagPtr if the + * corresponding tagCnt is 1. */ } TkTextElideInfo; /* - * The constant below is used to specify a line when what is really - * wanted is the entire text. For now, just use a very big number. + * The constant below is used to specify a line when what is really wanted is + * the entire text. For now, just use a very big number. */ -#define TK_END_OF_TEXT 1000000 +#define TK_END_OF_TEXT 1000000 /* * The following definition specifies the maximum number of characters needed * in a string to hold a position specifier. */ -#define TK_POS_CHARS 30 +#define TK_POS_CHARS 30 /* * Mask used for those options which may impact the pixel height calculations * of individual lines displayed in the widget. */ -#define TK_TEXT_LINE_GEOMETRY 1 +#define TK_TEXT_LINE_GEOMETRY 1 /* * Mask used for those options which may impact the start and end lines used * in the widget. */ -#define TK_TEXT_LINE_RANGE 2 +#define TK_TEXT_LINE_RANGE 2 /* * Used as 'action' values in calls to TkTextInvalidateLineMetrics */ -#define TK_TEXT_INVALIDATE_ONLY 0 -#define TK_TEXT_INVALIDATE_INSERT 1 -#define TK_TEXT_INVALIDATE_DELETE 2 +#define TK_TEXT_INVALIDATE_ONLY 0 +#define TK_TEXT_INVALIDATE_INSERT 1 +#define TK_TEXT_INVALIDATE_DELETE 2 /* * Used as special 'pickPlace' values in calls to TkTextSetYView. Zero or * positive values indicate a number of pixels. */ -#define TK_TEXT_PICKPLACE -1 -#define TK_TEXT_NOPIXELADJUST -2 +#define TK_TEXT_PICKPLACE -1 +#define TK_TEXT_NOPIXELADJUST -2 /* * Declarations for variables shared among the text-related files: @@ -1075,7 +1073,7 @@ MODULE_SCOPE void TkTextIndexForwChars(const TkText *textPtr, TkTextIndex *dstPtr, TkTextCountType type); MODULE_SCOPE void TkTextIndexOfX(TkText *textPtr, int x, TkTextIndex *indexPtr); -MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr, +MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr, const TkTextIndex *indexPtr); MODULE_SCOPE TkTextSegment *TkTextIndexToSeg(const TkTextIndex *indexPtr, int *offsetPtr); @@ -1096,7 +1094,7 @@ MODULE_SCOPE int TkTextIsElided(const TkText *textPtr, MODULE_SCOPE TkTextIndex *TkTextMakeByteIndex(TkTextBTree tree, const TkText *textPtr, int lineIndex, int byteIndex, TkTextIndex *indexPtr); -MODULE_SCOPE int TkTextMakePixelIndex(TkText *textPtr, +MODULE_SCOPE int TkTextMakePixelIndex(TkText *textPtr, int pixelIndex, TkTextIndex *indexPtr); MODULE_SCOPE void TkTextInvalidateLineMetrics( TkSharedText *sharedTextPtr, TkText *textPtr, @@ -1118,7 +1116,7 @@ MODULE_SCOPE void TkTextPixelIndex(TkText *textPtr, int x, int y, TkTextIndex *indexPtr, int *nearest); MODULE_SCOPE int TkTextPrintIndex(const TkText *textPtr, const TkTextIndex *indexPtr, char *string); -MODULE_SCOPE Tcl_Obj* TkTextNewIndexObj(TkText *textPtr, +MODULE_SCOPE Tcl_Obj * TkTextNewIndexObj(TkText *textPtr, const TkTextIndex *indexPtr); MODULE_SCOPE void TkTextRedrawRegion(TkText *textPtr, int x, int y, int width, int height); diff --git a/generic/tkUndo.h b/generic/tkUndo.h index 5d50edd..6061549 100644 --- a/generic/tkUndo.h +++ b/generic/tkUndo.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUndo.h,v 1.5 2005/11/27 02:36:14 das Exp $ + * RCS: @(#) $Id: tkUndo.h,v 1.5.2.1 2007/06/25 19:12:13 dgp Exp $ */ #ifndef _TKUNDO @@ -52,13 +52,13 @@ typedef struct TkUndoSubAtom { * apply/revert scripts. If NULL then it is * assumed the apply/revert scripts already * contain everything. */ - TkUndoProc *funcPtr; /* Function pointer for callback to perform + TkUndoProc *funcPtr; /* Function pointer for callback to perform * undo/redo actions. */ - ClientData clientData; /* data for 'funcPtr' */ + ClientData clientData; /* Data for 'funcPtr'. */ Tcl_Obj *action; /* Command to apply the action that was - * taken */ - struct TkUndoSubAtom *next; /* Pointer to the next element in the linked - * list */ + * taken. */ + struct TkUndoSubAtom *next; /* Pointer to the next element in the linked + * list. */ } TkUndoSubAtom; /* @@ -68,11 +68,12 @@ typedef struct TkUndoSubAtom { typedef struct TkUndoAtom { TkUndoAtomType type; /* The type that will trigger the required * action. */ - TkUndoSubAtom *apply; /* Linked list of 'apply' actions to perform - * for this operation. */ - TkUndoSubAtom *revert; /* Linked list of 'revert' actions to perform - * for this operation. */ - struct TkUndoAtom *next; /* Pointer to the next element in the stack */ + TkUndoSubAtom *apply; /* Linked list of 'apply' actions to perform + * for this operation. */ + TkUndoSubAtom *revert; /* Linked list of 'revert' actions to perform + * for this operation. */ + struct TkUndoAtom *next; /* Pointer to the next element in the + * stack. */ } TkUndoAtom; /* @@ -80,10 +81,10 @@ typedef struct TkUndoAtom { */ typedef struct TkUndoRedoStack { - TkUndoAtom *undoStack; /* The undo stack */ - TkUndoAtom *redoStack; /* The redo stack */ + TkUndoAtom *undoStack; /* The undo stack. */ + TkUndoAtom *redoStack; /* The redo stack. */ Tcl_Interp *interp; /* The interpreter in which to execute the - * revert and apply scripts */ + * revert and apply scripts. */ int maxdepth; int depth; } TkUndoRedoStack; |