summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvImg.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkCanvImg.c')
-rw-r--r--generic/tkCanvImg.c521
1 files changed, 256 insertions, 265 deletions
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
index eed7bb4..d4c4486 100644
--- a/generic/tkCanvImg.c
+++ b/generic/tkCanvImg.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkCanvImg.c --
*
* This file implements image items for canvas widgets.
@@ -6,10 +6,10 @@
* 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: tkCanvImg.c,v 1.8 2004/11/17 22:17:11 hobbs Exp $
+ * RCS: @(#) $Id: tkCanvImg.c,v 1.9 2005/11/04 15:23:05 dkf Exp $
*/
#include <stdio.h>
@@ -23,24 +23,24 @@
typedef struct ImageItem {
Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
+ * types. MUST BE FIRST IN STRUCTURE. */
Tk_Canvas canvas; /* Canvas containing the image. */
double x, y; /* Coordinates of positioning point for
* image. */
- Tk_Anchor anchor; /* Where to anchor image relative to
- * (x,y). */
- char *imageString; /* String describing -image option (malloc-ed).
- * NULL means no image right now. */
+ Tk_Anchor anchor; /* Where to anchor image relative to (x,y). */
+ char *imageString; /* String describing -image option
+ * (malloc-ed). NULL means no image right
+ * now. */
char *activeImageString; /* String describing -activeimage option.
* NULL means no image right now. */
char *disabledImageString; /* String describing -disabledimage option.
* NULL means no image right now. */
- Tk_Image image; /* Image to display in window, or NULL if
- * no image at present. */
- Tk_Image activeImage; /* Image to display in window, or NULL if
- * no image at present. */
- Tk_Image disabledImage; /* Image to display in window, or NULL if
- * no image at present. */
+ Tk_Image image; /* Image to display in window, or NULL if no
+ * image at present. */
+ Tk_Image activeImage; /* Image to display in window, or NULL if no
+ * image at present. */
+ Tk_Image disabledImage; /* Image to display in window, or NULL if no
+ * image at present. */
} ImageItem;
/*
@@ -57,86 +57,81 @@ static Tk_CustomOption tagsOption = {
};
static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_STRING, "-activeimage", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(ImageItem, activeImageString),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_ANCHOR, "-anchor", (char *) NULL, (char *) NULL,
+ {TK_CONFIG_STRING, "-activeimage", NULL, NULL,
+ NULL, Tk_Offset(ImageItem, activeImageString), TK_CONFIG_NULL_OK},
+ {TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
"center", Tk_Offset(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_STRING, "-disabledimage", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(ImageItem, disabledImageString),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-image", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(ImageItem, imageString), TK_CONFIG_NULL_OK},
- {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_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
+ {TK_CONFIG_STRING, "-disabledimage", NULL, NULL,
+ NULL, Tk_Offset(ImageItem, disabledImageString), TK_CONFIG_NULL_OK},
+ {TK_CONFIG_STRING, "-image", NULL, NULL,
+ NULL, Tk_Offset(ImageItem, imageString), TK_CONFIG_NULL_OK},
+ {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_END, NULL, NULL, NULL, NULL, 0, 0}
};
/*
- * Prototypes for procedures defined in this file:
+ * Prototypes for functions defined in this file:
*/
-static void ImageChangedProc _ANSI_ARGS_((ClientData clientData,
+static void ImageChangedProc(ClientData clientData,
int x, int y, int width, int height, int imgWidth,
- int imgHeight));
-static int ImageCoords _ANSI_ARGS_((Tcl_Interp *interp,
+ int imgHeight);
+static int ImageCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- Tcl_Obj *CONST argv[]));
-static int ImageToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double ImageToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *coordPtr));
-static int ImageToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-static void ComputeImageBbox _ANSI_ARGS_((Tk_Canvas canvas,
- ImageItem *imgPtr));
-static int ConfigureImage _ANSI_ARGS_((Tcl_Interp *interp,
+ Tcl_Obj *CONST argv[]);
+static int ImageToArea(Tk_Canvas canvas,
+ Tk_Item *itemPtr, double *rectPtr);
+static double ImageToPoint(Tk_Canvas canvas,
+ Tk_Item *itemPtr, double *coordPtr);
+static int ImageToPostscript(Tcl_Interp *interp,
+ Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
+static void ComputeImageBbox(Tk_Canvas canvas, ImageItem *imgPtr);
+static int ConfigureImage(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- Tcl_Obj *CONST argv[], int flags));
-static int CreateImage _ANSI_ARGS_((Tcl_Interp *interp,
+ Tcl_Obj *CONST argv[], int flags);
+static int CreateImage(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, Tcl_Obj *CONST argv[]));
-static void DeleteImage _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayImage _ANSI_ARGS_((Tk_Canvas canvas,
+ int argc, Tcl_Obj *CONST argv[]);
+static void DeleteImage(Tk_Canvas canvas,
+ Tk_Item *itemPtr, Display *display);
+static void DisplayImage(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static void ScaleImage _ANSI_ARGS_((Tk_Canvas canvas,
+ int x, int y, int width, int height);
+static void ScaleImage(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslateImage _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
+ double scaleX, double scaleY);
+static void TranslateImage(Tk_Canvas canvas,
+ Tk_Item *itemPtr, double deltaX, double deltaY);
/*
- * The structures below defines the image item type in terms of
- * procedures that can be invoked by generic item code.
+ * The structures below defines the image item type in terms of functions that
+ * can be invoked by generic item code.
*/
Tk_ItemType tkImageType = {
- "image", /* name */
- sizeof(ImageItem), /* itemSize */
- CreateImage, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureImage, /* configureProc */
- ImageCoords, /* coordProc */
- DeleteImage, /* deleteProc */
- DisplayImage, /* displayProc */
- TK_CONFIG_OBJS, /* flags */
- ImageToPoint, /* pointProc */
- ImageToArea, /* areaProc */
- ImageToPostscript, /* postscriptProc */
- ScaleImage, /* scaleProc */
- TranslateImage, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* icursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL, /* nextPtr */
+ "image", /* name */
+ sizeof(ImageItem), /* itemSize */
+ CreateImage, /* createProc */
+ configSpecs, /* configSpecs */
+ ConfigureImage, /* configureProc */
+ ImageCoords, /* coordProc */
+ DeleteImage, /* deleteProc */
+ DisplayImage, /* displayProc */
+ TK_CONFIG_OBJS, /* flags */
+ ImageToPoint, /* pointProc */
+ ImageToArea, /* areaProc */
+ ImageToPostscript, /* postscriptProc */
+ ScaleImage, /* scaleProc */
+ TranslateImage, /* translateProc */
+ NULL, /* indexProc */
+ NULL, /* icursorProc */
+ NULL, /* selectionProc */
+ NULL, /* insertProc */
+ NULL, /* dTextProc */
+ NULL, /* nextPtr */
};
/*
@@ -144,14 +139,13 @@ Tk_ItemType tkImageType = {
*
* CreateImage --
*
- * This procedure is invoked to create a new image
- * item in a canvas.
+ * This function is invoked to create a new image 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 caller.
+ * 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:
* A new image item is created.
@@ -160,13 +154,13 @@ Tk_ItemType tkImageType = {
*/
static int
-CreateImage(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 rectangle. */
+CreateImage(
+ 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 rectangle. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
int i;
@@ -189,8 +183,8 @@ CreateImage(interp, canvas, itemPtr, objc, objv)
imgPtr->disabledImage = NULL;
/*
- * 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) {
@@ -209,7 +203,7 @@ CreateImage(interp, canvas, itemPtr, objc, objv)
return TCL_OK;
}
- error:
+ error:
DeleteImage(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
return TCL_ERROR;
}
@@ -219,9 +213,8 @@ CreateImage(interp, canvas, itemPtr, objc, objv)
*
* ImageCoords --
*
- * This procedure is invoked to process the "coords" widget
- * command on image items. See the user documentation for
- * details on what it does.
+ * This function is invoked to process the "coords" widget command on
+ * image items. See the user documentation for details on what it does.
*
* Results:
* Returns TCL_OK or TCL_ERROR, and sets the interp's result.
@@ -233,20 +226,19 @@ CreateImage(interp, canvas, itemPtr, objc, objv)
*/
static int
-ImageCoords(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, ... */
+ImageCoords(
+ 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, ... */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
if (objc == 0) {
Tcl_Obj *obj = Tcl_NewObj();
+
Tcl_Obj *subobj = Tcl_NewDoubleObj(imgPtr->x);
Tcl_ListObjAppendElement(interp, obj, subobj);
subobj = Tcl_NewDoubleObj(imgPtr->y);
@@ -273,7 +265,7 @@ ImageCoords(interp, canvas, itemPtr, objc, objv)
ComputeImageBbox(canvas, imgPtr);
} else {
char buf[64];
-
+
sprintf(buf, "wrong # coordinates: expected 0 or 2, got %d", objc);
Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_ERROR;
@@ -286,12 +278,12 @@ ImageCoords(interp, canvas, itemPtr, objc, objv)
*
* ConfigureImage --
*
- * This procedure is invoked to configure various aspects
- * of an image item, such as its anchor position.
+ * This function is invoked to configure various aspects of an image
+ * 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.
@@ -300,13 +292,13 @@ ImageCoords(interp, canvas, itemPtr, objc, objv)
*/
static int
-ConfigureImage(interp, canvas, itemPtr, objc, objv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Canvas canvas; /* Canvas containing itemPtr. */
- Tk_Item *itemPtr; /* Image 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. */
+ConfigureImage(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ Tk_Canvas canvas, /* Canvas containing itemPtr. */
+ Tk_Item *itemPtr, /* Image 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. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
Tk_Window tkwin;
@@ -319,10 +311,10 @@ ConfigureImage(interp, canvas, itemPtr, objc, objv, flags)
}
/*
- * Create the image. Save the old image around and don't free it
- * until after the new one is allocated. This keeps the reference
- * count from going to zero so the image doesn't have to be recreated
- * if it hasn't changed.
+ * Create the image. Save the old image around and don't free it until
+ * after the new one is allocated. This keeps the reference count from
+ * going to zero so the image doesn't have to be recreated if it hasn't
+ * changed.
*/
if (imgPtr->activeImageString != NULL) {
@@ -378,8 +370,8 @@ ConfigureImage(interp, canvas, itemPtr, objc, objv, flags)
*
* DeleteImage --
*
- * This procedure is called to clean up the data structure
- * associated with a image item.
+ * This function is called to clean up the data structure associated with
+ * a image item.
*
* Results:
* None.
@@ -391,11 +383,10 @@ ConfigureImage(interp, canvas, itemPtr, objc, objv, flags)
*/
static void
-DeleteImage(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall canvas widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
+DeleteImage(
+ Tk_Canvas canvas, /* Info about overall canvas widget. */
+ Tk_Item *itemPtr, /* Item that is being deleted. */
+ Display *display) /* Display containing window for canvas. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
@@ -424,27 +415,24 @@ DeleteImage(canvas, itemPtr, display)
*
* ComputeImageBbox --
*
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a image item.
- * This procedure is where the child image'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 image item. This function is where the
+ * child image'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.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static void
-ComputeImageBbox(canvas, imgPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- ImageItem *imgPtr; /* Item whose bbox is to be
- * recomputed. */
+ComputeImageBbox(
+ Tk_Canvas canvas, /* Canvas that contains item. */
+ ImageItem *imgPtr) /* Item whose bbox is to be recomputed. */
{
int width, height;
int x, y;
@@ -480,36 +468,36 @@ ComputeImageBbox(canvas, imgPtr)
Tk_SizeOfImage(image, &width, &height);
switch (imgPtr->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;
}
/*
@@ -527,35 +515,34 @@ ComputeImageBbox(canvas, imgPtr)
*
* DisplayImage --
*
- * This procedure is invoked to draw a image item in a given
- * drawable.
+ * This function is invoked to draw a image item in a given drawable.
*
* Results:
* None.
*
* Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
+ * ItemPtr is drawn in drawable using the transformation information in
+ * canvas.
*
*--------------------------------------------------------------
*/
static void
-DisplayImage(canvas, itemPtr, display, drawable, x, y, width, height)
- 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 x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
+DisplayImage(
+ 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 x, int y, int width, int height)
+ /* Describes region of canvas that must be
+ * redisplayed (not used). */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
short drawableX, drawableY;
Tk_Image image;
Tk_State state = itemPtr->state;
- if(state == TK_STATE_NULL) {
+ if (state == TK_STATE_NULL) {
state = ((TkCanvas *)canvas)->canvas_state;
}
@@ -589,14 +576,14 @@ DisplayImage(canvas, itemPtr, display, drawable, x, y, width, height)
*
* ImageToPoint --
*
- * Computes the distance from a given point to a given
- * rectangle, in canvas units.
+ * Computes the distance from a given point to a given rectangle, 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 image. If the
- * point isn't inside the image then the return value is the
- * distance from the point to the image.
+ * The return value is 0 if the point whose x and y coordinates are
+ * coordPtr[0] and coordPtr[1] is inside the image. If the point isn't
+ * inside the image then the return value is the distance from the point
+ * to the image.
*
* Side effects:
* None.
@@ -605,10 +592,10 @@ DisplayImage(canvas, itemPtr, display, drawable, x, y, width, height)
*/
static double
-ImageToPoint(canvas, itemPtr, coordPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *coordPtr; /* Pointer to x and y coordinates. */
+ImageToPoint(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item to check against point. */
+ double *coordPtr) /* Pointer to x and y coordinates. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
@@ -646,14 +633,13 @@ ImageToPoint(canvas, itemPtr, coordPtr)
*
* ImageToArea --
*
- * 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.
@@ -662,12 +648,12 @@ ImageToPoint(canvas, itemPtr, coordPtr)
*/
static int
-ImageToArea(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
- * area. */
+ImageToArea(
+ 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. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
@@ -691,15 +677,13 @@ ImageToArea(canvas, itemPtr, rectPtr)
*
* ImageToPostscript --
*
- * This procedure is called to generate Postscript for
- * image items.
+ * This function is called to generate Postscript for image 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.
@@ -708,15 +692,13 @@ ImageToArea(canvas, itemPtr, rectPtr)
*/
static int
-ImageToPostscript(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.*/
+ImageToPostscript(
+ 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.*/
{
ImageItem *imgPtr = (ImageItem *)itemPtr;
Tk_Window canvasWin = Tk_CanvasTkwin(canvas);
@@ -745,33 +727,34 @@ ImageToPostscript(interp, canvas, itemPtr, prepass)
/*
* Image item without actual image specified.
*/
+
return TCL_OK;
}
Tk_SizeOfImage(image, &width, &height);
/*
- * Compute the coordinates of the lower-left corner of the image,
- * taking into account the anchor position for the image.
+ * Compute the coordinates of the lower-left corner of the image, taking
+ * into account the anchor position for the image.
*/
x = imgPtr->x;
y = Tk_CanvasPsY(canvas, imgPtr->y);
switch (imgPtr->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;
}
if (!prepass) {
sprintf(buffer, "%.15g %.15g", x, y);
- Tcl_AppendResult(interp, buffer, " translate\n", (char *) NULL);
+ Tcl_AppendResult(interp, buffer, " translate\n", NULL);
}
return Tk_PostscriptImage(image, interp, canvasWin,
@@ -783,14 +766,14 @@ ImageToPostscript(interp, canvas, itemPtr, prepass)
*
* ScaleImage --
*
- * This procedure is invoked to rescale an item.
+ * This function is invoked to rescale an item.
*
* Results:
* None.
*
* Side effects:
- * The item referred to by itemPtr is rescaled so that the
- * following transformation is applied to all point coordinates:
+ * The item 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)
*
@@ -798,12 +781,13 @@ ImageToPostscript(interp, canvas, itemPtr, prepass)
*/
static void
-ScaleImage(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing rectangle. */
- Tk_Item *itemPtr; /* Rectangle to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
+ScaleImage(
+ Tk_Canvas canvas, /* Canvas containing rectangle. */
+ Tk_Item *itemPtr, /* Rectangle to be scaled. */
+ double originX, double originY,
+ /* Origin about which to scale rect. */
+ double scaleX, /* Amount to scale in X direction. */
+ double scaleY) /* Amount to scale in Y direction. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
@@ -817,25 +801,24 @@ ScaleImage(canvas, itemPtr, originX, originY, scaleX, scaleY)
*
* TranslateImage --
*
- * This procedure is called to move an item by a given amount.
+ * This function is called to move an item by a given amount.
*
* Results:
* None.
*
* Side effects:
- * The position of the item is offset by (xDelta, yDelta), and
- * the bounding box is updated in the generic part of the item
- * structure.
+ * The position of the item is offset by (xDelta, yDelta), and the
+ * bounding box is updated in the generic part of the item structure.
*
*--------------------------------------------------------------
*/
static void
-TranslateImage(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. */
+TranslateImage(
+ 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. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
@@ -849,9 +832,9 @@ TranslateImage(canvas, itemPtr, deltaX, deltaY)
*
* ImageChangedProc --
*
- * This procedure is invoked by the image code whenever the manager
- * for an image does something that affects the image's size or
- * how it is displayed.
+ * This function is invoked by the image code whenever the manager for an
+ * image does something that affects the image's size or how it is
+ * displayed.
*
* Results:
* None.
@@ -863,21 +846,21 @@ TranslateImage(canvas, itemPtr, deltaX, deltaY)
*/
static void
-ImageChangedProc(clientData, x, y, width, height, imgWidth, imgHeight)
- ClientData clientData; /* Pointer to canvas item for image. */
- int x, y; /* Upper left pixel (within image)
- * that must be redisplayed. */
- int width, height; /* Dimensions of area to redisplay
- * (may be <= 0). */
- int imgWidth, imgHeight; /* New dimensions of image. */
+ImageChangedProc(
+ ClientData clientData, /* Pointer to canvas item for image. */
+ int x, int y, /* Upper left pixel (within image) that must
+ * be redisplayed. */
+ int width, int height, /* Dimensions of area to redisplay (may be <=
+ * 0). */
+ int imgWidth, int imgHeight)/* New dimensions of image. */
{
ImageItem *imgPtr = (ImageItem *) clientData;
/*
- * If the image's size changed and it's not anchored at its
- * northwest corner then just redisplay the entire area of the
- * image. This is a bit over-conservative, but we need to do
- * something because a size change also means a position change.
+ * If the image's size changed and it's not anchored at its northwest
+ * corner then just redisplay the entire area of the image. This is a bit
+ * over-conservative, but we need to do something because a size change
+ * also means a position change.
*/
if (((imgPtr->header.x2 - imgPtr->header.x1) != imgWidth)
@@ -887,9 +870,17 @@ ImageChangedProc(clientData, x, y, width, height, imgWidth, imgHeight)
height = imgHeight;
Tk_CanvasEventuallyRedraw(imgPtr->canvas, imgPtr->header.x1,
imgPtr->header.y1, imgPtr->header.x2, imgPtr->header.y2);
- }
+ }
ComputeImageBbox(imgPtr->canvas, imgPtr);
Tk_CanvasEventuallyRedraw(imgPtr->canvas, imgPtr->header.x1 + x,
imgPtr->header.y1 + y, (int) (imgPtr->header.x1 + x + width),
(int) (imgPtr->header.y1 + y + height));
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */