From dfce4fc83d241943de682a09befb0413b089409b Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 13 Nov 2005 00:45:47 +0000 Subject: ANSIfy --- generic/tkGC.c | 131 +++++----- generic/tkScrollbar.c | 255 ++++++++++---------- generic/tkScrollbar.h | 153 ++++++------ generic/tkUtil.c | 654 +++++++++++++++++++++++++------------------------- 4 files changed, 595 insertions(+), 598 deletions(-) diff --git a/generic/tkGC.c b/generic/tkGC.c index 5bb16f5..d6fb348 100644 --- a/generic/tkGC.c +++ b/generic/tkGC.c @@ -1,26 +1,26 @@ -/* +/* * tkGC.c -- * - * This file maintains a database of read-only graphics contexts - * for the Tk toolkit, in order to allow GC's to be shared. + * This file maintains a database of read-only graphics contexts for the + * Tk toolkit, in order to allow GC's to be shared. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994 Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkGC.c,v 1.5 2004/01/13 02:06:00 davygrvy Exp $ + * RCS: @(#) $Id: tkGC.c,v 1.6 2005/11/13 00:45:47 dkf Exp $ */ #include "tkPort.h" #include "tkInt.h" /* - * One of the following data structures exists for each GC that is - * currently active. The structure is indexed with two hash tables, - * one based on the values in the graphics context and the other - * based on the display and GC identifier. + * One of the following data structures exists for each GC that is currently + * active. The structure is indexed with two hash tables, one based on the + * values in the graphics context and the other based on the display and GC + * identifier. */ typedef struct { @@ -39,43 +39,43 @@ typedef struct { } ValueKey; /* - * Forward declarations for procedures defined in this file: + * Forward declarations for functions defined in this file: */ -static void GCInit _ANSI_ARGS_((TkDisplay *dispPtr)); +static void GCInit(TkDisplay *dispPtr); /* *---------------------------------------------------------------------- * * Tk_GetGC -- * - * Given a desired set of values for a graphics context, find - * a read-only graphics context with the desired values. + * Given a desired set of values for a graphics context, find a read-only + * graphics context with the desired values. * * Results: - * The return value is the X identifer for the desired graphics - * context. The caller should never modify this GC, and should - * call Tk_FreeGC when the GC is no longer needed. + * The return value is the X identifer for the desired graphics context. + * The caller should never modify this GC, and should call Tk_FreeGC when + * the GC is no longer needed. * * Side effects: - * The GC is added to an internal database with a reference count. - * For each call to this procedure, there should eventually be a call - * to Tk_FreeGC, so that the database can be cleaned up when GC's - * aren't needed anymore. + * The GC is added to an internal database with a reference count. For + * each call to this function, there should eventually be a call to + * Tk_FreeGC, so that the database can be cleaned up when GC's aren't + * needed anymore. * *---------------------------------------------------------------------- */ GC -Tk_GetGC(tkwin, valueMask, valuePtr) - Tk_Window tkwin; /* Window in which GC will be used. */ - register unsigned long valueMask; - /* 1 bits correspond to values specified - * in *valuesPtr; other values are set - * from defaults. */ - register XGCValues *valuePtr; - /* Values are specified here for bits set - * in valueMask. */ +Tk_GetGC( + Tk_Window tkwin, /* Window in which GC will be used. */ + register unsigned long valueMask, + /* 1 bits correspond to values specified in + * *valuesPtr; other values are set from + * defaults. */ + register XGCValues *valuePtr) + /* Values are specified here for bits set in + * valueMask. */ { ValueKey valueKey; Tcl_HashEntry *valueHashPtr, *idHashPtr; @@ -89,15 +89,15 @@ Tk_GetGC(tkwin, valueMask, valuePtr) } /* - * Must zero valueKey at start to clear out pad bytes that may be - * part of structure on some systems. + * Must zero valueKey at start to clear out pad bytes that may be part of + * structure on some systems. */ - memset((VOID *) &valueKey, 0, sizeof(valueKey)); + memset((void *) &valueKey, 0, sizeof(valueKey)); /* - * First, check to see if there's already a GC that will work - * for this request (exact matches only, sorry). + * First, check to see if there's already a GC that will work for this + * request (exact matches only, sorry). */ if (valueMask & GCFunction) { @@ -218,7 +218,7 @@ Tk_GetGC(tkwin, valueMask, valuePtr) valueKey.display = Tk_Display(tkwin); valueKey.screenNum = Tk_ScreenNumber(tkwin); valueKey.depth = Tk_Depth(tkwin); - valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable, + valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable, (char *) &valueKey, &new); if (!new) { gcPtr = (TkGC *) Tcl_GetHashValue(valueHashPtr); @@ -227,15 +227,15 @@ Tk_GetGC(tkwin, valueMask, valuePtr) } /* - * No GC is currently available for this set of values. Allocate a - * new GC and add a new structure to the database. + * No GC is currently available for this set of values. Allocate a new GC + * and add a new structure to the database. */ gcPtr = (TkGC *) ckalloc(sizeof(TkGC)); /* - * Find or make a drawable to use to specify the screen and depth - * of the GC. We may have to make a small pixmap, to avoid doing + * Find or make a drawable to use to specify the screen and depth of the + * GC. We may have to make a small pixmap, to avoid doing * Tk_MakeWindowExist on the window. */ @@ -256,7 +256,7 @@ Tk_GetGC(tkwin, valueMask, valuePtr) gcPtr->display = valueKey.display; gcPtr->refCount = 1; gcPtr->valueHashPtr = valueHashPtr; - idHashPtr = Tcl_CreateHashEntry(&dispPtr->gcIdTable, + idHashPtr = Tcl_CreateHashEntry(&dispPtr->gcIdTable, (char *) gcPtr->gc, &new); if (!new) { Tcl_Panic("GC already registered in Tk_GetGC"); @@ -275,23 +275,23 @@ Tk_GetGC(tkwin, valueMask, valuePtr) * * Tk_FreeGC -- * - * This procedure is called to release a graphics context allocated by + * This function is called to release a graphics context allocated by * Tk_GetGC. * * Results: * None. * * Side effects: - * The reference count associated with gc is decremented, and - * gc is officially deallocated if no-one is using it anymore. + * The reference count associated with gc is decremented, and gc is + * officially deallocated if no-one is using it anymore. * *---------------------------------------------------------------------- */ void -Tk_FreeGC(display, gc) - Display *display; /* Display for which gc was allocated. */ - GC gc; /* Graphics context to be released. */ +Tk_FreeGC( + Display *display, /* Display for which gc was allocated. */ + GC gc) /* Graphics context to be released. */ { Tcl_HashEntry *idHashPtr; register TkGC *gcPtr; @@ -302,10 +302,11 @@ Tk_FreeGC(display, gc) } if (dispPtr->gcInit < 0) { /* - * The GCCleanup has been called, and remaining GCs have been - * freed. This may still get called by other things shutting - * down, but the GCs should no longer be in use. + * The GCCleanup has been called, and remaining GCs have been freed. + * This may still get called by other things shutting down, but the + * GCs should no longer be in use. */ + return; } @@ -329,9 +330,8 @@ Tk_FreeGC(display, gc) * * TkGCCleanup -- * - * Frees the structures used for GC management. - * We need to have it called near the end, when other cleanup that - * calls Tk_FreeGC is all done. + * Frees the structures used for GC management. We need to have it called + * near the end, when other cleanup that calls Tk_FreeGC is all done. * * Results: * None. @@ -343,22 +343,23 @@ Tk_FreeGC(display, gc) */ void -TkGCCleanup(dispPtr) - TkDisplay *dispPtr; /* display to clean up resources in */ +TkGCCleanup( + TkDisplay *dispPtr) /* display to clean up resources in */ { Tcl_HashEntry *entryPtr; Tcl_HashSearch search; TkGC *gcPtr; for (entryPtr = Tcl_FirstHashEntry(&dispPtr->gcIdTable, &search); - entryPtr != NULL; - entryPtr = Tcl_NextHashEntry(&search)) { + entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { gcPtr = (TkGC *) Tcl_GetHashValue(entryPtr); + /* - * This call is not needed, as it is only used on Unix to restore - * the Id to the stack pool, and we don't want to use them anymore. + * This call is not needed, as it is only used on Unix to restore the + * Id to the stack pool, and we don't want to use them anymore. * Tk_FreeXId(gcPtr->display, (XID) XGContextFromGC(gcPtr->gc)); */ + XFreeGC(gcPtr->display, gcPtr->gc); Tcl_DeleteHashEntry(gcPtr->valueHashPtr); Tcl_DeleteHashEntry(entryPtr); @@ -386,8 +387,8 @@ TkGCCleanup(dispPtr) */ static void -GCInit(dispPtr) - TkDisplay *dispPtr; +GCInit( + TkDisplay *dispPtr) { if (dispPtr->gcInit < 0) { Tcl_Panic("called GCInit after GCCleanup"); @@ -396,3 +397,11 @@ GCInit(dispPtr) Tcl_InitHashTable(&dispPtr->gcValueTable, sizeof(ValueKey)/sizeof(int)); Tcl_InitHashTable(&dispPtr->gcIdTable, TCL_ONE_WORD_KEYS); } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index dcbb999..5ed8ecb 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -1,18 +1,17 @@ -/* +/* * tkScrollbar.c -- * - * This module implements a scrollbar widgets for the Tk - * toolkit. A scrollbar displays a slider and two arrows; - * mouse clicks on features within the scrollbar cause - * scrolling commands to be invoked. + * This module implements a scrollbar widgets for the Tk toolkit. A + * scrollbar displays a slider and two arrows; mouse clicks on features + * within the scrollbar cause scrolling commands to be invoked. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScrollbar.c,v 1.6 2002/08/05 04:30:40 dgp Exp $ + * RCS: @(#) $Id: tkScrollbar.c,v 1.7 2005/11/13 00:45:47 dkf Exp $ */ #include "tkPort.h" @@ -48,10 +47,8 @@ Tk_ConfigSpec tkpScrollbarConfigSpecs[] = { {TK_CONFIG_BORDER, "-background", "background", "Background", DEF_SCROLLBAR_BG_MONO, Tk_Offset(TkScrollbar, bgBorder), TK_CONFIG_MONO_ONLY}, - {TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL, - (char *) NULL, 0, 0}, - {TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL, - (char *) NULL, 0, 0}, + {TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0}, + {TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0}, {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_SCROLLBAR_BORDER_WIDTH, Tk_Offset(TkScrollbar, borderWidth), 0}, {TK_CONFIG_STRING, "-command", "command", "Command", @@ -93,30 +90,27 @@ Tk_ConfigSpec tkpScrollbarConfigSpecs[] = { TK_CONFIG_MONO_ONLY}, {TK_CONFIG_PIXELS, "-width", "width", "Width", DEF_SCROLLBAR_WIDTH, Tk_Offset(TkScrollbar, width), 0}, - {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, 0} + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0} }; /* - * Forward declarations for procedures defined later in this file: + * Forward declarations for functions defined later in this file: */ -static int ConfigureScrollbar _ANSI_ARGS_((Tcl_Interp *interp, - TkScrollbar *scrollPtr, int argc, CONST char **argv, - int flags)); -static void ScrollbarCmdDeletedProc _ANSI_ARGS_(( - ClientData clientData)); -static int ScrollbarWidgetCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *, int argc, CONST char **argv)); +static int ConfigureScrollbar(Tcl_Interp *interp, + TkScrollbar *scrollPtr, int argc, + CONST char **argv, int flags); +static void ScrollbarCmdDeletedProc(ClientData clientData); +static int ScrollbarWidgetCmd(ClientData clientData, + Tcl_Interp *, int argc, CONST char **argv); /* *-------------------------------------------------------------- * * Tk_ScrollbarCmd -- * - * This procedure is invoked to process the "scrollbar" Tcl - * command. See the user documentation for details on what - * it does. + * This function is invoked to process the "scrollbar" Tcl command. See + * the user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -128,12 +122,11 @@ static int ScrollbarWidgetCmd _ANSI_ARGS_((ClientData clientData, */ int -Tk_ScrollbarCmd(clientData, interp, argc, argv) - ClientData clientData; /* Main window associated with - * interpreter. */ - Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - CONST char **argv; /* Argument strings. */ +Tk_ScrollbarCmd( + ClientData clientData, /* Main window associated with interpreter. */ + Tcl_Interp *interp, /* Current interpreter. */ + int argc, /* Number of arguments. */ + CONST char **argv) /* Argument strings. */ { Tk_Window tkwin = (Tk_Window) clientData; register TkScrollbar *scrollPtr; @@ -141,11 +134,11 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " pathName ?options?\"", (char *) NULL); + argv[0], " pathName ?options?\"", NULL); return TCL_ERROR; } - new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL); + new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], NULL); if (new == NULL) { return TCL_ERROR; } @@ -156,9 +149,9 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) Tk_SetClassProcs(new, &tkpScrollbarProcs, (ClientData) scrollPtr); /* - * Initialize fields that won't be initialized by ConfigureScrollbar, - * or which ConfigureScrollbar expects to have reasonable values - * (e.g. resource pointers). + * Initialize fields that won't be initialized by ConfigureScrollbar, or + * which ConfigureScrollbar expects to have reasonable values (e.g. + * resource pointers). */ scrollPtr->tkwin = new; @@ -212,9 +205,9 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) * * ScrollbarWidgetCmd -- * - * This procedure is invoked to process the Tcl command - * that corresponds to a widget managed by this module. - * See the user documentation for details on what it does. + * This function is invoked to process the Tcl command that corresponds + * to a widget managed by this module. See the user documentation for + * details on what it does. * * Results: * A standard Tcl result. @@ -226,12 +219,11 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) */ static int -ScrollbarWidgetCmd(clientData, interp, argc, argv) - ClientData clientData; /* Information about scrollbar - * widget. */ - Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - CONST char **argv; /* Argument strings. */ +ScrollbarWidgetCmd( + ClientData clientData, /* Information about scrollbar widget. */ + Tcl_Interp *interp, /* Current interpreter. */ + int argc, /* Number of arguments. */ + CONST char **argv) /* Argument strings. */ { register TkScrollbar *scrollPtr = (TkScrollbar *) clientData; int result = TCL_OK; @@ -240,7 +232,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option ?arg arg ...?\"", (char *) NULL); + argv[0], " option ?arg arg ...?\"", NULL); return TCL_ERROR; } Tcl_Preserve((ClientData) scrollPtr); @@ -250,21 +242,21 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) int oldActiveField; if (argc == 2) { switch (scrollPtr->activeField) { - case TOP_ARROW: - Tcl_SetResult(interp, "arrow1", TCL_STATIC); - break; - case SLIDER: - Tcl_SetResult(interp, "slider", TCL_STATIC); - break; - case BOTTOM_ARROW: - Tcl_SetResult(interp, "arrow2", TCL_STATIC); - break; + case TOP_ARROW: + Tcl_SetResult(interp, "arrow1", TCL_STATIC); + break; + case SLIDER: + Tcl_SetResult(interp, "slider", TCL_STATIC); + break; + case BOTTOM_ARROW: + Tcl_SetResult(interp, "arrow2", TCL_STATIC); + break; } goto done; } if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " activate element\"", (char *) NULL); + argv[0], " activate element\"", NULL); goto error; } c = argv[2][0]; @@ -287,7 +279,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " cget option\"", - (char *) NULL); + NULL); goto error; } result = Tk_ConfigureValue(interp, scrollPtr->tkwin, @@ -297,7 +289,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) if (argc == 2) { result = Tk_ConfigureInfo(interp, scrollPtr->tkwin, tkpScrollbarConfigSpecs, (char *) scrollPtr, - (char *) NULL, 0); + NULL, 0); } else if (argc == 3) { result = Tk_ConfigureInfo(interp, scrollPtr->tkwin, tkpScrollbarConfigSpecs, (char *) scrollPtr, argv[2], 0); @@ -312,7 +304,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " delta xDelta yDelta\"", (char *) NULL); + argv[0], " delta xDelta yDelta\"", NULL); goto error; } if ((Tcl_GetInt(interp, argv[2], &xDelta) != TCL_OK) @@ -342,7 +334,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " fraction x y\"", (char *) NULL); + argv[0], " fraction x y\"", NULL); goto error; } if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) @@ -373,7 +365,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " get\"", (char *) NULL); + argv[0], " get\"", NULL); goto error; } if (scrollPtr->flags & NEW_STYLE_COMMANDS) { @@ -381,7 +373,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) Tcl_PrintDouble(interp, scrollPtr->firstFraction, first); Tcl_PrintDouble(interp, scrollPtr->lastFraction, last); - Tcl_AppendResult(interp, first, " ", last, (char *) NULL); + Tcl_AppendResult(interp, first, " ", last, NULL); } else { char buf[TCL_INTEGER_SPACE * 4]; @@ -395,7 +387,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " identify x y\"", (char *) NULL); + argv[0], " identify x y\"", NULL); goto error; } if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) @@ -404,21 +396,21 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) } thing = TkpScrollbarPosition(scrollPtr, x,y); switch (thing) { - case TOP_ARROW: - Tcl_SetResult(interp, "arrow1", TCL_STATIC); - break; - case TOP_GAP: - Tcl_SetResult(interp, "trough1", TCL_STATIC); - break; - case SLIDER: - Tcl_SetResult(interp, "slider", TCL_STATIC); - break; - case BOTTOM_GAP: - Tcl_SetResult(interp, "trough2", TCL_STATIC); - break; - case BOTTOM_ARROW: - Tcl_SetResult(interp, "arrow2", TCL_STATIC); - break; + case TOP_ARROW: + Tcl_SetResult(interp, "arrow1", TCL_STATIC); + break; + case TOP_GAP: + Tcl_SetResult(interp, "trough1", TCL_STATIC); + break; + case SLIDER: + Tcl_SetResult(interp, "slider", TCL_STATIC); + break; + case BOTTOM_GAP: + Tcl_SetResult(interp, "trough2", TCL_STATIC); + break; + case BOTTOM_ARROW: + Tcl_SetResult(interp, "arrow2", TCL_STATIC); + break; } } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) { int totalUnits, windowUnits, firstUnit, lastUnit; @@ -489,8 +481,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " set firstFraction lastFraction\" or \"", argv[0], - " set totalUnits windowUnits firstUnit lastUnit\"", - (char *) NULL); + " set totalUnits windowUnits firstUnit lastUnit\"", NULL); goto error; } TkpComputeScrollbarGeometry(scrollPtr); @@ -498,14 +489,15 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": must be activate, cget, configure, delta, fraction, ", - "get, identify, or set", (char *) NULL); + "get, identify, or set", NULL); goto error; } - done: + + done: Tcl_Release((ClientData) scrollPtr); return result; - error: + error: Tcl_Release((ClientData) scrollPtr); return TCL_ERROR; } @@ -515,32 +507,30 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) * * ConfigureScrollbar -- * - * This procedure is called to process an argv/argc list, plus - * the Tk option database, in order to configure (or - * reconfigure) a scrollbar widget. + * This function is called to process an argv/argc list, plus the Tk + * option database, in order to configure (or reconfigure) a scrollbar + * widget. * * Results: - * The return value is a standard Tcl result. If TCL_ERROR is - * returned, then the interp's result contains an error message. + * The return value is a standard Tcl result. If TCL_ERROR is returned, + * then the interp's result contains an error message. * * Side effects: - * Configuration information, such as colors, border width, - * etc. get set for scrollPtr; old resources get freed, - * if there were any. + * Configuration information, such as colors, border width, etc. get set + * for scrollPtr; old resources get freed, if there were any. * *---------------------------------------------------------------------- */ static int -ConfigureScrollbar(interp, scrollPtr, argc, argv, flags) - Tcl_Interp *interp; /* Used for error reporting. */ - register TkScrollbar *scrollPtr; /* Information about widget; may or - * may not already have values for - * some fields. */ - int argc; /* Number of valid entries in argv. */ - CONST char **argv; /* Arguments. */ - int flags; /* Flags to pass to - * Tk_ConfigureWidget. */ +ConfigureScrollbar( + Tcl_Interp *interp, /* Used for error reporting. */ + register TkScrollbar *scrollPtr, + /* Information about widget; may or may not + * already have values for some fields. */ + int argc, /* Number of valid entries in argv. */ + CONST char **argv, /* Arguments. */ + int flags) /* Flags to pass to Tk_ConfigureWidget. */ { if (Tk_ConfigureWidget(interp, scrollPtr->tkwin, tkpScrollbarConfigSpecs, argc, argv, (char *) scrollPtr, flags) != TCL_OK) { @@ -548,8 +538,8 @@ ConfigureScrollbar(interp, scrollPtr, argc, argv, flags) } /* - * A few options need special processing, such as setting the - * background from a 3-D border. + * A few options need special processing, such as setting the background + * from a 3-D border. */ if (scrollPtr->command != NULL) { @@ -565,10 +555,9 @@ ConfigureScrollbar(interp, scrollPtr, argc, argv, flags) TkpConfigureScrollbar(scrollPtr); /* - * Register the desired geometry for the window (leave enough space - * for the two arrows plus a minimum-size slider, plus border around - * the whole window, if any). Then arrange for the window to be - * redisplayed. + * Register the desired geometry for the window (leave enough space for + * the two arrows plus a minimum-size slider, plus border around the whole + * window, if any). Then arrange for the window to be redisplayed. */ TkpComputeScrollbarGeometry(scrollPtr); @@ -581,23 +570,23 @@ ConfigureScrollbar(interp, scrollPtr, argc, argv, flags) * * TkScrollbarEventProc -- * - * This procedure is invoked by the Tk dispatcher for various - * events on scrollbars. + * This function is invoked by the Tk dispatcher for various events on + * scrollbars. * * Results: * None. * * Side effects: - * When the window gets deleted, internal structures get - * cleaned up. When it gets exposed, it is redisplayed. + * When the window gets deleted, internal structures get cleaned up. + * When it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ void -TkScrollbarEventProc(clientData, eventPtr) - ClientData clientData; /* Information about window. */ - XEvent *eventPtr; /* Information about event. */ +TkScrollbarEventProc( + ClientData clientData, /* Information about window. */ + XEvent *eventPtr) /* Information about event. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; @@ -614,11 +603,10 @@ TkScrollbarEventProc(clientData, eventPtr) Tcl_CancelIdleCall(TkpDisplayScrollbar, (ClientData) scrollPtr); } /* - * Free up all the stuff that requires special handling, then - * let Tk_FreeOptions handle all the standard option-related - * stuff. + * Free up all the stuff that requires special handling, then let + * Tk_FreeOptions handle all the standard option-related stuff. */ - + Tk_FreeOptions(tkpScrollbarConfigSpecs, (char *) scrollPtr, scrollPtr->display, 0); Tcl_EventuallyFree((ClientData) scrollPtr, TCL_DYNAMIC); @@ -647,9 +635,9 @@ TkScrollbarEventProc(clientData, eventPtr) * * ScrollbarCmdDeletedProc -- * - * This procedure is invoked when a widget command is deleted. If - * the widget isn't already in the process of being destroyed, - * this command destroys it. + * This function is invoked when a widget command is deleted. If the + * widget isn't already in the process of being destroyed, this command + * destroys it. * * Results: * None. @@ -661,17 +649,17 @@ TkScrollbarEventProc(clientData, eventPtr) */ static void -ScrollbarCmdDeletedProc(clientData) - ClientData clientData; /* Pointer to widget record for widget. */ +ScrollbarCmdDeletedProc( + ClientData clientData) /* Pointer to widget record for widget. */ { TkScrollbar *scrollPtr = (TkScrollbar *) clientData; Tk_Window tkwin = scrollPtr->tkwin; /* - * This procedure could be invoked either because the window was - * destroyed and the command was then deleted (in which case tkwin - * is NULL) or because the command was deleted, and then this procedure - * destroys the widget. + * This function could be invoked either because the window was destroyed + * and the command was then deleted (in which case tkwin is NULL) or + * because the command was deleted, and then this function destroys the + * widget. */ if (tkwin != NULL) { @@ -685,8 +673,7 @@ ScrollbarCmdDeletedProc(clientData) * * TkScrollbarEventuallyRedraw -- * - * Arrange for one or more of the fields of a scrollbar - * to be redrawn. + * Arrange for one or more of the fields of a scrollbar to be redrawn. * * Results: * None. @@ -698,8 +685,8 @@ ScrollbarCmdDeletedProc(clientData) */ void -TkScrollbarEventuallyRedraw(scrollPtr) - register TkScrollbar *scrollPtr; /* Information about widget. */ +TkScrollbarEventuallyRedraw( + TkScrollbar *scrollPtr) /* Information about widget. */ { if ((scrollPtr->tkwin == NULL) || (!Tk_IsMapped(scrollPtr->tkwin))) { return; @@ -709,3 +696,11 @@ TkScrollbarEventuallyRedraw(scrollPtr) scrollPtr->flags |= REDRAW_PENDING; } } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h index f16880a..7c07c7e 100644 --- a/generic/tkScrollbar.h +++ b/generic/tkScrollbar.h @@ -1,15 +1,15 @@ /* * tkScrollbar.h -- * - * Declarations of types and functions used to implement - * the scrollbar widget. + * Declarations of types and functions used to implement the scrollbar + * widget. * * Copyright (c) 1996 by Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScrollbar.h,v 1.6 2000/11/22 01:49:38 ericm Exp $ + * RCS: @(#) $Id: tkScrollbar.h,v 1.7 2005/11/13 00:45:47 dkf Exp $ */ #ifndef _TKSCROLLBAR @@ -25,30 +25,29 @@ #endif /* - * A data structure of the following type is kept for each scrollbar - * widget. + * A data structure of the following type is kept for each scrollbar widget. */ typedef struct TkScrollbar { - Tk_Window tkwin; /* Window that embodies the scrollbar. NULL + Tk_Window tkwin; /* Window that embodies the scrollbar. NULL * means that the window has been destroyed * but the data structures haven't yet been * cleaned up.*/ - Display *display; /* Display containing widget. Used, among + Display *display; /* Display containing widget. Used, among * other things, so that resources can be * freed even after tkwin has gone away. */ Tcl_Interp *interp; /* Interpreter associated with scrollbar. */ Tcl_Command widgetCmd; /* Token for scrollbar's widget command. */ int vertical; /* Non-zero means vertical orientation * requested, zero means horizontal. */ - int width; /* Desired narrow dimension of scrollbar, - * in pixels. */ + int width; /* Desired narrow dimension of scrollbar, in + * pixels. */ char *command; /* Command prefix to use when invoking - * scrolling commands. NULL means don't - * invoke commands. Malloc'ed. */ + * scrolling commands. NULL means don't invoke + * commands. Malloc'ed. */ int commandSize; /* Number of non-NULL bytes in command. */ - int repeatDelay; /* How long to wait before auto-repeating - * on scrolling actions (in ms). */ + int repeatDelay; /* How long to wait before auto-repeating on + * scrolling actions (in ms). */ int repeatInterval; /* Interval between autorepeats (in ms). */ int jump; /* Value of -jump option. */ @@ -64,60 +63,58 @@ typedef struct TkScrollbar { XColor *troughColorPtr; /* Color for drawing trough. */ int relief; /* Indicates whether window as a whole is * raised, sunken, or flat. */ - int highlightWidth; /* Width in pixels of highlight to draw - * around widget when it has the focus. - * <= 0 means don't draw a highlight. */ + int highlightWidth; /* Width in pixels of highlight to draw around + * widget when it has the focus. <= 0 means + * don't draw a highlight. */ XColor *highlightBgColorPtr; - /* Color for drawing traversal highlight - * area when highlight is off. */ + /* Color for drawing traversal highlight area + * when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ int inset; /* Total width of all borders, including * traversal highlight and 3-D border. - * Indicates how much interior stuff must - * be offset from outside edges to leave - * room for borders. */ + * Indicates how much interior stuff must be + * offset from outside edges to leave room for + * borders. */ int elementBorderWidth; /* Width of border to draw around elements - * inside scrollbar (arrows and slider). - * -1 means use borderWidth. */ + * inside scrollbar (arrows and slider). -1 + * means use borderWidth. */ int arrowLength; /* Length of arrows along long dimension of * scrollbar, including space for a small gap * between the arrow and the slider. * Recomputed on window size changes. */ - int sliderFirst; /* Pixel coordinate of top or left edge - * of slider area, including border. */ - int sliderLast; /* Coordinate of pixel just after bottom - * or right edge of slider area, including + int sliderFirst; /* Pixel coordinate of top or left edge of + * slider area, including border. */ + int sliderLast; /* Coordinate of pixel just after bottom or + * right edge of slider area, including * border. */ int activeField; /* Names field to be displayed in active - * colors, such as TOP_ARROW, or 0 for - * no field. */ - int activeRelief; /* Value of -activeRelief option: relief - * to use for active element. */ + * colors, such as TOP_ARROW, or 0 for no + * field. */ + int activeRelief; /* Value of -activeRelief option: relief to + * use for active element. */ /* - * Information describing the application related to the scrollbar. - * This information is provided by the application by invoking the - * "set" widget command. This information can now be provided in - * two ways: the "old" form (totalUnits, windowUnits, firstUnit, - * and lastUnit), or the "new" form (firstFraction and lastFraction). - * FirstFraction and lastFraction will always be valid, but - * the old-style information is only valid if the NEW_STYLE_COMMANDS - * flag is 0. + * Information describing the application related to the scrollbar. This + * information is provided by the application by invoking the "set" widget + * command. This information can now be provided in two ways: the "old" + * form (totalUnits, windowUnits, firstUnit, and lastUnit), or the "new" + * form (firstFraction and lastFraction). FirstFraction and lastFraction + * will always be valid, but the old-style information is only valid if + * the NEW_STYLE_COMMANDS flag is 0. */ - int totalUnits; /* Total dimension of application, in - * units. Valid only if the NEW_STYLE_COMMANDS - * flag isn't set. */ + int totalUnits; /* Total dimension of application, in units. + * Valid only if the NEW_STYLE_COMMANDS flag + * isn't set. */ int windowUnits; /* Maximum number of units that can be - * displayed in the window at once. Valid - * only if the NEW_STYLE_COMMANDS flag isn't - * set. */ + * displayed in the window at once. Valid only + * if the NEW_STYLE_COMMANDS flag isn't set. */ int firstUnit; /* Number of last unit visible in - * application's window. Valid only if the + * application's window. Valid only if the * NEW_STYLE_COMMANDS flag isn't set. */ int lastUnit; /* Index of last unit visible in window. - * Valid only if the NEW_STYLE_COMMANDS - * flag isn't set. */ + * Valid only if the NEW_STYLE_COMMANDS flag + * isn't set. */ double firstFraction; /* Position of first visible thing in window, * specified as a fraction between 0 and * 1.0. */ @@ -130,16 +127,16 @@ typedef struct TkScrollbar { */ Tk_Cursor cursor; /* Current cursor for window, or None. */ - 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 + 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. */ } TkScrollbar; /* - * Legal values for "activeField" field of Scrollbar structures. These - * are also the return values from the ScrollbarPosition procedure. + * Legal values for "activeField" field of Scrollbar structures. These are + * also the return values from the ScrollbarPosition function. */ #define OUTSIDE 0 @@ -151,14 +148,13 @@ typedef struct TkScrollbar { /* * Flag bits for scrollbars: - * - * REDRAW_PENDING: Non-zero means a DoWhenIdle handler - * has already been queued to redraw - * this window. + * + * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has + * already been queued to redraw this window. * NEW_STYLE_COMMANDS: Non-zero means the new style of commands - * should be used to communicate with the - * widget: ".t yview scroll 2 lines", instead - * of ".t yview 40", for example. + * should be used to communicate with the widget: + * ".t yview scroll 2 lines", instead of + * ".t yview 40", for example. * GOT_FOCUS: Non-zero means this window has the input * focus. */ @@ -168,7 +164,7 @@ typedef struct TkScrollbar { #define GOT_FOCUS 4 /* - * Declaration of scrollbar class procedures structure. + * Declaration of scrollbar class functions structure. */ extern Tk_ClassProcs tkpScrollbarProcs; @@ -180,25 +176,20 @@ extern Tk_ClassProcs tkpScrollbarProcs; extern Tk_ConfigSpec tkpScrollbarConfigSpecs[]; /* - * Declaration of procedures used in the implementation of the scrollbar - * widget. + * Declaration of functions used in the implementation of the scrollbar + * widget. */ -EXTERN void TkScrollbarEventProc _ANSI_ARGS_(( - ClientData clientData, XEvent *eventPtr)); -EXTERN void TkScrollbarEventuallyRedraw _ANSI_ARGS_(( - TkScrollbar *scrollPtr)); -EXTERN void TkpComputeScrollbarGeometry _ANSI_ARGS_(( - TkScrollbar *scrollPtr)); -EXTERN TkScrollbar * TkpCreateScrollbar _ANSI_ARGS_((Tk_Window tkwin)); -EXTERN void TkpDestroyScrollbar _ANSI_ARGS_(( - TkScrollbar *scrollPtr)); -EXTERN void TkpDisplayScrollbar _ANSI_ARGS_(( - ClientData clientData)); -EXTERN void TkpConfigureScrollbar _ANSI_ARGS_(( - TkScrollbar *scrollPtr)); -EXTERN int TkpScrollbarPosition _ANSI_ARGS_(( - TkScrollbar *scrollPtr, int x, int y)); +EXTERN void TkScrollbarEventProc(ClientData clientData, + XEvent *eventPtr); +EXTERN void TkScrollbarEventuallyRedraw(TkScrollbar *scrollPtr); +EXTERN void TkpComputeScrollbarGeometry(TkScrollbar *scrollPtr); +EXTERN TkScrollbar * TkpCreateScrollbar(Tk_Window tkwin); +EXTERN void TkpDestroyScrollbar(TkScrollbar *scrollPtr); +EXTERN void TkpDisplayScrollbar(ClientData clientData); +EXTERN void TkpConfigureScrollbar(TkScrollbar *scrollPtr); +EXTERN int TkpScrollbarPosition(TkScrollbar *scrollPtr, + int x, int y); # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 415b0f6..f73a2dd 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1,62 +1,60 @@ -/* +/* * tkUtil.c -- * - * This file contains miscellaneous utility procedures that - * are used by the rest of Tk, such as a procedure for drawing - * a focus highlight. + * This file contains miscellaneous utility functions that are used by + * the rest of Tk, such as a function for drawing a focus highlight. * * Copyright (c) 1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUtil.c,v 1.12 2002/08/05 04:30:40 dgp Exp $ + * RCS: @(#) $Id: tkUtil.c,v 1.13 2005/11/13 00:45:47 dkf Exp $ */ #include "tkInt.h" #include "tkPort.h" /* - * The structure below defines the implementation of the "statekey" - * Tcl object, used for quickly finding a mapping in a TkStateMap. + * The structure below defines the implementation of the "statekey" Tcl + * object, used for quickly finding a mapping in a TkStateMap. */ Tcl_ObjType tkStateKeyObjType = { - "statekey", /* name */ - (Tcl_FreeInternalRepProc *) NULL, /* freeIntRepProc */ - (Tcl_DupInternalRepProc *) NULL, /* dupIntRepProc */ - (Tcl_UpdateStringProc *) NULL, /* updateStringProc */ - (Tcl_SetFromAnyProc *) NULL /* setFromAnyProc */ + "statekey", /* name */ + NULL, /* freeIntRepProc */ + NULL, /* dupIntRepProc */ + NULL, /* updateStringProc */ + NULL /* setFromAnyProc */ }; - /* *-------------------------------------------------------------- * * TkStateParseProc -- * - * This procedure is invoked during option processing to handle - * the "-state" and "-default" options. + * This function is invoked during option processing to handle the + * "-state" and "-default" options. * * Results: * A standard Tcl return value. * * Side effects: - * The state for a given item gets replaced by the state - * indicated in the value argument. + * The state for a given item gets replaced by the state indicated in the + * value argument. * *-------------------------------------------------------------- */ int -TkStateParseProc(clientData, interp, tkwin, value, widgRec, offset) - ClientData clientData; /* some flags.*/ - Tcl_Interp *interp; /* Used for reporting errors. */ - Tk_Window tkwin; /* Window containing canvas widget. */ - CONST char *value; /* Value of option. */ - char *widgRec; /* Pointer to record for item. */ - int offset; /* Offset into item. */ +TkStateParseProc( + ClientData clientData, /* some flags.*/ + Tcl_Interp *interp, /* Used for reporting errors. */ + Tk_Window tkwin, /* Window containing canvas widget. */ + CONST char *value, /* Value of option. */ + char *widgRec, /* Pointer to record for item. */ + int offset) /* Offset into item. */ { int c; int flags = (int)clientData; @@ -90,18 +88,17 @@ TkStateParseProc(clientData, interp, tkwin, value, widgRec, offset) } Tcl_AppendResult(interp, "bad ", (flags&4)?"-default" : "state", - " value \"", value, "\": must be normal", - (char *) NULL); + " value \"", value, "\": must be normal", NULL); if (flags&1) { - Tcl_AppendResult(interp, ", active",(char *) NULL); + Tcl_AppendResult(interp, ", active", NULL); } if (flags&2) { - Tcl_AppendResult(interp, ", hidden",(char *) NULL); + Tcl_AppendResult(interp, ", hidden", NULL); } if (flags&3) { - Tcl_AppendResult(interp, ",",(char *) NULL); + Tcl_AppendResult(interp, ",", NULL); } - Tcl_AppendResult(interp, " or disabled",(char *) NULL); + Tcl_AppendResult(interp, " or disabled", NULL); *statePtr = TK_STATE_NORMAL; return TCL_ERROR; } @@ -111,16 +108,15 @@ TkStateParseProc(clientData, interp, tkwin, value, widgRec, offset) * * TkStatePrintProc -- * - * This procedure is invoked by the Tk configuration code - * to produce a printable string for the "-state" - * configuration option. + * This function is invoked by the Tk configuration code to produce a + * printable string for the "-state" configuration option. * * Results: - * The return value is a string describing the state for - * the item referred to by "widgRec". In addition, *freeProcPtr - * is filled in with the address of a procedure to call to free - * the result string when it's no longer needed (or NULL to - * indicate that the string doesn't need to be freed). + * The return value is a string describing the state for the item + * referred to by "widgRec". In addition, *freeProcPtr is filled in with + * the address of a function to call to free the result string when it's + * no longer needed (or NULL to indicate that the string doesn't need to + * be freed). * * Side effects: * None. @@ -129,14 +125,14 @@ TkStateParseProc(clientData, interp, tkwin, value, widgRec, offset) */ char * -TkStatePrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) - ClientData clientData; /* Ignored. */ - Tk_Window tkwin; /* Window containing canvas widget. */ - char *widgRec; /* Pointer to record for item. */ - int offset; /* Offset into item. */ - Tcl_FreeProc **freeProcPtr; /* Pointer to variable to fill in with - * information about how to reclaim - * storage for return string. */ +TkStatePrintProc( + ClientData clientData, /* Ignored. */ + Tk_Window tkwin, /* Window containing canvas widget. */ + char *widgRec, /* Pointer to record for item. */ + int offset, /* Offset into item. */ + Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with + * information about how to reclaim storage + * for return string. */ { register Tk_State *statePtr = (Tk_State *) (widgRec + offset); @@ -158,8 +154,8 @@ TkStatePrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) * * TkOrientParseProc -- * - * This procedure is invoked during option processing to handle - * the "-orient" option. + * This function is invoked during option processing to handle the + * "-orient" option. * * Results: * A standard Tcl return value. @@ -172,13 +168,13 @@ TkStatePrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) */ int -TkOrientParseProc(clientData, interp, tkwin, value, widgRec, offset) - ClientData clientData; /* some flags.*/ - Tcl_Interp *interp; /* Used for reporting errors. */ - Tk_Window tkwin; /* Window containing canvas widget. */ - CONST char *value; /* Value of option. */ - char *widgRec; /* Pointer to record for item. */ - int offset; /* Offset into item. */ +TkOrientParseProc( + ClientData clientData, /* some flags.*/ + Tcl_Interp *interp, /* Used for reporting errors. */ + Tk_Window tkwin, /* Window containing canvas widget. */ + CONST char *value, /* Value of option. */ + char *widgRec, /* Pointer to record for item. */ + int offset) /* Offset into item. */ { int c; size_t length; @@ -202,8 +198,7 @@ TkOrientParseProc(clientData, interp, tkwin, value, widgRec, offset) return TCL_OK; } Tcl_AppendResult(interp, "bad orientation \"", value, - "\": must be vertical or horizontal", - (char *) NULL); + "\": must be vertical or horizontal", NULL); *orientPtr = 0; return TCL_ERROR; } @@ -213,16 +208,15 @@ TkOrientParseProc(clientData, interp, tkwin, value, widgRec, offset) * * TkOrientPrintProc -- * - * This procedure is invoked by the Tk configuration code - * to produce a printable string for the "-orient" - * configuration option. + * This function is invoked by the Tk configuration code to produce a + * printable string for the "-orient" configuration option. * * Results: - * The return value is a string describing the orientation for - * the item referred to by "widgRec". In addition, *freeProcPtr - * is filled in with the address of a procedure to call to free - * the result string when it's no longer needed (or NULL to - * indicate that the string doesn't need to be freed). + * The return value is a string describing the orientation for the item + * referred to by "widgRec". In addition, *freeProcPtr is filled in with + * the address of a function to call to free the result string when it's + * no longer needed (or NULL to indicate that the string doesn't need to + * be freed). * * Side effects: * None. @@ -231,14 +225,14 @@ TkOrientParseProc(clientData, interp, tkwin, value, widgRec, offset) */ char * -TkOrientPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) - ClientData clientData; /* Ignored. */ - Tk_Window tkwin; /* Window containing canvas widget. */ - char *widgRec; /* Pointer to record for item. */ - int offset; /* Offset into item. */ - Tcl_FreeProc **freeProcPtr; /* Pointer to variable to fill in with - * information about how to reclaim - * storage for return string. */ +TkOrientPrintProc( + ClientData clientData, /* Ignored. */ + Tk_Window tkwin, /* Window containing canvas widget. */ + char *widgRec, /* Pointer to record for item. */ + int offset, /* Offset into item. */ + Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with + * information about how to reclaim storage + * for return string. */ { register int *statePtr = (int *) (widgRec + offset); @@ -254,19 +248,20 @@ TkOrientPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) * * TkOffsetParseProc -- * - * Converts the offset of a stipple or tile into the Tk_TSOffset structure. + * Converts the offset of a stipple or tile into the Tk_TSOffset + * structure. * *---------------------------------------------------------------------- */ int -TkOffsetParseProc(clientData, interp, tkwin, value, widgRec, offset) - ClientData clientData; /* not used */ - Tcl_Interp *interp; /* Interpreter to send results back to */ - Tk_Window tkwin; /* Window on same display as tile */ - CONST char *value; /* Name of image */ - char *widgRec; /* Widget structure record */ - int offset; /* Offset of tile in record */ +TkOffsetParseProc( + ClientData clientData, /* not used */ + Tcl_Interp *interp, /* Interpreter to send results back to */ + Tk_Window tkwin, /* Window on same display as tile */ + CONST char *value, /* Name of image */ + char *widgRec, /* Widget structure record */ + int offset) /* Offset of tile in record */ { Tk_TSOffset *offsetPtr = (Tk_TSOffset *)(widgRec + offset); Tk_TSOffset tsoffset; @@ -281,58 +276,67 @@ TkOffsetParseProc(clientData, interp, tkwin, value, widgRec, offset) p = value; switch(value[0]) { - case '#': - if (((int)clientData) & TK_OFFSET_RELATIVE) { - tsoffset.flags = TK_OFFSET_RELATIVE; - p++; break; - } - goto badTSOffset; - case 'e': - switch(value[1]) { - case '\0': - tsoffset.flags = TK_OFFSET_RIGHT|TK_OFFSET_MIDDLE; - goto goodTSOffset; - case 'n': - if (value[2]!='d' || value[3]!='\0') {goto badTSOffset;} - tsoffset.flags = INT_MAX; - goto goodTSOffset; - } - case 'w': - if (value[1] != '\0') {goto badTSOffset;} - tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_MIDDLE; + case '#': + if (((int)clientData) & TK_OFFSET_RELATIVE) { + tsoffset.flags = TK_OFFSET_RELATIVE; + p++; + break; + } + goto badTSOffset; + case 'e': + switch(value[1]) { + case '\0': + tsoffset.flags = TK_OFFSET_RIGHT|TK_OFFSET_MIDDLE; goto goodTSOffset; case 'n': - if ((value[1] != '\0') && (value[2] != '\0')) { + if (value[2]!='d' || value[3]!='\0') { goto badTSOffset; } - switch(value[1]) { - case '\0': tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_TOP; - goto goodTSOffset; - case 'w': tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_TOP; - goto goodTSOffset; - case 'e': tsoffset.flags = TK_OFFSET_RIGHT|TK_OFFSET_TOP; - goto goodTSOffset; - } + tsoffset.flags = INT_MAX; + goto goodTSOffset; + } + case 'w': + if (value[1] != '\0') {goto badTSOffset;} + tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_MIDDLE; + goto goodTSOffset; + case 'n': + if ((value[1] != '\0') && (value[2] != '\0')) { goto badTSOffset; - case 's': - if ((value[1] != '\0') && (value[2] != '\0')) { - goto badTSOffset; - } - switch(value[1]) { - case '\0': tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_BOTTOM; - goto goodTSOffset; - case 'w': tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_BOTTOM; - goto goodTSOffset; - case 'e': tsoffset.flags = TK_OFFSET_RIGHT|TK_OFFSET_BOTTOM; - goto goodTSOffset; - } + } + switch(value[1]) { + case '\0': + tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_TOP; + goto goodTSOffset; + case 'w': + tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_TOP; + goto goodTSOffset; + case 'e': + tsoffset.flags = TK_OFFSET_RIGHT|TK_OFFSET_TOP; + goto goodTSOffset; + } + goto badTSOffset; + case 's': + if ((value[1] != '\0') && (value[2] != '\0')) { goto badTSOffset; - case 'c': - if (strncmp(value, "center", strlen(value)) != 0) { - goto badTSOffset; - } - tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_MIDDLE; + } + switch(value[1]) { + case '\0': + tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_BOTTOM; + goto goodTSOffset; + case 'w': + tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_BOTTOM; goto goodTSOffset; + case 'e': + tsoffset.flags = TK_OFFSET_RIGHT|TK_OFFSET_BOTTOM; + goto goodTSOffset; + } + goto badTSOffset; + case 'c': + if (strncmp(value, "center", strlen(value)) != 0) { + goto badTSOffset; + } + tsoffset.flags = TK_OFFSET_CENTER|TK_OFFSET_MIDDLE; + goto goodTSOffset; } if ((q = strchr(p,',')) == NULL) { if (((int)clientData) & TK_OFFSET_INDEX) { @@ -351,33 +355,31 @@ TkOffsetParseProc(clientData, interp, tkwin, value, widgRec, offset) if (result != TCL_OK) { return TCL_ERROR; } - if (Tk_GetPixels(interp, tkwin, (char *) q+1, &tsoffset.yoffset) != TCL_OK) { + if (Tk_GetPixels(interp, tkwin, (char*)q+1, &tsoffset.yoffset) != TCL_OK) { return TCL_ERROR; } - -goodTSOffset: - /* below is a hack to allow the stipple/tile offset to be stored - * in the internal tile structure. Most of the times, offsetPtr - * is a pointer to an already existing tile structure. However - * if this structure is not already created, we must do it - * with Tk_GetTile()!!!!; + goodTSOffset: + /* + * Below is a hack to allow the stipple/tile offset to be stored in the + * internal tile structure. Most of the times, offsetPtr is a pointer to + * an already existing tile structure. However if this structure is not + * already created, we must do it with Tk_GetTile()!!!!; */ - memcpy(offsetPtr,&tsoffset, sizeof(Tk_TSOffset)); + memcpy(offsetPtr, &tsoffset, sizeof(Tk_TSOffset)); return TCL_OK; -badTSOffset: + badTSOffset: Tcl_AppendResult(interp, "bad offset \"", value, - "\": expected \"x,y\"", (char *) NULL); + "\": expected \"x,y\"", NULL); if (((int) clientData) & TK_OFFSET_RELATIVE) { - Tcl_AppendResult(interp, ", \"#x,y\"", (char *) NULL); + Tcl_AppendResult(interp, ", \"#x,y\"", NULL); } if (((int) clientData) & TK_OFFSET_INDEX) { - Tcl_AppendResult(interp, ", ", (char *) NULL); + Tcl_AppendResult(interp, ", ", NULL); } - Tcl_AppendResult(interp, ", n, ne, e, se, s, sw, w, nw, or center", - (char *) NULL); + Tcl_AppendResult(interp, ", n, ne, e, se, s, sw, w, nw, or center", NULL); return TCL_ERROR; } @@ -395,12 +397,12 @@ badTSOffset: */ char * -TkOffsetPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) - ClientData clientData; /* not used */ - Tk_Window tkwin; /* not used */ - char *widgRec; /* Widget structure record */ - int offset; /* Offset of tile in record */ - Tcl_FreeProc **freeProcPtr; /* not used */ +TkOffsetPrintProc( + ClientData clientData, /* not used */ + Tk_Window tkwin, /* not used */ + char *widgRec, /* Widget structure record */ + int offset, /* Offset of tile in record */ + Tcl_FreeProc **freeProcPtr) /* not used */ { Tk_TSOffset *offsetPtr = (Tk_TSOffset *)(widgRec + offset); char *p, *q; @@ -438,7 +440,7 @@ TkOffsetPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) } else if ((offsetPtr->flags) & TK_OFFSET_RIGHT) { return "se"; } - } + } q = p = (char *) ckalloc(32); if ((offsetPtr->flags) & TK_OFFSET_RELATIVE) { *q++ = '#'; @@ -448,7 +450,6 @@ TkOffsetPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) return p; } - /* *---------------------------------------------------------------------- * @@ -460,14 +461,14 @@ TkOffsetPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) */ int -TkPixelParseProc(clientData, interp, tkwin, value, widgRec, offset) - ClientData clientData; /* if non-NULL, negative values are - * allowed as well */ - Tcl_Interp *interp; /* Interpreter to send results back to */ - Tk_Window tkwin; /* Window on same display as tile */ - CONST char *value; /* Name of image */ - char *widgRec; /* Widget structure record */ - int offset; /* Offset of tile in record */ +TkPixelParseProc( + ClientData clientData, /* If non-NULL, negative values are allowed as + * well */ + Tcl_Interp *interp, /* Interpreter to send results back to */ + Tk_Window tkwin, /* Window on same display as tile */ + CONST char *value, /* Name of image */ + char *widgRec, /* Widget structure record */ + int offset) /* Offset of tile in record */ { double *doublePtr = (double *)(widgRec + offset); int result; @@ -475,8 +476,7 @@ TkPixelParseProc(clientData, interp, tkwin, value, widgRec, offset) result = TkGetDoublePixels(interp, tkwin, value, doublePtr); if ((result == TCL_OK) && (clientData == NULL) && (*doublePtr < 0.0)) { - Tcl_AppendResult(interp, "bad screen distance \"", value, - "\"", (char *) NULL); + Tcl_AppendResult(interp, "bad screen distance \"", value, "\"", NULL); return TCL_ERROR; } return result; @@ -496,18 +496,18 @@ TkPixelParseProc(clientData, interp, tkwin, value, widgRec, offset) */ char * -TkPixelPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) - ClientData clientData; /* not used */ - Tk_Window tkwin; /* not used */ - char *widgRec; /* Widget structure record */ - int offset; /* Offset of tile in record */ - Tcl_FreeProc **freeProcPtr; /* not used */ +TkPixelPrintProc( + ClientData clientData, /* not used */ + Tk_Window tkwin, /* not used */ + char *widgRec, /* Widget structure record */ + int offset, /* Offset of tile in record */ + Tcl_FreeProc **freeProcPtr) /* not used */ { double *doublePtr = (double *)(widgRec + offset); char *p; p = (char *) ckalloc(24); - Tcl_PrintDouble((Tcl_Interp *) NULL, *doublePtr, p); + Tcl_PrintDouble(NULL, *doublePtr, p); *freeProcPtr = TCL_DYNAMIC; return p; } @@ -517,31 +517,31 @@ TkPixelPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) * * TkDrawInsetFocusHighlight -- * - * This procedure draws a rectangular ring around the outside of - * a widget to indicate that it has received the input focus. It - * takes an additional padding argument that specifies how much - * padding is present outside th widget. + * This function draws a rectangular ring around the outside of a widget + * to indicate that it has received the input focus. It takes an + * additional padding argument that specifies how much padding is present + * outside the widget. * * Results: * None. * * Side effects: - * A rectangle "width" pixels wide is drawn in "drawable", - * corresponding to the outer area of "tkwin". + * A rectangle "width" pixels wide is drawn in "drawable", corresponding + * to the outer area of "tkwin". * *---------------------------------------------------------------------- */ void -TkDrawInsetFocusHighlight(tkwin, gc, width, drawable, padding) - Tk_Window tkwin; /* Window whose focus highlight ring is - * to be drawn. */ - GC gc; /* Graphics context to use for drawing - * the highlight ring. */ - int width; /* Width of the highlight ring, in pixels. */ - Drawable drawable; /* Where to draw the ring (typically a - * pixmap for double buffering). */ - int padding; /* Width of padding outside of widget. */ +TkDrawInsetFocusHighlight( + Tk_Window tkwin, /* Window whose focus highlight ring is to be + * drawn. */ + GC gc, /* Graphics context to use for drawing the + * highlight ring. */ + int width, /* Width of the highlight ring, in pixels. */ + Drawable drawable, /* Where to draw the ring (typically a pixmap + * for double buffering). */ + int padding) /* Width of padding outside of widget. */ { XRectangle rects[4]; @@ -569,34 +569,34 @@ TkDrawInsetFocusHighlight(tkwin, gc, width, drawable, padding) * * Tk_DrawFocusHighlight -- * - * This procedure draws a rectangular ring around the outside of - * a widget to indicate that it has received the input focus. + * This function draws a rectangular ring around the outside of a widget + * to indicate that it has received the input focus. * - * This function is now deprecated. Use TkpDrawHighlightBorder instead, - * since this function does not handle drawing the Focus ring properly - * on the Macintosh - you need to know the background GC as well - * as the foreground since the Mac focus ring separated from the widget - * by a 1 pixel border. + * This function is now deprecated. Use TkpDrawHighlightBorder instead, + * since this function does not handle drawing the Focus ring properly on + * the Macintosh - you need to know the background GC as well as the + * foreground since the Mac focus ring separated from the widget by a 1 + * pixel border. * * Results: * None. * * Side effects: - * A rectangle "width" pixels wide is drawn in "drawable", - * corresponding to the outer area of "tkwin". + * A rectangle "width" pixels wide is drawn in "drawable", corresponding + * to the outer area of "tkwin". * *---------------------------------------------------------------------- */ void -Tk_DrawFocusHighlight(tkwin, gc, width, drawable) - Tk_Window tkwin; /* Window whose focus highlight ring is - * to be drawn. */ - GC gc; /* Graphics context to use for drawing - * the highlight ring. */ - int width; /* Width of the highlight ring, in pixels. */ - Drawable drawable; /* Where to draw the ring (typically a - * pixmap for double buffering). */ +Tk_DrawFocusHighlight( + Tk_Window tkwin, /* Window whose focus highlight ring is to be + * drawn. */ + GC gc, /* Graphics context to use for drawing the + * highlight ring. */ + int width, /* Width of the highlight ring, in pixels. */ + Drawable drawable) /* Where to draw the ring (typically a pixmap + * for double buffering). */ { TkDrawInsetFocusHighlight(tkwin, gc, width, drawable, 0); } @@ -606,19 +606,18 @@ Tk_DrawFocusHighlight(tkwin, gc, width, drawable) * * Tk_GetScrollInfo -- * - * This procedure is invoked to parse "xview" and "yview" - * scrolling commands for widgets using the new scrolling - * command syntax ("moveto" or "scroll" options). + * This function is invoked to parse "xview" and "yview" scrolling + * commands for widgets using the new scrolling command syntax ("moveto" + * or "scroll" options). * * Results: * The return value is either TK_SCROLL_MOVETO, TK_SCROLL_PAGES, - * TK_SCROLL_UNITS, or TK_SCROLL_ERROR. This indicates whether - * the command was successfully parsed and what form the command - * took. If TK_SCROLL_MOVETO, *dblPtr is filled in with the - * desired position; if TK_SCROLL_PAGES or TK_SCROLL_UNITS, - * *intPtr is filled in with the number of lines to move (may be - * negative); if TK_SCROLL_ERROR, the interp's result contains an - * error message. + * TK_SCROLL_UNITS, or TK_SCROLL_ERROR. This indicates whether the + * command was successfully parsed and what form the command took. If + * TK_SCROLL_MOVETO, *dblPtr is filled in with the desired position; if + * TK_SCROLL_PAGES or TK_SCROLL_UNITS, *intPtr is filled in with the + * number of lines to move (may be negative); if TK_SCROLL_ERROR, the + * interp's result contains an error message. * * Side effects: * None. @@ -627,14 +626,14 @@ Tk_DrawFocusHighlight(tkwin, gc, width, drawable) */ int -Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) - Tcl_Interp *interp; /* Used for error reporting. */ - int argc; /* # arguments for command. */ - CONST char **argv; /* Arguments for command. */ - double *dblPtr; /* Filled in with argument "moveto" - * option, if any. */ - int *intPtr; /* Filled in with number of pages - * or lines to scroll, if any. */ +Tk_GetScrollInfo( + Tcl_Interp *interp, /* Used for error reporting. */ + int argc, /* # arguments for command. */ + CONST char **argv, /* Arguments for command. */ + double *dblPtr, /* Filled in with argument "moveto" option, if + * any. */ + int *intPtr) /* Filled in with number of pages or lines to + * scroll, if any. */ { int c; size_t length; @@ -643,9 +642,8 @@ Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) c = argv[2][0]; if ((c == 'm') && (strncmp(argv[2], "moveto", length) == 0)) { if (argc != 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " ", argv[1], " moveto fraction\"", - (char *) NULL); + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], + " ", argv[1], " moveto fraction\"", NULL); return TK_SCROLL_ERROR; } if (Tcl_GetDouble(interp, argv[3], dblPtr) != TCL_OK) { @@ -655,9 +653,8 @@ Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) } else if ((c == 's') && (strncmp(argv[2], "scroll", length) == 0)) { if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " ", argv[1], " scroll number units|pages\"", - (char *) NULL); + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], + " ", argv[1], " scroll number units|pages\"", NULL); return TK_SCROLL_ERROR; } if (Tcl_GetInt(interp, argv[3], intPtr) != TCL_OK) { @@ -667,17 +664,16 @@ Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) c = argv[4][0]; if ((c == 'p') && (strncmp(argv[4], "pages", length) == 0)) { return TK_SCROLL_PAGES; - } else if ((c == 'u') - && (strncmp(argv[4], "units", length) == 0)) { + } else if ((c == 'u') && (strncmp(argv[4], "units", length) == 0)) { return TK_SCROLL_UNITS; } else { Tcl_AppendResult(interp, "bad argument \"", argv[4], - "\": must be units or pages", (char *) NULL); + "\": must be units or pages", NULL); return TK_SCROLL_ERROR; } } Tcl_AppendResult(interp, "unknown option \"", argv[2], - "\": must be moveto or scroll", (char *) NULL); + "\": must be moveto or scroll", NULL); return TK_SCROLL_ERROR; } @@ -686,19 +682,18 @@ Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) * * Tk_GetScrollInfoObj -- * - * This procedure is invoked to parse "xview" and "yview" - * scrolling commands for widgets using the new scrolling - * command syntax ("moveto" or "scroll" options). + * This function is invoked to parse "xview" and "yview" scrolling + * commands for widgets using the new scrolling command syntax ("moveto" + * or "scroll" options). * * Results: * The return value is either TK_SCROLL_MOVETO, TK_SCROLL_PAGES, - * TK_SCROLL_UNITS, or TK_SCROLL_ERROR. This indicates whether - * the command was successfully parsed and what form the command - * took. If TK_SCROLL_MOVETO, *dblPtr is filled in with the - * desired position; if TK_SCROLL_PAGES or TK_SCROLL_UNITS, - * *intPtr is filled in with the number of lines to move (may be - * negative); if TK_SCROLL_ERROR, the interp's result contains an - * error message. + * TK_SCROLL_UNITS, or TK_SCROLL_ERROR. This indicates whether the + * command was successfully parsed and what form the command took. If + * TK_SCROLL_MOVETO, *dblPtr is filled in with the desired position; if + * TK_SCROLL_PAGES or TK_SCROLL_UNITS, *intPtr is filled in with the + * number of lines to move (may be negative); if TK_SCROLL_ERROR, the + * interp's result contains an error message. * * Side effects: * None. @@ -707,14 +702,14 @@ Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) */ int -Tk_GetScrollInfoObj(interp, objc, objv, dblPtr, intPtr) - Tcl_Interp *interp; /* Used for error reporting. */ - int objc; /* # arguments for command. */ - Tcl_Obj *CONST objv[]; /* Arguments for command. */ - double *dblPtr; /* Filled in with argument "moveto" - * option, if any. */ - int *intPtr; /* Filled in with number of pages - * or lines to scroll, if any. */ +Tk_GetScrollInfoObj( + Tcl_Interp *interp, /* Used for error reporting. */ + int objc, /* # arguments for command. */ + Tcl_Obj *CONST objv[], /* Arguments for command. */ + double *dblPtr, /* Filled in with argument "moveto" option, if + * any. */ + int *intPtr) /* Filled in with number of pages or lines to + * scroll, if any. */ { int c; size_t length; @@ -746,17 +741,16 @@ Tk_GetScrollInfoObj(interp, objc, objv, dblPtr, intPtr) c = arg4[0]; if ((c == 'p') && (strncmp(arg4, "pages", length) == 0)) { return TK_SCROLL_PAGES; - } else if ((c == 'u') - && (strncmp(arg4, "units", length) == 0)) { + } else if ((c == 'u') && (strncmp(arg4, "units", length) == 0)) { return TK_SCROLL_UNITS; } else { Tcl_AppendResult(interp, "bad argument \"", arg4, - "\": must be units or pages", (char *) NULL); + "\": must be units or pages", NULL); return TK_SCROLL_ERROR; } } Tcl_AppendResult(interp, "unknown option \"", arg2, - "\": must be moveto or scroll", (char *) NULL); + "\": must be moveto or scroll", NULL); return TK_SCROLL_ERROR; } @@ -766,66 +760,68 @@ Tk_GetScrollInfoObj(interp, objc, objv, dblPtr, intPtr) * TkComputeAnchor -- * * Determine where to place a rectangle so that it will be properly - * anchored with respect to the given window. Used by widgets - * to align a box of text inside a window. When anchoring with - * respect to one of the sides, the rectangle be placed inside of - * the internal border of the window. + * anchored with respect to the given window. Used by widgets to align a + * box of text inside a window. When anchoring with respect to one of the + * sides, the rectangle be placed inside of the internal border of the + * window. * * Results: - * *xPtr and *yPtr set to the upper-left corner of the rectangle - * anchored in the window. + * *xPtr and *yPtr set to the upper-left corner of the rectangle anchored + * in the window. * * Side effects: * None. * *--------------------------------------------------------------------------- */ + void -TkComputeAnchor(anchor, tkwin, padX, padY, innerWidth, innerHeight, xPtr, yPtr) - Tk_Anchor anchor; /* Desired anchor. */ - Tk_Window tkwin; /* Anchored with respect to this window. */ - int padX, padY; /* Use this extra padding inside window, in +TkComputeAnchor( + Tk_Anchor anchor, /* Desired anchor. */ + Tk_Window tkwin, /* Anchored with respect to this window. */ + int padX, int padY, /* Use this extra padding inside window, in * addition to the internal border. */ - int innerWidth, innerHeight;/* Size of rectangle to anchor in window. */ - int *xPtr, *yPtr; /* Returns upper-left corner of anchored + int innerWidth, int innerHeight; + /* Size of rectangle to anchor in window. */ + int *xPtr, int *yPtr) /* Returns upper-left corner of anchored * rectangle. */ { switch (anchor) { - case TK_ANCHOR_NW: - case TK_ANCHOR_W: - case TK_ANCHOR_SW: - *xPtr = Tk_InternalBorderLeft(tkwin) + padX; - break; + case TK_ANCHOR_NW: + case TK_ANCHOR_W: + case TK_ANCHOR_SW: + *xPtr = Tk_InternalBorderLeft(tkwin) + padX; + break; - case TK_ANCHOR_N: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_S: - *xPtr = (Tk_Width(tkwin) - innerWidth) / 2; - break; + case TK_ANCHOR_N: + case TK_ANCHOR_CENTER: + case TK_ANCHOR_S: + *xPtr = (Tk_Width(tkwin) - innerWidth) / 2; + break; - default: - *xPtr = Tk_Width(tkwin) - (Tk_InternalBorderRight(tkwin) + padX) - - innerWidth; - break; + default: + *xPtr = Tk_Width(tkwin) - (Tk_InternalBorderRight(tkwin) + padX) + - innerWidth; + break; } switch (anchor) { - case TK_ANCHOR_NW: - case TK_ANCHOR_N: - case TK_ANCHOR_NE: - *yPtr = Tk_InternalBorderTop(tkwin) + padY; - break; - - case TK_ANCHOR_W: - case TK_ANCHOR_CENTER: - case TK_ANCHOR_E: - *yPtr = (Tk_Height(tkwin) - innerHeight) / 2; - break; - - default: - *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY - - innerHeight; - break; + case TK_ANCHOR_NW: + case TK_ANCHOR_N: + case TK_ANCHOR_NE: + *yPtr = Tk_InternalBorderTop(tkwin) + padY; + break; + + case TK_ANCHOR_W: + case TK_ANCHOR_CENTER: + case TK_ANCHOR_E: + *yPtr = (Tk_Height(tkwin) - innerHeight) / 2; + break; + + default: + *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY + - innerHeight; + break; } } @@ -837,10 +833,9 @@ TkComputeAnchor(anchor, tkwin, padX, padY, innerWidth, innerHeight, xPtr, yPtr) * Given a lookup table, map a number to a string in the table. * * Results: - * If numKey was equal to the numeric key of one of the elements - * in the table, returns the string key of that element. - * Returns NULL if numKey was not equal to any of the numeric keys - * in the table. + * If numKey was equal to the numeric key of one of the elements in the + * table, returns the string key of that element. Returns NULL if numKey + * was not equal to any of the numeric keys in the table. * * Side effects. * None. @@ -849,9 +844,9 @@ TkComputeAnchor(anchor, tkwin, padX, padY, innerWidth, innerHeight, xPtr, yPtr) */ char * -TkFindStateString(mapPtr, numKey) - CONST TkStateMap *mapPtr; /* The state table. */ - int numKey; /* The key to try to find in the table. */ +TkFindStateString( + CONST TkStateMap *mapPtr, /* The state table. */ + int numKey) /* The key to try to find in the table. */ { for ( ; mapPtr->strKey != NULL; mapPtr++) { if (numKey == mapPtr->numKey) { @@ -869,12 +864,12 @@ TkFindStateString(mapPtr, numKey) * Given a lookup table, map a string to a number in the table. * * Results: - * If strKey was equal to the string keys of one of the elements - * in the table, returns the numeric key of that element. - * Returns the numKey associated with the last element (the NULL - * string one) in the table if strKey was not equal to any of the - * string keys in the table. In that case, an error message is - * also left in the interp's result (if interp is not NULL). + * If strKey was equal to the string keys of one of the elements in the + * table, returns the numeric key of that element. Returns the numKey + * associated with the last element (the NULL string one) in the table if + * strKey was not equal to any of the string keys in the table. In that + * case, an error message is also left in the interp's result (if interp + * is not NULL). * * Side effects. * None. @@ -883,11 +878,11 @@ TkFindStateString(mapPtr, numKey) */ int -TkFindStateNum(interp, option, mapPtr, strKey) - Tcl_Interp *interp; /* Interp for error reporting. */ - CONST char *option; /* String to use when constructing error. */ - CONST TkStateMap *mapPtr; /* Lookup table. */ - CONST char *strKey; /* String to try to find in lookup table. */ +TkFindStateNum( + Tcl_Interp *interp, /* Interp for error reporting. */ + CONST char *option, /* String to use when constructing error. */ + CONST TkStateMap *mapPtr, /* Lookup table. */ + CONST char *strKey) /* String to try to find in lookup table. */ { CONST TkStateMap *mPtr; @@ -899,22 +894,22 @@ TkFindStateNum(interp, option, mapPtr, strKey) if (interp != NULL) { mPtr = mapPtr; Tcl_AppendResult(interp, "bad ", option, " value \"", strKey, - "\": must be ", mPtr->strKey, (char *) NULL); + "\": must be ", mPtr->strKey, NULL); for (mPtr++; mPtr->strKey != NULL; mPtr++) { - Tcl_AppendResult(interp, - ((mPtr[1].strKey != NULL) ? ", " : ", or "), - mPtr->strKey, (char *) NULL); + Tcl_AppendResult(interp, + ((mPtr[1].strKey != NULL) ? ", " : ", or "), + mPtr->strKey, NULL); } } return mPtr->numKey; } int -TkFindStateNumObj(interp, optionPtr, mapPtr, keyPtr) - Tcl_Interp *interp; /* Interp for error reporting. */ - Tcl_Obj *optionPtr; /* String to use when constructing error. */ - CONST TkStateMap *mapPtr; /* Lookup table. */ - Tcl_Obj *keyPtr; /* String key to find in lookup table. */ +TkFindStateNumObj( + Tcl_Interp *interp, /* Interp for error reporting. */ + Tcl_Obj *optionPtr, /* String to use when constructing error. */ + CONST TkStateMap *mapPtr, /* Lookup table. */ + Tcl_Obj *keyPtr) /* String key to find in lookup table. */ { CONST TkStateMap *mPtr; CONST char *key; @@ -934,20 +929,27 @@ TkFindStateNumObj(interp, optionPtr, mapPtr, keyPtr) } keyPtr->internalRep.twoPtrValue.ptr1 = (VOID *) mapPtr; keyPtr->internalRep.twoPtrValue.ptr2 = (VOID *) mPtr->numKey; - keyPtr->typePtr = &tkStateKeyObjType; + keyPtr->typePtr = &tkStateKeyObjType; return mPtr->numKey; } } if (interp != NULL) { mPtr = mapPtr; - Tcl_AppendResult(interp, "bad ", - Tcl_GetStringFromObj(optionPtr, NULL), " value \"", key, - "\": must be ", mPtr->strKey, (char *) NULL); + Tcl_AppendResult(interp, "bad ", Tcl_GetString(optionPtr), + " value \"", key, "\": must be ", mPtr->strKey, NULL); for (mPtr++; mPtr->strKey != NULL; mPtr++) { - Tcl_AppendResult(interp, - ((mPtr[1].strKey != NULL) ? ", " : ", or "), - mPtr->strKey, (char *) NULL); + Tcl_AppendResult(interp, + ((mPtr[1].strKey != NULL) ? ", " : ", or "), + mPtr->strKey, NULL); } } return mPtr->numKey; } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ -- cgit v0.12