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