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