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