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