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