annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tkCanvas.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * tkCanvas.h --
jpayne@69 3 *
jpayne@69 4 * Declarations shared among all the files that implement canvas widgets.
jpayne@69 5 *
jpayne@69 6 * Copyright (c) 1991-1994 The Regents of the University of California.
jpayne@69 7 * Copyright (c) 1994-1995 Sun Microsystems, Inc.
jpayne@69 8 * Copyright (c) 1998 by Scriptics Corporation.
jpayne@69 9 *
jpayne@69 10 * See the file "license.terms" for information on usage and redistribution of
jpayne@69 11 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
jpayne@69 12 */
jpayne@69 13
jpayne@69 14 #ifndef _TKCANVAS
jpayne@69 15 #define _TKCANVAS
jpayne@69 16
jpayne@69 17 #ifndef _TK
jpayne@69 18 #include "tk.h"
jpayne@69 19 #endif
jpayne@69 20
jpayne@69 21 #ifndef USE_OLD_TAG_SEARCH
jpayne@69 22 typedef struct TagSearchExpr_s TagSearchExpr;
jpayne@69 23
jpayne@69 24 struct TagSearchExpr_s {
jpayne@69 25 TagSearchExpr *next; /* For linked lists of expressions - used in
jpayne@69 26 * bindings. */
jpayne@69 27 Tk_Uid uid; /* The uid of the whole expression. */
jpayne@69 28 Tk_Uid *uids; /* Expresion compiled to an array of uids. */
jpayne@69 29 int allocated; /* Available space for array of uids. */
jpayne@69 30 int length; /* Length of expression. */
jpayne@69 31 int index; /* Current position in expression
jpayne@69 32 * evaluation. */
jpayne@69 33 int match; /* This expression matches event's item's
jpayne@69 34 * tags. */
jpayne@69 35 };
jpayne@69 36 #endif /* not USE_OLD_TAG_SEARCH */
jpayne@69 37
jpayne@69 38 /*
jpayne@69 39 * The record below describes a canvas widget. It is made available to the
jpayne@69 40 * item functions so they can access certain shared fields such as the overall
jpayne@69 41 * displacement and scale factor for the canvas.
jpayne@69 42 */
jpayne@69 43
jpayne@69 44 typedef struct TkCanvas {
jpayne@69 45 Tk_Window tkwin; /* Window that embodies the canvas. NULL means
jpayne@69 46 * that the window has been destroyed but the
jpayne@69 47 * data structures haven't yet been cleaned
jpayne@69 48 * up.*/
jpayne@69 49 Display *display; /* Display containing widget; needed, among
jpayne@69 50 * other things, to release resources after
jpayne@69 51 * tkwin has already gone away. */
jpayne@69 52 Tcl_Interp *interp; /* Interpreter associated with canvas. */
jpayne@69 53 Tcl_Command widgetCmd; /* Token for canvas's widget command. */
jpayne@69 54 Tk_Item *firstItemPtr; /* First in list of all items in canvas, or
jpayne@69 55 * NULL if canvas empty. */
jpayne@69 56 Tk_Item *lastItemPtr; /* Last in list of all items in canvas, or
jpayne@69 57 * NULL if canvas empty. */
jpayne@69 58
jpayne@69 59 /*
jpayne@69 60 * Information used when displaying widget:
jpayne@69 61 */
jpayne@69 62
jpayne@69 63 int borderWidth; /* Width of 3-D border around window. */
jpayne@69 64 Tk_3DBorder bgBorder; /* Used for canvas background. */
jpayne@69 65 int relief; /* Indicates whether window as a whole is
jpayne@69 66 * raised, sunken, or flat. */
jpayne@69 67 int highlightWidth; /* Width in pixels of highlight to draw around
jpayne@69 68 * widget when it has the focus. <= 0 means
jpayne@69 69 * don't draw a highlight. */
jpayne@69 70 XColor *highlightBgColorPtr;
jpayne@69 71 /* Color for drawing traversal highlight area
jpayne@69 72 * when highlight is off. */
jpayne@69 73 XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
jpayne@69 74 int inset; /* Total width of all borders, including
jpayne@69 75 * traversal highlight and 3-D border.
jpayne@69 76 * Indicates how much interior stuff must be
jpayne@69 77 * offset from outside edges to leave room for
jpayne@69 78 * borders. */
jpayne@69 79 GC pixmapGC; /* Used to copy bits from a pixmap to the
jpayne@69 80 * screen and also to clear the pixmap. */
jpayne@69 81 int width, height; /* Dimensions to request for canvas window,
jpayne@69 82 * specified in pixels. */
jpayne@69 83 int redrawX1, redrawY1; /* Upper left corner of area to redraw, in
jpayne@69 84 * pixel coordinates. Border pixels are
jpayne@69 85 * included. Only valid if REDRAW_PENDING flag
jpayne@69 86 * is set. */
jpayne@69 87 int redrawX2, redrawY2; /* Lower right corner of area to redraw, in
jpayne@69 88 * integer canvas coordinates. Border pixels
jpayne@69 89 * will *not* be redrawn. */
jpayne@69 90 int confine; /* Non-zero means constrain view to keep as
jpayne@69 91 * much of canvas visible as possible. */
jpayne@69 92
jpayne@69 93 /*
jpayne@69 94 * Information used to manage the selection and insertion cursor:
jpayne@69 95 */
jpayne@69 96
jpayne@69 97 Tk_CanvasTextInfo textInfo; /* Contains lots of fields; see tk.h for
jpayne@69 98 * details. This structure is shared with the
jpayne@69 99 * code that implements individual items. */
jpayne@69 100 int insertOnTime; /* Number of milliseconds cursor should spend
jpayne@69 101 * in "on" state for each blink. */
jpayne@69 102 int insertOffTime; /* Number of milliseconds cursor should spend
jpayne@69 103 * in "off" state for each blink. */
jpayne@69 104 Tcl_TimerToken insertBlinkHandler;
jpayne@69 105 /* Timer handler used to blink cursor on and
jpayne@69 106 * off. */
jpayne@69 107
jpayne@69 108 /*
jpayne@69 109 * Transformation applied to canvas as a whole: to compute screen
jpayne@69 110 * coordinates (X,Y) from canvas coordinates (x,y), do the following:
jpayne@69 111 *
jpayne@69 112 * X = x - xOrigin;
jpayne@69 113 * Y = y - yOrigin;
jpayne@69 114 */
jpayne@69 115
jpayne@69 116 int xOrigin, yOrigin; /* Canvas coordinates corresponding to
jpayne@69 117 * upper-left corner of window, given in
jpayne@69 118 * canvas pixel units. */
jpayne@69 119 int drawableXOrigin, drawableYOrigin;
jpayne@69 120 /* During redisplay, these fields give the
jpayne@69 121 * canvas coordinates corresponding to the
jpayne@69 122 * upper-left corner of the drawable where
jpayne@69 123 * items are actually being drawn (typically a
jpayne@69 124 * pixmap smaller than the whole window). */
jpayne@69 125
jpayne@69 126 /*
jpayne@69 127 * Information used for event bindings associated with items.
jpayne@69 128 */
jpayne@69 129
jpayne@69 130 Tk_BindingTable bindingTable;
jpayne@69 131 /* Table of all bindings currently defined for
jpayne@69 132 * this canvas. NULL means that no bindings
jpayne@69 133 * exist, so the table hasn't been created.
jpayne@69 134 * Each "object" used for this table is either
jpayne@69 135 * a Tk_Uid for a tag or the address of an
jpayne@69 136 * item named by id. */
jpayne@69 137 Tk_Item *currentItemPtr; /* The item currently containing the mouse
jpayne@69 138 * pointer, or NULL if none. */
jpayne@69 139 Tk_Item *newCurrentPtr; /* The item that is about to become the
jpayne@69 140 * current one, or NULL. This field is used to
jpayne@69 141 * detect deletions of the new current item
jpayne@69 142 * pointer that occur during Leave processing
jpayne@69 143 * of the previous current item. */
jpayne@69 144 double closeEnough; /* The mouse is assumed to be inside an item
jpayne@69 145 * if it is this close to it. */
jpayne@69 146 XEvent pickEvent; /* The event upon which the current choice of
jpayne@69 147 * currentItem is based. Must be saved so that
jpayne@69 148 * if the currentItem is deleted, can pick
jpayne@69 149 * another. */
jpayne@69 150 int state; /* Last known modifier state. Used to defer
jpayne@69 151 * picking a new current object while buttons
jpayne@69 152 * are down. */
jpayne@69 153
jpayne@69 154 /*
jpayne@69 155 * Information used for managing scrollbars:
jpayne@69 156 */
jpayne@69 157
jpayne@69 158 char *xScrollCmd; /* Command prefix for communicating with
jpayne@69 159 * horizontal scrollbar. NULL means no
jpayne@69 160 * horizontal scrollbar. Malloc'ed. */
jpayne@69 161 char *yScrollCmd; /* Command prefix for communicating with
jpayne@69 162 * vertical scrollbar. NULL means no vertical
jpayne@69 163 * scrollbar. Malloc'ed. */
jpayne@69 164 int scrollX1, scrollY1, scrollX2, scrollY2;
jpayne@69 165 /* These four coordinates define the region
jpayne@69 166 * that is the 100% area for scrolling (i.e.
jpayne@69 167 * these numbers determine the size and
jpayne@69 168 * location of the sliders on scrollbars).
jpayne@69 169 * Units are pixels in canvas coords. */
jpayne@69 170 char *regionString; /* The option string from which scrollX1 etc.
jpayne@69 171 * are derived. Malloc'ed. */
jpayne@69 172 int xScrollIncrement; /* If >0, defines a grid for horizontal
jpayne@69 173 * scrolling. This is the size of the "unit",
jpayne@69 174 * and the left edge of the screen will always
jpayne@69 175 * lie on an even unit boundary. */
jpayne@69 176 int yScrollIncrement; /* If >0, defines a grid for horizontal
jpayne@69 177 * scrolling. This is the size of the "unit",
jpayne@69 178 * and the left edge of the screen will always
jpayne@69 179 * lie on an even unit boundary. */
jpayne@69 180
jpayne@69 181 /*
jpayne@69 182 * Information used for scanning:
jpayne@69 183 */
jpayne@69 184
jpayne@69 185 int scanX; /* X-position at which scan started (e.g.
jpayne@69 186 * button was pressed here). */
jpayne@69 187 int scanXOrigin; /* Value of xOrigin field when scan started. */
jpayne@69 188 int scanY; /* Y-position at which scan started (e.g.
jpayne@69 189 * button was pressed here). */
jpayne@69 190 int scanYOrigin; /* Value of yOrigin field when scan started. */
jpayne@69 191
jpayne@69 192 /*
jpayne@69 193 * Information used to speed up searches by remembering the last item
jpayne@69 194 * created or found with an item id search.
jpayne@69 195 */
jpayne@69 196
jpayne@69 197 Tk_Item *hotPtr; /* Pointer to "hot" item (one that's been
jpayne@69 198 * recently used. NULL means there's no hot
jpayne@69 199 * item. */
jpayne@69 200 Tk_Item *hotPrevPtr; /* Pointer to predecessor to hotPtr (NULL
jpayne@69 201 * means item is first in list). This is only
jpayne@69 202 * a hint and may not really be hotPtr's
jpayne@69 203 * predecessor. */
jpayne@69 204
jpayne@69 205 /*
jpayne@69 206 * Miscellaneous information:
jpayne@69 207 */
jpayne@69 208
jpayne@69 209 Tk_Cursor cursor; /* Current cursor for window, or NULL. */
jpayne@69 210 char *takeFocus; /* Value of -takefocus option; not used in the
jpayne@69 211 * C code, but used by keyboard traversal
jpayne@69 212 * scripts. Malloc'ed, but may be NULL. */
jpayne@69 213 double pixelsPerMM; /* Scale factor between MM and pixels; used
jpayne@69 214 * when converting coordinates. */
jpayne@69 215 int flags; /* Various flags; see below for
jpayne@69 216 * definitions. */
jpayne@69 217 int nextId; /* Number to use as id for next item created
jpayne@69 218 * in widget. */
jpayne@69 219 Tk_PostscriptInfo psInfo; /* Pointer to information used for generating
jpayne@69 220 * Postscript for the canvas. NULL means no
jpayne@69 221 * Postscript is currently being generated. */
jpayne@69 222 Tcl_HashTable idTable; /* Table of integer indices. */
jpayne@69 223
jpayne@69 224 /*
jpayne@69 225 * Additional information, added by the 'dash'-patch
jpayne@69 226 */
jpayne@69 227
jpayne@69 228 void *reserved1;
jpayne@69 229 Tk_State canvas_state; /* State of canvas. */
jpayne@69 230 void *reserved2;
jpayne@69 231 void *reserved3;
jpayne@69 232 Tk_TSOffset tsoffset;
jpayne@69 233 #ifndef USE_OLD_TAG_SEARCH
jpayne@69 234 TagSearchExpr *bindTagExprs;/* Linked list of tag expressions used in
jpayne@69 235 * bindings. */
jpayne@69 236 #endif
jpayne@69 237 } TkCanvas;
jpayne@69 238
jpayne@69 239 /*
jpayne@69 240 * Flag bits for canvases:
jpayne@69 241 *
jpayne@69 242 * REDRAW_PENDING - 1 means a DoWhenIdle handler has already been
jpayne@69 243 * created to redraw some or all of the canvas.
jpayne@69 244 * REDRAW_BORDERS - 1 means that the borders need to be redrawn
jpayne@69 245 * during the next redisplay operation.
jpayne@69 246 * REPICK_NEEDED - 1 means DisplayCanvas should pick a new
jpayne@69 247 * current item before redrawing the canvas.
jpayne@69 248 * GOT_FOCUS - 1 means the focus is currently in this widget,
jpayne@69 249 * so should draw the insertion cursor and
jpayne@69 250 * traversal highlight.
jpayne@69 251 * CURSOR_ON - 1 means the insertion cursor is in the "on"
jpayne@69 252 * phase of its blink cycle. 0 means either we
jpayne@69 253 * don't have the focus or the cursor is in the
jpayne@69 254 * "off" phase of its cycle.
jpayne@69 255 * UPDATE_SCROLLBARS - 1 means the scrollbars should get updated as
jpayne@69 256 * part of the next display operation.
jpayne@69 257 * LEFT_GRABBED_ITEM - 1 means that the mouse left the current item
jpayne@69 258 * while a grab was in effect, so we didn't
jpayne@69 259 * change canvasPtr->currentItemPtr.
jpayne@69 260 * REPICK_IN_PROGRESS - 1 means PickCurrentItem is currently
jpayne@69 261 * executing. If it should be called recursively,
jpayne@69 262 * it should simply return immediately.
jpayne@69 263 * BBOX_NOT_EMPTY - 1 means that the bounding box of the area that
jpayne@69 264 * should be redrawn is not empty.
jpayne@69 265 */
jpayne@69 266
jpayne@69 267 #define REDRAW_PENDING 1
jpayne@69 268 #define REDRAW_BORDERS 2
jpayne@69 269 #define REPICK_NEEDED 4
jpayne@69 270 #define GOT_FOCUS 8
jpayne@69 271 #define CURSOR_ON 0x10
jpayne@69 272 #define UPDATE_SCROLLBARS 0x20
jpayne@69 273 #define LEFT_GRABBED_ITEM 0x40
jpayne@69 274 #define REPICK_IN_PROGRESS 0x100
jpayne@69 275 #define BBOX_NOT_EMPTY 0x200
jpayne@69 276
jpayne@69 277 /*
jpayne@69 278 * Flag bits for canvas items (redraw_flags):
jpayne@69 279 *
jpayne@69 280 * FORCE_REDRAW - 1 means that the new coordinates of some item
jpayne@69 281 * are not yet registered using
jpayne@69 282 * Tk_CanvasEventuallyRedraw(). It should still
jpayne@69 283 * be done by the general canvas code.
jpayne@69 284 */
jpayne@69 285
jpayne@69 286 #define FORCE_REDRAW 8
jpayne@69 287
jpayne@69 288 /*
jpayne@69 289 * Canvas-related functions that are shared among Tk modules but not exported
jpayne@69 290 * to the outside world:
jpayne@69 291 */
jpayne@69 292
jpayne@69 293 MODULE_SCOPE int TkCanvPostscriptCmd(TkCanvas *canvasPtr,
jpayne@69 294 Tcl_Interp *interp, int argc, const char **argv);
jpayne@69 295 MODULE_SCOPE int TkCanvTranslatePath(TkCanvas *canvPtr,
jpayne@69 296 int numVertex, double *coordPtr, int closed,
jpayne@69 297 XPoint *outPtr);
jpayne@69 298 /*
jpayne@69 299 * Standard item types provided by Tk:
jpayne@69 300 */
jpayne@69 301
jpayne@69 302 MODULE_SCOPE Tk_ItemType tkArcType, tkBitmapType, tkImageType, tkLineType;
jpayne@69 303 MODULE_SCOPE Tk_ItemType tkOvalType, tkPolygonType;
jpayne@69 304 MODULE_SCOPE Tk_ItemType tkRectangleType, tkTextType, tkWindowType;
jpayne@69 305
jpayne@69 306 /*
jpayne@69 307 * Convenience macro.
jpayne@69 308 */
jpayne@69 309
jpayne@69 310 #define Canvas(canvas) ((TkCanvas *) (canvas))
jpayne@69 311
jpayne@69 312 #endif /* _TKCANVAS */