OSDN Git Service

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