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