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