summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvWind.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-11-04 15:23:05 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-11-04 15:23:05 (GMT)
commit5a7ebb1e1c5d20b44b554a170872eafaabaf0cae (patch)
treebbfefe8e3a1da78eb57ba0c66ea9dcf6bbcb6552 /generic/tkCanvWind.c
parent1a7fe73d9dd7662dc54d12ef4efa9a8cd9a24e7b (diff)
downloadtk-5a7ebb1e1c5d20b44b554a170872eafaabaf0cae.zip
tk-5a7ebb1e1c5d20b44b554a170872eafaabaf0cae.tar.gz
tk-5a7ebb1e1c5d20b44b554a170872eafaabaf0cae.tar.bz2
ANSIfy
Diffstat (limited to 'generic/tkCanvWind.c')
-rw-r--r--generic/tkCanvWind.c623
1 files changed, 300 insertions, 323 deletions
diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c
index a5e05c6..5950f32 100644
--- a/generic/tkCanvWind.c
+++ b/generic/tkCanvWind.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkCanvWind.c --
*
* This file implements window items for canvas widgets.
@@ -6,10 +6,10 @@
* Copyright (c) 1992-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: tkCanvWind.c,v 1.11 2004/11/17 22:46:12 hobbs Exp $
+ * RCS: @(#) $Id: tkCanvWind.c,v 1.12 2005/11/04 15:23:05 dkf Exp $
*/
#include <stdio.h>
@@ -51,100 +51,96 @@ static Tk_CustomOption tagsOption = {
};
static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_ANCHOR, "-anchor", (char *) NULL, (char *) NULL,
+ {TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
"center", Tk_Offset(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_PIXELS, "-height", (char *) NULL, (char *) NULL,
+ {TK_CONFIG_PIXELS, "-height", NULL, NULL,
"0", Tk_Offset(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_CUSTOM, "-state", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK,
- &stateOption},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
+ {TK_CONFIG_CUSTOM, "-state", NULL, NULL,
+ NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ {TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
+ NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
+ {TK_CONFIG_PIXELS, "-width", NULL, NULL,
"0", Tk_Offset(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_WINDOW, "-window", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(WindowItem, tkwin), TK_CONFIG_NULL_OK},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
+ {TK_CONFIG_WINDOW, "-window", NULL, NULL,
+ NULL, Tk_Offset(WindowItem, tkwin), TK_CONFIG_NULL_OK},
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0}
};
/*
- * Prototypes for procedures defined in this file:
+ * Prototypes for functions defined in this file:
*/
-static void ComputeWindowBbox _ANSI_ARGS_((Tk_Canvas canvas,
- WindowItem *winItemPtr));
-static int ConfigureWinItem _ANSI_ARGS_((Tcl_Interp *interp,
+static void ComputeWindowBbox(Tk_Canvas canvas,
+ WindowItem *winItemPtr);
+static int ConfigureWinItem(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
- Tcl_Obj *CONST objv[], int flags));
-static int CreateWinItem _ANSI_ARGS_((Tcl_Interp *interp,
+ Tcl_Obj *CONST objv[], int flags);
+static int CreateWinItem(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *CONST objv[]));
-static void DeleteWinItem _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayWinItem _ANSI_ARGS_((Tk_Canvas canvas,
+ int objc, Tcl_Obj *CONST objv[]);
+static void DeleteWinItem(Tk_Canvas canvas,
+ Tk_Item *itemPtr, Display *display);
+static void DisplayWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static void ScaleWinItem _ANSI_ARGS_((Tk_Canvas canvas,
+ int x, int y, int width, int height);
+static void ScaleWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslateWinItem _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-static int WinItemCoords _ANSI_ARGS_((Tcl_Interp *interp,
+ double scaleX, double scaleY);
+static void TranslateWinItem(Tk_Canvas canvas,
+ Tk_Item *itemPtr, double deltaX, double deltaY);
+static int WinItemCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
- Tcl_Obj *CONST objv[]));
-static void WinItemLostSlaveProc _ANSI_ARGS_((
- ClientData clientData, Tk_Window tkwin));
-static void WinItemRequestProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-static void WinItemStructureProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-static int WinItemToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static int WinItemToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-static double WinItemToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *pointPtr));
+ Tcl_Obj *CONST objv[]);
+static void WinItemLostSlaveProc(ClientData clientData,
+ Tk_Window tkwin);
+static void WinItemRequestProc(ClientData clientData,
+ Tk_Window tkwin);
+static void WinItemStructureProc(ClientData clientData,
+ XEvent *eventPtr);
+static int WinItemToArea(Tk_Canvas canvas,
+ Tk_Item *itemPtr, double *rectPtr);
+static int WinItemToPostscript(Tcl_Interp *interp,
+ Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
+static double WinItemToPoint(Tk_Canvas canvas,
+ Tk_Item *itemPtr, double *pointPtr);
#ifdef X_GetImage
-static int xerrorhandler _ANSI_ARGS_((ClientData clientData,
- XErrorEvent *e));
+static int xerrorhandler(ClientData clientData, XErrorEvent *e);
#endif
-static int CanvasPsWindow _ANSI_ARGS_((Tcl_Interp *interp,
+static int CanvasPsWindow(Tcl_Interp *interp,
Tk_Window tkwin, Tk_Canvas canvas, double x,
- double y, int width, int height));
+ double y, int width, int height);
/*
- * The structure below defines the window item type by means of procedures
+ * The structure below defines the window item type by means of functions
* that can be invoked by generic item code.
*/
Tk_ItemType tkWindowType = {
- "window", /* name */
- sizeof(WindowItem), /* itemSize */
- CreateWinItem, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureWinItem, /* configureProc */
- WinItemCoords, /* coordProc */
- DeleteWinItem, /* deleteProc */
- DisplayWinItem, /* displayProc */
- 1|TK_CONFIG_OBJS, /* flags */
- WinItemToPoint, /* pointProc */
- WinItemToArea, /* areaProc */
- WinItemToPostscript, /* postscriptProc */
- ScaleWinItem, /* scaleProc */
- TranslateWinItem, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* cursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL, /* nextPtr */
+ "window", /* name */
+ sizeof(WindowItem), /* itemSize */
+ CreateWinItem, /* createProc */
+ configSpecs, /* configSpecs */
+ ConfigureWinItem, /* configureProc */
+ WinItemCoords, /* coordProc */
+ DeleteWinItem, /* deleteProc */
+ DisplayWinItem, /* displayProc */
+ 1|TK_CONFIG_OBJS, /* flags */
+ WinItemToPoint, /* pointProc */
+ WinItemToArea, /* areaProc */
+ WinItemToPostscript, /* postscriptProc */
+ ScaleWinItem, /* scaleProc */
+ TranslateWinItem, /* translateProc */
+ NULL, /* indexProc */
+ NULL, /* cursorProc */
+ NULL, /* selectionProc */
+ NULL, /* insertProc */
+ NULL, /* dTextProc */
+ NULL, /* nextPtr */
};
-
/*
- * The structure below defines the official type record for the
- * placer:
+ * The structure below defines the official type record for the canvas (as
+ * geometry manager):
*/
static Tk_GeomMgr canvasGeomType = {
@@ -158,14 +154,12 @@ static Tk_GeomMgr canvasGeomType = {
*
* CreateWinItem --
*
- * This procedure is invoked to create a new window
- * item in a canvas.
+ * This function is invoked to create a new window item in a canvas.
*
* Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * the interp's result; in this case itemPtr is
- * left uninitialized, so it can be safely freed by the
+ * A standard Tcl return value. If an error occurred in creating the
+ * item, then an error message is left in the interp's result; in this
+ * case itemPtr is left uninitialized, so it can be safely freed by the
* caller.
*
* Side effects:
@@ -175,13 +169,13 @@ static Tk_GeomMgr canvasGeomType = {
*/
static int
-CreateWinItem(interp, canvas, itemPtr, objc, objv)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- Tk_Canvas canvas; /* Canvas to hold new item. */
- Tk_Item *itemPtr; /* Record to hold new item; header
- * has been initialized by caller. */
- int objc; /* Number of arguments in objv. */
- Tcl_Obj *CONST objv[]; /* Arguments describing window. */
+CreateWinItem(
+ Tcl_Interp *interp, /* Interpreter for error reporting. */
+ Tk_Canvas canvas, /* Canvas to hold new item. */
+ Tk_Item *itemPtr, /* Record to hold new item; header has been
+ * initialized by caller. */
+ int objc, /* Number of arguments in objv. */
+ Tcl_Obj *CONST objv[]) /* Arguments describing window. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
int i;
@@ -201,8 +195,8 @@ CreateWinItem(interp, canvas, itemPtr, objc, objv)
winItemPtr->canvas = canvas;
/*
- * Process the arguments to fill in the item record.
- * Only 1 (list) or 2 (x y) coords are allowed.
+ * Process the arguments to fill in the item record. Only 1 (list) or 2 (x
+ * y) coords are allowed.
*/
if (objc == 1) {
@@ -222,7 +216,7 @@ CreateWinItem(interp, canvas, itemPtr, objc, objv)
return TCL_OK;
}
- error:
+ error:
DeleteWinItem(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
return TCL_ERROR;
}
@@ -232,9 +226,8 @@ CreateWinItem(interp, canvas, itemPtr, objc, objv)
*
* WinItemCoords --
*
- * This procedure is invoked to process the "coords" widget
- * command on window items. See the user documentation for
- * details on what it does.
+ * This function is invoked to process the "coords" widget command on
+ * window items. See the user documentation for details on what it does.
*
* Results:
* Returns TCL_OK or TCL_ERROR, and sets the interp's result.
@@ -246,15 +239,13 @@ CreateWinItem(interp, canvas, itemPtr, objc, objv)
*/
static int
-WinItemCoords(interp, canvas, itemPtr, objc, objv)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item whose coordinates are to be
- * read or modified. */
- int objc; /* Number of coordinates supplied in
- * objv. */
- Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
+WinItemCoords(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item whose coordinates are to be read or
+ * modified. */
+ int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Obj *CONST objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
@@ -299,12 +290,12 @@ WinItemCoords(interp, canvas, itemPtr, objc, objv)
*
* ConfigureWinItem --
*
- * This procedure is invoked to configure various aspects
- * of a window item, such as its anchor position.
+ * This function is invoked to configure various aspects of a window
+ * item, such as its anchor position.
*
* Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in the interp's result.
+ * A standard Tcl result code. If an error occurs, then an error message
+ * is left in the interp's result.
*
* Side effects:
* Configuration information may be set for itemPtr.
@@ -313,13 +304,13 @@ WinItemCoords(interp, canvas, itemPtr, objc, objv)
*/
static int
-ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Canvas canvas; /* Canvas containing itemPtr. */
- Tk_Item *itemPtr; /* Window item to reconfigure. */
- int objc; /* Number of elements in objv. */
- Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
+ConfigureWinItem(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ Tk_Canvas canvas, /* Canvas containing itemPtr. */
+ Tk_Item *itemPtr, /* Window item to reconfigure. */
+ int objc, /* Number of elements in objv. */
+ Tcl_Obj *CONST objv[], /* Arguments describing things to configure. */
+ int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
Tk_Window oldWindow;
@@ -340,8 +331,7 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags)
if (oldWindow != NULL) {
Tk_DeleteEventHandler(oldWindow, StructureNotifyMask,
WinItemStructureProc, (ClientData) winItemPtr);
- Tk_ManageGeometry(oldWindow, (Tk_GeomMgr *) NULL,
- (ClientData) NULL);
+ Tk_ManageGeometry(oldWindow, NULL, (ClientData) NULL);
Tk_UnmaintainGeometry(oldWindow, canvasTkwin);
Tk_UnmapWindow(oldWindow);
}
@@ -349,10 +339,10 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags)
Tk_Window ancestor, parent;
/*
- * Make sure that the canvas is either the parent of the
- * window associated with the item or a descendant of that
- * parent. Also, don't allow a top-of-hierarchy window to be
- * managed inside a canvas.
+ * Make sure that the canvas is either the parent of the window
+ * associated with the item or a descendant of that parent. Also,
+ * don't allow a top-of-hierarchy window to be managed inside a
+ * canvas.
*/
parent = Tk_Parent(winItemPtr->tkwin);
@@ -362,10 +352,10 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags)
break;
}
if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) {
- badWindow:
+ badWindow:
Tcl_AppendResult(interp, "can't use ",
Tk_PathName(winItemPtr->tkwin),
- " in a window item of this canvas", (char *) NULL);
+ " in a window item of this canvas", NULL);
winItemPtr->tkwin = NULL;
return TCL_ERROR;
}
@@ -401,8 +391,8 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags)
*
* DeleteWinItem --
*
- * This procedure is called to clean up the data structure
- * associated with a window item.
+ * This function is called to clean up the data structure associated with
+ * a window item.
*
* Results:
* None.
@@ -414,11 +404,10 @@ ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags)
*/
static void
-DeleteWinItem(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Overall info about widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
+DeleteWinItem(
+ Tk_Canvas canvas, /* Overall info about widget. */
+ Tk_Item *itemPtr, /* Item that is being deleted. */
+ Display *display) /* Display containing window for canvas. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
@@ -426,7 +415,7 @@ DeleteWinItem(canvas, itemPtr, display)
if (winItemPtr->tkwin != NULL) {
Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
WinItemStructureProc, (ClientData) winItemPtr);
- Tk_ManageGeometry(winItemPtr->tkwin, (Tk_GeomMgr *) NULL,
+ Tk_ManageGeometry(winItemPtr->tkwin, NULL,
(ClientData) NULL);
if (canvasTkwin != Tk_Parent(winItemPtr->tkwin)) {
Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin);
@@ -440,26 +429,23 @@ DeleteWinItem(canvas, itemPtr, display)
*
* ComputeWindowBbox --
*
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a window item.
- * This procedure is where the child window's placement is
- * computed.
+ * This function is invoked to compute the bounding box of all the pixels
+ * that may be drawn as part of a window item. This function is where the
+ * child window's placement is computed.
*
* Results:
* None.
*
* Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
+ * The fields x1, y1, x2, and y2 are updated in the header for itemPtr.
*
*--------------------------------------------------------------
*/
static void
-ComputeWindowBbox(canvas, winItemPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- WindowItem *winItemPtr; /* Item whose bbox is to be
- * recomputed. */
+ComputeWindowBbox(
+ Tk_Canvas canvas, /* Canvas that contains item. */
+ WindowItem *winItemPtr) /* Item whose bbox is to be recomputed. */
{
int width, height, x, y;
Tk_State state = winItemPtr->header.state;
@@ -472,10 +458,10 @@ ComputeWindowBbox(canvas, winItemPtr)
}
if ((winItemPtr->tkwin == NULL) || (state == TK_STATE_HIDDEN)) {
/*
- * There is no window for this item yet. Just give it a 1x1
- * bounding box. Don't give it a 0x0 bounding box; there are
- * strange cases where this bounding box might be used as the
- * dimensions of the window, and 0x0 causes problems under X.
+ * There is no window for this item yet. Just give it a 1x1 bounding
+ * box. Don't give it a 0x0 bounding box; there are strange cases
+ * where this bounding box might be used as the dimensions of the
+ * window, and 0x0 causes problems under X.
*/
winItemPtr->header.x1 = x;
@@ -509,36 +495,36 @@ ComputeWindowBbox(canvas, winItemPtr)
*/
switch (winItemPtr->anchor) {
- case TK_ANCHOR_N:
- x -= width/2;
- break;
- case TK_ANCHOR_NE:
- x -= width;
- break;
- case TK_ANCHOR_E:
- x -= width;
- y -= height/2;
- break;
- case TK_ANCHOR_SE:
- x -= width;
- y -= height;
- break;
- case TK_ANCHOR_S:
- x -= width/2;
- y -= height;
- break;
- case TK_ANCHOR_SW:
- y -= height;
- break;
- case TK_ANCHOR_W:
- y -= height/2;
- break;
- case TK_ANCHOR_NW:
- break;
- case TK_ANCHOR_CENTER:
- x -= width/2;
- y -= height/2;
- break;
+ case TK_ANCHOR_N:
+ x -= width/2;
+ break;
+ case TK_ANCHOR_NE:
+ x -= width;
+ break;
+ case TK_ANCHOR_E:
+ x -= width;
+ y -= height/2;
+ break;
+ case TK_ANCHOR_SE:
+ x -= width;
+ y -= height;
+ break;
+ case TK_ANCHOR_S:
+ x -= width/2;
+ y -= height;
+ break;
+ case TK_ANCHOR_SW:
+ y -= height;
+ break;
+ case TK_ANCHOR_W:
+ y -= height/2;
+ break;
+ case TK_ANCHOR_NW:
+ break;
+ case TK_ANCHOR_CENTER:
+ x -= width/2;
+ y -= height/2;
+ break;
}
/*
@@ -556,36 +542,32 @@ ComputeWindowBbox(canvas, winItemPtr)
*
* DisplayWinItem --
*
- * This procedure is invoked to "draw" a window item in a given
- * drawable. Since the window draws itself, we needn't do any
- * actual redisplay here. However, this procedure takes care
- * of actually repositioning the child window so that it occupies
- * the correct screen position.
+ * This function is invoked to "draw" a window item in a given drawable.
+ * Since the window draws itself, we needn't do any actual redisplay
+ * here. However, this function takes care of actually repositioning the
+ * child window so that it occupies the correct screen position.
*
* Results:
* None.
*
* Side effects:
- * The child window's position may get changed. Note: this
- * procedure gets called both when a window needs to be displayed
- * and when it ceases to be visible on the screen (e.g. it was
- * scrolled or moved off-screen or the enclosing canvas is
- * unmapped).
+ * The child window's position may get changed. Note: this function gets
+ * called both when a window needs to be displayed and when it ceases to
+ * be visible on the screen (e.g. it was scrolled or moved off-screen or
+ * the enclosing canvas is unmapped).
*
*--------------------------------------------------------------
*/
static void
-DisplayWinItem(canvas, itemPtr, display, drawable, regionX, regionY,
- regionWidth, regionHeight)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int regionX, regionY, regionWidth, regionHeight;
- /* Describes region of canvas that
- * must be redisplayed (not used). */
+DisplayWinItem(
+ Tk_Canvas canvas, /* Canvas that contains item. */
+ Tk_Item *itemPtr, /* Item to be displayed. */
+ Display *display, /* Display on which to draw item. */
+ Drawable drawable, /* Pixmap or window in which to draw item. */
+ int regionX, int regionY, int regionWidth, int regionHeight)
+ /* Describes region of canvas that must be
+ * redisplayed (not used). */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
int width, height;
@@ -613,16 +595,16 @@ DisplayWinItem(canvas, itemPtr, display, drawable, regionX, regionY,
height = winItemPtr->header.y2 - winItemPtr->header.y1;
/*
- * If the window is completely out of the visible area of the canvas
- * then unmap it. This code used not to be present (why unmap the
- * window if it isn't visible anyway?) but this could cause the
- * window to suddenly reappear if the canvas window got resized.
+ * If the window is completely out of the visible area of the canvas then
+ * unmap it. This code used not to be present (why unmap the window if it
+ * isn't visible anyway?) but this could cause the window to suddenly
+ * reappear if the canvas window got resized.
*/
if (((x + width) <= 0) || ((y + height) <= 0)
|| (x >= Tk_Width(canvasTkwin)) || (y >= Tk_Height(canvasTkwin))) {
if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) {
- Tk_UnmapWindow(winItemPtr->tkwin);
+ Tk_UnmapWindow(winItemPtr->tkwin);
} else {
Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin);
}
@@ -630,8 +612,8 @@ DisplayWinItem(canvas, itemPtr, display, drawable, regionX, regionY,
}
/*
- * Reposition and map the window (but in different ways depending
- * on whether the canvas is the window's parent).
+ * Reposition and map the window (but in different ways depending on
+ * whether the canvas is the window's parent).
*/
if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) {
@@ -652,14 +634,14 @@ DisplayWinItem(canvas, itemPtr, display, drawable, regionX, regionY,
*
* WinItemToPoint --
*
- * Computes the distance from a given point to a given
- * window, in canvas units.
+ * Computes the distance from a given point to a given window, in canvas
+ * units.
*
* Results:
- * The return value is 0 if the point whose x and y coordinates
- * are coordPtr[0] and coordPtr[1] is inside the window. If the
- * point isn't inside the window then the return value is the
- * distance from the point to the window.
+ * The return value is 0 if the point whose x and y coordinates are
+ * coordPtr[0] and coordPtr[1] is inside the window. If the point isn't
+ * inside the window then the return value is the distance from the point
+ * to the window.
*
* Side effects:
* None.
@@ -668,10 +650,10 @@ DisplayWinItem(canvas, itemPtr, display, drawable, regionX, regionY,
*/
static double
-WinItemToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
+WinItemToPoint(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item to check against point. */
+ double *pointPtr) /* Pointer to x and y coordinates. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
@@ -709,14 +691,13 @@ WinItemToPoint(canvas, itemPtr, pointPtr)
*
* WinItemToArea --
*
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangle.
+ * This function is called to determine whether an item lies entirely
+ * inside, entirely outside, or overlapping a given rectangle.
*
* Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
+ * -1 is returned if the item is entirely outside the area given by
+ * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given
+ * area.
*
* Side effects:
* None.
@@ -725,11 +706,11 @@ WinItemToPoint(canvas, itemPtr, pointPtr)
*/
static int
-WinItemToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against rectangle. */
- double *rectPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
+WinItemToArea(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item to check against rectangle. */
+ double *rectPtr) /* Pointer to array of four coordinates
+ * (x1,y1,x2,y2) describing rectangular
* area. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
@@ -754,8 +735,8 @@ WinItemToArea(canvas, itemPtr, rectPtr)
*
* xerrorhandler --
*
- * This is a dummy function to catch X11 errors during an
- * attempt to print a canvas window.
+ * This is a dummy function to catch X11 errors during an attempt to
+ * print a canvas window.
*
* Results:
* None.
@@ -768,11 +749,11 @@ WinItemToArea(canvas, itemPtr, rectPtr)
#ifdef X_GetImage
static int
-xerrorhandler(clientData, e)
- ClientData clientData;
- XErrorEvent *e;
+xerrorhandler(
+ ClientData clientData,
+ XErrorEvent *e)
{
- return 0;
+ return 0;
}
#endif
@@ -782,15 +763,13 @@ xerrorhandler(clientData, e)
*
* WinItemToPostscript --
*
- * This procedure is called to generate Postscript for
- * window items.
+ * This function is called to generate Postscript for window items.
*
* Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used to be there.
- * If no error occurs, then Postscript for the item is appended
- * to the result.
+ * The return value is a standard Tcl result. If an error occurs in
+ * generating Postscript then an error message is left in interp->result,
+ * replacing whatever used to be there. If no error occurs, then
+ * Postscript for the item is appended to the result.
*
* Side effects:
* None.
@@ -799,15 +778,13 @@ xerrorhandler(clientData, e)
*/
static int
-WinItemToPostscript(interp, canvas, itemPtr, prepass)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- Tk_Item *itemPtr; /* Item for which Postscript is
- * wanted. */
- int prepass; /* 1 means this is a prepass to
- * collect font information; 0 means
- * final Postscript is being created.*/
+WinItemToPostscript(
+ Tcl_Interp *interp, /* Leave Postscript or error message here. */
+ Tk_Canvas canvas, /* Information about overall canvas. */
+ Tk_Item *itemPtr, /* Item for which Postscript is wanted. */
+ int prepass) /* 1 means this is a prepass to collect font
+ * information; 0 means final Postscript is
+ * being created. */
{
WindowItem *winItemPtr = (WindowItem *)itemPtr;
@@ -818,80 +795,75 @@ WinItemToPostscript(interp, canvas, itemPtr, prepass)
if (prepass || winItemPtr->tkwin == NULL) {
return TCL_OK;
}
-
+
width = Tk_Width(tkwin);
height = Tk_Height(tkwin);
/*
- * Compute the coordinates of the lower-left corner of the window,
- * taking into account the anchor position for the window.
+ * Compute the coordinates of the lower-left corner of the window, taking
+ * into account the anchor position for the window.
*/
x = winItemPtr->x;
y = Tk_CanvasPsY(canvas, winItemPtr->y);
-
+
switch (winItemPtr->anchor) {
- case TK_ANCHOR_NW: y -= height; break;
- case TK_ANCHOR_N: x -= width/2.0; y -= height; break;
- case TK_ANCHOR_NE: x -= width; y -= height; break;
- case TK_ANCHOR_E: x -= width; y -= height/2.0; break;
- case TK_ANCHOR_SE: x -= width; break;
- case TK_ANCHOR_S: x -= width/2.0; break;
- case TK_ANCHOR_SW: break;
- case TK_ANCHOR_W: y -= height/2.0; break;
- case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break;
+ case TK_ANCHOR_NW: y -= height; break;
+ case TK_ANCHOR_N: x -= width/2.0; y -= height; break;
+ case TK_ANCHOR_NE: x -= width; y -= height; break;
+ case TK_ANCHOR_E: x -= width; y -= height/2.0; break;
+ case TK_ANCHOR_SE: x -= width; break;
+ case TK_ANCHOR_S: x -= width/2.0; break;
+ case TK_ANCHOR_SW: break;
+ case TK_ANCHOR_W: y -= height/2.0; break;
+ case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break;
}
return CanvasPsWindow(interp, tkwin, canvas, x, y, width, height);
}
-
+
static int
-CanvasPsWindow(interp, tkwin, canvas, x, y, width, height)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Window tkwin; /* window to be printed */
- Tk_Canvas canvas; /* Information about overall canvas. */
- double x, y; /* origin of window. */
- int width, height; /* width/height of window. */
+CanvasPsWindow(
+ Tcl_Interp *interp, /* Leave Postscript or error message here. */
+ Tk_Window tkwin, /* window to be printed */
+ Tk_Canvas canvas, /* Information about overall canvas. */
+ double x, double y, /* origin of window. */
+ int width, int height) /* width/height of window. */
{
char buffer[256];
XImage *ximage;
int result;
Tcl_DString buffer1, buffer2;
#ifdef X_GetImage
- Tk_ErrorHandler handle;
+ Tk_ErrorHandler handle;
#endif
sprintf(buffer, "\n%%%% %s item (%s, %d x %d)\n%.15g %.15g translate\n",
Tk_Class(tkwin), Tk_PathName(tkwin), width, height, x, y);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
+ Tcl_AppendResult(interp, buffer, NULL);
- /* first try if the widget has its own "postscript" command. If it
- * exists, this will produce much better postscript than
- * when a pixmap is used.
+ /*
+ * First try if the widget has its own "postscript" command. If it exists,
+ * this will produce much better postscript than when a pixmap is used.
*/
Tcl_DStringInit(&buffer1);
Tcl_DStringInit(&buffer2);
Tcl_DStringGetResult(interp, &buffer2);
- sprintf (buffer, "%s postscript -prolog 0\n", Tk_PathName(tkwin));
+ sprintf(buffer, "%s postscript -prolog 0\n", Tk_PathName(tkwin));
result = Tcl_Eval(interp, buffer);
Tcl_DStringGetResult(interp, &buffer1);
Tcl_DStringResult(interp, &buffer2);
Tcl_DStringFree(&buffer2);
if (result == TCL_OK) {
- Tcl_AppendResult(interp,
- "50 dict begin\nsave\ngsave\n",
- (char *) NULL);
- sprintf (buffer,
- "0 %d moveto %d 0 rlineto 0 -%d rlineto -%d",
+ Tcl_AppendResult(interp, "50 dict begin\nsave\ngsave\n", NULL);
+ sprintf(buffer, "0 %d moveto %d 0 rlineto 0 -%d rlineto -%d",
height, width, height, width);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
+ Tcl_AppendResult(interp, buffer, NULL);
Tcl_AppendResult(interp, " 0 rlineto closepath\n",
"1.000 1.000 1.000 setrgbcolor AdjustColor\nfill\ngrestore\n",
- Tcl_DStringValue(&buffer1), "\nrestore\nend\n\n\n",
- (char *) NULL);
+ Tcl_DStringValue(&buffer1), "\nrestore\nend\n\n\n", NULL);
Tcl_DStringFree(&buffer1);
return result;
@@ -899,17 +871,18 @@ CanvasPsWindow(interp, tkwin, canvas, x, y, width, height)
Tcl_DStringFree(&buffer1);
/*
- * If the window is off the screen it will generate an BadMatch/XError
- * We catch any BadMatch errors here
+ * If the window is off the screen it will generate a BadMatch/XError. We
+ * catch any BadMatch errors here
*/
+
#ifdef X_GetImage
handle = Tk_CreateErrorHandler(Tk_Display(tkwin), BadMatch,
X_GetImage, -1, xerrorhandler, (ClientData) tkwin);
#endif
/*
- * Generate an XImage from the window. We can then read pixel
- * values out of the XImage.
+ * Generate an XImage from the window. We can then read pixel values out
+ * of the XImage.
*/
ximage = XGetImage(Tk_Display(tkwin), Tk_WindowId(tkwin), 0, 0,
@@ -919,7 +892,7 @@ CanvasPsWindow(interp, tkwin, canvas, x, y, width, height)
Tk_DeleteErrorHandler(handle);
#endif
- if (ximage == (XImage*) NULL) {
+ if (ximage == NULL) {
return TCL_OK;
}
@@ -935,15 +908,14 @@ CanvasPsWindow(interp, tkwin, canvas, x, y, width, height)
*
* ScaleWinItem --
*
- * This procedure is invoked to rescale a window item.
+ * This function is invoked to rescale a window item.
*
* Results:
* None.
*
* Side effects:
- * The window referred to by itemPtr is rescaled
- * so that the following transformation is applied to all
- * point coordinates:
+ * The window referred to by itemPtr is rescaled so that the following
+ * transformation is applied to all point coordinates:
* x' = originX + scaleX*(x-originX)
* y' = originY + scaleY*(y-originY)
*
@@ -951,12 +923,13 @@ CanvasPsWindow(interp, tkwin, canvas, x, y, width, height)
*/
static void
-ScaleWinItem(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing window. */
- Tk_Item *itemPtr; /* Window to be scaled. */
- double originX, originY; /* Origin about which to scale window. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
+ScaleWinItem(
+ Tk_Canvas canvas, /* Canvas containing window. */
+ Tk_Item *itemPtr, /* Window to be scaled. */
+ double originX, double originY,
+ /* Origin about which to scale window. */
+ double scaleX, /* Amount to scale in X direction. */
+ double scaleY) /* Amount to scale in Y direction. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
@@ -976,25 +949,24 @@ ScaleWinItem(canvas, itemPtr, originX, originY, scaleX, scaleY)
*
* TranslateWinItem --
*
- * This procedure is called to move a window by a given amount.
+ * This function is called to move a window by a given amount.
*
* Results:
* None.
*
* Side effects:
- * The position of the window is offset by (xDelta, yDelta),
- * and the bounding box is updated in the generic part of the
- * item structure.
+ * The position of the window is offset by (xDelta, yDelta), and the
+ * bounding box is updated in the generic part of the item structure.
*
*--------------------------------------------------------------
*/
static void
-TranslateWinItem(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
+TranslateWinItem(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double deltaX, double deltaY)
+ /* Amount by which item is to be moved. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
@@ -1008,25 +980,23 @@ TranslateWinItem(canvas, itemPtr, deltaX, deltaY)
*
* WinItemStructureProc --
*
- * This procedure is invoked whenever StructureNotify events
- * occur for a window that's managed as part of a canvas window
- * item. This procudure's only purpose is to clean up when
- * windows are deleted.
+ * This function is invoked whenever StructureNotify events occur for a
+ * window that's managed as part of a canvas window item. This function's
+ * only purpose is to clean up when windows are deleted.
*
* Results:
* None.
*
* Side effects:
- * The window is disassociated from the window item when it is
- * deleted.
+ * The window is disassociated from the window item when it is deleted.
*
*--------------------------------------------------------------
*/
static void
-WinItemStructureProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to record describing window item. */
- XEvent *eventPtr; /* Describes what just happened. */
+WinItemStructureProc(
+ ClientData clientData, /* Pointer to record describing window item. */
+ XEvent *eventPtr) /* Describes what just happened. */
{
WindowItem *winItemPtr = (WindowItem *) clientData;
@@ -1040,8 +1010,8 @@ WinItemStructureProc(clientData, eventPtr)
*
* WinItemRequestProc --
*
- * This procedure is invoked whenever a window that's associated
- * with a window canvas item changes its requested dimensions.
+ * This function is invoked whenever a window that's associated with a
+ * window canvas item changes its requested dimensions.
*
* Results:
* None.
@@ -1054,16 +1024,15 @@ WinItemStructureProc(clientData, eventPtr)
*/
static void
-WinItemRequestProc(clientData, tkwin)
- ClientData clientData; /* Pointer to record for window item. */
- Tk_Window tkwin; /* Window that changed its desired
- * size. */
+WinItemRequestProc(
+ ClientData clientData, /* Pointer to record for window item. */
+ Tk_Window tkwin) /* Window that changed its desired size. */
{
WindowItem *winItemPtr = (WindowItem *) clientData;
ComputeWindowBbox(winItemPtr->canvas, winItemPtr);
- DisplayWinItem(winItemPtr->canvas, (Tk_Item *) winItemPtr,
- (Display *) NULL, (Drawable) None, 0, 0, 0, 0);
+ DisplayWinItem(winItemPtr->canvas, (Tk_Item *) winItemPtr, NULL,
+ (Drawable) None, 0, 0, 0, 0);
}
/*
@@ -1071,8 +1040,8 @@ WinItemRequestProc(clientData, tkwin)
*
* WinItemLostSlaveProc --
*
- * This procedure is invoked by Tk whenever some other geometry
- * claims control over a slave that used to be managed by us.
+ * This function is invoked by Tk whenever some other geometry claims
+ * control over a slave that used to be managed by us.
*
* Results:
* None.
@@ -1085,10 +1054,10 @@ WinItemRequestProc(clientData, tkwin)
/* ARGSUSED */
static void
-WinItemLostSlaveProc(clientData, tkwin)
- ClientData clientData; /* WindowItem structure for slave window that
+WinItemLostSlaveProc(
+ ClientData clientData, /* WindowItem structure for slave window that
* was stolen away. */
- Tk_Window tkwin; /* Tk's handle for the slave window. */
+ Tk_Window tkwin) /* Tk's handle for the slave window. */
{
WindowItem *winItemPtr = (WindowItem *) clientData;
Tk_Window canvasTkwin = Tk_CanvasTkwin(winItemPtr->canvas);
@@ -1101,3 +1070,11 @@ WinItemLostSlaveProc(clientData, tkwin)
Tk_UnmapWindow(winItemPtr->tkwin);
winItemPtr->tkwin = NULL;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */