1 /*
2  * tk.h --
3  *
4  *	Declarations for Tk-related things that are visible outside of the Tk
5  *	module itself.
6  *
7  * Copyright (c) 1989-1994 The Regents of the University of California.
8  * Copyright (c) 1994 The Australian National University.
9  * Copyright (c) 1994-1998 Sun Microsystems, Inc.
10  * Copyright (c) 1998-2000 Ajuba Solutions.
11  *
12  * See the file "license.terms" for information on usage and redistribution of
13  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
14  */
15 
16 #ifndef _TK
17 #define _TK
18 
19 #include <tcl.h>
20 #if (TCL_MAJOR_VERSION != 8) || (TCL_MINOR_VERSION < 5)
21 #	error Tk 8.5 must be compiled with tcl.h from Tcl 8.5 or better
22 #endif
23 
24 #ifndef _ANSI_ARGS_
25 #   ifndef NO_PROTOTYPES
26 #	define _ANSI_ARGS_(x)	x
27 #   else
28 #	define _ANSI_ARGS_(x)	()
29 #   endif
30 #endif
31 
32 /*
33  * For C++ compilers, use extern "C"
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * When version numbers change here, you must also go into the following files
42  * and update the version numbers:
43  *
44  * library/tk.tcl	(1 LOC patch)
45  * unix/configure.in	(2 LOC Major, 2 LOC minor, 1 LOC patch)
46  * win/configure.in	(as above)
47  * README		(sections 0 and 1)
48  * macosx/Wish.xcode/project.pbxproj (not patchlevel) 1 LOC
49  * macosx/Wish-Common.xcconfig (not patchlevel) 1 LOC
50  * win/README		(not patchlevel)
51  * unix/README		(not patchlevel)
52  * unix/tk.spec		(1 LOC patch)
53  * win/tcl.m4		(not patchlevel)
54  *
55  * You may also need to update some of these files when the numbers change for
56  * the version of Tcl that this release of Tk is compiled against.
57  */
58 
59 #define TK_MAJOR_VERSION	8
60 #define TK_MINOR_VERSION	5
61 #define TK_RELEASE_LEVEL	TCL_FINAL_RELEASE
62 #define TK_RELEASE_SERIAL	19
63 
64 #define TK_VERSION		"8.5"
65 #define TK_PATCH_LEVEL		"8.5.19"
66 
67 /*
68  * A special definition used to allow this header file to be included from
69  * windows or mac resource files so that they can obtain version information.
70  * RC_INVOKED is defined by default by the windows RC tool and manually set
71  * for macintosh.
72  *
73  * Resource compilers don't like all the C stuff, like typedefs and procedure
74  * declarations, that occur below, so block them out.
75  */
76 
77 #ifndef RC_INVOKED
78 
79 #ifndef _XLIB_H
80 #   include <X11/Xlib.h>
81 #   ifdef MAC_OSX_TK
82 #	include <X11/X.h>
83 #   endif
84 #endif
85 #ifdef __STDC__
86 #   include <stddef.h>
87 #endif
88 
89 #ifdef BUILD_tk
90 #undef TCL_STORAGE_CLASS
91 #define TCL_STORAGE_CLASS	DLLEXPORT
92 #endif
93 
94 /*
95  *----------------------------------------------------------------------
96  *
97  * Decide whether or not to use input methods.
98  */
99 
100 #ifdef XNQueryInputStyle
101 #define TK_USE_INPUT_METHODS
102 #endif
103 
104 /*
105  * Dummy types that are used by clients:
106  */
107 
108 typedef struct Tk_BindingTable_ *Tk_BindingTable;
109 typedef struct Tk_Canvas_ *Tk_Canvas;
110 typedef struct Tk_Cursor_ *Tk_Cursor;
111 typedef struct Tk_ErrorHandler_ *Tk_ErrorHandler;
112 typedef struct Tk_Font_ *Tk_Font;
113 typedef struct Tk_Image__ *Tk_Image;
114 typedef struct Tk_ImageMaster_ *Tk_ImageMaster;
115 typedef struct Tk_OptionTable_ *Tk_OptionTable;
116 typedef struct Tk_PostscriptInfo_ *Tk_PostscriptInfo;
117 typedef struct Tk_TextLayout_ *Tk_TextLayout;
118 typedef struct Tk_Window_ *Tk_Window;
119 typedef struct Tk_3DBorder_ *Tk_3DBorder;
120 typedef struct Tk_Style_ *Tk_Style;
121 typedef struct Tk_StyleEngine_ *Tk_StyleEngine;
122 typedef struct Tk_StyledElement_ *Tk_StyledElement;
123 
124 /*
125  * Additional types exported to clients.
126  */
127 
128 typedef const char *Tk_Uid;
129 
130 /*
131  *----------------------------------------------------------------------
132  *
133  * The enum below defines the valid types for Tk configuration options as
134  * implemented by Tk_InitOptions, Tk_SetOptions, etc.
135  */
136 
137 typedef enum {
138     TK_OPTION_BOOLEAN,
139     TK_OPTION_INT,
140     TK_OPTION_DOUBLE,
141     TK_OPTION_STRING,
142     TK_OPTION_STRING_TABLE,
143     TK_OPTION_COLOR,
144     TK_OPTION_FONT,
145     TK_OPTION_BITMAP,
146     TK_OPTION_BORDER,
147     TK_OPTION_RELIEF,
148     TK_OPTION_CURSOR,
149     TK_OPTION_JUSTIFY,
150     TK_OPTION_ANCHOR,
151     TK_OPTION_SYNONYM,
152     TK_OPTION_PIXELS,
153     TK_OPTION_WINDOW,
154     TK_OPTION_END,
155     TK_OPTION_CUSTOM,
156     TK_OPTION_STYLE
157 } Tk_OptionType;
158 
159 /*
160  * Structures of the following type are used by widgets to specify their
161  * configuration options. Typically each widget has a static array of these
162  * structures, where each element of the array describes a single
163  * configuration option. The array is passed to Tk_CreateOptionTable.
164  */
165 
166 typedef struct Tk_OptionSpec {
167     Tk_OptionType type;		/* Type of option, such as TK_OPTION_COLOR;
168 				 * see definitions above. Last option in table
169 				 * must have type TK_OPTION_END. */
170     const char *optionName;	/* Name used to specify option in Tcl
171 				 * commands. */
172     const char *dbName;		/* Name for option in option database. */
173     const char *dbClass;	/* Class for option in database. */
174     const char *defValue;	/* Default value for option if not specified
175 				 * in command line, the option database, or
176 				 * the system. */
177     int objOffset;		/* Where in record to store a Tcl_Obj * that
178 				 * holds the value of this option, specified
179 				 * as an offset in bytes from the start of the
180 				 * record. Use the Tk_Offset macro to generate
181 				 * values for this. -1 means don't store the
182 				 * Tcl_Obj in the record. */
183     int internalOffset;		/* Where in record to store the internal
184 				 * representation of the value of this option,
185 				 * such as an int or XColor *. This field is
186 				 * specified as an offset in bytes from the
187 				 * start of the record. Use the Tk_Offset
188 				 * macro to generate values for it. -1 means
189 				 * don't store the internal representation in
190 				 * the record. */
191     int flags;			/* Any combination of the values defined
192 				 * below. */
193     ClientData clientData;	/* An alternate place to put option-specific
194 				 * data. Used for the monochrome default value
195 				 * for colors, etc. */
196     int typeMask;		/* An arbitrary bit mask defined by the class
197 				 * manager; typically bits correspond to
198 				 * certain kinds of options such as all those
199 				 * that require a redisplay when they change.
200 				 * Tk_SetOptions returns the bit-wise OR of
201 				 * the typeMasks of all options that were
202 				 * changed. */
203 } Tk_OptionSpec;
204 
205 /*
206  * Flag values for Tk_OptionSpec structures. These flags are shared by
207  * Tk_ConfigSpec structures, so be sure to coordinate any changes carefully.
208  */
209 
210 #define TK_OPTION_NULL_OK		(1 << 0)
211 #define TK_OPTION_DONT_SET_DEFAULT	(1 << 3)
212 
213 /*
214  * The following structure and function types are used by TK_OPTION_CUSTOM
215  * options; the structure holds pointers to the functions needed by the Tk
216  * option config code to handle a custom option.
217  */
218 
219 typedef int (Tk_CustomOptionSetProc) _ANSI_ARGS_((ClientData clientData,
220 	Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec,
221 	int offset, char *saveInternalPtr, int flags));
222 typedef Tcl_Obj *(Tk_CustomOptionGetProc) _ANSI_ARGS_((ClientData clientData,
223 	Tk_Window tkwin, char *widgRec, int offset));
224 typedef void (Tk_CustomOptionRestoreProc) _ANSI_ARGS_((ClientData clientData,
225 	Tk_Window tkwin, char *internalPtr, char *saveInternalPtr));
226 typedef void (Tk_CustomOptionFreeProc) _ANSI_ARGS_((ClientData clientData,
227 	Tk_Window tkwin, char *internalPtr));
228 
229 typedef struct Tk_ObjCustomOption {
230     const char *name;		/* Name of the custom option. */
231     Tk_CustomOptionSetProc *setProc;
232 				/* Function to use to set a record's option
233 				 * value from a Tcl_Obj */
234     Tk_CustomOptionGetProc *getProc;
235 				/* Function to use to get a Tcl_Obj
236 				 * representation from an internal
237 				 * representation of an option. */
238     Tk_CustomOptionRestoreProc *restoreProc;
239 				/* Function to use to restore a saved value
240 				 * for the internal representation. */
241     Tk_CustomOptionFreeProc *freeProc;
242 				/* Function to use to free the internal
243 				 * representation of an option. */
244     ClientData clientData;	/* Arbitrary one-word value passed to the
245 				 * handling procs. */
246 } Tk_ObjCustomOption;
247 
248 /*
249  * Macro to use to fill in "offset" fields of the Tk_OptionSpec structure.
250  * Computes number of bytes from beginning of structure to a given field.
251  */
252 
253 #ifdef offsetof
254 #define Tk_Offset(type, field) ((int) offsetof(type, field))
255 #else
256 #define Tk_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
257 #endif
258 
259 /*
260  * The following two structures are used for error handling. When config
261  * options are being modified, the old values are saved in a Tk_SavedOptions
262  * structure. If an error occurs, then the contents of the structure can be
263  * used to restore all of the old values. The contents of this structure are
264  * for the private use Tk. No-one outside Tk should ever read or write any of
265  * the fields of these structures.
266  */
267 
268 typedef struct Tk_SavedOption {
269     struct TkOption *optionPtr;	/* Points to information that describes the
270 				 * option. */
271     Tcl_Obj *valuePtr;		/* The old value of the option, in the form of
272 				 * a Tcl object; may be NULL if the value was
273 				 * not saved as an object. */
274     double internalForm;	/* The old value of the option, in some
275 				 * internal representation such as an int or
276 				 * (XColor *). Valid only if the field
277 				 * optionPtr->specPtr->objOffset is < 0. The
278 				 * space must be large enough to accommodate a
279 				 * double, a long, or a pointer; right now it
280 				 * looks like a double (i.e., 8 bytes) is big
281 				 * enough. Also, using a double guarantees
282 				 * that the field is properly aligned for
283 				 * storing large values. */
284 } Tk_SavedOption;
285 
286 #ifdef TCL_MEM_DEBUG
287 #   define TK_NUM_SAVED_OPTIONS 2
288 #else
289 #   define TK_NUM_SAVED_OPTIONS 20
290 #endif
291 
292 typedef struct Tk_SavedOptions {
293     char *recordPtr;		/* The data structure in which to restore
294 				 * configuration options. */
295     Tk_Window tkwin;		/* Window associated with recordPtr; needed to
296 				 * restore certain options. */
297     int numItems;		/* The number of valid items in items field. */
298     Tk_SavedOption items[TK_NUM_SAVED_OPTIONS];
299 				/* Items used to hold old values. */
300     struct Tk_SavedOptions *nextPtr;
301 				/* Points to next structure in list; needed if
302 				 * too many options changed to hold all the
303 				 * old values in a single structure. NULL
304 				 * means no more structures. */
305 } Tk_SavedOptions;
306 
307 /*
308  * Structure used to describe application-specific configuration options:
309  * indicates procedures to call to parse an option and to return a text string
310  * describing an option. THESE ARE DEPRECATED; PLEASE USE THE NEW STRUCTURES
311  * LISTED ABOVE.
312  */
313 
314 /*
315  * This is a temporary flag used while tkObjConfig and new widgets are in
316  * development.
317  */
318 
319 #ifndef __NO_OLD_CONFIG
320 
321 typedef int (Tk_OptionParseProc) _ANSI_ARGS_((ClientData clientData,
322 	Tcl_Interp *interp, Tk_Window tkwin, CONST84 char *value, char *widgRec,
323 	int offset));
324 typedef char *(Tk_OptionPrintProc) _ANSI_ARGS_((ClientData clientData,
325 	Tk_Window tkwin, char *widgRec, int offset,
326 	Tcl_FreeProc **freeProcPtr));
327 
328 typedef struct Tk_CustomOption {
329     Tk_OptionParseProc *parseProc;
330 				/* Procedure to call to parse an option and
331 				 * store it in converted form. */
332     Tk_OptionPrintProc *printProc;
333 				/* Procedure to return a printable string
334 				 * describing an existing option. */
335     ClientData clientData;	/* Arbitrary one-word value used by option
336 				 * parser: passed to parseProc and
337 				 * printProc. */
338 } Tk_CustomOption;
339 
340 /*
341  * Structure used to specify information for Tk_ConfigureWidget. Each
342  * structure gives complete information for one option, including how the
343  * option is specified on the command line, where it appears in the option
344  * database, etc.
345  */
346 
347 typedef struct Tk_ConfigSpec {
348     int type;			/* Type of option, such as TK_CONFIG_COLOR;
349 				 * see definitions below. Last option in table
350 				 * must have type TK_CONFIG_END. */
351     char *argvName;		/* Switch used to specify option in argv. NULL
352 				 * means this spec is part of a group. */
353     Tk_Uid dbName;		/* Name for option in option database. */
354     Tk_Uid dbClass;		/* Class for option in database. */
355     Tk_Uid defValue;		/* Default value for option if not specified
356 				 * in command line or database. */
357     int offset;			/* Where in widget record to store value; use
358 				 * Tk_Offset macro to generate values for
359 				 * this. */
360     int specFlags;		/* Any combination of the values defined
361 				 * below; other bits are used internally by
362 				 * tkConfig.c. */
363     Tk_CustomOption *customPtr;	/* If type is TK_CONFIG_CUSTOM then this is a
364 				 * pointer to info about how to parse and
365 				 * print the option. Otherwise it is
366 				 * irrelevant. */
367 } Tk_ConfigSpec;
368 
369 /*
370  * Type values for Tk_ConfigSpec structures. See the user documentation for
371  * details.
372  */
373 
374 typedef enum {
375     TK_CONFIG_BOOLEAN, TK_CONFIG_INT, TK_CONFIG_DOUBLE, TK_CONFIG_STRING,
376     TK_CONFIG_UID, TK_CONFIG_COLOR, TK_CONFIG_FONT, TK_CONFIG_BITMAP,
377     TK_CONFIG_BORDER, TK_CONFIG_RELIEF, TK_CONFIG_CURSOR,
378     TK_CONFIG_ACTIVE_CURSOR, TK_CONFIG_JUSTIFY, TK_CONFIG_ANCHOR,
379     TK_CONFIG_SYNONYM, TK_CONFIG_CAP_STYLE, TK_CONFIG_JOIN_STYLE,
380     TK_CONFIG_PIXELS, TK_CONFIG_MM, TK_CONFIG_WINDOW, TK_CONFIG_CUSTOM,
381     TK_CONFIG_END
382 } Tk_ConfigTypes;
383 
384 /*
385  * Possible values for flags argument to Tk_ConfigureWidget:
386  */
387 
388 #define TK_CONFIG_ARGV_ONLY	1
389 #define TK_CONFIG_OBJS		0x80
390 
391 /*
392  * Possible flag values for Tk_ConfigSpec structures. Any bits at or above
393  * TK_CONFIG_USER_BIT may be used by clients for selecting certain entries.
394  * Before changing any values here, coordinate with tkOldConfig.c
395  * (internal-use-only flags are defined there).
396  */
397 
398 #define TK_CONFIG_NULL_OK		(1 << 0)
399 #define TK_CONFIG_COLOR_ONLY		(1 << 1)
400 #define TK_CONFIG_MONO_ONLY		(1 << 2)
401 #define TK_CONFIG_DONT_SET_DEFAULT	(1 << 3)
402 #define TK_CONFIG_OPTION_SPECIFIED      (1 << 4)
403 #define TK_CONFIG_USER_BIT		0x100
404 #endif /* __NO_OLD_CONFIG */
405 
406 /*
407  * Structure used to specify how to handle argv options.
408  */
409 
410 typedef struct {
411     char *key;			/* The key string that flags the option in the
412 				 * argv array. */
413     int type;			/* Indicates option type; see below. */
414     char *src;			/* Value to be used in setting dst; usage
415 				 * depends on type. */
416     char *dst;			/* Address of value to be modified; usage
417 				 * depends on type. */
418     char *help;			/* Documentation message describing this
419 				 * option. */
420 } Tk_ArgvInfo;
421 
422 /*
423  * Legal values for the type field of a Tk_ArgvInfo: see the user
424  * documentation for details.
425  */
426 
427 #define TK_ARGV_CONSTANT		15
428 #define TK_ARGV_INT			16
429 #define TK_ARGV_STRING			17
430 #define TK_ARGV_UID			18
431 #define TK_ARGV_REST			19
432 #define TK_ARGV_FLOAT			20
433 #define TK_ARGV_FUNC			21
434 #define TK_ARGV_GENFUNC			22
435 #define TK_ARGV_HELP			23
436 #define TK_ARGV_CONST_OPTION		24
437 #define TK_ARGV_OPTION_VALUE		25
438 #define TK_ARGV_OPTION_NAME_VALUE	26
439 #define TK_ARGV_END			27
440 
441 /*
442  * Flag bits for passing to Tk_ParseArgv:
443  */
444 
445 #define TK_ARGV_NO_DEFAULTS		0x1
446 #define TK_ARGV_NO_LEFTOVERS		0x2
447 #define TK_ARGV_NO_ABBREV		0x4
448 #define TK_ARGV_DONT_SKIP_FIRST_ARG	0x8
449 
450 /*
451  * Enumerated type for describing actions to be taken in response to a
452  * restrictProc established by Tk_RestrictEvents.
453  */
454 
455 typedef enum {
456     TK_DEFER_EVENT, TK_PROCESS_EVENT, TK_DISCARD_EVENT
457 } Tk_RestrictAction;
458 
459 /*
460  * Priority levels to pass to Tk_AddOption:
461  */
462 
463 #define TK_WIDGET_DEFAULT_PRIO	20
464 #define TK_STARTUP_FILE_PRIO	40
465 #define TK_USER_DEFAULT_PRIO	60
466 #define TK_INTERACTIVE_PRIO	80
467 #define TK_MAX_PRIO		100
468 
469 /*
470  * Relief values returned by Tk_GetRelief:
471  */
472 
473 #define TK_RELIEF_NULL		-1
474 #define TK_RELIEF_FLAT		0
475 #define TK_RELIEF_GROOVE	1
476 #define TK_RELIEF_RAISED	2
477 #define TK_RELIEF_RIDGE		3
478 #define TK_RELIEF_SOLID		4
479 #define TK_RELIEF_SUNKEN	5
480 
481 /*
482  * "Which" argument values for Tk_3DBorderGC:
483  */
484 
485 #define TK_3D_FLAT_GC		1
486 #define TK_3D_LIGHT_GC		2
487 #define TK_3D_DARK_GC		3
488 
489 /*
490  * Special EnterNotify/LeaveNotify "mode" for use in events generated by
491  * tkShare.c. Pick a high enough value that it's unlikely to conflict with
492  * existing values (like NotifyNormal) or any new values defined in the
493  * future.
494  */
495 
496 #define TK_NOTIFY_SHARE		20
497 
498 /*
499  * Enumerated type for describing a point by which to anchor something:
500  */
501 
502 typedef enum {
503     TK_ANCHOR_N, TK_ANCHOR_NE, TK_ANCHOR_E, TK_ANCHOR_SE,
504     TK_ANCHOR_S, TK_ANCHOR_SW, TK_ANCHOR_W, TK_ANCHOR_NW,
505     TK_ANCHOR_CENTER
506 } Tk_Anchor;
507 
508 /*
509  * Enumerated type for describing a style of justification:
510  */
511 
512 typedef enum {
513     TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER
514 } Tk_Justify;
515 
516 /*
517  * The following structure is used by Tk_GetFontMetrics() to return
518  * information about the properties of a Tk_Font.
519  */
520 
521 typedef struct Tk_FontMetrics {
522     int ascent;			/* The amount in pixels that the tallest
523 				 * letter sticks up above the baseline, plus
524 				 * any extra blank space added by the designer
525 				 * of the font. */
526     int descent;		/* The largest amount in pixels that any
527 				 * letter sticks below the baseline, plus any
528 				 * extra blank space added by the designer of
529 				 * the font. */
530     int linespace;		/* The sum of the ascent and descent. How far
531 				 * apart two lines of text in the same font
532 				 * should be placed so that none of the
533 				 * characters in one line overlap any of the
534 				 * characters in the other line. */
535 } Tk_FontMetrics;
536 
537 /*
538  * Flags passed to Tk_MeasureChars:
539  */
540 
541 #define TK_WHOLE_WORDS		1
542 #define TK_AT_LEAST_ONE		2
543 #define TK_PARTIAL_OK		4
544 
545 /*
546  * Flags passed to Tk_ComputeTextLayout:
547  */
548 
549 #define TK_IGNORE_TABS		8
550 #define TK_IGNORE_NEWLINES	16
551 
552 /*
553  * Widget class procedures used to implement platform specific widget
554  * behavior.
555  */
556 
557 typedef Window (Tk_ClassCreateProc) _ANSI_ARGS_((Tk_Window tkwin,
558 	Window parent, ClientData instanceData));
559 typedef void (Tk_ClassWorldChangedProc) _ANSI_ARGS_((ClientData instanceData));
560 typedef void (Tk_ClassModalProc) _ANSI_ARGS_((Tk_Window tkwin,
561 	XEvent *eventPtr));
562 
563 typedef struct Tk_ClassProcs {
564     unsigned int size;
565     Tk_ClassWorldChangedProc *worldChangedProc;
566 				/* Procedure to invoke when the widget needs
567 				 * to respond in some way to a change in the
568 				 * world (font changes, etc.) */
569     Tk_ClassCreateProc *createProc;
570 				/* Procedure to invoke when the platform-
571 				 * dependent window needs to be created. */
572     Tk_ClassModalProc *modalProc;
573 				/* Procedure to invoke after all bindings on a
574 				 * widget have been triggered in order to
575 				 * handle a modal loop. */
576 } Tk_ClassProcs;
577 
578 /*
579  * Simple accessor for Tk_ClassProcs structure. Checks that the structure is
580  * not NULL, then checks the size field and returns either the requested
581  * field, if present, or NULL if the structure is too small to have the field
582  * (or NULL if the structure is NULL).
583  *
584  * A more general version of this function may be useful if other
585  * size-versioned structure pop up in the future:
586  *
587  *	#define Tk_GetField(name, who, which) \
588  *	    (((who) == NULL) ? NULL :
589  *	    (((who)->size <= Tk_Offset(name, which)) ? NULL :(name)->which))
590  */
591 
592 #define Tk_GetClassProc(procs, which) \
593     (((procs) == NULL) ? NULL : \
594     (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))
595 
596 /*
597  * Each geometry manager (the packer, the placer, etc.) is represented by a
598  * structure of the following form, which indicates procedures to invoke in
599  * the geometry manager to carry out certain functions.
600  */
601 
602 typedef void (Tk_GeomRequestProc) _ANSI_ARGS_((ClientData clientData,
603 	Tk_Window tkwin));
604 typedef void (Tk_GeomLostSlaveProc) _ANSI_ARGS_((ClientData clientData,
605 	Tk_Window tkwin));
606 
607 typedef struct Tk_GeomMgr {
608     const char *name;		/* Name of the geometry manager (command used
609 				 * to invoke it, or name of widget class that
610 				 * allows embedded widgets). */
611     Tk_GeomRequestProc *requestProc;
612 				/* Procedure to invoke when a slave's
613 				 * requested geometry changes. */
614     Tk_GeomLostSlaveProc *lostSlaveProc;
615 				/* Procedure to invoke when a slave is taken
616 				 * away from one geometry manager by another.
617 				 * NULL means geometry manager doesn't care
618 				 * when slaves are lost. */
619 } Tk_GeomMgr;
620 
621 /*
622  * Result values returned by Tk_GetScrollInfo:
623  */
624 
625 #define TK_SCROLL_MOVETO	1
626 #define TK_SCROLL_PAGES		2
627 #define TK_SCROLL_UNITS		3
628 #define TK_SCROLL_ERROR		4
629 
630 /*
631  *----------------------------------------------------------------------
632  *
633  * Extensions to the X event set
634  *
635  *----------------------------------------------------------------------
636  */
637 
638 #define VirtualEvent	    (MappingNotify + 1)
639 #define ActivateNotify	    (MappingNotify + 2)
640 #define DeactivateNotify    (MappingNotify + 3)
641 #define MouseWheelEvent     (MappingNotify + 4)
642 #define TK_LASTEVENT	    (MappingNotify + 5)
643 
644 #define MouseWheelMask	    (1L << 28)
645 #define ActivateMask	    (1L << 29)
646 #define VirtualEventMask    (1L << 30)
647 
648 /*
649  * A virtual event shares most of its fields with the XKeyEvent and
650  * XButtonEvent structures. 99% of the time a virtual event will be an
651  * abstraction of a key or button event, so this structure provides the most
652  * information to the user. The only difference is the changing of the detail
653  * field for a virtual event so that it holds the name of the virtual event
654  * being triggered.
655  *
656  * When using this structure, you should ensure that you zero out all the
657  * fields first using memset() or bzero().
658  */
659 
660 typedef struct {
661     int type;
662     unsigned long serial;	/* # of last request processed by server. */
663     Bool send_event;		/* True if this came from a SendEvent
664 				 * request. */
665     Display *display;		/* Display the event was read from. */
666     Window event;		/* Window on which event was requested. */
667     Window root;		/* Root window that the event occured on. */
668     Window subwindow;		/* Child window. */
669     Time time;			/* Milliseconds. */
670     int x, y;			/* Pointer x, y coordinates in event
671 				 * window. */
672     int x_root, y_root;		/* Coordinates relative to root. */
673     unsigned int state;		/* Key or button mask */
674     Tk_Uid name;		/* Name of virtual event. */
675     Bool same_screen;		/* Same screen flag. */
676     Tcl_Obj *user_data;		/* Application-specific data reference; Tk
677 				 * will decrement the reference count *once*
678 				 * when it has finished processing the
679 				 * event. */
680 } XVirtualEvent;
681 
682 typedef struct {
683     int type;
684     unsigned long serial;	/* # of last request processed by server. */
685     Bool send_event;		/* True if this came from a SendEvent
686 				 * request. */
687     Display *display;		/* Display the event was read from. */
688     Window window;		/* Window in which event occurred. */
689 } XActivateDeactivateEvent;
690 typedef XActivateDeactivateEvent XActivateEvent;
691 typedef XActivateDeactivateEvent XDeactivateEvent;
692 
693 /*
694  *----------------------------------------------------------------------
695  *
696  * Macros for querying Tk_Window structures. See the manual entries for
697  * documentation.
698  *
699  *----------------------------------------------------------------------
700  */
701 
702 #define Tk_Display(tkwin)	(((Tk_FakeWin *) (tkwin))->display)
703 #define Tk_ScreenNumber(tkwin)	(((Tk_FakeWin *) (tkwin))->screenNum)
704 #define Tk_Screen(tkwin) \
705     (ScreenOfDisplay(Tk_Display(tkwin), Tk_ScreenNumber(tkwin)))
706 #define Tk_Depth(tkwin)		(((Tk_FakeWin *) (tkwin))->depth)
707 #define Tk_Visual(tkwin)	(((Tk_FakeWin *) (tkwin))->visual)
708 #define Tk_WindowId(tkwin)	(((Tk_FakeWin *) (tkwin))->window)
709 #define Tk_PathName(tkwin) 	(((Tk_FakeWin *) (tkwin))->pathName)
710 #define Tk_Name(tkwin)		(((Tk_FakeWin *) (tkwin))->nameUid)
711 #define Tk_Class(tkwin) 	(((Tk_FakeWin *) (tkwin))->classUid)
712 #define Tk_X(tkwin)		(((Tk_FakeWin *) (tkwin))->changes.x)
713 #define Tk_Y(tkwin)		(((Tk_FakeWin *) (tkwin))->changes.y)
714 #define Tk_Width(tkwin)		(((Tk_FakeWin *) (tkwin))->changes.width)
715 #define Tk_Height(tkwin) \
716     (((Tk_FakeWin *) (tkwin))->changes.height)
717 #define Tk_Changes(tkwin)	(&((Tk_FakeWin *) (tkwin))->changes)
718 #define Tk_Attributes(tkwin)	(&((Tk_FakeWin *) (tkwin))->atts)
719 #define Tk_IsEmbedded(tkwin) \
720     (((Tk_FakeWin *) (tkwin))->flags & TK_EMBEDDED)
721 #define Tk_IsContainer(tkwin) \
722     (((Tk_FakeWin *) (tkwin))->flags & TK_CONTAINER)
723 #define Tk_IsMapped(tkwin) \
724     (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED)
725 #define Tk_IsTopLevel(tkwin) \
726     (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL)
727 #define Tk_HasWrapper(tkwin) \
728     (((Tk_FakeWin *) (tkwin))->flags & TK_HAS_WRAPPER)
729 #define Tk_WinManaged(tkwin) \
730     (((Tk_FakeWin *) (tkwin))->flags & TK_WIN_MANAGED)
731 #define Tk_TopWinHierarchy(tkwin) \
732     (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY)
733 #define Tk_IsManageable(tkwin) \
734     (((Tk_FakeWin *) (tkwin))->flags & TK_WM_MANAGEABLE)
735 #define Tk_ReqWidth(tkwin)	(((Tk_FakeWin *) (tkwin))->reqWidth)
736 #define Tk_ReqHeight(tkwin)	(((Tk_FakeWin *) (tkwin))->reqHeight)
737 /* Tk_InternalBorderWidth is deprecated */
738 #define Tk_InternalBorderWidth(tkwin) \
739     (((Tk_FakeWin *) (tkwin))->internalBorderLeft)
740 #define Tk_InternalBorderLeft(tkwin) \
741     (((Tk_FakeWin *) (tkwin))->internalBorderLeft)
742 #define Tk_InternalBorderRight(tkwin) \
743     (((Tk_FakeWin *) (tkwin))->internalBorderRight)
744 #define Tk_InternalBorderTop(tkwin) \
745     (((Tk_FakeWin *) (tkwin))->internalBorderTop)
746 #define Tk_InternalBorderBottom(tkwin) \
747     (((Tk_FakeWin *) (tkwin))->internalBorderBottom)
748 #define Tk_MinReqWidth(tkwin)	(((Tk_FakeWin *) (tkwin))->minReqWidth)
749 #define Tk_MinReqHeight(tkwin)	(((Tk_FakeWin *) (tkwin))->minReqHeight)
750 #define Tk_Parent(tkwin)	(((Tk_FakeWin *) (tkwin))->parentPtr)
751 #define Tk_Colormap(tkwin)	(((Tk_FakeWin *) (tkwin))->atts.colormap)
752 
753 /*
754  * The structure below is needed by the macros above so that they can access
755  * the fields of a Tk_Window. The fields not needed by the macros are declared
756  * as "dummyX". The structure has its own type in order to prevent apps from
757  * accessing Tk_Window fields except using official macros. WARNING!! The
758  * structure definition must be kept consistent with the TkWindow structure in
759  * tkInt.h. If you change one, then change the other. See the declaration in
760  * tkInt.h for documentation on what the fields are used for internally.
761  */
762 
763 typedef struct Tk_FakeWin {
764     Display *display;
765     char *dummy1;		/* dispPtr */
766     int screenNum;
767     Visual *visual;
768     int depth;
769     Window window;
770     char *dummy2;		/* childList */
771     char *dummy3;		/* lastChildPtr */
772     Tk_Window parentPtr;	/* parentPtr */
773     char *dummy4;		/* nextPtr */
774     char *dummy5;		/* mainPtr */
775     char *pathName;
776     Tk_Uid nameUid;
777     Tk_Uid classUid;
778     XWindowChanges changes;
779     unsigned int dummy6;	/* dirtyChanges */
780     XSetWindowAttributes atts;
781     unsigned long dummy7;	/* dirtyAtts */
782     unsigned int flags;
783     char *dummy8;		/* handlerList */
784 #ifdef TK_USE_INPUT_METHODS
785     XIC dummy9;			/* inputContext */
786 #endif /* TK_USE_INPUT_METHODS */
787     ClientData *dummy10;	/* tagPtr */
788     int dummy11;		/* numTags */
789     int dummy12;		/* optionLevel */
790     char *dummy13;		/* selHandlerList */
791     char *dummy14;		/* geomMgrPtr */
792     ClientData dummy15;		/* geomData */
793     int reqWidth, reqHeight;
794     int internalBorderLeft;
795     char *dummy16;		/* wmInfoPtr */
796     char *dummy17;		/* classProcPtr */
797     ClientData dummy18;		/* instanceData */
798     char *dummy19;		/* privatePtr */
799     int internalBorderRight;
800     int internalBorderTop;
801     int internalBorderBottom;
802     int minReqWidth;
803     int minReqHeight;
804 } Tk_FakeWin;
805 
806 /*
807  * Flag values for TkWindow (and Tk_FakeWin) structures are:
808  *
809  * TK_MAPPED:			1 means window is currently mapped,
810  *				0 means unmapped.
811  * TK_TOP_LEVEL:		1 means this is a top-level widget.
812  * TK_ALREADY_DEAD:		1 means the window is in the process of
813  *				being destroyed already.
814  * TK_NEED_CONFIG_NOTIFY:	1 means that the window has been reconfigured
815  *				before it was made to exist. At the time of
816  *				making it exist a ConfigureNotify event needs
817  *				to be generated.
818  * TK_GRAB_FLAG:		Used to manage grabs. See tkGrab.c for details
819  * TK_CHECKED_IC:		1 means we've already tried to get an input
820  *				context for this window; if the ic field is
821  *				NULL it means that there isn't a context for
822  *				the field.
823  * TK_DONT_DESTROY_WINDOW:	1 means that Tk_DestroyWindow should not
824  *				invoke XDestroyWindow to destroy this widget's
825  *				X window. The flag is set when the window has
826  *				already been destroyed elsewhere (e.g. by
827  *				another application) or when it will be
828  *				destroyed later (e.g. by destroying its parent)
829  * TK_WM_COLORMAP_WINDOW:	1 means that this window has at some time
830  *				appeared in the WM_COLORMAP_WINDOWS property
831  *				for its toplevel, so we have to remove it from
832  *				that property if the window is deleted and the
833  *				toplevel isn't.
834  * TK_EMBEDDED:			1 means that this window (which must be a
835  *				toplevel) is not a free-standing window but
836  *				rather is embedded in some other application.
837  * TK_CONTAINER:		1 means that this window is a container, and
838  *				that some other application (either in this
839  *				process or elsewhere) may be embedding itself
840  *				inside the window.
841  * TK_BOTH_HALVES:		1 means that this window is used for
842  *				application embedding (either as container or
843  *				embedded application), and both the containing
844  *				and embedded halves are associated with
845  *				windows in this particular process.
846  * TK_DEFER_MODAL:		1 means that this window has deferred a modal
847  *				loop until all of the bindings for the current
848  *				event have been invoked.
849  * TK_WRAPPER:			1 means that this window is the extra wrapper
850  *				window created around a toplevel to hold the
851  *				menubar under Unix. See tkUnixWm.c for more
852  *				information.
853  * TK_REPARENTED:		1 means that this window has been reparented
854  *				so that as far as the window system is
855  *				concerned it isn't a child of its Tk parent.
856  *				Initially this is used only for special Unix
857  *				menubar windows.
858  * TK_ANONYMOUS_WINDOW:		1 means that this window has no name, and is
859  *				thus not accessible from Tk.
860  * TK_HAS_WRAPPER		1 means that this window has a wrapper window
861  * TK_WIN_MANAGED		1 means that this window is a child of the root
862  *				window, and is managed by the window manager.
863  * TK_TOP_HIERARCHY		1 means this window is at the top of a physical
864  *				window hierarchy within this process, i.e. the
865  *				window's parent either doesn't exist or is not
866  *				owned by this Tk application.
867  * TK_PROP_PROPCHANGE		1 means that PropertyNotify events in the
868  *				window's children should propagate up to this
869  *				window.
870  * TK_WM_MANAGEABLE		1 marks a window as capable of being converted
871  *				into a toplevel using [wm manage].
872  */
873 
874 #define TK_MAPPED		1
875 #define TK_TOP_LEVEL		2
876 #define TK_ALREADY_DEAD		4
877 #define TK_NEED_CONFIG_NOTIFY	8
878 #define TK_GRAB_FLAG		0x10
879 #define TK_CHECKED_IC		0x20
880 #define TK_DONT_DESTROY_WINDOW	0x40
881 #define TK_WM_COLORMAP_WINDOW	0x80
882 #define TK_EMBEDDED		0x100
883 #define TK_CONTAINER		0x200
884 #define TK_BOTH_HALVES		0x400
885 #define TK_DEFER_MODAL		0x800
886 #define TK_WRAPPER		0x1000
887 #define TK_REPARENTED		0x2000
888 #define TK_ANONYMOUS_WINDOW	0x4000
889 #define TK_HAS_WRAPPER		0x8000
890 #define TK_WIN_MANAGED		0x10000
891 #define TK_TOP_HIERARCHY	0x20000
892 #define TK_PROP_PROPCHANGE	0x40000
893 #define TK_WM_MANAGEABLE	0x80000
894 
895 /*
896  *----------------------------------------------------------------------
897  *
898  * Procedure prototypes and structures used for defining new canvas items:
899  *
900  *----------------------------------------------------------------------
901  */
902 
903 typedef enum {
904     TK_STATE_NULL = -1, TK_STATE_ACTIVE, TK_STATE_DISABLED,
905     TK_STATE_NORMAL, TK_STATE_HIDDEN
906 } Tk_State;
907 
908 typedef struct Tk_SmoothMethod {
909     char *name;
910     int (*coordProc) _ANSI_ARGS_((Tk_Canvas canvas,
911 		double *pointPtr, int numPoints, int numSteps,
912 		XPoint xPoints[], double dblPoints[]));
913     void (*postscriptProc) _ANSI_ARGS_((Tcl_Interp *interp,
914 		Tk_Canvas canvas, double *coordPtr,
915 		int numPoints, int numSteps));
916 } Tk_SmoothMethod;
917 
918 /*
919  * For each item in a canvas widget there exists one record with the following
920  * structure. Each actual item is represented by a record with the following
921  * stuff at its beginning, plus additional type-specific stuff after that.
922  */
923 
924 #define TK_TAG_SPACE 3
925 
926 typedef struct Tk_Item {
927     int id;			/* Unique identifier for this item (also
928 				 * serves as first tag for item). */
929     struct Tk_Item *nextPtr;	/* Next in display list of all items in this
930 				 * canvas. Later items in list are drawn on
931 				 * top of earlier ones. */
932     Tk_Uid staticTagSpace[TK_TAG_SPACE];
933 				/* Built-in space for limited # of tags. */
934     Tk_Uid *tagPtr;		/* Pointer to array of tags. Usually points to
935 				 * staticTagSpace, but may point to malloc-ed
936 				 * space if there are lots of tags. */
937     int tagSpace;		/* Total amount of tag space available at
938 				 * tagPtr. */
939     int numTags;		/* Number of tag slots actually used at
940 				 * *tagPtr. */
941     struct Tk_ItemType *typePtr;/* Table of procedures that implement this
942 				 * type of item. */
943     int x1, y1, x2, y2;		/* Bounding box for item, in integer canvas
944 				 * units. Set by item-specific code and
945 				 * guaranteed to contain every pixel drawn in
946 				 * item. Item area includes x1 and y1 but not
947 				 * x2 and y2. */
948     struct Tk_Item *prevPtr;	/* Previous in display list of all items in
949 				 * this canvas. Later items in list are drawn
950 				 * just below earlier ones. */
951     Tk_State state;		/* State of item. */
952     char *reserved1;		/* reserved for future use */
953     int redraw_flags;		/* Some flags used in the canvas */
954 
955     /*
956      *------------------------------------------------------------------
957      * Starting here is additional type-specific stuff; see the declarations
958      * for individual types to see what is part of each type. The actual space
959      * below is determined by the "itemInfoSize" of the type's Tk_ItemType
960      * record.
961      *------------------------------------------------------------------
962      */
963 } Tk_Item;
964 
965 /*
966  * Flag bits for canvases (redraw_flags):
967  *
968  * TK_ITEM_STATE_DEPENDANT -	1 means that object needs to be redrawn if the
969  *				canvas state changes.
970  * TK_ITEM_DONT_REDRAW - 	1 means that the object redraw is already been
971  *				prepared, so the general canvas code doesn't
972  *				need to do that any more.
973  */
974 
975 #define TK_ITEM_STATE_DEPENDANT		1
976 #define TK_ITEM_DONT_REDRAW		2
977 
978 /*
979  * Records of the following type are used to describe a type of item (e.g.
980  * lines, circles, etc.) that can form part of a canvas widget.
981  */
982 
983 #ifdef USE_OLD_CANVAS
984 typedef int	Tk_ItemCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
985 		    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
986 		    char **argv));
987 typedef int	Tk_ItemConfigureProc _ANSI_ARGS_((Tcl_Interp *interp,
988 		    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
989 		    char **argv, int flags));
990 typedef int	Tk_ItemCoordProc _ANSI_ARGS_((Tcl_Interp *interp,
991 		    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
992 		    char **argv));
993 #else
994 typedef int	Tk_ItemCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
995 		    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
996 		    Tcl_Obj *const objv[]));
997 typedef int	Tk_ItemConfigureProc _ANSI_ARGS_((Tcl_Interp *interp,
998 		    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
999 		    Tcl_Obj *const objv[], int flags));
1000 typedef int	Tk_ItemCoordProc _ANSI_ARGS_((Tcl_Interp *interp,
1001 		    Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
1002 		    Tcl_Obj *const argv[]));
1003 #endif
1004 typedef void	Tk_ItemDeleteProc _ANSI_ARGS_((Tk_Canvas canvas,
1005 		    Tk_Item *itemPtr, Display *display));
1006 typedef void	Tk_ItemDisplayProc _ANSI_ARGS_((Tk_Canvas canvas,
1007 		    Tk_Item *itemPtr, Display *display, Drawable dst,
1008 		    int x, int y, int width, int height));
1009 typedef double	Tk_ItemPointProc _ANSI_ARGS_((Tk_Canvas canvas,
1010 		    Tk_Item *itemPtr, double *pointPtr));
1011 typedef int	Tk_ItemAreaProc _ANSI_ARGS_((Tk_Canvas canvas,
1012 		    Tk_Item *itemPtr, double *rectPtr));
1013 typedef int	Tk_ItemPostscriptProc _ANSI_ARGS_((Tcl_Interp *interp,
1014 		    Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
1015 typedef void	Tk_ItemScaleProc _ANSI_ARGS_((Tk_Canvas canvas,
1016 		    Tk_Item *itemPtr, double originX, double originY,
1017 		    double scaleX, double scaleY));
1018 typedef void	Tk_ItemTranslateProc _ANSI_ARGS_((Tk_Canvas canvas,
1019 		    Tk_Item *itemPtr, double deltaX, double deltaY));
1020 typedef int	Tk_ItemIndexProc _ANSI_ARGS_((Tcl_Interp *interp,
1021 		    Tk_Canvas canvas, Tk_Item *itemPtr, char *indexString,
1022 		    int *indexPtr));
1023 typedef void	Tk_ItemCursorProc _ANSI_ARGS_((Tk_Canvas canvas,
1024 		    Tk_Item *itemPtr, int index));
1025 typedef int	Tk_ItemSelectionProc _ANSI_ARGS_((Tk_Canvas canvas,
1026 		    Tk_Item *itemPtr, int offset, char *buffer,
1027 		    int maxBytes));
1028 typedef void	Tk_ItemInsertProc _ANSI_ARGS_((Tk_Canvas canvas,
1029 		    Tk_Item *itemPtr, int beforeThis, char *string));
1030 typedef void	Tk_ItemDCharsProc _ANSI_ARGS_((Tk_Canvas canvas,
1031 		    Tk_Item *itemPtr, int first, int last));
1032 
1033 #ifndef __NO_OLD_CONFIG
1034 
1035 typedef struct Tk_ItemType {
1036     char *name;			/* The name of this type of item, such as
1037 				 * "line". */
1038     int itemSize;		/* Total amount of space needed for item's
1039 				 * record. */
1040     Tk_ItemCreateProc *createProc;
1041 				/* Procedure to create a new item of this
1042 				 * type. */
1043     Tk_ConfigSpec *configSpecs;	/* Pointer to array of configuration specs for
1044 				 * this type. Used for returning configuration
1045 				 * info. */
1046     Tk_ItemConfigureProc *configProc;
1047 				/* Procedure to call to change configuration
1048 				 * options. */
1049     Tk_ItemCoordProc *coordProc;/* Procedure to call to get and set the item's
1050 				 * coordinates. */
1051     Tk_ItemDeleteProc *deleteProc;
1052 				/* Procedure to delete existing item of this
1053 				 * type. */
1054     Tk_ItemDisplayProc *displayProc;
1055 				/* Procedure to display items of this type. */
1056     int alwaysRedraw;		/* Non-zero means displayProc should be called
1057 				 * even when the item has been moved
1058 				 * off-screen. */
1059     Tk_ItemPointProc *pointProc;/* Computes distance from item to a given
1060 				 * point. */
1061     Tk_ItemAreaProc *areaProc;	/* Computes whether item is inside, outside,
1062 				 * or overlapping an area. */
1063     Tk_ItemPostscriptProc *postscriptProc;
1064 				/* Procedure to write a Postscript description
1065 				 * for items of this type. */
1066     Tk_ItemScaleProc *scaleProc;/* Procedure to rescale items of this type. */
1067     Tk_ItemTranslateProc *translateProc;
1068 				/* Procedure to translate items of this
1069 				 * type. */
1070     Tk_ItemIndexProc *indexProc;/* Procedure to determine index of indicated
1071 				 * character. NULL if item doesn't support
1072 				 * indexing. */
1073     Tk_ItemCursorProc *icursorProc;
1074 				/* Procedure to set insert cursor posn to just
1075 				 * before a given position. */
1076     Tk_ItemSelectionProc *selectionProc;
1077 				/* Procedure to return selection (in STRING
1078 				 * format) when it is in this item. */
1079     Tk_ItemInsertProc *insertProc;
1080 				/* Procedure to insert something into an
1081 				 * item. */
1082     Tk_ItemDCharsProc *dCharsProc;
1083 				/* Procedure to delete characters from an
1084 				 * item. */
1085     struct Tk_ItemType *nextPtr;/* Used to link types together into a list. */
1086     char *reserved1;		/* Reserved for future extension. */
1087     int reserved2;		/* Carefully compatible with */
1088     char *reserved3;		/* Jan Nijtmans dash patch */
1089     char *reserved4;
1090 } Tk_ItemType;
1091 
1092 #endif
1093 
1094 /*
1095  * The following structure provides information about the selection and the
1096  * insertion cursor. It is needed by only a few items, such as those that
1097  * display text. It is shared by the generic canvas code and the item-specific
1098  * code, but most of the fields should be written only by the canvas generic
1099  * code.
1100  */
1101 
1102 typedef struct Tk_CanvasTextInfo {
1103     Tk_3DBorder selBorder;	/* Border and background for selected
1104 				 * characters. Read-only to items.*/
1105     int selBorderWidth;		/* Width of border around selection. Read-only
1106 				 * to items. */
1107     XColor *selFgColorPtr;	/* Foreground color for selected text.
1108 				 * Read-only to items. */
1109     Tk_Item *selItemPtr;	/* Pointer to selected item. NULL means
1110 				 * selection isn't in this canvas. Writable by
1111 				 * items. */
1112     int selectFirst;		/* Character index of first selected
1113 				 * character. Writable by items. */
1114     int selectLast;		/* Character index of last selected character.
1115 				 * Writable by items. */
1116     Tk_Item *anchorItemPtr;	/* Item corresponding to "selectAnchor": not
1117 				 * necessarily selItemPtr. Read-only to
1118 				 * items. */
1119     int selectAnchor;		/* Character index of fixed end of selection
1120 				 * (i.e. "select to" operation will use this
1121 				 * as one end of the selection). Writable by
1122 				 * items. */
1123     Tk_3DBorder insertBorder;	/* Used to draw vertical bar for insertion
1124 				 * cursor. Read-only to items. */
1125     int insertWidth;		/* Total width of insertion cursor. Read-only
1126 				 * to items. */
1127     int insertBorderWidth;	/* Width of 3-D border around insert cursor.
1128 				 * Read-only to items. */
1129     Tk_Item *focusItemPtr;	/* Item that currently has the input focus, or
1130 				 * NULL if no such item. Read-only to items. */
1131     int gotFocus;		/* Non-zero means that the canvas widget has
1132 				 * the input focus. Read-only to items.*/
1133     int cursorOn;		/* Non-zero means that an insertion cursor
1134 				 * should be displayed in focusItemPtr.
1135 				 * Read-only to items.*/
1136 } Tk_CanvasTextInfo;
1137 
1138 /*
1139  * Structures used for Dashing and Outline.
1140  */
1141 
1142 typedef struct Tk_Dash {
1143     int number;
1144     union {
1145 	char *pt;
1146 	char array[sizeof(char *)];
1147     } pattern;
1148 } Tk_Dash;
1149 
1150 typedef struct Tk_TSOffset {
1151     int flags;			/* Flags; see below for possible values */
1152     int xoffset;		/* x offset */
1153     int yoffset;		/* y offset */
1154 } Tk_TSOffset;
1155 
1156 /*
1157  * Bit fields in Tk_Offset->flags:
1158  */
1159 
1160 #define TK_OFFSET_INDEX		1
1161 #define TK_OFFSET_RELATIVE	2
1162 #define TK_OFFSET_LEFT		4
1163 #define TK_OFFSET_CENTER	8
1164 #define TK_OFFSET_RIGHT		16
1165 #define TK_OFFSET_TOP		32
1166 #define TK_OFFSET_MIDDLE	64
1167 #define TK_OFFSET_BOTTOM	128
1168 
1169 typedef struct Tk_Outline {
1170     GC gc;			/* Graphics context. */
1171     double width;		/* Width of outline. */
1172     double activeWidth;		/* Width of outline. */
1173     double disabledWidth;	/* Width of outline. */
1174     int offset;			/* Dash offset. */
1175     Tk_Dash dash;		/* Dash pattern. */
1176     Tk_Dash activeDash;		/* Dash pattern if state is active. */
1177     Tk_Dash disabledDash;	/* Dash pattern if state is disabled. */
1178     VOID *reserved1;		/* Reserved for future expansion. */
1179     VOID *reserved2;
1180     VOID *reserved3;
1181     Tk_TSOffset tsoffset;	/* Stipple offset for outline. */
1182     XColor *color;		/* Outline color. */
1183     XColor *activeColor;	/* Outline color if state is active. */
1184     XColor *disabledColor;	/* Outline color if state is disabled. */
1185     Pixmap stipple;		/* Outline Stipple pattern. */
1186     Pixmap activeStipple;	/* Outline Stipple pattern if state is
1187 				 * active. */
1188     Pixmap disabledStipple;	/* Outline Stipple pattern if state is
1189 				 * disabled. */
1190 } Tk_Outline;
1191 
1192 /*
1193  *----------------------------------------------------------------------
1194  *
1195  * Procedure prototypes and structures used for managing images:
1196  *
1197  *----------------------------------------------------------------------
1198  */
1199 
1200 typedef struct Tk_ImageType Tk_ImageType;
1201 #ifdef USE_OLD_IMAGE
1202 typedef int (Tk_ImageCreateProc) _ANSI_ARGS_((Tcl_Interp *interp,
1203 	char *name, int argc, char **argv, Tk_ImageType *typePtr,
1204 	Tk_ImageMaster master, ClientData *masterDataPtr));
1205 #else
1206 typedef int (Tk_ImageCreateProc) _ANSI_ARGS_((Tcl_Interp *interp,
1207 	char *name, int objc, Tcl_Obj *const objv[], Tk_ImageType *typePtr,
1208 	Tk_ImageMaster master, ClientData *masterDataPtr));
1209 #endif
1210 typedef ClientData (Tk_ImageGetProc) _ANSI_ARGS_((Tk_Window tkwin,
1211 	ClientData masterData));
1212 typedef void (Tk_ImageDisplayProc) _ANSI_ARGS_((ClientData instanceData,
1213 	Display *display, Drawable drawable, int imageX, int imageY,
1214 	int width, int height, int drawableX, int drawableY));
1215 typedef void (Tk_ImageFreeProc) _ANSI_ARGS_((ClientData instanceData,
1216 	Display *display));
1217 typedef void (Tk_ImageDeleteProc) _ANSI_ARGS_((ClientData masterData));
1218 typedef void (Tk_ImageChangedProc) _ANSI_ARGS_((ClientData clientData,
1219 	int x, int y, int width, int height, int imageWidth,
1220 	int imageHeight));
1221 typedef int (Tk_ImagePostscriptProc) _ANSI_ARGS_((ClientData clientData,
1222 	Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo,
1223 	int x, int y, int width, int height, int prepass));
1224 
1225 /*
1226  * The following structure represents a particular type of image (bitmap, xpm
1227  * image, etc.). It provides information common to all images of that type,
1228  * such as the type name and a collection of procedures in the image manager
1229  * that respond to various events. Each image manager is represented by one of
1230  * these structures.
1231  */
1232 
1233 struct Tk_ImageType {
1234     char *name;			/* Name of image type. */
1235     Tk_ImageCreateProc *createProc;
1236 				/* Procedure to call to create a new image of
1237 				 * this type. */
1238     Tk_ImageGetProc *getProc;	/* Procedure to call the first time
1239 				 * Tk_GetImage is called in a new way (new
1240 				 * visual or screen). */
1241     Tk_ImageDisplayProc *displayProc;
1242 				/* Call to draw image, in response to
1243 				 * Tk_RedrawImage calls. */
1244     Tk_ImageFreeProc *freeProc;	/* Procedure to call whenever Tk_FreeImage is
1245 				 * called to release an instance of an
1246 				 * image. */
1247     Tk_ImageDeleteProc *deleteProc;
1248 				/* Procedure to call to delete image. It will
1249 				 * not be called until after freeProc has been
1250 				 * called for each instance of the image. */
1251     Tk_ImagePostscriptProc *postscriptProc;
1252 				/* Procedure to call to produce postscript
1253 				 * output for the image. */
1254     struct Tk_ImageType *nextPtr;
1255 				/* Next in list of all image types currently
1256 				 * known. Filled in by Tk, not by image
1257 				 * manager. */
1258     char *reserved;		/* reserved for future expansion */
1259 };
1260 
1261 /*
1262  *----------------------------------------------------------------------
1263  *
1264  * Additional definitions used to manage images of type "photo".
1265  *
1266  *----------------------------------------------------------------------
1267  */
1268 
1269 /*
1270  * The following type is used to identify a particular photo image to be
1271  * manipulated:
1272  */
1273 
1274 typedef void *Tk_PhotoHandle;
1275 
1276 /*
1277  * The following structure describes a block of pixels in memory:
1278  */
1279 
1280 typedef struct Tk_PhotoImageBlock {
1281     unsigned char *pixelPtr;	/* Pointer to the first pixel. */
1282     int width;			/* Width of block, in pixels. */
1283     int height;			/* Height of block, in pixels. */
1284     int pitch;			/* Address difference between corresponding
1285 				 * pixels in successive lines. */
1286     int pixelSize;		/* Address difference between successive
1287 				 * pixels in the same line. */
1288     int offset[4];		/* Address differences between the red, green,
1289 				 * blue and alpha components of the pixel and
1290 				 * the pixel as a whole. */
1291 } Tk_PhotoImageBlock;
1292 
1293 /*
1294  * The following values control how blocks are combined into photo images when
1295  * the alpha component of a pixel is not 255, a.k.a. the compositing rule.
1296  */
1297 
1298 #define TK_PHOTO_COMPOSITE_OVERLAY	0
1299 #define TK_PHOTO_COMPOSITE_SET		1
1300 
1301 /*
1302  * Procedure prototypes and structures used in reading and writing photo
1303  * images:
1304  */
1305 
1306 typedef struct Tk_PhotoImageFormat Tk_PhotoImageFormat;
1307 #ifdef USE_OLD_IMAGE
1308 typedef int (Tk_ImageFileMatchProc) _ANSI_ARGS_((Tcl_Channel chan,
1309 	char *fileName, char *formatString, int *widthPtr, int *heightPtr));
1310 typedef int (Tk_ImageStringMatchProc) _ANSI_ARGS_((char *string,
1311 	char *formatString, int *widthPtr, int *heightPtr));
1312 typedef int (Tk_ImageFileReadProc) _ANSI_ARGS_((Tcl_Interp *interp,
1313 	Tcl_Channel chan, char *fileName, char *formatString,
1314 	Tk_PhotoHandle imageHandle, int destX, int destY,
1315 	int width, int height, int srcX, int srcY));
1316 typedef int (Tk_ImageStringReadProc) _ANSI_ARGS_((Tcl_Interp *interp,
1317 	char *string, char *formatString, Tk_PhotoHandle imageHandle,
1318 	int destX, int destY, int width, int height, int srcX, int srcY));
1319 typedef int (Tk_ImageFileWriteProc) _ANSI_ARGS_((Tcl_Interp *interp,
1320 	char *fileName, char *formatString, Tk_PhotoImageBlock *blockPtr));
1321 typedef int (Tk_ImageStringWriteProc) _ANSI_ARGS_((Tcl_Interp *interp,
1322 	Tcl_DString *dataPtr, char *formatString,
1323 	Tk_PhotoImageBlock *blockPtr));
1324 #else
1325 typedef int (Tk_ImageFileMatchProc) _ANSI_ARGS_((Tcl_Channel chan,
1326 	const char *fileName, Tcl_Obj *format, int *widthPtr,
1327 	int *heightPtr, Tcl_Interp *interp));
1328 typedef int (Tk_ImageStringMatchProc) _ANSI_ARGS_((Tcl_Obj *dataObj,
1329 	Tcl_Obj *format, int *widthPtr, int *heightPtr,
1330 	Tcl_Interp *interp));
1331 typedef int (Tk_ImageFileReadProc) _ANSI_ARGS_((Tcl_Interp *interp,
1332 	Tcl_Channel chan, const char *fileName, Tcl_Obj *format,
1333 	Tk_PhotoHandle imageHandle, int destX, int destY,
1334 	int width, int height, int srcX, int srcY));
1335 typedef int (Tk_ImageStringReadProc) _ANSI_ARGS_((Tcl_Interp *interp,
1336 	Tcl_Obj *dataObj, Tcl_Obj *format, Tk_PhotoHandle imageHandle,
1337 	int destX, int destY, int width, int height, int srcX, int srcY));
1338 typedef int (Tk_ImageFileWriteProc) _ANSI_ARGS_((Tcl_Interp *interp,
1339 	const char *fileName, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr));
1340 typedef int (Tk_ImageStringWriteProc) _ANSI_ARGS_((Tcl_Interp *interp,
1341 	Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr));
1342 #endif
1343 
1344 /*
1345  * The following structure represents a particular file format for storing
1346  * images (e.g., PPM, GIF, JPEG, etc.). It provides information to allow image
1347  * files of that format to be recognized and read into a photo image.
1348  */
1349 
1350 struct Tk_PhotoImageFormat {
1351     char *name;			/* Name of image file format */
1352     Tk_ImageFileMatchProc *fileMatchProc;
1353 				/* Procedure to call to determine whether an
1354 				 * image file matches this format. */
1355     Tk_ImageStringMatchProc *stringMatchProc;
1356 				/* Procedure to call to determine whether the
1357 				 * data in a string matches this format. */
1358     Tk_ImageFileReadProc *fileReadProc;
1359 				/* Procedure to call to read data from an
1360 				 * image file into a photo image. */
1361     Tk_ImageStringReadProc *stringReadProc;
1362 				/* Procedure to call to read data from a
1363 				 * string into a photo image. */
1364     Tk_ImageFileWriteProc *fileWriteProc;
1365 				/* Procedure to call to write data from a
1366 				 * photo image to a file. */
1367     Tk_ImageStringWriteProc *stringWriteProc;
1368 				/* Procedure to call to obtain a string
1369 				 * representation of the data in a photo
1370 				 * image.*/
1371     struct Tk_PhotoImageFormat *nextPtr;
1372 				/* Next in list of all photo image formats
1373 				 * currently known. Filled in by Tk, not by
1374 				 * image format handler. */
1375 };
1376 
1377 /*
1378  *----------------------------------------------------------------------
1379  *
1380  * Procedure prototypes and structures used for managing styles:
1381  *
1382  *----------------------------------------------------------------------
1383  */
1384 
1385 /*
1386  * Style support version tag.
1387  */
1388 
1389 #define TK_STYLE_VERSION_1      0x1
1390 #define TK_STYLE_VERSION        TK_STYLE_VERSION_1
1391 
1392 /*
1393  * The following structures and prototypes are used as static templates to
1394  * declare widget elements.
1395  */
1396 
1397 typedef void (Tk_GetElementSizeProc) _ANSI_ARGS_((ClientData clientData,
1398         char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin,
1399         int width, int height, int inner, int *widthPtr, int *heightPtr));
1400 typedef void (Tk_GetElementBoxProc) _ANSI_ARGS_((ClientData clientData,
1401         char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin,
1402         int x, int y, int width, int height, int inner, int *xPtr, int *yPtr,
1403         int *widthPtr, int *heightPtr));
1404 typedef int (Tk_GetElementBorderWidthProc) _ANSI_ARGS_((ClientData clientData,
1405         char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin));
1406 typedef void (Tk_DrawElementProc) _ANSI_ARGS_((ClientData clientData,
1407         char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin,
1408         Drawable d, int x, int y, int width, int height, int state));
1409 
1410 typedef struct Tk_ElementOptionSpec {
1411     char *name;                 /* Name of the required option. */
1412     Tk_OptionType type;         /* Accepted option type. TK_OPTION_END means
1413                                  * any. */
1414 } Tk_ElementOptionSpec;
1415 
1416 typedef struct Tk_ElementSpec {
1417     int version;                /* Version of the style support. */
1418     char *name;                 /* Name of element. */
1419     Tk_ElementOptionSpec *options;
1420                                 /* List of required options. Last one's name
1421                                  * must be NULL. */
1422     Tk_GetElementSizeProc *getSize;
1423                                 /* Compute the external (resp. internal) size
1424                                  * of the element from its desired internal
1425                                  * (resp. external) size. */
1426     Tk_GetElementBoxProc *getBox;
1427                                 /* Compute the inscribed or bounding boxes
1428                                  * within a given area. */
1429     Tk_GetElementBorderWidthProc *getBorderWidth;
1430                                 /* Return the element's internal border width.
1431                                  * Mostly useful for widgets. */
1432     Tk_DrawElementProc *draw;	/* Draw the element in the given bounding
1433 				 * box. */
1434 } Tk_ElementSpec;
1435 
1436 /*
1437  * Element state flags. Can be OR'ed.
1438  */
1439 
1440 #define TK_ELEMENT_STATE_ACTIVE         1<<0
1441 #define TK_ELEMENT_STATE_DISABLED       1<<1
1442 #define TK_ELEMENT_STATE_FOCUS          1<<2
1443 #define TK_ELEMENT_STATE_PRESSED        1<<3
1444 
1445 /*
1446  *----------------------------------------------------------------------
1447  *
1448  * The definitions below provide backward compatibility for functions and
1449  * types related to event handling that used to be in Tk but have moved to
1450  * Tcl.
1451  *
1452  *----------------------------------------------------------------------
1453  */
1454 
1455 #define TK_READABLE		TCL_READABLE
1456 #define TK_WRITABLE		TCL_WRITABLE
1457 #define TK_EXCEPTION		TCL_EXCEPTION
1458 
1459 #define TK_DONT_WAIT		TCL_DONT_WAIT
1460 #define TK_X_EVENTS		TCL_WINDOW_EVENTS
1461 #define TK_WINDOW_EVENTS	TCL_WINDOW_EVENTS
1462 #define TK_FILE_EVENTS		TCL_FILE_EVENTS
1463 #define TK_TIMER_EVENTS		TCL_TIMER_EVENTS
1464 #define TK_IDLE_EVENTS		TCL_IDLE_EVENTS
1465 #define TK_ALL_EVENTS		TCL_ALL_EVENTS
1466 
1467 #define Tk_IdleProc		Tcl_IdleProc
1468 #define Tk_FileProc		Tcl_FileProc
1469 #define Tk_TimerProc		Tcl_TimerProc
1470 #define Tk_TimerToken		Tcl_TimerToken
1471 
1472 #define Tk_BackgroundError	Tcl_BackgroundError
1473 #define Tk_CancelIdleCall	Tcl_CancelIdleCall
1474 #define Tk_CreateFileHandler	Tcl_CreateFileHandler
1475 #define Tk_CreateTimerHandler	Tcl_CreateTimerHandler
1476 #define Tk_DeleteFileHandler	Tcl_DeleteFileHandler
1477 #define Tk_DeleteTimerHandler	Tcl_DeleteTimerHandler
1478 #define Tk_DoOneEvent		Tcl_DoOneEvent
1479 #define Tk_DoWhenIdle		Tcl_DoWhenIdle
1480 #define Tk_Sleep		Tcl_Sleep
1481 
1482 /* Additional stuff that has moved to Tcl: */
1483 
1484 #define Tk_EventuallyFree	Tcl_EventuallyFree
1485 #define Tk_FreeProc		Tcl_FreeProc
1486 #define Tk_Preserve		Tcl_Preserve
1487 #define Tk_Release		Tcl_Release
1488 
1489 /* Removed Tk_Main, use macro instead */
1490 #define Tk_Main(argc, argv, proc) \
1491     Tk_MainEx(argc, argv, proc, Tcl_CreateInterp())
1492 
1493 const char *		Tk_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
1494 			    const char *version, int exact));
1495 EXTERN const char *	Tk_PkgInitStubsCheck _ANSI_ARGS_((Tcl_Interp *interp,
1496 			    const char *version, int exact));
1497 
1498 #ifndef USE_TK_STUBS
1499 #define Tk_InitStubs(interp, version, exact) \
1500     Tk_PkgInitStubsCheck(interp, version, exact)
1501 #endif /* USE_TK_STUBS */
1502 
1503 #define Tk_InitImageArgs(interp, argc, argv) /**/
1504 
1505 /*
1506  *----------------------------------------------------------------------
1507  *
1508  * Additional procedure types defined by Tk.
1509  *
1510  *----------------------------------------------------------------------
1511  */
1512 
1513 typedef int (Tk_ErrorProc) _ANSI_ARGS_((ClientData clientData,
1514 	XErrorEvent *errEventPtr));
1515 typedef void (Tk_EventProc) _ANSI_ARGS_((ClientData clientData,
1516 	XEvent *eventPtr));
1517 typedef int (Tk_GenericProc) _ANSI_ARGS_((ClientData clientData,
1518 	XEvent *eventPtr));
1519 typedef int (Tk_ClientMessageProc) _ANSI_ARGS_((Tk_Window tkwin,
1520 	XEvent *eventPtr));
1521 typedef int (Tk_GetSelProc) _ANSI_ARGS_((ClientData clientData,
1522 	Tcl_Interp *interp, char *portion));
1523 typedef void (Tk_LostSelProc) _ANSI_ARGS_((ClientData clientData));
1524 typedef Tk_RestrictAction (Tk_RestrictProc) _ANSI_ARGS_((
1525 	ClientData clientData, XEvent *eventPtr));
1526 typedef int (Tk_SelectionProc) _ANSI_ARGS_((ClientData clientData,
1527 	int offset, char *buffer, int maxBytes));
1528 
1529 /*
1530  *----------------------------------------------------------------------
1531  *
1532  * Platform independent exported procedures and variables.
1533  *
1534  *----------------------------------------------------------------------
1535  */
1536 
1537 #include "tkDecls.h"
1538 
1539 #ifdef USE_OLD_IMAGE
1540 #undef Tk_CreateImageType
1541 #define Tk_CreateImageType		Tk_CreateOldImageType
1542 #undef Tk_CreatePhotoImageFormat
1543 #define Tk_CreatePhotoImageFormat	Tk_CreateOldPhotoImageFormat
1544 #endif /* USE_OLD_IMAGE */
1545 
1546 /*
1547  *----------------------------------------------------------------------
1548  *
1549  * Allow users to say that they don't want to alter their source to add extra
1550  * arguments to Tk_PhotoPutBlock() et al; DO NOT DEFINE THIS WHEN BUILDING TK.
1551  *
1552  * This goes after the inclusion of the stubbed-decls so that the declarations
1553  * of what is actually there can be correct.
1554  */
1555 
1556 #ifdef USE_COMPOSITELESS_PHOTO_PUT_BLOCK
1557 #   ifdef Tk_PhotoPutBlock
1558 #	undef Tk_PhotoPutBlock
1559 #   endif
1560 #   define Tk_PhotoPutBlock		Tk_PhotoPutBlock_NoComposite
1561 #   ifdef Tk_PhotoPutZoomedBlock
1562 #	undef Tk_PhotoPutZoomedBlock
1563 #   endif
1564 #   define Tk_PhotoPutZoomedBlock	Tk_PhotoPutZoomedBlock_NoComposite
1565 #   define USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1566 #else /* !USE_COMPOSITELESS_PHOTO_PUT_BLOCK */
1567 #   ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1568 #	ifdef Tk_PhotoPutBlock
1569 #	    undef Tk_PhotoPutBlock
1570 #	endif
1571 #	define Tk_PhotoPutBlock		Tk_PhotoPutBlock_Panic
1572 #	ifdef Tk_PhotoPutZoomedBlock
1573 #	    undef Tk_PhotoPutZoomedBlock
1574 #	endif
1575 #	define Tk_PhotoPutZoomedBlock	Tk_PhotoPutZoomedBlock_Panic
1576 #   endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */
1577 #endif /* USE_COMPOSITELESS_PHOTO_PUT_BLOCK */
1578 #ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1579 #   ifdef Tk_PhotoExpand
1580 #	undef Tk_PhotoExpand
1581 #   endif
1582 #   define Tk_PhotoExpand		Tk_PhotoExpand_Panic
1583 #   ifdef Tk_PhotoSetSize
1584 #	undef Tk_PhotoSetSize
1585 #   endif
1586 #   define Tk_PhotoSetSize		Tk_PhotoSetSize_Panic
1587 #endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */
1588 
1589 #undef TCL_STORAGE_CLASS
1590 #define TCL_STORAGE_CLASS DLLIMPORT
1591 
1592 #endif /* RC_INVOKED */
1593 
1594 /*
1595  * end block for C++
1596  */
1597 
1598 #ifdef __cplusplus
1599 }
1600 #endif
1601 
1602 #endif /* _TK */
1603 
1604 /*
1605  * Local Variables:
1606  * mode: c
1607  * c-basic-offset: 4
1608  * fill-column: 78
1609  * End:
1610  */
1611