codekingpro/portable-devtools
114k
1/*2 * tk.h --3 *4 * Declarations for Tk-related things that are visible outside of the Tk5 * 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 of13 * this file, and for a DISCLAIMER OF ALL WARRANTIES.14 */15 16#ifndef _TK17#define _TK18 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 better22#endif23 24#ifndef CONST8425# define CONST84 const26# define CONST84_RETURN const27#endif28#ifndef CONST8629# define CONST86 CONST8430#endif31#ifndef EXTERN32# define EXTERN extern TCL_STORAGE_CLASS33#endif34 35/*36 * Utility macros: STRINGIFY takes an argument and wraps it in "" (double37 * quotation marks), JOIN joins two arguments.38 */39 40#ifndef STRINGIFY41# define STRINGIFY(x) STRINGIFY1(x)42# define STRINGIFY1(x) #x43#endif44#ifndef JOIN45# define JOIN(a,b) JOIN1(a,b)46# define JOIN1(a,b) a##b47#endif48 49/*50 * For C++ compilers, use extern "C"51 */52 53#ifdef __cplusplus54extern "C" {55#endif56 57/*58 * When version numbers change here, you must also go into the following files59 * 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 LOC66 * 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 for72 * the version of Tcl that this release of Tk is compiled against.73 */74 75#define TK_MAJOR_VERSION 876#define TK_MINOR_VERSION 677#define TK_RELEASE_LEVEL TCL_FINAL_RELEASE78#define TK_RELEASE_SERIAL 1379 80#define TK_VERSION "8.6"81#define TK_PATCH_LEVEL "8.6.13"8283/*84 * A special definition used to allow this header file to be included from85 * 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 set87 * for macintosh.88 *89 * Resource compilers don't like all the C stuff, like typedefs and procedure90 * declarations, that occur below, so block them out.91 */92 93#ifndef RC_INVOKED94 95#if !defined(_XLIB_H) && !defined(_X11_XLIB_H_)96#if defined(__GNUC__) && !defined(__cplusplus)97# pragma GCC diagnostic ignored "-Wc++-compat"98#endif99# include <X11/Xlib.h>100# ifdef MAC_OSX_TK101# include <X11/X.h>102# endif103#endif104#if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \105 || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC)106# include <stddef.h>107#endif108 109#ifdef BUILD_tk110#undef TCL_STORAGE_CLASS111#define TCL_STORAGE_CLASS DLLEXPORT112#endif113 114/*115 *----------------------------------------------------------------------116 *117 * Decide whether or not to use input methods.118 */119 120#ifdef XNQueryInputStyle121#define TK_USE_INPUT_METHODS122#endif123124/*125 * Dummy types that are used by clients:126 */127 128#define Tk_ImageModel Tk_ImageMaster129typedef struct Tk_BindingTable_ *Tk_BindingTable;130typedef struct Tk_Canvas_ *Tk_Canvas;131typedef struct Tk_Cursor_ *Tk_Cursor;132typedef struct Tk_ErrorHandler_ *Tk_ErrorHandler;133typedef struct Tk_Font_ *Tk_Font;134typedef struct Tk_Image__ *Tk_Image;135typedef struct Tk_ImageMaster_ *Tk_ImageMaster;136typedef struct Tk_OptionTable_ *Tk_OptionTable;137typedef struct Tk_PostscriptInfo_ *Tk_PostscriptInfo;138typedef struct Tk_TextLayout_ *Tk_TextLayout;139typedef struct Tk_Window_ *Tk_Window;140typedef struct Tk_3DBorder_ *Tk_3DBorder;141typedef struct Tk_Style_ *Tk_Style;142typedef struct Tk_StyleEngine_ *Tk_StyleEngine;143typedef struct Tk_StyledElement_ *Tk_StyledElement;144 145/*146 * Additional types exported to clients.147 */148 149typedef const char *Tk_Uid;150151/*152 *----------------------------------------------------------------------153 *154 * The enum below defines the valid types for Tk configuration options as155 * implemented by Tk_InitOptions, Tk_SetOptions, etc.156 */157 158typedef enum {159 TK_OPTION_BOOLEAN,160 TK_OPTION_INT,161 TK_OPTION_DOUBLE,162 TK_OPTION_STRING,163 TK_OPTION_STRING_TABLE,164 TK_OPTION_COLOR,165 TK_OPTION_FONT,166 TK_OPTION_BITMAP,167 TK_OPTION_BORDER,168 TK_OPTION_RELIEF,169 TK_OPTION_CURSOR,170 TK_OPTION_JUSTIFY,171 TK_OPTION_ANCHOR,172 TK_OPTION_SYNONYM,173 TK_OPTION_PIXELS,174 TK_OPTION_WINDOW,175 TK_OPTION_END,176 TK_OPTION_CUSTOM,177 TK_OPTION_STYLE178} Tk_OptionType;179 180/*181 * Structures of the following type are used by widgets to specify their182 * configuration options. Typically each widget has a static array of these183 * structures, where each element of the array describes a single184 * configuration option. The array is passed to Tk_CreateOptionTable.185 */186 187typedef struct Tk_OptionSpec {188 Tk_OptionType type; /* Type of option, such as TK_OPTION_COLOR;189 * see definitions above. Last option in table190 * must have type TK_OPTION_END. */191 const char *optionName; /* Name used to specify option in Tcl192 * commands. */193 const char *dbName; /* Name for option in option database. */194 const char *dbClass; /* Class for option in database. */195 const char *defValue; /* Default value for option if not specified196 * in command line, the option database, or197 * the system. */198 int objOffset; /* Where in record to store a Tcl_Obj * that199 * holds the value of this option, specified200 * as an offset in bytes from the start of the201 * record. Use the Tk_Offset macro to generate202 * values for this. -1 means don't store the203 * Tcl_Obj in the record. */204 int internalOffset; /* Where in record to store the internal205 * representation of the value of this option,206 * such as an int or XColor *. This field is207 * specified as an offset in bytes from the208 * start of the record. Use the Tk_Offset209 * macro to generate values for it. -1 means210 * don't store the internal representation in211 * the record. */212 int flags; /* Any combination of the values defined213 * below. */214 const void *clientData; /* An alternate place to put option-specific215 * data. Used for the monochrome default value216 * for colors, etc. */217 int typeMask; /* An arbitrary bit mask defined by the class218 * manager; typically bits correspond to219 * certain kinds of options such as all those220 * that require a redisplay when they change.221 * Tk_SetOptions returns the bit-wise OR of222 * the typeMasks of all options that were223 * changed. */224} Tk_OptionSpec;225 226/*227 * Flag values for Tk_OptionSpec structures. These flags are shared by228 * Tk_ConfigSpec structures, so be sure to coordinate any changes carefully.229 */230 231#define TK_OPTION_NULL_OK (1 << 0)232#define TK_OPTION_DONT_SET_DEFAULT (1 << 3)233 234/*235 * The following structure and function types are used by TK_OPTION_CUSTOM236 * options; the structure holds pointers to the functions needed by the Tk237 * option config code to handle a custom option.238 */239 240typedef int (Tk_CustomOptionSetProc) (ClientData clientData,241 Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec,242 int offset, char *saveInternalPtr, int flags);243typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData,244 Tk_Window tkwin, char *widgRec, int offset);245typedef void (Tk_CustomOptionRestoreProc) (ClientData clientData,246 Tk_Window tkwin, char *internalPtr, char *saveInternalPtr);247typedef void (Tk_CustomOptionFreeProc) (ClientData clientData, Tk_Window tkwin,248 char *internalPtr);249 250typedef struct Tk_ObjCustomOption {251 const char *name; /* Name of the custom option. */252 Tk_CustomOptionSetProc *setProc;253 /* Function to use to set a record's option254 * value from a Tcl_Obj */255 Tk_CustomOptionGetProc *getProc;256 /* Function to use to get a Tcl_Obj257 * representation from an internal258 * representation of an option. */259 Tk_CustomOptionRestoreProc *restoreProc;260 /* Function to use to restore a saved value261 * for the internal representation. */262 Tk_CustomOptionFreeProc *freeProc;263 /* Function to use to free the internal264 * representation of an option. */265 ClientData clientData; /* Arbitrary one-word value passed to the266 * handling procs. */267} Tk_ObjCustomOption;268 269/*270 * Macro to use to fill in "offset" fields of the Tk_OptionSpec structure.271 * Computes number of bytes from beginning of structure to a given field.272 */273 274#define Tk_Offset(type, field) ((int) offsetof(type, field))275/* Workaround for platforms missing offsetof(), e.g. VC++ 6.0 */276#ifndef offsetof277# define offsetof(type, field) ((size_t) ((char *) &((type *) 0)->field))278#endif279 280/*281 * The following two structures are used for error handling. When config282 * options are being modified, the old values are saved in a Tk_SavedOptions283 * structure. If an error occurs, then the contents of the structure can be284 * used to restore all of the old values. The contents of this structure are285 * for the private use Tk. No-one outside Tk should ever read or write any of286 * the fields of these structures.287 */288 289typedef struct Tk_SavedOption {290 struct TkOption *optionPtr; /* Points to information that describes the291 * option. */292 Tcl_Obj *valuePtr; /* The old value of the option, in the form of293 * a Tcl object; may be NULL if the value was294 * not saved as an object. */295 double internalForm; /* The old value of the option, in some296 * internal representation such as an int or297 * (XColor *). Valid only if the field298 * optionPtr->specPtr->objOffset is < 0. The299 * space must be large enough to accommodate a300 * double, a long, or a pointer; right now it301 * looks like a double (i.e., 8 bytes) is big302 * enough. Also, using a double guarantees303 * that the field is properly aligned for304 * storing large values. */305} Tk_SavedOption;306 307#ifdef TCL_MEM_DEBUG308# define TK_NUM_SAVED_OPTIONS 2309#else310# define TK_NUM_SAVED_OPTIONS 20311#endif312 313typedef struct Tk_SavedOptions {314 char *recordPtr; /* The data structure in which to restore315 * configuration options. */316 Tk_Window tkwin; /* Window associated with recordPtr; needed to317 * restore certain options. */318 int numItems; /* The number of valid items in items field. */319 Tk_SavedOption items[TK_NUM_SAVED_OPTIONS];320 /* Items used to hold old values. */321 struct Tk_SavedOptions *nextPtr;322 /* Points to next structure in list; needed if323 * too many options changed to hold all the324 * old values in a single structure. NULL325 * means no more structures. */326} Tk_SavedOptions;327328/*329 * Structure used to describe application-specific configuration options:330 * indicates procedures to call to parse an option and to return a text string331 * describing an option. THESE ARE DEPRECATED; PLEASE USE THE NEW STRUCTURES332 * LISTED ABOVE.333 */334 335/*336 * This is a temporary flag used while tkObjConfig and new widgets are in337 * development.338 */339 340#ifndef __NO_OLD_CONFIG341 342typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp,343 Tk_Window tkwin, CONST84 char *value, char *widgRec, int offset);344typedef CONST86 char *(Tk_OptionPrintProc) (ClientData clientData,345 Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);346 347typedef struct Tk_CustomOption {348 Tk_OptionParseProc *parseProc;349 /* Procedure to call to parse an option and350 * store it in converted form. */351 Tk_OptionPrintProc *printProc;352 /* Procedure to return a printable string353 * describing an existing option. */354 ClientData clientData; /* Arbitrary one-word value used by option355 * parser: passed to parseProc and356 * printProc. */357} Tk_CustomOption;358 359/*360 * Structure used to specify information for Tk_ConfigureWidget. Each361 * structure gives complete information for one option, including how the362 * option is specified on the command line, where it appears in the option363 * database, etc.364 */365 366typedef struct Tk_ConfigSpec {367 int type; /* Type of option, such as TK_CONFIG_COLOR;368 * see definitions below. Last option in table369 * must have type TK_CONFIG_END. */370 CONST86 char *argvName; /* Switch used to specify option in argv. NULL371 * means this spec is part of a group. */372 Tk_Uid dbName; /* Name for option in option database. */373 Tk_Uid dbClass; /* Class for option in database. */374 Tk_Uid defValue; /* Default value for option if not specified375 * in command line or database. */376 int offset; /* Where in widget record to store value; use377 * Tk_Offset macro to generate values for378 * this. */379 int specFlags; /* Any combination of the values defined380 * below; other bits are used internally by381 * tkConfig.c. */382 CONST86 Tk_CustomOption *customPtr;383 /* If type is TK_CONFIG_CUSTOM then this is a384 * pointer to info about how to parse and385 * print the option. Otherwise it is386 * irrelevant. */387} Tk_ConfigSpec;388 389/*390 * Type values for Tk_ConfigSpec structures. See the user documentation for391 * details.392 */393 394typedef enum {395 TK_CONFIG_BOOLEAN, TK_CONFIG_INT, TK_CONFIG_DOUBLE, TK_CONFIG_STRING,396 TK_CONFIG_UID, TK_CONFIG_COLOR, TK_CONFIG_FONT, TK_CONFIG_BITMAP,397 TK_CONFIG_BORDER, TK_CONFIG_RELIEF, TK_CONFIG_CURSOR,398 TK_CONFIG_ACTIVE_CURSOR, TK_CONFIG_JUSTIFY, TK_CONFIG_ANCHOR,399 TK_CONFIG_SYNONYM, TK_CONFIG_CAP_STYLE, TK_CONFIG_JOIN_STYLE,400 TK_CONFIG_PIXELS, TK_CONFIG_MM, TK_CONFIG_WINDOW, TK_CONFIG_CUSTOM,401 TK_CONFIG_END402} Tk_ConfigTypes;403 404/*405 * Possible values for flags argument to Tk_ConfigureWidget:406 */407 408#define TK_CONFIG_ARGV_ONLY 1409#define TK_CONFIG_OBJS 0x80410 411/*412 * Possible flag values for Tk_ConfigSpec structures. Any bits at or above413 * TK_CONFIG_USER_BIT may be used by clients for selecting certain entries.414 * Before changing any values here, coordinate with tkOldConfig.c415 * (internal-use-only flags are defined there).416 */417 418#define TK_CONFIG_NULL_OK (1 << 0)419#define TK_CONFIG_COLOR_ONLY (1 << 1)420#define TK_CONFIG_MONO_ONLY (1 << 2)421#define TK_CONFIG_DONT_SET_DEFAULT (1 << 3)422#define TK_CONFIG_OPTION_SPECIFIED (1 << 4)423#define TK_CONFIG_USER_BIT 0x100424#endif /* __NO_OLD_CONFIG */425426/*427 * Structure used to specify how to handle argv options.428 */429 430typedef struct {431 CONST86 char *key; /* The key string that flags the option in the432 * argv array. */433 int type; /* Indicates option type; see below. */434 char *src; /* Value to be used in setting dst; usage435 * depends on type. */436 char *dst; /* Address of value to be modified; usage437 * depends on type. */438 CONST86 char *help; /* Documentation message describing this439 * option. */440} Tk_ArgvInfo;441 442/*443 * Legal values for the type field of a Tk_ArgvInfo: see the user444 * documentation for details.445 */446 447#define TK_ARGV_CONSTANT 15448#define TK_ARGV_INT 16449#define TK_ARGV_STRING 17450#define TK_ARGV_UID 18451#define TK_ARGV_REST 19452#define TK_ARGV_FLOAT 20453#define TK_ARGV_FUNC 21454#define TK_ARGV_GENFUNC 22455#define TK_ARGV_HELP 23456#define TK_ARGV_CONST_OPTION 24457#define TK_ARGV_OPTION_VALUE 25458#define TK_ARGV_OPTION_NAME_VALUE 26459#define TK_ARGV_END 27460 461/*462 * Flag bits for passing to Tk_ParseArgv:463 */464 465#define TK_ARGV_NO_DEFAULTS 0x1466#define TK_ARGV_NO_LEFTOVERS 0x2467#define TK_ARGV_NO_ABBREV 0x4468#define TK_ARGV_DONT_SKIP_FIRST_ARG 0x8469470/*471 * Enumerated type for describing actions to be taken in response to a472 * restrictProc established by Tk_RestrictEvents.473 */474 475typedef enum {476 TK_DEFER_EVENT, TK_PROCESS_EVENT, TK_DISCARD_EVENT477} Tk_RestrictAction;478 479/*480 * Priority levels to pass to Tk_AddOption:481 */482 483#define TK_WIDGET_DEFAULT_PRIO 20484#define TK_STARTUP_FILE_PRIO 40485#define TK_USER_DEFAULT_PRIO 60486#define TK_INTERACTIVE_PRIO 80487#define TK_MAX_PRIO 100488 489/*490 * Relief values returned by Tk_GetRelief:491 */492 493#define TK_RELIEF_NULL -1494#define TK_RELIEF_FLAT 0495#define TK_RELIEF_GROOVE 1496#define TK_RELIEF_RAISED 2497#define TK_RELIEF_RIDGE 3498#define TK_RELIEF_SOLID 4499#define TK_RELIEF_SUNKEN 5500 501/*502 * "Which" argument values for Tk_3DBorderGC:503 */504 505#define TK_3D_FLAT_GC 1506#define TK_3D_LIGHT_GC 2507#define TK_3D_DARK_GC 3508 509/*510 * Special EnterNotify/LeaveNotify "mode" for use in events generated by511 * tkShare.c. Pick a high enough value that it's unlikely to conflict with512 * existing values (like NotifyNormal) or any new values defined in the513 * future.514 */515 516#define TK_NOTIFY_SHARE 20517 518/*519 * Enumerated type for describing a point by which to anchor something:520 */521 522typedef enum {523 TK_ANCHOR_N, TK_ANCHOR_NE, TK_ANCHOR_E, TK_ANCHOR_SE,524 TK_ANCHOR_S, TK_ANCHOR_SW, TK_ANCHOR_W, TK_ANCHOR_NW,525 TK_ANCHOR_CENTER526} Tk_Anchor;527528/*529 * Enumerated type for describing a style of justification:530 */531 532typedef enum {533 TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER534} Tk_Justify;535 536/*537 * The following structure is used by Tk_GetFontMetrics() to return538 * information about the properties of a Tk_Font.539 */540 541typedef struct Tk_FontMetrics {542 int ascent; /* The amount in pixels that the tallest543 * letter sticks up above the baseline, plus544 * any extra blank space added by the designer545 * of the font. */546 int descent; /* The largest amount in pixels that any547 * letter sticks below the baseline, plus any548 * extra blank space added by the designer of549 * the font. */550 int linespace; /* The sum of the ascent and descent. How far551 * apart two lines of text in the same font552 * should be placed so that none of the553 * characters in one line overlap any of the554 * characters in the other line. */555} Tk_FontMetrics;556 557/*558 * Flags passed to Tk_MeasureChars:559 */560 561#define TK_WHOLE_WORDS 1562#define TK_AT_LEAST_ONE 2563#define TK_PARTIAL_OK 4564 565/*566 * Flags passed to Tk_ComputeTextLayout:567 */568 569#define TK_IGNORE_TABS 8570#define TK_IGNORE_NEWLINES 16571572/*573 * Widget class procedures used to implement platform specific widget574 * behavior.575 */576 577typedef Window (Tk_ClassCreateProc) (Tk_Window tkwin, Window parent,578 ClientData instanceData);579typedef void (Tk_ClassWorldChangedProc) (ClientData instanceData);580typedef void (Tk_ClassModalProc) (Tk_Window tkwin, XEvent *eventPtr);581 582typedef struct Tk_ClassProcs {583 unsigned int size;584 Tk_ClassWorldChangedProc *worldChangedProc;585 /* Procedure to invoke when the widget needs586 * to respond in some way to a change in the587 * world (font changes, etc.) */588 Tk_ClassCreateProc *createProc;589 /* Procedure to invoke when the platform-590 * dependent window needs to be created. */591 Tk_ClassModalProc *modalProc;592 /* Procedure to invoke after all bindings on a593 * widget have been triggered in order to594 * handle a modal loop. */595} Tk_ClassProcs;596 597/*598 * Simple accessor for Tk_ClassProcs structure. Checks that the structure is599 * not NULL, then checks the size field and returns either the requested600 * field, if present, or NULL if the structure is too small to have the field601 * (or NULL if the structure is NULL).602 *603 * A more general version of this function may be useful if other604 * size-versioned structure pop up in the future:605 *606 * #define Tk_GetField(name, who, which) \607 * (((who) == NULL) ? NULL :608 * (((who)->size <= Tk_Offset(name, which)) ? NULL :(name)->which))609 */610 611#define Tk_GetClassProc(procs, which) \612 (((procs) == NULL) ? NULL : \613 (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))614615/*616 * Each geometry manager (the packer, the placer, etc.) is represented by a617 * structure of the following form, which indicates procedures to invoke in618 * the geometry manager to carry out certain functions.619 */620 621#define Tk_GeomLostContentProc Tk_GeomLostSlaveProc622typedef void (Tk_GeomRequestProc) (ClientData clientData, Tk_Window tkwin);623typedef void (Tk_GeomLostContentProc) (ClientData clientData, Tk_Window tkwin);624 625typedef struct Tk_GeomMgr {626 const char *name; /* Name of the geometry manager (command used627 * to invoke it, or name of widget class that628 * allows embedded widgets). */629 Tk_GeomRequestProc *requestProc;630 /* Procedure to invoke when a content's631 * requested geometry changes. */632 Tk_GeomLostContentProc *lostSlaveProc;633 /* Procedure to invoke when content is taken634 * away from one geometry manager by another.635 * NULL means geometry manager doesn't care636 * when content lost. */637} Tk_GeomMgr;638 639/*640 * Result values returned by Tk_GetScrollInfo:641 */642 643#define TK_SCROLL_MOVETO 1644#define TK_SCROLL_PAGES 2645#define TK_SCROLL_UNITS 3646#define TK_SCROLL_ERROR 4647648/*649 *----------------------------------------------------------------------650 *651 * Extensions to the X event set652 *653 *----------------------------------------------------------------------654 */655 656#define VirtualEvent (MappingNotify + 1)657#define ActivateNotify (MappingNotify + 2)658#define DeactivateNotify (MappingNotify + 3)659#define MouseWheelEvent (MappingNotify + 4)660#define TK_LASTEVENT (MappingNotify + 5)661 662#define MouseWheelMask (1L << 28)663#define ActivateMask (1L << 29)664#define VirtualEventMask (1L << 30)665 666/*667 * A virtual event shares most of its fields with the XKeyEvent and668 * XButtonEvent structures. 99% of the time a virtual event will be an669 * abstraction of a key or button event, so this structure provides the most670 * information to the user. The only difference is the changing of the detail671 * field for a virtual event so that it holds the name of the virtual event672 * being triggered.673 *674 * When using this structure, you should ensure that you zero out all the675 * fields first using memset() or bzero().676 */677 678typedef struct {679 int type;680 unsigned long serial; /* # of last request processed by server. */681 Bool send_event; /* True if this came from a SendEvent682 * request. */683 Display *display; /* Display the event was read from. */684 Window event; /* Window on which event was requested. */685 Window root; /* Root window that the event occurred on. */686 Window subwindow; /* Child window. */687 Time time; /* Milliseconds. */688 int x, y; /* Pointer x, y coordinates in event689 * window. */690 int x_root, y_root; /* Coordinates relative to root. */691 unsigned int state; /* Key or button mask */692 Tk_Uid name; /* Name of virtual event. */693 Bool same_screen; /* Same screen flag. */694 Tcl_Obj *user_data; /* Application-specific data reference; Tk695 * will decrement the reference count *once*696 * when it has finished processing the697 * event. */698} XVirtualEvent;699 700typedef struct {701 int type;702 unsigned long serial; /* # of last request processed by server. */703 Bool send_event; /* True if this came from a SendEvent704 * request. */705 Display *display; /* Display the event was read from. */706 Window window; /* Window in which event occurred. */707} XActivateDeactivateEvent;708typedef XActivateDeactivateEvent XActivateEvent;709typedef XActivateDeactivateEvent XDeactivateEvent;710711/*712 *----------------------------------------------------------------------713 *714 * Macros for querying Tk_Window structures. See the manual entries for715 * documentation.716 *717 *----------------------------------------------------------------------718 */719 720#define Tk_Display(tkwin) (((Tk_FakeWin *) (tkwin))->display)721#define Tk_ScreenNumber(tkwin) (((Tk_FakeWin *) (tkwin))->screenNum)722#define Tk_Screen(tkwin) \723 (ScreenOfDisplay(Tk_Display(tkwin), Tk_ScreenNumber(tkwin)))724#define Tk_Depth(tkwin) (((Tk_FakeWin *) (tkwin))->depth)725#define Tk_Visual(tkwin) (((Tk_FakeWin *) (tkwin))->visual)726#define Tk_WindowId(tkwin) (((Tk_FakeWin *) (tkwin))->window)727#define Tk_PathName(tkwin) (((Tk_FakeWin *) (tkwin))->pathName)728#define Tk_Name(tkwin) (((Tk_FakeWin *) (tkwin))->nameUid)729#define Tk_Class(tkwin) (((Tk_FakeWin *) (tkwin))->classUid)730#define Tk_X(tkwin) (((Tk_FakeWin *) (tkwin))->changes.x)731#define Tk_Y(tkwin) (((Tk_FakeWin *) (tkwin))->changes.y)732#define Tk_Width(tkwin) (((Tk_FakeWin *) (tkwin))->changes.width)733#define Tk_Height(tkwin) \734 (((Tk_FakeWin *) (tkwin))->changes.height)735#define Tk_Changes(tkwin) (&((Tk_FakeWin *) (tkwin))->changes)736#define Tk_Attributes(tkwin) (&((Tk_FakeWin *) (tkwin))->atts)737#define Tk_IsEmbedded(tkwin) \738 (((Tk_FakeWin *) (tkwin))->flags & TK_EMBEDDED)739#define Tk_IsContainer(tkwin) \740 (((Tk_FakeWin *) (tkwin))->flags & TK_CONTAINER)741#define Tk_IsMapped(tkwin) \742 (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED)743#define Tk_IsTopLevel(tkwin) \744 (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL)745#define Tk_HasWrapper(tkwin) \746 (((Tk_FakeWin *) (tkwin))->flags & TK_HAS_WRAPPER)747#define Tk_WinManaged(tkwin) \748 (((Tk_FakeWin *) (tkwin))->flags & TK_WIN_MANAGED)749#define Tk_TopWinHierarchy(tkwin) \750 (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY)751#define Tk_IsManageable(tkwin) \752 (((Tk_FakeWin *) (tkwin))->flags & TK_WM_MANAGEABLE)753#define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth)754#define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight)755/* Tk_InternalBorderWidth is deprecated */756#define Tk_InternalBorderWidth(tkwin) \757 (((Tk_FakeWin *) (tkwin))->internalBorderLeft)758#define Tk_InternalBorderLeft(tkwin) \759 (((Tk_FakeWin *) (tkwin))->internalBorderLeft)760#define Tk_InternalBorderRight(tkwin) \761 (((Tk_FakeWin *) (tkwin))->internalBorderRight)762#define Tk_InternalBorderTop(tkwin) \763 (((Tk_FakeWin *) (tkwin))->internalBorderTop)764#define Tk_InternalBorderBottom(tkwin) \765 (((Tk_FakeWin *) (tkwin))->internalBorderBottom)766#define Tk_MinReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->minReqWidth)767#define Tk_MinReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->minReqHeight)768#define Tk_Parent(tkwin) (((Tk_FakeWin *) (tkwin))->parentPtr)769#define Tk_Colormap(tkwin) (((Tk_FakeWin *) (tkwin))->atts.colormap)770 771/*772 * The structure below is needed by the macros above so that they can access773 * the fields of a Tk_Window. The fields not needed by the macros are declared774 * as "dummyX". The structure has its own type in order to prevent apps from775 * accessing Tk_Window fields except using official macros. WARNING!! The776 * structure definition must be kept consistent with the TkWindow structure in777 * tkInt.h. If you change one, then change the other. See the declaration in778 * tkInt.h for documentation on what the fields are used for internally.779 */780 781typedef struct Tk_FakeWin {782 Display *display;783 char *dummy1; /* dispPtr */784 int screenNum;785 Visual *visual;786 int depth;787 Window window;788 char *dummy2; /* childList */789 char *dummy3; /* lastChildPtr */790 Tk_Window parentPtr; /* parentPtr */791 char *dummy4; /* nextPtr */792 char *dummy5; /* mainPtr */793 char *pathName;794 Tk_Uid nameUid;795 Tk_Uid classUid;796 XWindowChanges changes;797 unsigned int dummy6; /* dirtyChanges */798 XSetWindowAttributes atts;799 unsigned long dummy7; /* dirtyAtts */800 unsigned int flags;801 char *dummy8; /* handlerList */802#ifdef TK_USE_INPUT_METHODS803 XIC dummy9; /* inputContext */804#endif /* TK_USE_INPUT_METHODS */805 ClientData *dummy10; /* tagPtr */806 int dummy11; /* numTags */807 int dummy12; /* optionLevel */808 char *dummy13; /* selHandlerList */809 char *dummy14; /* geomMgrPtr */810 ClientData dummy15; /* geomData */811 int reqWidth, reqHeight;812 int internalBorderLeft;813 char *dummy16; /* wmInfoPtr */814 char *dummy17; /* classProcPtr */815 ClientData dummy18; /* instanceData */816 char *dummy19; /* privatePtr */817 int internalBorderRight;818 int internalBorderTop;819 int internalBorderBottom;820 int minReqWidth;821 int minReqHeight;822#ifdef TK_USE_INPUT_METHODS823 int dummy20;824#endif /* TK_USE_INPUT_METHODS */825 char *dummy21; /* geomMgrName */826 Tk_Window dummy22; /* maintainerPtr */827} Tk_FakeWin;828 829/*830 * Flag values for TkWindow (and Tk_FakeWin) structures are:831 *832 * TK_MAPPED: 1 means window is currently mapped,833 * 0 means unmapped.834 * TK_TOP_LEVEL: 1 means this is a top-level widget.835 * TK_ALREADY_DEAD: 1 means the window is in the process of836 * being destroyed already.837 * TK_NEED_CONFIG_NOTIFY: 1 means that the window has been reconfigured838 * before it was made to exist. At the time of839 * making it exist a ConfigureNotify event needs840 * to be generated.841 * TK_GRAB_FLAG: Used to manage grabs. See tkGrab.c for details842 * TK_CHECKED_IC: 1 means we've already tried to get an input843 * context for this window; if the ic field is844 * NULL it means that there isn't a context for845 * the field.846 * TK_DONT_DESTROY_WINDOW: 1 means that Tk_DestroyWindow should not847 * invoke XDestroyWindow to destroy this widget's848 * X window. The flag is set when the window has849 * already been destroyed elsewhere (e.g. by850 * another application) or when it will be851 * destroyed later (e.g. by destroying its parent)852 * TK_WM_COLORMAP_WINDOW: 1 means that this window has at some time853 * appeared in the WM_COLORMAP_WINDOWS property854 * for its toplevel, so we have to remove it from855 * that property if the window is deleted and the856 * toplevel isn't.857 * TK_EMBEDDED: 1 means that this window (which must be a858 * toplevel) is not a free-standing window but859 * rather is embedded in some other application.860 * TK_CONTAINER: 1 means that this window is a container, and861 * that some other application (either in this862 * process or elsewhere) may be embedding itself863 * inside the window.864 * TK_BOTH_HALVES: 1 means that this window is used for865 * application embedding (either as container or866 * embedded application), and both the containing867 * and embedded halves are associated with868 * windows in this particular process.869 * TK_WRAPPER: 1 means that this window is the extra wrapper870 * window created around a toplevel to hold the871 * menubar under Unix. See tkUnixWm.c for more872 * information.873 * TK_REPARENTED: 1 means that this window has been reparented874 * so that as far as the window system is875 * concerned it isn't a child of its Tk parent.876 * Initially this is used only for special Unix877 * menubar windows.878 * TK_ANONYMOUS_WINDOW: 1 means that this window has no name, and is879 * thus not accessible from Tk.880 * TK_HAS_WRAPPER 1 means that this window has a wrapper window881 * TK_WIN_MANAGED 1 means that this window is a child of the root882 * window, and is managed by the window manager.883 * TK_TOP_HIERARCHY 1 means this window is at the top of a physical884 * window hierarchy within this process, i.e. the885 * window's parent either doesn't exist or is not886 * owned by this Tk application.887 * TK_PROP_PROPCHANGE 1 means that PropertyNotify events in the888 * window's children should propagate up to this889 * window.890 * TK_WM_MANAGEABLE 1 marks a window as capable of being converted891 * into a toplevel using [wm manage].892 * TK_CAN_INPUT_TEXT 1 means that this window accepts text input.893 * Used on macOS to indicate that key events can be894 * processed with the NSTextInputClient protocol.895 * Not currently accessible through the public API.896 */897 898#define TK_MAPPED 1899#define TK_TOP_LEVEL 2900#define TK_ALREADY_DEAD 4901#define TK_NEED_CONFIG_NOTIFY 8902#define TK_GRAB_FLAG 0x10903#define TK_CHECKED_IC 0x20904#define TK_DONT_DESTROY_WINDOW 0x40905#define TK_WM_COLORMAP_WINDOW 0x80906#define TK_EMBEDDED 0x100907#define TK_CONTAINER 0x200908#define TK_BOTH_HALVES 0x400909 910#define TK_WRAPPER 0x1000911#define TK_REPARENTED 0x2000912#define TK_ANONYMOUS_WINDOW 0x4000913#define TK_HAS_WRAPPER 0x8000914#define TK_WIN_MANAGED 0x10000915#define TK_TOP_HIERARCHY 0x20000916#define TK_PROP_PROPCHANGE 0x40000917#define TK_WM_MANAGEABLE 0x80000918#define TK_CAN_INPUT_TEXT 0x100000919920/*921 *----------------------------------------------------------------------922 *923 * Procedure prototypes and structures used for defining new canvas items:924 *925 *----------------------------------------------------------------------926 */927 928typedef enum {929 TK_STATE_NULL = -1, TK_STATE_ACTIVE, TK_STATE_DISABLED,930 TK_STATE_NORMAL, TK_STATE_HIDDEN931} Tk_State;932 933typedef struct Tk_SmoothMethod {934 CONST86 char *name;935 int (*coordProc) (Tk_Canvas canvas, double *pointPtr, int numPoints,936 int numSteps, XPoint xPoints[], double dblPoints[]);937 void (*postscriptProc) (Tcl_Interp *interp, Tk_Canvas canvas,938 double *coordPtr, int numPoints, int numSteps);939} Tk_SmoothMethod;940 941/*942 * For each item in a canvas widget there exists one record with the following943 * structure. Each actual item is represented by a record with the following944 * stuff at its beginning, plus additional type-specific stuff after that.945 */946 947#define TK_TAG_SPACE 3948 949typedef struct Tk_Item {950 int id; /* Unique identifier for this item (also951 * serves as first tag for item). */952 struct Tk_Item *nextPtr; /* Next in display list of all items in this953 * canvas. Later items in list are drawn on954 * top of earlier ones. */955 Tk_Uid staticTagSpace[TK_TAG_SPACE];956 /* Built-in space for limited # of tags. */957 Tk_Uid *tagPtr; /* Pointer to array of tags. Usually points to958 * staticTagSpace, but may point to malloc-ed959 * space if there are lots of tags. */960 int tagSpace; /* Total amount of tag space available at961 * tagPtr. */962 int numTags; /* Number of tag slots actually used at963 * *tagPtr. */964 struct Tk_ItemType *typePtr;/* Table of procedures that implement this965 * type of item. */966 int x1, y1, x2, y2; /* Bounding box for item, in integer canvas967 * units. Set by item-specific code and968 * guaranteed to contain every pixel drawn in969 * item. Item area includes x1 and y1 but not970 * x2 and y2. */971 struct Tk_Item *prevPtr; /* Previous in display list of all items in972 * this canvas. Later items in list are drawn973 * just below earlier ones. */974 Tk_State state; /* State of item. */975 char *reserved1; /* reserved for future use */976 int redraw_flags; /* Some flags used in the canvas */977 978 /*979 *------------------------------------------------------------------980 * Starting here is additional type-specific stuff; see the declarations981 * for individual types to see what is part of each type. The actual space982 * below is determined by the "itemInfoSize" of the type's Tk_ItemType983 * record.984 *------------------------------------------------------------------985 */986} Tk_Item;987 988/*989 * Flag bits for canvases (redraw_flags):990 *991 * TK_ITEM_STATE_DEPENDANT - 1 means that object needs to be redrawn if the992 * canvas state changes.993 * TK_ITEM_DONT_REDRAW - 1 means that the object redraw is already been994 * prepared, so the general canvas code doesn't995 * need to do that any more.996 */997 998#define TK_ITEM_STATE_DEPENDANT 1999#define TK_ITEM_DONT_REDRAW 21000 1001/*1002 * Records of the following type are used to describe a type of item (e.g.1003 * lines, circles, etc.) that can form part of a canvas widget.1004 */1005 1006#ifdef USE_OLD_CANVAS1007typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas,1008 Tk_Item *itemPtr, int argc, char **argv);1009typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,1010 Tk_Item *itemPtr, int argc, char **argv, int flags);1011typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,1012 Tk_Item *itemPtr, int argc, char **argv);1013#else1014typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas,1015 Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);1016typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,1017 Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[],1018 int flags);1019typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,1020 Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);1021#endif /* USE_OLD_CANVAS */1022typedef void (Tk_ItemDeleteProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1023 Display *display);1024typedef void (Tk_ItemDisplayProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1025 Display *display, Drawable dst, int x, int y, int width,1026 int height);1027typedef double (Tk_ItemPointProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1028 double *pointPtr);1029typedef int (Tk_ItemAreaProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1030 double *rectPtr);1031typedef int (Tk_ItemPostscriptProc)(Tcl_Interp *interp, Tk_Canvas canvas,1032 Tk_Item *itemPtr, int prepass);1033typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1034 double originX, double originY, double scaleX,1035 double scaleY);1036typedef void (Tk_ItemTranslateProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1037 double deltaX, double deltaY);1038#ifdef USE_OLD_CANVAS1039typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,1040 Tk_Item *itemPtr, char *indexString, int *indexPtr);1041#else1042typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,1043 Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr);1044#endif /* USE_OLD_CANVAS */1045typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1046 int index);1047typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1048 int offset, char *buffer, int maxBytes);1049#ifdef USE_OLD_CANVAS1050typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1051 int beforeThis, char *string);1052#else1053typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1054 int beforeThis, Tcl_Obj *string);1055#endif /* USE_OLD_CANVAS */1056typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr,1057 int first, int last);1058 1059#ifndef __NO_OLD_CONFIG1060 1061typedef struct Tk_ItemType {1062 CONST86 char *name; /* The name of this type of item, such as1063 * "line". */1064 int itemSize; /* Total amount of space needed for item's1065 * record. */1066 Tk_ItemCreateProc *createProc;1067 /* Procedure to create a new item of this1068 * type. */1069 CONST86 Tk_ConfigSpec *configSpecs; /* Pointer to array of configuration specs for1070 * this type. Used for returning configuration1071 * info. */1072 Tk_ItemConfigureProc *configProc;1073 /* Procedure to call to change configuration1074 * options. */1075 Tk_ItemCoordProc *coordProc;/* Procedure to call to get and set the item's1076 * coordinates. */1077 Tk_ItemDeleteProc *deleteProc;1078 /* Procedure to delete existing item of this1079 * type. */1080 Tk_ItemDisplayProc *displayProc;1081 /* Procedure to display items of this type. */1082 int alwaysRedraw; /* Non-zero means displayProc should be called1083 * even when the item has been moved1084 * off-screen. */1085 Tk_ItemPointProc *pointProc;/* Computes distance from item to a given1086 * point. */1087 Tk_ItemAreaProc *areaProc; /* Computes whether item is inside, outside,1088 * or overlapping an area. */1089 Tk_ItemPostscriptProc *postscriptProc;1090 /* Procedure to write a Postscript description1091 * for items of this type. */1092 Tk_ItemScaleProc *scaleProc;/* Procedure to rescale items of this type. */1093 Tk_ItemTranslateProc *translateProc;1094 /* Procedure to translate items of this1095 * type. */1096 Tk_ItemIndexProc *indexProc;/* Procedure to determine index of indicated1097 * character. NULL if item doesn't support1098 * indexing. */1099 Tk_ItemCursorProc *icursorProc;1100 /* Procedure to set insert cursor posn to just1101 * before a given position. */1102 Tk_ItemSelectionProc *selectionProc;1103 /* Procedure to return selection (in STRING1104 * format) when it is in this item. */1105 Tk_ItemInsertProc *insertProc;1106 /* Procedure to insert something into an1107 * item. */1108 Tk_ItemDCharsProc *dCharsProc;1109 /* Procedure to delete characters from an1110 * item. */1111 struct Tk_ItemType *nextPtr;/* Used to link types together into a list. */1112 char *reserved1; /* Reserved for future extension. */1113 int reserved2; /* Carefully compatible with */1114 char *reserved3; /* Jan Nijtmans dash patch */1115 char *reserved4;1116} Tk_ItemType;1117 1118/*1119 * Flag (used in the alwaysRedraw field) to say whether an item supports1120 * point-level manipulation like the line and polygon items.1121 */1122 1123#define TK_MOVABLE_POINTS 21124 1125#endif /* __NO_OLD_CONFIG */1126 1127/*1128 * The following structure provides information about the selection and the1129 * insertion cursor. It is needed by only a few items, such as those that1130 * display text. It is shared by the generic canvas code and the item-specific1131 * code, but most of the fields should be written only by the canvas generic1132 * code.1133 */1134 1135typedef struct Tk_CanvasTextInfo {1136 Tk_3DBorder selBorder; /* Border and background for selected1137 * characters. Read-only to items.*/1138 int selBorderWidth; /* Width of border around selection. Read-only1139 * to items. */1140 XColor *selFgColorPtr; /* Foreground color for selected text.1141 * Read-only to items. */1142 Tk_Item *selItemPtr; /* Pointer to selected item. NULL means1143 * selection isn't in this canvas. Writable by1144 * items. */1145 int selectFirst; /* Character index of first selected1146 * character. Writable by items. */1147 int selectLast; /* Character index of last selected character.1148 * Writable by items. */1149 Tk_Item *anchorItemPtr; /* Item corresponding to "selectAnchor": not1150 * necessarily selItemPtr. Read-only to1151 * items. */1152 int selectAnchor; /* Character index of fixed end of selection1153 * (i.e. "select to" operation will use this1154 * as one end of the selection). Writable by1155 * items. */1156 Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion1157 * cursor. Read-only to items. */1158 int insertWidth; /* Total width of insertion cursor. Read-only1159 * to items. */1160 int insertBorderWidth; /* Width of 3-D border around insert cursor.1161 * Read-only to items. */1162 Tk_Item *focusItemPtr; /* Item that currently has the input focus, or1163 * NULL if no such item. Read-only to items. */1164 int gotFocus; /* Non-zero means that the canvas widget has1165 * the input focus. Read-only to items.*/1166 int cursorOn; /* Non-zero means that an insertion cursor1167 * should be displayed in focusItemPtr.1168 * Read-only to items.*/1169} Tk_CanvasTextInfo;1170 1171/*1172 * Structures used for Dashing and Outline.1173 */1174 1175typedef struct Tk_Dash {1176 int number;1177 union {1178 char *pt;1179 char array[sizeof(char *)];1180 } pattern;1181} Tk_Dash;1182 1183typedef struct Tk_TSOffset {1184 int flags; /* Flags; see below for possible values */1185 int xoffset; /* x offset */1186 int yoffset; /* y offset */1187} Tk_TSOffset;1188 1189/*1190 * Bit fields in Tk_TSOffset->flags:1191 */1192 1193#define TK_OFFSET_INDEX 11194#define TK_OFFSET_RELATIVE 21195#define TK_OFFSET_LEFT 41196#define TK_OFFSET_CENTER 81197#define TK_OFFSET_RIGHT 161198#define TK_OFFSET_TOP 321199#define TK_OFFSET_MIDDLE 641200#define TK_OFFSET_BOTTOM 128