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 54 extern "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 12 79 80 #define TK_VERSION "8.6" 81 #define TK_PATCH_LEVEL "8.6.12" 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 #if defined(__GNUC__) && !defined(__cplusplus) 97 # pragma GCC diagnostic ignored "-Wc++-compat" 98 #endif 99 # include <X11/Xlib.h> 100 # ifdef MAC_OSX_TK 101 # include <X11/X.h> 102 # endif 103 #endif 104 #if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \ 105 || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC) 106 # include <stddef.h> 107 #endif 108 109 #ifdef BUILD_tk 110 #undef TCL_STORAGE_CLASS 111 #define TCL_STORAGE_CLASS DLLEXPORT 112 #endif 113 114 /* 115 *---------------------------------------------------------------------- 116 * 117 * Decide whether or not to use input methods. 118 */ 119 120 #ifdef XNQueryInputStyle 121 #define TK_USE_INPUT_METHODS 122 #endif 123 124 /* 125 * Dummy types that are used by clients: 126 */ 127 128 #define Tk_ImageModel Tk_ImageMaster 129 typedef struct Tk_BindingTable_ *Tk_BindingTable; 130 typedef struct Tk_Canvas_ *Tk_Canvas; 131 typedef struct Tk_Cursor_ *Tk_Cursor; 132 typedef struct Tk_ErrorHandler_ *Tk_ErrorHandler; 133 typedef struct Tk_Font_ *Tk_Font; 134 typedef struct Tk_Image__ *Tk_Image; 135 typedef struct Tk_ImageMaster_ *Tk_ImageMaster; 136 typedef struct Tk_OptionTable_ *Tk_OptionTable; 137 typedef struct Tk_PostscriptInfo_ *Tk_PostscriptInfo; 138 typedef struct Tk_TextLayout_ *Tk_TextLayout; 139 typedef struct Tk_Window_ *Tk_Window; 140 typedef struct Tk_3DBorder_ *Tk_3DBorder; 141 typedef struct Tk_Style_ *Tk_Style; 142 typedef struct Tk_StyleEngine_ *Tk_StyleEngine; 143 typedef struct Tk_StyledElement_ *Tk_StyledElement; 144 145 /* 146 * Additional types exported to clients. 147 */ 148 149 typedef const char *Tk_Uid; 150 151 /* 152 *---------------------------------------------------------------------- 153 * 154 * The enum below defines the valid types for Tk configuration options as 155 * implemented by Tk_InitOptions, Tk_SetOptions, etc. 156 */ 157 158 typedef 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_STYLE 178 } Tk_OptionType; 179 180 /* 181 * Structures of the following type are used by widgets to specify their 182 * configuration options. Typically each widget has a static array of these 183 * structures, where each element of the array describes a single 184 * configuration option. The array is passed to Tk_CreateOptionTable. 185 */ 186 187 typedef struct Tk_OptionSpec { 188 Tk_OptionType type; /* Type of option, such as TK_OPTION_COLOR; 189 * see definitions above. Last option in table 190 * must have type TK_OPTION_END. */ 191 const char *optionName; /* Name used to specify option in Tcl 192 * 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 specified 196 * in command line, the option database, or 197 * the system. */ 198 int objOffset; /* Where in record to store a Tcl_Obj * that 199 * holds the value of this option, specified 200 * as an offset in bytes from the start of the 201 * record. Use the Tk_Offset macro to generate 202 * values for this. -1 means don't store the 203 * Tcl_Obj in the record. */ 204 int internalOffset; /* Where in record to store the internal 205 * representation of the value of this option, 206 * such as an int or XColor *. This field is 207 * specified as an offset in bytes from the 208 * start of the record. Use the Tk_Offset 209 * macro to generate values for it. -1 means 210 * don't store the internal representation in 211 * the record. */ 212 int flags; /* Any combination of the values defined 213 * below. */ 214 const void *clientData; /* An alternate place to put option-specific 215 * data. Used for the monochrome default value 216 * for colors, etc. */ 217 int typeMask; /* An arbitrary bit mask defined by the class 218 * manager; typically bits correspond to 219 * certain kinds of options such as all those 220 * that require a redisplay when they change. 221 * Tk_SetOptions returns the bit-wise OR of 222 * the typeMasks of all options that were 223 * changed. */ 224 } Tk_OptionSpec; 225 226 /* 227 * Flag values for Tk_OptionSpec structures. These flags are shared by 228 * 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_CUSTOM 236 * options; the structure holds pointers to the functions needed by the Tk 237 * option config code to handle a custom option. 238 */ 239 240 typedef int (Tk_CustomOptionSetProc) (ClientData clientData, 241 Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec, 242 int offset, char *saveInternalPtr, int flags); 243 typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData, 244 Tk_Window tkwin, char *widgRec, int offset); 245 typedef void (Tk_CustomOptionRestoreProc) (ClientData clientData, 246 Tk_Window tkwin, char *internalPtr, char *saveInternalPtr); 247 typedef void (Tk_CustomOptionFreeProc) (ClientData clientData, Tk_Window tkwin, 248 char *internalPtr); 249 250 typedef 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 option 254 * value from a Tcl_Obj */ 255 Tk_CustomOptionGetProc *getProc; 256 /* Function to use to get a Tcl_Obj 257 * representation from an internal 258 * representation of an option. */ 259 Tk_CustomOptionRestoreProc *restoreProc; 260 /* Function to use to restore a saved value 261 * for the internal representation. */ 262 Tk_CustomOptionFreeProc *freeProc; 263 /* Function to use to free the internal 264 * representation of an option. */ 265 ClientData clientData; /* Arbitrary one-word value passed to the 266 * 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 offsetof 277 # define offsetof(type, field) ((size_t) ((char *) &((type *) 0)->field)) 278 #endif 279 280 /* 281 * The following two structures are used for error handling. When config 282 * options are being modified, the old values are saved in a Tk_SavedOptions 283 * structure. If an error occurs, then the contents of the structure can be 284 * used to restore all of the old values. The contents of this structure are 285 * for the private use Tk. No-one outside Tk should ever read or write any of 286 * the fields of these structures. 287 */ 288 289 typedef struct Tk_SavedOption { 290 struct TkOption *optionPtr; /* Points to information that describes the 291 * option. */ 292 Tcl_Obj *valuePtr; /* The old value of the option, in the form of 293 * a Tcl object; may be NULL if the value was 294 * not saved as an object. */ 295 double internalForm; /* The old value of the option, in some 296 * internal representation such as an int or 297 * (XColor *). Valid only if the field 298 * optionPtr->specPtr->objOffset is < 0. The 299 * space must be large enough to accommodate a 300 * double, a long, or a pointer; right now it 301 * looks like a double (i.e., 8 bytes) is big 302 * enough. Also, using a double guarantees 303 * that the field is properly aligned for 304 * storing large values. */ 305 } Tk_SavedOption; 306 307 #ifdef TCL_MEM_DEBUG 308 # define TK_NUM_SAVED_OPTIONS 2 309 #else 310 # define TK_NUM_SAVED_OPTIONS 20 311 #endif 312 313 typedef struct Tk_SavedOptions { 314 char *recordPtr; /* The data structure in which to restore 315 * configuration options. */ 316 Tk_Window tkwin; /* Window associated with recordPtr; needed to 317 * 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 if 323 * too many options changed to hold all the 324 * old values in a single structure. NULL 325 * means no more structures. */ 326 } Tk_SavedOptions; 327 328 /* 329 * Structure used to describe application-specific configuration options: 330 * indicates procedures to call to parse an option and to return a text string 331 * describing an option. THESE ARE DEPRECATED; PLEASE USE THE NEW STRUCTURES 332 * LISTED ABOVE. 333 */ 334 335 /* 336 * This is a temporary flag used while tkObjConfig and new widgets are in 337 * development. 338 */ 339 340 #ifndef __NO_OLD_CONFIG 341 342 typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp, 343 Tk_Window tkwin, CONST84 char *value, char *widgRec, int offset); 344 typedef CONST86 char *(Tk_OptionPrintProc) (ClientData clientData, 345 Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); 346 347 typedef struct Tk_CustomOption { 348 Tk_OptionParseProc *parseProc; 349 /* Procedure to call to parse an option and 350 * store it in converted form. */ 351 Tk_OptionPrintProc *printProc; 352 /* Procedure to return a printable string 353 * describing an existing option. */ 354 ClientData clientData; /* Arbitrary one-word value used by option 355 * parser: passed to parseProc and 356 * printProc. */ 357 } Tk_CustomOption; 358 359 /* 360 * Structure used to specify information for Tk_ConfigureWidget. Each 361 * structure gives complete information for one option, including how the 362 * option is specified on the command line, where it appears in the option 363 * database, etc. 364 */ 365 366 typedef struct Tk_ConfigSpec { 367 int type; /* Type of option, such as TK_CONFIG_COLOR; 368 * see definitions below. Last option in table 369 * must have type TK_CONFIG_END. */ 370 CONST86 char *argvName; /* Switch used to specify option in argv. NULL 371 * 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 specified 375 * in command line or database. */ 376 int offset; /* Where in widget record to store value; use 377 * Tk_Offset macro to generate values for 378 * this. */ 379 int specFlags; /* Any combination of the values defined 380 * below; other bits are used internally by 381 * tkConfig.c. */ 382 CONST86 Tk_CustomOption *customPtr; 383 /* If type is TK_CONFIG_CUSTOM then this is a 384 * pointer to info about how to parse and 385 * print the option. Otherwise it is 386 * irrelevant. */ 387 } Tk_ConfigSpec; 388 389 /* 390 * Type values for Tk_ConfigSpec structures. See the user documentation for 391 * details. 392 */ 393 394 typedef 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_END 402 } Tk_ConfigTypes; 403 404 /* 405 * Possible values for flags argument to Tk_ConfigureWidget: 406 */ 407 408 #define TK_CONFIG_ARGV_ONLY 1 409 #define TK_CONFIG_OBJS 0x80 410 411 /* 412 * Possible flag values for Tk_ConfigSpec structures. Any bits at or above 413 * TK_CONFIG_USER_BIT may be used by clients for selecting certain entries. 414 * Before changing any values here, coordinate with tkOldConfig.c 415 * (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 0x100 424 #endif /* __NO_OLD_CONFIG */ 425 426 /* 427 * Structure used to specify how to handle argv options. 428 */ 429 430 typedef struct { 431 CONST86 char *key; /* The key string that flags the option in the 432 * argv array. */ 433 int type; /* Indicates option type; see below. */ 434 char *src; /* Value to be used in setting dst; usage 435 * depends on type. */ 436 char *dst; /* Address of value to be modified; usage 437 * depends on type. */ 438 CONST86 char *help; /* Documentation message describing this 439 * option. */ 440 } Tk_ArgvInfo; 441 442 /* 443 * Legal values for the type field of a Tk_ArgvInfo: see the user 444 * documentation for details. 445 */ 446 447 #define TK_ARGV_CONSTANT 15 448 #define TK_ARGV_INT 16 449 #define TK_ARGV_STRING 17 450 #define TK_ARGV_UID 18 451 #define TK_ARGV_REST 19 452 #define TK_ARGV_FLOAT 20 453 #define TK_ARGV_FUNC 21 454 #define TK_ARGV_GENFUNC 22 455 #define TK_ARGV_HELP 23 456 #define TK_ARGV_CONST_OPTION 24 457 #define TK_ARGV_OPTION_VALUE 25 458 #define TK_ARGV_OPTION_NAME_VALUE 26 459 #define TK_ARGV_END 27 460 461 /* 462 * Flag bits for passing to Tk_ParseArgv: 463 */ 464 465 #define TK_ARGV_NO_DEFAULTS 0x1 466 #define TK_ARGV_NO_LEFTOVERS 0x2 467 #define TK_ARGV_NO_ABBREV 0x4 468 #define TK_ARGV_DONT_SKIP_FIRST_ARG 0x8 469 470 /* 471 * Enumerated type for describing actions to be taken in response to a 472 * restrictProc established by Tk_RestrictEvents. 473 */ 474 475 typedef enum { 476 TK_DEFER_EVENT, TK_PROCESS_EVENT, TK_DISCARD_EVENT 477 } Tk_RestrictAction; 478 479 /* 480 * Priority levels to pass to Tk_AddOption: 481 */ 482 483 #define TK_WIDGET_DEFAULT_PRIO 20 484 #define TK_STARTUP_FILE_PRIO 40 485 #define TK_USER_DEFAULT_PRIO 60 486 #define TK_INTERACTIVE_PRIO 80 487 #define TK_MAX_PRIO 100 488 489 /* 490 * Relief values returned by Tk_GetRelief: 491 */ 492 493 #define TK_RELIEF_NULL -1 494 #define TK_RELIEF_FLAT 0 495 #define TK_RELIEF_GROOVE 1 496 #define TK_RELIEF_RAISED 2 497 #define TK_RELIEF_RIDGE 3 498 #define TK_RELIEF_SOLID 4 499 #define TK_RELIEF_SUNKEN 5 500 501 /* 502 * "Which" argument values for Tk_3DBorderGC: 503 */ 504 505 #define TK_3D_FLAT_GC 1 506 #define TK_3D_LIGHT_GC 2 507 #define TK_3D_DARK_GC 3 508 509 /* 510 * Special EnterNotify/LeaveNotify "mode" for use in events generated by 511 * tkShare.c. Pick a high enough value that it's unlikely to conflict with 512 * existing values (like NotifyNormal) or any new values defined in the 513 * future. 514 */ 515 516 #define TK_NOTIFY_SHARE 20 517 518 /* 519 * Enumerated type for describing a point by which to anchor something: 520 */ 521 522 typedef 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_CENTER 526 } Tk_Anchor; 527 528 /* 529 * Enumerated type for describing a style of justification: 530 */ 531 532 typedef enum { 533 TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER 534 } Tk_Justify; 535 536 /* 537 * The following structure is used by Tk_GetFontMetrics() to return 538 * information about the properties of a Tk_Font. 539 */ 540 541 typedef struct Tk_FontMetrics { 542 int ascent; /* The amount in pixels that the tallest 543 * letter sticks up above the baseline, plus 544 * any extra blank space added by the designer 545 * of the font. */ 546 int descent; /* The largest amount in pixels that any 547 * letter sticks below the baseline, plus any 548 * extra blank space added by the designer of 549 * the font. */ 550 int linespace; /* The sum of the ascent and descent. How far 551 * apart two lines of text in the same font 552 * should be placed so that none of the 553 * characters in one line overlap any of the 554 * characters in the other line. */ 555 } Tk_FontMetrics; 556 557 /* 558 * Flags passed to Tk_MeasureChars: 559 */ 560 561 #define TK_WHOLE_WORDS 1 562 #define TK_AT_LEAST_ONE 2 563 #define TK_PARTIAL_OK 4 564 565 /* 566 * Flags passed to Tk_ComputeTextLayout: 567 */ 568 569 #define TK_IGNORE_TABS 8 570 #define TK_IGNORE_NEWLINES 16 571 572 /* 573 * Widget class procedures used to implement platform specific widget 574 * behavior. 575 */ 576 577 typedef Window (Tk_ClassCreateProc) (Tk_Window tkwin, Window parent, 578 ClientData instanceData); 579 typedef void (Tk_ClassWorldChangedProc) (ClientData instanceData); 580 typedef void (Tk_ClassModalProc) (Tk_Window tkwin, XEvent *eventPtr); 581 582 typedef struct Tk_ClassProcs { 583 unsigned int size; 584 Tk_ClassWorldChangedProc *worldChangedProc; 585 /* Procedure to invoke when the widget needs 586 * to respond in some way to a change in the 587 * 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 a 593 * widget have been triggered in order to 594 * handle a modal loop. */ 595 } Tk_ClassProcs; 596 597 /* 598 * Simple accessor for Tk_ClassProcs structure. Checks that the structure is 599 * not NULL, then checks the size field and returns either the requested 600 * field, if present, or NULL if the structure is too small to have the field 601 * (or NULL if the structure is NULL). 602 * 603 * A more general version of this function may be useful if other 604 * 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)) 614 615 /* 616 * Each geometry manager (the packer, the placer, etc.) is represented by a 617 * structure of the following form, which indicates procedures to invoke in 618 * the geometry manager to carry out certain functions. 619 */ 620 621 #define Tk_GeomLostContentProc Tk_GeomLostSlaveProc 622 typedef void (Tk_GeomRequestProc) (ClientData clientData, Tk_Window tkwin); 623 typedef void (Tk_GeomLostContentProc) (ClientData clientData, Tk_Window tkwin); 624 625 typedef struct Tk_GeomMgr { 626 const char *name; /* Name of the geometry manager (command used 627 * to invoke it, or name of widget class that 628 * allows embedded widgets). */ 629 Tk_GeomRequestProc *requestProc; 630 /* Procedure to invoke when a content's 631 * requested geometry changes. */ 632 Tk_GeomLostContentProc *lostSlaveProc; 633 /* Procedure to invoke when content is taken 634 * away from one geometry manager by another. 635 * NULL means geometry manager doesn't care 636 * when content lost. */ 637 } Tk_GeomMgr; 638 639 /* 640 * Result values returned by Tk_GetScrollInfo: 641 */ 642 643 #define TK_SCROLL_MOVETO 1 644 #define TK_SCROLL_PAGES 2 645 #define TK_SCROLL_UNITS 3 646 #define TK_SCROLL_ERROR 4 647 648 /* 649 *---------------------------------------------------------------------- 650 * 651 * Extensions to the X event set 652 * 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 and 668 * XButtonEvent structures. 99% of the time a virtual event will be an 669 * abstraction of a key or button event, so this structure provides the most 670 * information to the user. The only difference is the changing of the detail 671 * field for a virtual event so that it holds the name of the virtual event 672 * being triggered. 673 * 674 * When using this structure, you should ensure that you zero out all the 675 * fields first using memset() or bzero(). 676 */ 677 678 typedef struct { 679 int type; 680 unsigned long serial; /* # of last request processed by server. */ 681 Bool send_event; /* True if this came from a SendEvent 682 * 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 event 689 * 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; Tk 695 * will decrement the reference count *once* 696 * when it has finished processing the 697 * event. */ 698 } XVirtualEvent; 699 700 typedef struct { 701 int type; 702 unsigned long serial; /* # of last request processed by server. */ 703 Bool send_event; /* True if this came from a SendEvent 704 * request. */ 705 Display *display; /* Display the event was read from. */ 706 Window window; /* Window in which event occurred. */ 707 } XActivateDeactivateEvent; 708 typedef XActivateDeactivateEvent XActivateEvent; 709 typedef XActivateDeactivateEvent XDeactivateEvent; 710 711 /* 712 *---------------------------------------------------------------------- 713 * 714 * Macros for querying Tk_Window structures. See the manual entries for 715 * 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 access 773 * the fields of a Tk_Window. The fields not needed by the macros are declared 774 * as "dummyX". The structure has its own type in order to prevent apps from 775 * accessing Tk_Window fields except using official macros. WARNING!! The 776 * structure definition must be kept consistent with the TkWindow structure in 777 * tkInt.h. If you change one, then change the other. See the declaration in 778 * tkInt.h for documentation on what the fields are used for internally. 779 */ 780 781 typedef 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_METHODS 803 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_METHODS 823 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 of 836 * being destroyed already. 837 * TK_NEED_CONFIG_NOTIFY: 1 means that the window has been reconfigured 838 * before it was made to exist. At the time of 839 * making it exist a ConfigureNotify event needs 840 * to be generated. 841 * TK_GRAB_FLAG: Used to manage grabs. See tkGrab.c for details 842 * TK_CHECKED_IC: 1 means we've already tried to get an input 843 * context for this window; if the ic field is 844 * NULL it means that there isn't a context for 845 * the field. 846 * TK_DONT_DESTROY_WINDOW: 1 means that Tk_DestroyWindow should not 847 * invoke XDestroyWindow to destroy this widget's 848 * X window. The flag is set when the window has 849 * already been destroyed elsewhere (e.g. by 850 * another application) or when it will be 851 * destroyed later (e.g. by destroying its parent) 852 * TK_WM_COLORMAP_WINDOW: 1 means that this window has at some time 853 * appeared in the WM_COLORMAP_WINDOWS property 854 * for its toplevel, so we have to remove it from 855 * that property if the window is deleted and the 856 * toplevel isn't. 857 * TK_EMBEDDED: 1 means that this window (which must be a 858 * toplevel) is not a free-standing window but 859 * rather is embedded in some other application. 860 * TK_CONTAINER: 1 means that this window is a container, and 861 * that some other application (either in this 862 * process or elsewhere) may be embedding itself 863 * inside the window. 864 * TK_BOTH_HALVES: 1 means that this window is used for 865 * application embedding (either as container or 866 * embedded application), and both the containing 867 * and embedded halves are associated with 868 * windows in this particular process. 869 * TK_WRAPPER: 1 means that this window is the extra wrapper 870 * window created around a toplevel to hold the 871 * menubar under Unix. See tkUnixWm.c for more 872 * information. 873 * TK_REPARENTED: 1 means that this window has been reparented 874 * so that as far as the window system is 875 * concerned it isn't a child of its Tk parent. 876 * Initially this is used only for special Unix 877 * menubar windows. 878 * TK_ANONYMOUS_WINDOW: 1 means that this window has no name, and is 879 * thus not accessible from Tk. 880 * TK_HAS_WRAPPER 1 means that this window has a wrapper window 881 * TK_WIN_MANAGED 1 means that this window is a child of the root 882 * window, and is managed by the window manager. 883 * TK_TOP_HIERARCHY 1 means this window is at the top of a physical 884 * window hierarchy within this process, i.e. the 885 * window's parent either doesn't exist or is not 886 * owned by this Tk application. 887 * TK_PROP_PROPCHANGE 1 means that PropertyNotify events in the 888 * window's children should propagate up to this 889 * window. 890 * TK_WM_MANAGEABLE 1 marks a window as capable of being converted 891 * 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 be 894 * processed with the NSTextInputClient protocol. 895 * Not currently accessible through the public API. 896 */ 897 898 #define TK_MAPPED 1 899 #define TK_TOP_LEVEL 2 900 #define TK_ALREADY_DEAD 4 901 #define TK_NEED_CONFIG_NOTIFY 8 902 #define TK_GRAB_FLAG 0x10 903 #define TK_CHECKED_IC 0x20 904 #define TK_DONT_DESTROY_WINDOW 0x40 905 #define TK_WM_COLORMAP_WINDOW 0x80 906 #define TK_EMBEDDED 0x100 907 #define TK_CONTAINER 0x200 908 #define TK_BOTH_HALVES 0x400 909 910 #define TK_WRAPPER 0x1000 911 #define TK_REPARENTED 0x2000 912 #define TK_ANONYMOUS_WINDOW 0x4000 913 #define TK_HAS_WRAPPER 0x8000 914 #define TK_WIN_MANAGED 0x10000 915 #define TK_TOP_HIERARCHY 0x20000 916 #define TK_PROP_PROPCHANGE 0x40000 917 #define TK_WM_MANAGEABLE 0x80000 918 #define TK_CAN_INPUT_TEXT 0x100000 919 920 /* 921 *---------------------------------------------------------------------- 922 * 923 * Procedure prototypes and structures used for defining new canvas items: 924 * 925 *---------------------------------------------------------------------- 926 */ 927 928 typedef enum { 929 TK_STATE_NULL = -1, TK_STATE_ACTIVE, TK_STATE_DISABLED, 930 TK_STATE_NORMAL, TK_STATE_HIDDEN 931 } Tk_State; 932 933 typedef 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 following 943 * structure. Each actual item is represented by a record with the following 944 * stuff at its beginning, plus additional type-specific stuff after that. 945 */ 946 947 #define TK_TAG_SPACE 3 948 949 typedef struct Tk_Item { 950 int id; /* Unique identifier for this item (also 951 * serves as first tag for item). */ 952 struct Tk_Item *nextPtr; /* Next in display list of all items in this 953 * canvas. Later items in list are drawn on 954 * 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 to 958 * staticTagSpace, but may point to malloc-ed 959 * space if there are lots of tags. */ 960 int tagSpace; /* Total amount of tag space available at 961 * tagPtr. */ 962 int numTags; /* Number of tag slots actually used at 963 * *tagPtr. */ 964 struct Tk_ItemType *typePtr;/* Table of procedures that implement this 965 * type of item. */ 966 int x1, y1, x2, y2; /* Bounding box for item, in integer canvas 967 * units. Set by item-specific code and 968 * guaranteed to contain every pixel drawn in 969 * item. Item area includes x1 and y1 but not 970 * x2 and y2. */ 971 struct Tk_Item *prevPtr; /* Previous in display list of all items in 972 * this canvas. Later items in list are drawn 973 * 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 declarations 981 * for individual types to see what is part of each type. The actual space 982 * below is determined by the "itemInfoSize" of the type's Tk_ItemType 983 * 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 the 992 * canvas state changes. 993 * TK_ITEM_DONT_REDRAW - 1 means that the object redraw is already been 994 * prepared, so the general canvas code doesn't 995 * need to do that any more. 996 */ 997 998 #define TK_ITEM_STATE_DEPENDANT 1 999 #define TK_ITEM_DONT_REDRAW 2 1000 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_CANVAS 1007 typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1008 Tk_Item *itemPtr, int argc, char **argv); 1009 typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1010 Tk_Item *itemPtr, int argc, char **argv, int flags); 1011 typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1012 Tk_Item *itemPtr, int argc, char **argv); 1013 #else 1014 typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1015 Tk_Item *itemPtr, int argc, Tcl_Obj *const objv[]); 1016 typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1017 Tk_Item *itemPtr, int argc, Tcl_Obj *const objv[], 1018 int flags); 1019 typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1020 Tk_Item *itemPtr, int argc, Tcl_Obj *const argv[]); 1021 #endif /* USE_OLD_CANVAS */ 1022 typedef void (Tk_ItemDeleteProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1023 Display *display); 1024 typedef void (Tk_ItemDisplayProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1025 Display *display, Drawable dst, int x, int y, int width, 1026 int height); 1027 typedef double (Tk_ItemPointProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1028 double *pointPtr); 1029 typedef int (Tk_ItemAreaProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1030 double *rectPtr); 1031 typedef int (Tk_ItemPostscriptProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1032 Tk_Item *itemPtr, int prepass); 1033 typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1034 double originX, double originY, double scaleX, 1035 double scaleY); 1036 typedef void (Tk_ItemTranslateProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1037 double deltaX, double deltaY); 1038 #ifdef USE_OLD_CANVAS 1039 typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1040 Tk_Item *itemPtr, char *indexString, int *indexPtr); 1041 #else 1042 typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, 1043 Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr); 1044 #endif /* USE_OLD_CANVAS */ 1045 typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1046 int index); 1047 typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1048 int offset, char *buffer, int maxBytes); 1049 #ifdef USE_OLD_CANVAS 1050 typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1051 int beforeThis, char *string); 1052 #else 1053 typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1054 int beforeThis, Tcl_Obj *string); 1055 #endif /* USE_OLD_CANVAS */ 1056 typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr, 1057 int first, int last); 1058 1059 #ifndef __NO_OLD_CONFIG 1060 1061 typedef struct Tk_ItemType { 1062 CONST86 char *name; /* The name of this type of item, such as 1063 * "line". */ 1064 int itemSize; /* Total amount of space needed for item's 1065 * record. */ 1066 Tk_ItemCreateProc *createProc; 1067 /* Procedure to create a new item of this 1068 * type. */ 1069 CONST86 Tk_ConfigSpec *configSpecs; /* Pointer to array of configuration specs for 1070 * this type. Used for returning configuration 1071 * info. */ 1072 Tk_ItemConfigureProc *configProc; 1073 /* Procedure to call to change configuration 1074 * options. */ 1075 Tk_ItemCoordProc *coordProc;/* Procedure to call to get and set the item's 1076 * coordinates. */ 1077 Tk_ItemDeleteProc *deleteProc; 1078 /* Procedure to delete existing item of this 1079 * type. */ 1080 Tk_ItemDisplayProc *displayProc; 1081 /* Procedure to display items of this type. */ 1082 int alwaysRedraw; /* Non-zero means displayProc should be called 1083 * even when the item has been moved 1084 * off-screen. */ 1085 Tk_ItemPointProc *pointProc;/* Computes distance from item to a given 1086 * 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 description 1091 * 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 this 1095 * type. */ 1096 Tk_ItemIndexProc *indexProc;/* Procedure to determine index of indicated 1097 * character. NULL if item doesn't support 1098 * indexing. */ 1099 Tk_ItemCursorProc *icursorProc; 1100 /* Procedure to set insert cursor posn to just 1101 * before a given position. */ 1102 Tk_ItemSelectionProc *selectionProc; 1103 /* Procedure to return selection (in STRING 1104 * format) when it is in this item. */ 1105 Tk_ItemInsertProc *insertProc; 1106 /* Procedure to insert something into an 1107 * item. */ 1108 Tk_ItemDCharsProc *dCharsProc; 1109 /* Procedure to delete characters from an 1110 * 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 supports 1120 * point-level manipulation like the line and polygon items. 1121 */ 1122 1123 #define TK_MOVABLE_POINTS 2 1124 1125 #endif /* __NO_OLD_CONFIG */ 1126 1127 /* 1128 * The following structure provides information about the selection and the 1129 * insertion cursor. It is needed by only a few items, such as those that 1130 * display text. It is shared by the generic canvas code and the item-specific 1131 * code, but most of the fields should be written only by the canvas generic 1132 * code. 1133 */ 1134 1135 typedef struct Tk_CanvasTextInfo { 1136 Tk_3DBorder selBorder; /* Border and background for selected 1137 * characters. Read-only to items.*/ 1138 int selBorderWidth; /* Width of border around selection. Read-only 1139 * to items. */ 1140 XColor *selFgColorPtr; /* Foreground color for selected text. 1141 * Read-only to items. */ 1142 Tk_Item *selItemPtr; /* Pointer to selected item. NULL means 1143 * selection isn't in this canvas. Writable by 1144 * items. */ 1145 int selectFirst; /* Character index of first selected 1146 * 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": not 1150 * necessarily selItemPtr. Read-only to 1151 * items. */ 1152 int selectAnchor; /* Character index of fixed end of selection 1153 * (i.e. "select to" operation will use this 1154 * as one end of the selection). Writable by 1155 * items. */ 1156 Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion 1157 * cursor. Read-only to items. */ 1158 int insertWidth; /* Total width of insertion cursor. Read-only 1159 * 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, or 1163 * NULL if no such item. Read-only to items. */ 1164 int gotFocus; /* Non-zero means that the canvas widget has 1165 * the input focus. Read-only to items.*/ 1166 int cursorOn; /* Non-zero means that an insertion cursor 1167 * should be displayed in focusItemPtr. 1168 * Read-only to items.*/ 1169 } Tk_CanvasTextInfo; 1170 1171 /* 1172 * Structures used for Dashing and Outline. 1173 */ 1174 1175 typedef struct Tk_Dash { 1176 int number; 1177 union { 1178 char *pt; 1179 char array[sizeof(char *)]; 1180 } pattern; 1181 } Tk_Dash; 1182 1183 typedef 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 1 1194 #define TK_OFFSET_RELATIVE 2 1195 #define TK_OFFSET_LEFT 4 1196 #define TK_OFFSET_CENTER 8 1197 #define TK_OFFSET_RIGHT 16 1198 #define TK_OFFSET_TOP 32 1199 #define TK_OFFSET_MIDDLE 64 1200 #define TK_OFFSET_BOTTOM 128 1201 1202 typedef struct Tk_Outline { 1203 GC gc; /* Graphics context. */ 1204 double width; /* Width of outline. */ 1205 double activeWidth; /* Width of outline. */ 1206 double disabledWidth; /* Width of outline. */ 1207 int offset; /* Dash offset. */ 1208 Tk_Dash dash; /* Dash pattern. */ 1209 Tk_Dash activeDash; /* Dash pattern if state is active. */ 1210 Tk_Dash disabledDash; /* Dash pattern if state is disabled. */ 1211 void *reserved1; /* Reserved for future expansion. */ 1212 void *reserved2; 1213 void *reserved3; 1214 Tk_TSOffset tsoffset; /* Stipple offset for outline. */ 1215 XColor *color; /* Outline color. */ 1216 XColor *activeColor; /* Outline color if state is active. */ 1217 XColor *disabledColor; /* Outline color if state is disabled. */ 1218 Pixmap stipple; /* Outline Stipple pattern. */ 1219 Pixmap activeStipple; /* Outline Stipple pattern if state is 1220 * active. */ 1221 Pixmap disabledStipple; /* Outline Stipple pattern if state is 1222 * disabled. */ 1223 } Tk_Outline; 1224 1225 /* 1226 *---------------------------------------------------------------------- 1227 * 1228 * Procedure prototypes and structures used for managing images: 1229 * 1230 *---------------------------------------------------------------------- 1231 */ 1232 1233 typedef struct Tk_ImageType Tk_ImageType; 1234 #ifdef USE_OLD_IMAGE 1235 typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, int argc, 1236 char **argv, Tk_ImageType *typePtr, Tk_ImageMaster model, 1237 ClientData *clientDataPtr); 1238 #else 1239 typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, CONST86 char *name, int objc, 1240 Tcl_Obj *const objv[], CONST86 Tk_ImageType *typePtr, Tk_ImageMaster model, 1241 ClientData *clientDataPtr); 1242 #endif /* USE_OLD_IMAGE */ 1243 typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData clientData); 1244 typedef void (Tk_ImageDisplayProc) (ClientData clientData, Display *display, 1245 Drawable drawable, int imageX, int imageY, int width, int height, 1246 int drawableX, int drawableY); 1247 typedef void (Tk_ImageFreeProc) (ClientData clientData, Display *display); 1248 typedef void (Tk_ImageDeleteProc) (ClientData clientData); 1249 typedef void (Tk_ImageChangedProc) (ClientData clientData, int x, int y, 1250 int width, int height, int imageWidth, int imageHeight); 1251 typedef int (Tk_ImagePostscriptProc) (ClientData clientData, 1252 Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, 1253 int x, int y, int width, int height, int prepass); 1254 1255 /* 1256 * The following structure represents a particular type of image (bitmap, xpm 1257 * image, etc.). It provides information common to all images of that type, 1258 * such as the type name and a collection of procedures in the image manager 1259 * that respond to various events. Each image manager is represented by one of 1260 * these structures. 1261 */ 1262 1263 struct Tk_ImageType { 1264 CONST86 char *name; /* Name of image type. */ 1265 Tk_ImageCreateProc *createProc; 1266 /* Procedure to call to create a new image of 1267 * this type. */ 1268 Tk_ImageGetProc *getProc; /* Procedure to call the first time 1269 * Tk_GetImage is called in a new way (new 1270 * visual or screen). */ 1271 Tk_ImageDisplayProc *displayProc; 1272 /* Call to draw image, in response to 1273 * Tk_RedrawImage calls. */ 1274 Tk_ImageFreeProc *freeProc; /* Procedure to call whenever Tk_FreeImage is 1275 * called to release an instance of an 1276 * image. */ 1277 Tk_ImageDeleteProc *deleteProc; 1278 /* Procedure to call to delete image. It will 1279 * not be called until after freeProc has been 1280 * called for each instance of the image. */ 1281 Tk_ImagePostscriptProc *postscriptProc; 1282 /* Procedure to call to produce postscript 1283 * output for the image. */ 1284 struct Tk_ImageType *nextPtr; 1285 /* Next in list of all image types currently 1286 * known. Filled in by Tk, not by image 1287 * manager. */ 1288 char *reserved; /* reserved for future expansion */ 1289 }; 1290 1291 /* 1292 *---------------------------------------------------------------------- 1293 * 1294 * Additional definitions used to manage images of type "photo". 1295 * 1296 *---------------------------------------------------------------------- 1297 */ 1298 1299 /* 1300 * The following type is used to identify a particular photo image to be 1301 * manipulated: 1302 */ 1303 1304 typedef void *Tk_PhotoHandle; 1305 1306 /* 1307 * The following structure describes a block of pixels in memory: 1308 */ 1309 1310 typedef struct Tk_PhotoImageBlock { 1311 unsigned char *pixelPtr; /* Pointer to the first pixel. */ 1312 int width; /* Width of block, in pixels. */ 1313 int height; /* Height of block, in pixels. */ 1314 int pitch; /* Address difference between corresponding 1315 * pixels in successive lines. */ 1316 int pixelSize; /* Address difference between successive 1317 * pixels in the same line. */ 1318 int offset[4]; /* Address differences between the red, green, 1319 * blue and alpha components of the pixel and 1320 * the pixel as a whole. */ 1321 } Tk_PhotoImageBlock; 1322 1323 /* 1324 * The following values control how blocks are combined into photo images when 1325 * the alpha component of a pixel is not 255, a.k.a. the compositing rule. 1326 */ 1327 1328 #define TK_PHOTO_COMPOSITE_OVERLAY 0 1329 #define TK_PHOTO_COMPOSITE_SET 1 1330 1331 /* 1332 * Procedure prototypes and structures used in reading and writing photo 1333 * images: 1334 */ 1335 1336 typedef struct Tk_PhotoImageFormat Tk_PhotoImageFormat; 1337 #ifdef USE_OLD_IMAGE 1338 typedef int (Tk_ImageFileMatchProc) (Tcl_Channel chan, char *fileName, 1339 char *formatString, int *widthPtr, int *heightPtr); 1340 typedef int (Tk_ImageStringMatchProc) (char *string, char *formatString, 1341 int *widthPtr, int *heightPtr); 1342 typedef int (Tk_ImageFileReadProc) (Tcl_Interp *interp, Tcl_Channel chan, 1343 char *fileName, char *formatString, Tk_PhotoHandle imageHandle, 1344 int destX, int destY, int width, int height, int srcX, int srcY); 1345 typedef int (Tk_ImageStringReadProc) (Tcl_Interp *interp, char *string, 1346 char *formatString, Tk_PhotoHandle imageHandle, int destX, int destY, 1347 int width, int height, int srcX, int srcY); 1348 typedef int (Tk_ImageFileWriteProc) (Tcl_Interp *interp, char *fileName, 1349 char *formatString, Tk_PhotoImageBlock *blockPtr); 1350 typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, 1351 Tcl_DString *dataPtr, char *formatString, Tk_PhotoImageBlock *blockPtr); 1352 #else 1353 typedef int (Tk_ImageFileMatchProc) (Tcl_Channel chan, const char *fileName, 1354 Tcl_Obj *format, int *widthPtr, int *heightPtr, Tcl_Interp *interp); 1355 typedef int (Tk_ImageStringMatchProc) (Tcl_Obj *dataObj, Tcl_Obj *format, 1356 int *widthPtr, int *heightPtr, Tcl_Interp *interp); 1357 typedef int (Tk_ImageFileReadProc) (Tcl_Interp *interp, Tcl_Channel chan, 1358 const char *fileName, Tcl_Obj *format, Tk_PhotoHandle imageHandle, 1359 int destX, int destY, int width, int height, int srcX, int srcY); 1360 typedef int (Tk_ImageStringReadProc) (Tcl_Interp *interp, Tcl_Obj *dataObj, 1361 Tcl_Obj *format, Tk_PhotoHandle imageHandle, int destX, int destY, 1362 int width, int height, int srcX, int srcY); 1363 typedef int (Tk_ImageFileWriteProc) (Tcl_Interp *interp, const char *fileName, 1364 Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); 1365 typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format, 1366 Tk_PhotoImageBlock *blockPtr); 1367 #endif /* USE_OLD_IMAGE */ 1368 1369 /* 1370 * The following structure represents a particular file format for storing 1371 * images (e.g., PPM, GIF, JPEG, etc.). It provides information to allow image 1372 * files of that format to be recognized and read into a photo image. 1373 */ 1374 1375 struct Tk_PhotoImageFormat { 1376 CONST86 char *name; /* Name of image file format */ 1377 Tk_ImageFileMatchProc *fileMatchProc; 1378 /* Procedure to call to determine whether an 1379 * image file matches this format. */ 1380 Tk_ImageStringMatchProc *stringMatchProc; 1381 /* Procedure to call to determine whether the 1382 * data in a string matches this format. */ 1383 Tk_ImageFileReadProc *fileReadProc; 1384 /* Procedure to call to read data from an 1385 * image file into a photo image. */ 1386 Tk_ImageStringReadProc *stringReadProc; 1387 /* Procedure to call to read data from a 1388 * string into a photo image. */ 1389 Tk_ImageFileWriteProc *fileWriteProc; 1390 /* Procedure to call to write data from a 1391 * photo image to a file. */ 1392 Tk_ImageStringWriteProc *stringWriteProc; 1393 /* Procedure to call to obtain a string 1394 * representation of the data in a photo 1395 * image.*/ 1396 struct Tk_PhotoImageFormat *nextPtr; 1397 /* Next in list of all photo image formats 1398 * currently known. Filled in by Tk, not by 1399 * image format handler. */ 1400 }; 1401 1402 /* 1403 *---------------------------------------------------------------------- 1404 * 1405 * Procedure prototypes and structures used for managing styles: 1406 * 1407 *---------------------------------------------------------------------- 1408 */ 1409 1410 /* 1411 * Style support version tag. 1412 */ 1413 1414 #define TK_STYLE_VERSION_1 0x1 1415 #define TK_STYLE_VERSION TK_STYLE_VERSION_1 1416 1417 /* 1418 * The following structures and prototypes are used as static templates to 1419 * declare widget elements. 1420 */ 1421 1422 typedef void (Tk_GetElementSizeProc) (ClientData clientData, char *recordPtr, 1423 const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, int width, 1424 int height, int inner, int *widthPtr, int *heightPtr); 1425 typedef void (Tk_GetElementBoxProc) (ClientData clientData, char *recordPtr, 1426 const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, int x, int y, 1427 int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, 1428 int *heightPtr); 1429 typedef int (Tk_GetElementBorderWidthProc) (ClientData clientData, 1430 char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin); 1431 typedef void (Tk_DrawElementProc) (ClientData clientData, char *recordPtr, 1432 const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, Drawable d, int x, 1433 int y, int width, int height, int state); 1434 1435 typedef struct Tk_ElementOptionSpec { 1436 char *name; /* Name of the required option. */ 1437 Tk_OptionType type; /* Accepted option type. TK_OPTION_END means 1438 * any. */ 1439 } Tk_ElementOptionSpec; 1440 1441 typedef struct Tk_ElementSpec { 1442 int version; /* Version of the style support. */ 1443 char *name; /* Name of element. */ 1444 Tk_ElementOptionSpec *options; 1445 /* List of required options. Last one's name 1446 * must be NULL. */ 1447 Tk_GetElementSizeProc *getSize; 1448 /* Compute the external (resp. internal) size 1449 * of the element from its desired internal 1450 * (resp. external) size. */ 1451 Tk_GetElementBoxProc *getBox; 1452 /* Compute the inscribed or bounding boxes 1453 * within a given area. */ 1454 Tk_GetElementBorderWidthProc *getBorderWidth; 1455 /* Return the element's internal border width. 1456 * Mostly useful for widgets. */ 1457 Tk_DrawElementProc *draw; /* Draw the element in the given bounding 1458 * box. */ 1459 } Tk_ElementSpec; 1460 1461 /* 1462 * Element state flags. Can be OR'ed. 1463 */ 1464 1465 #define TK_ELEMENT_STATE_ACTIVE 1<<0 1466 #define TK_ELEMENT_STATE_DISABLED 1<<1 1467 #define TK_ELEMENT_STATE_FOCUS 1<<2 1468 #define TK_ELEMENT_STATE_PRESSED 1<<3 1469 1470 /* 1471 *---------------------------------------------------------------------- 1472 * 1473 * The definitions below provide backward compatibility for functions and 1474 * types related to event handling that used to be in Tk but have moved to 1475 * Tcl. 1476 * 1477 *---------------------------------------------------------------------- 1478 */ 1479 1480 #define TK_READABLE TCL_READABLE 1481 #define TK_WRITABLE TCL_WRITABLE 1482 #define TK_EXCEPTION TCL_EXCEPTION 1483 1484 #define TK_DONT_WAIT TCL_DONT_WAIT 1485 #define TK_X_EVENTS TCL_WINDOW_EVENTS 1486 #define TK_WINDOW_EVENTS TCL_WINDOW_EVENTS 1487 #define TK_FILE_EVENTS TCL_FILE_EVENTS 1488 #define TK_TIMER_EVENTS TCL_TIMER_EVENTS 1489 #define TK_IDLE_EVENTS TCL_IDLE_EVENTS 1490 #define TK_ALL_EVENTS TCL_ALL_EVENTS 1491 1492 #define Tk_IdleProc Tcl_IdleProc 1493 #define Tk_FileProc Tcl_FileProc 1494 #define Tk_TimerProc Tcl_TimerProc 1495 #define Tk_TimerToken Tcl_TimerToken 1496 1497 #define Tk_BackgroundError Tcl_BackgroundError 1498 #define Tk_CancelIdleCall Tcl_CancelIdleCall 1499 #define Tk_CreateFileHandler Tcl_CreateFileHandler 1500 #define Tk_CreateTimerHandler Tcl_CreateTimerHandler 1501 #define Tk_DeleteFileHandler Tcl_DeleteFileHandler 1502 #define Tk_DeleteTimerHandler Tcl_DeleteTimerHandler 1503 #define Tk_DoOneEvent Tcl_DoOneEvent 1504 #define Tk_DoWhenIdle Tcl_DoWhenIdle 1505 #define Tk_Sleep Tcl_Sleep 1506 1507 /* Additional stuff that has moved to Tcl: */ 1508 1509 #define Tk_EventuallyFree Tcl_EventuallyFree 1510 #define Tk_FreeProc Tcl_FreeProc 1511 #define Tk_Preserve Tcl_Preserve 1512 #define Tk_Release Tcl_Release 1513 1514 /* Removed Tk_Main, use macro instead */ 1515 #if defined(_WIN32) || defined(__CYGWIN__) 1516 #define Tk_Main(argc, argv, proc) Tk_MainEx(argc, argv, proc, \ 1517 (Tcl_FindExecutable(0), (Tcl_CreateInterp)())) 1518 #else 1519 #define Tk_Main(argc, argv, proc) Tk_MainEx(argc, argv, proc, \ 1520 (Tcl_FindExecutable(argv[0]), (Tcl_CreateInterp)())) 1521 #endif 1522 const char * Tk_InitStubs(Tcl_Interp *interp, const char *version, 1523 int exact); 1524 EXTERN const char * Tk_PkgInitStubsCheck(Tcl_Interp *interp, 1525 const char *version, int exact); 1526 1527 #ifndef USE_TK_STUBS 1528 #define Tk_InitStubs(interp, version, exact) \ 1529 Tk_PkgInitStubsCheck(interp, version, exact) 1530 #endif /* USE_TK_STUBS */ 1531 1532 #define Tk_InitImageArgs(interp, argc, argv) /**/ 1533 1534 /* 1535 *---------------------------------------------------------------------- 1536 * 1537 * Additional procedure types defined by Tk. 1538 * 1539 *---------------------------------------------------------------------- 1540 */ 1541 1542 typedef int (Tk_ErrorProc) (ClientData clientData, XErrorEvent *errEventPtr); 1543 typedef void (Tk_EventProc) (ClientData clientData, XEvent *eventPtr); 1544 typedef int (Tk_GenericProc) (ClientData clientData, XEvent *eventPtr); 1545 typedef int (Tk_ClientMessageProc) (Tk_Window tkwin, XEvent *eventPtr); 1546 typedef int (Tk_GetSelProc) (ClientData clientData, Tcl_Interp *interp, 1547 CONST86 char *portion); 1548 typedef void (Tk_LostSelProc) (ClientData clientData); 1549 typedef Tk_RestrictAction (Tk_RestrictProc) (ClientData clientData, 1550 XEvent *eventPtr); 1551 typedef int (Tk_SelectionProc) (ClientData clientData, int offset, 1552 char *buffer, int maxBytes); 1553 1554 /* 1555 *---------------------------------------------------------------------- 1556 * 1557 * Platform independent exported procedures and variables. 1558 * 1559 *---------------------------------------------------------------------- 1560 */ 1561 1562 #include "tkDecls.h" 1563 1564 #ifdef USE_OLD_IMAGE 1565 #undef Tk_CreateImageType 1566 #define Tk_CreateImageType Tk_CreateOldImageType 1567 #undef Tk_CreatePhotoImageFormat 1568 #define Tk_CreatePhotoImageFormat Tk_CreateOldPhotoImageFormat 1569 #endif /* USE_OLD_IMAGE */ 1570 1571 /* 1572 *---------------------------------------------------------------------- 1573 * 1574 * Allow users to say that they don't want to alter their source to add extra 1575 * arguments to Tk_PhotoPutBlock() et al; DO NOT DEFINE THIS WHEN BUILDING TK. 1576 * 1577 * This goes after the inclusion of the stubbed-decls so that the declarations 1578 * of what is actually there can be correct. 1579 */ 1580 1581 #ifdef USE_COMPOSITELESS_PHOTO_PUT_BLOCK 1582 # ifdef Tk_PhotoPutBlock 1583 # undef Tk_PhotoPutBlock 1584 # endif 1585 # define Tk_PhotoPutBlock Tk_PhotoPutBlock_NoComposite 1586 # ifdef Tk_PhotoPutZoomedBlock 1587 # undef Tk_PhotoPutZoomedBlock 1588 # endif 1589 # define Tk_PhotoPutZoomedBlock Tk_PhotoPutZoomedBlock_NoComposite 1590 # define USE_PANIC_ON_PHOTO_ALLOC_FAILURE 1591 #else /* !USE_COMPOSITELESS_PHOTO_PUT_BLOCK */ 1592 # ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE 1593 # ifdef Tk_PhotoPutBlock 1594 # undef Tk_PhotoPutBlock 1595 # endif 1596 # define Tk_PhotoPutBlock Tk_PhotoPutBlock_Panic 1597 # ifdef Tk_PhotoPutZoomedBlock 1598 # undef Tk_PhotoPutZoomedBlock 1599 # endif 1600 # define Tk_PhotoPutZoomedBlock Tk_PhotoPutZoomedBlock_Panic 1601 # endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */ 1602 #endif /* USE_COMPOSITELESS_PHOTO_PUT_BLOCK */ 1603 #ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE 1604 # ifdef Tk_PhotoExpand 1605 # undef Tk_PhotoExpand 1606 # endif 1607 # define Tk_PhotoExpand Tk_PhotoExpand_Panic 1608 # ifdef Tk_PhotoSetSize 1609 # undef Tk_PhotoSetSize 1610 # endif 1611 # define Tk_PhotoSetSize Tk_PhotoSetSize_Panic 1612 #endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */ 1613 1614 #undef TCL_STORAGE_CLASS 1615 #define TCL_STORAGE_CLASS DLLIMPORT 1616 1617 #endif /* RC_INVOKED */ 1618 1619 /* 1620 * end block for C++ 1621 */ 1622 1623 #ifdef __cplusplus 1624 } 1625 #endif 1626 1627 #endif /* _TK */ 1628 1629 /* 1630 * Local Variables: 1631 * mode: c 1632 * c-basic-offset: 4 1633 * fill-column: 78 1634 * End: 1635 */ 1636