/*1* tkCanvas.h --2*3* Declarations shared among all the files that implement4* canvas widgets.5*6* Copyright (c) 1991-1994 The Regents of the University of California.7* Copyright (c) 1994-1995 Sun Microsystems, Inc.8*9* See the file "license.terms" for information on usage and redistribution10* of this file, and for a DISCLAIMER OF ALL WARRANTIES.11*12* SCCS: @(#) tkCanvas.h 1.41 96/02/15 18:51:2813*/1415#ifndef _TKCANVAS16#define _TKCANVAS1718#ifndef _TK19#include "tk.h"20#endif2122/*23* The record below describes a canvas widget. It is made available24* to the item procedures so they can access certain shared fields such25* as the overall displacement and scale factor for the canvas.26*/2728typedef struct TkCanvas {29Tk_Window tkwin; /* Window that embodies the canvas. NULL30* means that the window has been destroyed31* but the data structures haven't yet been32* cleaned up.*/33Display *display; /* Display containing widget; needed, among34* other things, to release resources after35* tkwin has already gone away. */36Tcl_Interp *interp; /* Interpreter associated with canvas. */37Tcl_Command widgetCmd; /* Token for canvas's widget command. */38Tk_Item *firstItemPtr; /* First in list of all items in canvas,39* or NULL if canvas empty. */40Tk_Item *lastItemPtr; /* Last in list of all items in canvas,41* or NULL if canvas empty. */4243/*44* Information used when displaying widget:45*/4647int borderWidth; /* Width of 3-D border around window. */48Tk_3DBorder bgBorder; /* Used for canvas background. */49int relief; /* Indicates whether window as a whole is50* raised, sunken, or flat. */51int highlightWidth; /* Width in pixels of highlight to draw52* around widget when it has the focus.53* <= 0 means don't draw a highlight. */54XColor *highlightBgColorPtr;55/* Color for drawing traversal highlight56* area when highlight is off. */57XColor *highlightColorPtr; /* Color for drawing traversal highlight. */58int inset; /* Total width of all borders, including59* traversal highlight and 3-D border.60* Indicates how much interior stuff must61* be offset from outside edges to leave62* room for borders. */63GC pixmapGC; /* Used to copy bits from a pixmap to the64* screen and also to clear the pixmap. */65int width, height; /* Dimensions to request for canvas window,66* specified in pixels. */67int redrawX1, redrawY1; /* Upper left corner of area to redraw,68* in pixel coordinates. Border pixels69* are included. Only valid if70* REDRAW_PENDING flag is set. */71int redrawX2, redrawY2; /* Lower right corner of area to redraw,72* in integer canvas coordinates. Border73* pixels will *not* be redrawn. */74int confine; /* Non-zero means constrain view to keep75* as much of canvas visible as possible. */7677/*78* Information used to manage the selection and insertion cursor:79*/8081Tk_CanvasTextInfo textInfo; /* Contains lots of fields; see tk.h for82* details. This structure is shared with83* the code that implements individual items. */84int insertOnTime; /* Number of milliseconds cursor should spend85* in "on" state for each blink. */86int insertOffTime; /* Number of milliseconds cursor should spend87* in "off" state for each blink. */88Tcl_TimerToken insertBlinkHandler;89/* Timer handler used to blink cursor on and90* off. */9192/*93* Transformation applied to canvas as a whole: to compute screen94* coordinates (X,Y) from canvas coordinates (x,y), do the following:95*96* X = x - xOrigin;97* Y = y - yOrigin;98*/99100int xOrigin, yOrigin; /* Canvas coordinates corresponding to101* upper-left corner of window, given in102* canvas pixel units. */103int drawableXOrigin, drawableYOrigin;104/* During redisplay, these fields give the105* canvas coordinates corresponding to106* the upper-left corner of the drawable107* where items are actually being drawn108* (typically a pixmap smaller than the109* whole window). */110111/*112* Information used for event bindings associated with items.113*/114115Tk_BindingTable bindingTable;116/* Table of all bindings currently defined117* for this canvas. NULL means that no118* bindings exist, so the table hasn't been119* created. Each "object" used for this120* table is either a Tk_Uid for a tag or121* the address of an item named by id. */122Tk_Item *currentItemPtr; /* The item currently containing the mouse123* pointer, or NULL if none. */124Tk_Item *newCurrentPtr; /* The item that is about to become the125* current one, or NULL. This field is126* used to detect deletions of the new127* current item pointer that occur during128* Leave processing of the previous current129* item. */130double closeEnough; /* The mouse is assumed to be inside an131* item if it is this close to it. */132XEvent pickEvent; /* The event upon which the current choice133* of currentItem is based. Must be saved134* so that if the currentItem is deleted,135* can pick another. */136int state; /* Last known modifier state. Used to137* defer picking a new current object138* while buttons are down. */139140/*141* Information used for managing scrollbars:142*/143144char *xScrollCmd; /* Command prefix for communicating with145* horizontal scrollbar. NULL means no146* horizontal scrollbar. Malloc'ed*/147char *yScrollCmd; /* Command prefix for communicating with148* vertical scrollbar. NULL means no149* vertical scrollbar. Malloc'ed*/150int scrollX1, scrollY1, scrollX2, scrollY2;151/* These four coordinates define the region152* that is the 100% area for scrolling (i.e.153* these numbers determine the size and154* location of the sliders on scrollbars).155* Units are pixels in canvas coords. */156char *regionString; /* The option string from which scrollX1157* etc. are derived. Malloc'ed. */158int xScrollIncrement; /* If >0, defines a grid for horizontal159* scrolling. This is the size of the "unit",160* and the left edge of the screen will always161* lie on an even unit boundary. */162int yScrollIncrement; /* If >0, defines a grid for horizontal163* scrolling. This is the size of the "unit",164* and the left edge of the screen will always165* lie on an even unit boundary. */166167/*168* Information used for scanning:169*/170171int scanX; /* X-position at which scan started (e.g.172* button was pressed here). */173int scanXOrigin; /* Value of xOrigin field when scan started. */174int scanY; /* Y-position at which scan started (e.g.175* button was pressed here). */176int scanYOrigin; /* Value of yOrigin field when scan started. */177178/*179* Information used to speed up searches by remembering the last item180* created or found with an item id search.181*/182183Tk_Item *hotPtr; /* Pointer to "hot" item (one that's been184* recently used. NULL means there's no185* hot item. */186Tk_Item *hotPrevPtr; /* Pointer to predecessor to hotPtr (NULL187* means item is first in list). This is188* only a hint and may not really be hotPtr's189* predecessor. */190191/*192* Miscellaneous information:193*/194195Tk_Cursor cursor; /* Current cursor for window, or None. */196char *takeFocus; /* Value of -takefocus option; not used in197* the C code, but used by keyboard traversal198* scripts. Malloc'ed, but may be NULL. */199double pixelsPerMM; /* Scale factor between MM and pixels;200* used when converting coordinates. */201int flags; /* Various flags; see below for202* definitions. */203int nextId; /* Number to use as id for next item204* created in widget. */205struct TkPostscriptInfo *psInfoPtr;206/* Pointer to information used for generating207* Postscript for the canvas. NULL means208* no Postscript is currently being209* generated. */210} TkCanvas;211212/*213* Flag bits for canvases:214*215* REDRAW_PENDING - 1 means a DoWhenIdle handler has already216* been created to redraw some or all of the217* canvas.218* REDRAW_BORDERS - 1 means that the borders need to be redrawn219* during the next redisplay operation.220* REPICK_NEEDED - 1 means DisplayCanvas should pick a new221* current item before redrawing the canvas.222* GOT_FOCUS - 1 means the focus is currently in this223* widget, so should draw the insertion cursor224* and traversal highlight.225* CURSOR_ON - 1 means the insertion cursor is in the "on"226* phase of its blink cycle. 0 means either227* we don't have the focus or the cursor is in228* the "off" phase of its cycle.229* UPDATE_SCROLLBARS - 1 means the scrollbars should get updated230* as part of the next display operation.231* LEFT_GRABBED_ITEM - 1 means that the mouse left the current232* item while a grab was in effect, so we233* didn't change canvasPtr->currentItemPtr.234* REPICK_IN_PROGRESS - 1 means PickCurrentItem is currently235* executing. If it should be called recursively,236* it should simply return immediately.237*/238239#define REDRAW_PENDING 1240#define REDRAW_BORDERS 2241#define REPICK_NEEDED 4242#define GOT_FOCUS 8243#define CURSOR_ON 0x10244#define UPDATE_SCROLLBARS 0x20245#define LEFT_GRABBED_ITEM 0x40246#define REPICK_IN_PROGRESS 0x100247248/*249* Canvas-related procedures that are shared among Tk modules but not250* exported to the outside world:251*/252253extern int TkCanvPostscriptCmd _ANSI_ARGS_((TkCanvas *canvasPtr,254Tcl_Interp *interp, int argc, char **argv));255256#endif /* _TKCANVAS */257258259