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