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