1/* 2 * tkInt.h -- 3 * 4 * Declarations for things used internally by the Tk functions but not 5 * exported outside the module. 6 * 7 * Copyright (c) 1990-1994 The Regents of the University of California. 8 * Copyright (c) 1994-1997 Sun Microsystems, Inc. 9 * Copyright (c) 1998 by Scriptics Corporation. 10 * 11 * See the file "license.terms" for information on usage and redistribution of 12 * this file, and for a DISCLAIMER OF ALL WARRANTIES. 13 * 14 * RCS: $Id$ 15 */ 16 17#ifndef _TKINT 18#define _TKINT 19 20#ifndef _TK 21#include "tk.h" 22#endif 23#ifndef _TCL 24#include "tcl.h" 25#endif 26#ifndef _TKPORT 27#include "tkPort.h" 28#endif 29 30/* 31 * Ensure WORDS_BIGENDIAN is defined correcly: 32 * Needs to happen here in addition to configure to work with fat compiles on 33 * Darwin (where configure runs only once for multiple architectures). 34 */ 35 36#ifdef HAVE_SYS_TYPES_H 37# include <sys/types.h> 38#endif 39#ifdef HAVE_SYS_PARAM_H 40# include <sys/param.h> 41#endif 42#ifdef BYTE_ORDER 43# ifdef BIG_ENDIAN 44# if BYTE_ORDER == BIG_ENDIAN 45# undef WORDS_BIGENDIAN 46# define WORDS_BIGENDIAN 1 47# endif 48# endif 49# ifdef LITTLE_ENDIAN 50# if BYTE_ORDER == LITTLE_ENDIAN 51# undef WORDS_BIGENDIAN 52# endif 53# endif 54#endif 55 56/* 57 * Used to tag functions that are only to be visible within the module being 58 * built and not outside it (where this is supported by the linker). 59 */ 60 61#ifndef MODULE_SCOPE 62# ifdef __cplusplus 63# define MODULE_SCOPE extern "C" 64# else 65# define MODULE_SCOPE extern 66# endif 67#endif 68 69/* 70 * Macros used to cast between pointers and integers (e.g. when storing an int 71 * in ClientData), on 64-bit architectures they avoid gcc warning about "cast 72 * to/from pointer from/to integer of different size". 73 */ 74 75#if !defined(INT2PTR) && !defined(PTR2INT) 76# if defined(HAVE_INTPTR_T) || defined(intptr_t) 77# define INT2PTR(p) ((void*)(intptr_t)(p)) 78# define PTR2INT(p) ((int)(intptr_t)(p)) 79# else 80# define INT2PTR(p) ((void*)(p)) 81# define PTR2INT(p) ((int)(p)) 82# endif 83#endif 84#if !defined(UINT2PTR) && !defined(PTR2UINT) 85# if defined(HAVE_UINTPTR_T) || defined(uintptr_t) 86# define UINT2PTR(p) ((void*)(uintptr_t)(p)) 87# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p)) 88# else 89# define UINT2PTR(p) ((void*)(p)) 90# define PTR2UINT(p) ((unsigned int)(p)) 91# endif 92#endif 93 94/* 95 * Opaque type declarations: 96 */ 97 98typedef struct TkColormap TkColormap; 99typedef struct TkFontAttributes TkFontAttributes; 100typedef struct TkGrabEvent TkGrabEvent; 101typedef struct TkpCursor_ *TkpCursor; 102typedef struct TkRegion_ *TkRegion; 103typedef struct TkStressedCmap TkStressedCmap; 104typedef struct TkBindInfo_ *TkBindInfo; 105 106/* 107 * Function types. 108 */ 109 110typedef int (TkBindEvalProc)(ClientData clientData, Tcl_Interp *interp, 111 XEvent *eventPtr, Tk_Window tkwin, KeySym keySym); 112typedef void (TkBindFreeProc)(ClientData clientData); 113 114/* 115 * One of the following structures is maintained for each cursor in use in the 116 * system. This structure is used by tkCursor.c and the various system 117 * specific cursor files. 118 */ 119 120typedef struct TkCursor { 121 Tk_Cursor cursor; /* System specific identifier for cursor. */ 122 Display *display; /* Display containing cursor. Needed for 123 * disposal and retrieval of cursors. */ 124 int resourceRefCount; /* Number of active uses of this cursor (each 125 * active use corresponds to a call to 126 * Tk_AllocPreserveFromObj or Tk_Preserve). If 127 * this count is 0, then this structure is no 128 * longer valid and it isn't present in a hash 129 * table: it is being kept around only because 130 * there are objects referring to it. The 131 * structure is freed when resourceRefCount 132 * and objRefCount are both 0. */ 133 int objRefCount; /* Number of Tcl objects that reference this 134 * structure.. */ 135 Tcl_HashTable *otherTable; /* Second table (other than idTable) used to 136 * index this entry. */ 137 Tcl_HashEntry *hashPtr; /* Entry in otherTable for this structure 138 * (needed when deleting). */ 139 Tcl_HashEntry *idHashPtr; /* Entry in idTable for this structure (needed 140 * when deleting). */ 141 struct TkCursor *nextPtr; /* Points to the next TkCursor structure with 142 * the same name. Cursors with the same name 143 * but different displays are chained together 144 * off a single hash table entry. */ 145} TkCursor; 146 147/* 148 * The following structure is kept one-per-TkDisplay to maintain information 149 * about the caret (cursor location) on this display. This is used to dictate 150 * global focus location (Windows Accessibility guidelines) and to position 151 * the IME or XIM over-the-spot window. 152 */ 153 154typedef struct TkCaret { 155 struct TkWindow *winPtr; /* The window on which we requested caret 156 * placement. */ 157 int x; /* Relative x coord of the caret. */ 158 int y; /* Relative y coord of the caret. */ 159 int height; /* Specified height of the window. */ 160} TkCaret; 161 162/* 163 * One of the following structures is maintained for each display containing a 164 * window managed by Tk. In part, the structure is used to store thread- 165 * specific data, since each thread will have its own TkDisplay structure. 166 */ 167 168typedef struct TkDisplay { 169 Display *display; /* Xlib's info about display. */ 170 struct TkDisplay *nextPtr; /* Next in list of all displays. */ 171 char *name; /* Name of display (with any screen identifier 172 * removed). Malloc-ed. */ 173 Time lastEventTime; /* Time of last event received for this 174 * display. */ 175 176 /* 177 * Information used primarily by tk3d.c: 178 */ 179 180 int borderInit; /* 0 means borderTable needs initializing. */ 181 Tcl_HashTable borderTable; /* Maps from color name to TkBorder 182 * structure. */ 183 184 /* 185 * Information used by tkAtom.c only: 186 */ 187 188 int atomInit; /* 0 means stuff below hasn't been initialized 189 * yet. */ 190 Tcl_HashTable nameTable; /* Maps from names to Atom's. */ 191 Tcl_HashTable atomTable; /* Maps from Atom's back to names. */ 192 193 /* 194 * Information used primarily by tkBind.c: 195 */ 196 197 int bindInfoStale; /* Non-zero means the variables in this part 198 * of the structure are potentially incorrect 199 * and should be recomputed. */ 200 unsigned int modeModMask; /* Has one bit set to indicate the modifier 201 * corresponding to "mode shift". If no such 202 * modifier, than this is zero. */ 203 unsigned int metaModMask; /* Has one bit set to indicate the modifier 204 * corresponding to the "Meta" key. If no such 205 * modifier, then this is zero. */ 206 unsigned int altModMask; /* Has one bit set to indicate the modifier 207 * corresponding to the "Meta" key. If no such 208 * modifier, then this is zero. */ 209 enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage; 210 /* Indicates how to interpret lock 211 * modifier. */ 212 int numModKeyCodes; /* Number of entries in modKeyCodes array 213 * below. */ 214 KeyCode *modKeyCodes; /* Pointer to an array giving keycodes for all 215 * of the keys that have modifiers associated 216 * with them. Malloc'ed, but may be NULL. */ 217 218 /* 219 * Information used by tkBitmap.c only: 220 */ 221 222 int bitmapInit; /* 0 means tables above need initializing. */ 223 int bitmapAutoNumber; /* Used to number bitmaps. */ 224 Tcl_HashTable bitmapNameTable; 225 /* Maps from name of bitmap to the first 226 * TkBitmap record for that name. */ 227 Tcl_HashTable bitmapIdTable;/* Maps from bitmap id to the TkBitmap 228 * structure for the bitmap. */ 229 Tcl_HashTable bitmapDataTable; 230 /* Used by Tk_GetBitmapFromData to map from a 231 * collection of in-core data about a bitmap 232 * to a reference giving an automatically- 233 * generated name for the bitmap. */ 234 235 /* 236 * Information used by tkCanvas.c only: 237 */ 238 239 int numIdSearches; 240 int numSlowSearches; 241 242 /* 243 * Used by tkColor.c only: 244 */ 245 246 int colorInit; /* 0 means color module needs initializing. */ 247 TkStressedCmap *stressPtr; /* First in list of colormaps that have filled 248 * up, so we have to pick an approximate 249 * color. */ 250 Tcl_HashTable colorNameTable; 251 /* Maps from color name to TkColor structure 252 * for that color. */ 253 Tcl_HashTable colorValueTable; 254 /* Maps from integer RGB values to TkColor 255 * structures. */ 256 257 /* 258 * Used by tkCursor.c only: 259 */ 260 261 int cursorInit; /* 0 means cursor module need initializing. */ 262 Tcl_HashTable cursorNameTable; 263 /* Maps from a string name to a cursor to the 264 * TkCursor record for the cursor. */ 265 Tcl_HashTable cursorDataTable; 266 /* Maps from a collection of in-core data 267 * about a cursor to a TkCursor structure. */ 268 Tcl_HashTable cursorIdTable; 269 /* Maps from a cursor id to the TkCursor 270 * structure for the cursor. */ 271 char cursorString[20]; /* Used to store a cursor id string. */ 272 Font cursorFont; /* Font to use for standard cursors. None 273 * means font not loaded yet. */ 274 275 /* 276 * Information used by tkError.c only: 277 */ 278 279 struct TkErrorHandler *errorPtr; 280 /* First in list of error handlers for this 281 * display. NULL means no handlers exist at 282 * present. */ 283 int deleteCount; /* Counts # of handlers deleted since last 284 * time inactive handlers were garbage- 285 * collected. When this number gets big, 286 * handlers get cleaned up. */ 287 288 /* 289 * Used by tkEvent.c only: 290 */ 291 292 struct TkWindowEvent *delayedMotionPtr; 293 /* Points to a malloc-ed motion event whose 294 * processing has been delayed in the hopes 295 * that another motion event will come along 296 * right away and we can merge the two of them 297 * together. NULL means that there is no 298 * delayed motion event. */ 299 300 /* 301 * Information used by tkFocus.c only: 302 */ 303 304 int focusDebug; /* 1 means collect focus debugging 305 * statistics. */ 306 struct TkWindow *implicitWinPtr; 307 /* If the focus arrived at a toplevel window 308 * implicitly via an Enter event (rather than 309 * via a FocusIn event), this points to the 310 * toplevel window. Otherwise it is NULL. */ 311 struct TkWindow *focusPtr; /* Points to the window on this display that 312 * should be receiving keyboard events. When 313 * multiple applications on the display have 314 * the focus, this will refer to the innermost 315 * window in the innermost application. This 316 * information isn't used on Windows, but it's 317 * needed on the Mac, and also on X11 when XIM 318 * processing is being done. */ 319 320 /* 321 * Information used by tkGC.c only: 322 */ 323 324 Tcl_HashTable gcValueTable; /* Maps from a GC's values to a TkGC structure 325 * describing a GC with those values. */ 326 Tcl_HashTable gcIdTable; /* Maps from a GC to a TkGC. */ 327 int gcInit; /* 0 means the tables below need 328 * initializing. */ 329 330 /* 331 * Information used by tkGeometry.c only: 332 */ 333 334 Tcl_HashTable maintainHashTable; 335 /* Hash table that maps from a master's 336 * Tk_Window token to a list of slaves managed 337 * by that master. */ 338 int geomInit; 339 340 /* 341 * Information used by tkGet.c only: 342 */ 343 344 Tcl_HashTable uidTable; /* Stores all Tk_Uid used in a thread. */ 345 int uidInit; /* 0 means uidTable needs initializing. */ 346 347 /* 348 * Information used by tkGrab.c only: 349 */ 350 351 struct TkWindow *grabWinPtr;/* Window in which the pointer is currently 352 * grabbed, or NULL if none. */ 353 struct TkWindow *eventualGrabWinPtr; 354 /* Value that grabWinPtr will have once the 355 * grab event queue (below) has been 356 * completely emptied. */ 357 struct TkWindow *buttonWinPtr; 358 /* Window in which first mouse button was 359 * pressed while grab was in effect, or NULL 360 * if no such press in effect. */ 361 struct TkWindow *serverWinPtr; 362 /* If no application contains the pointer then 363 * this is NULL. Otherwise it contains the 364 * last window for which we've gotten an Enter 365 * or Leave event from the server (i.e. the 366 * last window known to have contained the 367 * pointer). Doesn't reflect events that were 368 * synthesized in tkGrab.c. */ 369 TkGrabEvent *firstGrabEventPtr; 370 /* First in list of enter/leave events 371 * synthesized by grab code. These events must 372 * be processed in order before any other 373 * events are processed. NULL means no such 374 * events. */ 375 TkGrabEvent *lastGrabEventPtr; 376 /* Last in list of synthesized events, or NULL 377 * if list is empty. */ 378 int grabFlags; /* Miscellaneous flag values. See definitions 379 * in tkGrab.c. */ 380 381 /* 382 * Information used by tkGrid.c only: 383 */ 384 385 int gridInit; /* 0 means table below needs initializing. */ 386 Tcl_HashTable gridHashTable;/* Maps from Tk_Window tokens to corresponding 387 * Grid structures. */ 388 389 /* 390 * Information used by tkImage.c only: 391 */ 392 393 int imageId; /* Value used to number image ids. */ 394 395 /* 396 * Information used by tkMacWinMenu.c only: 397 */ 398 399 int postCommandGeneration; 400 401 /* 402 * Information used by tkOption.c only. 403 */ 404 405 /* 406 * Information used by tkPack.c only. 407 */ 408 409 int packInit; /* 0 means table below needs initializing. */ 410 Tcl_HashTable packerHashTable; 411 /* Maps from Tk_Window tokens to corresponding 412 * Packer structures. */ 413 414 /* 415 * Information used by tkPlace.c only. 416 */ 417 418 int placeInit; /* 0 means tables below need initializing. */ 419 Tcl_HashTable masterTable; /* Maps from Tk_Window toke to the Master 420 * structure for the window, if it exists. */ 421 Tcl_HashTable slaveTable; /* Maps from Tk_Window toke to the Slave 422 * structure for the window, if it exists. */ 423 424 /* 425 * Information used by tkSelect.c and tkClipboard.c only: 426 */ 427 428 struct TkSelectionInfo *selectionInfoPtr; 429 /* First in list of selection information 430 * records. Each entry contains information 431 * about the current owner of a particular 432 * selection on this display. */ 433 Atom multipleAtom; /* Atom for MULTIPLE. None means selection 434 * stuff isn't initialized. */ 435 Atom incrAtom; /* Atom for INCR. */ 436 Atom targetsAtom; /* Atom for TARGETS. */ 437 Atom timestampAtom; /* Atom for TIMESTAMP. */ 438 Atom textAtom; /* Atom for TEXT. */ 439 Atom compoundTextAtom; /* Atom for COMPOUND_TEXT. */ 440 Atom applicationAtom; /* Atom for TK_APPLICATION. */ 441 Atom windowAtom; /* Atom for TK_WINDOW. */ 442 Atom clipboardAtom; /* Atom for CLIPBOARD. */ 443 Atom utf8Atom; /* Atom for UTF8_STRING. */ 444 445 Tk_Window clipWindow; /* Window used for clipboard ownership and to 446 * retrieve selections between processes. NULL 447 * means clipboard info hasn't been 448 * initialized. */ 449 int clipboardActive; /* 1 means we currently own the clipboard 450 * selection, 0 means we don't. */ 451 struct TkMainInfo *clipboardAppPtr; 452 /* Last application that owned clipboard. */ 453 struct TkClipboardTarget *clipTargetPtr; 454 /* First in list of clipboard type information 455 * records. Each entry contains information 456 * about the buffers for a given selection 457 * target. */ 458 459 /* 460 * Information used by tkSend.c only: 461 */ 462 463 Tk_Window commTkwin; /* Window used for communication between 464 * interpreters during "send" commands. NULL 465 * means send info hasn't been initialized 466 * yet. */ 467 Atom commProperty; /* X's name for comm property. */ 468 Atom registryProperty; /* X's name for property containing registry 469 * of interpreter names. */ 470 Atom appNameProperty; /* X's name for property used to hold the 471 * application name on each comm window. */ 472 473 /* 474 * Information used by tkXId.c only: 475 */ 476 477 struct TkIdStack *idStackPtr; 478 /* First in list of chunks of free resource 479 * identifiers, or NULL if there are no free 480 * resources. */ 481 XID (*defaultAllocProc) (Display *display); 482 /* Default resource allocator for display. */ 483 struct TkIdStack *windowStackPtr; 484 /* First in list of chunks of window ids that 485 * can't be reused right now. */ 486 Tcl_TimerToken idCleanupScheduled; 487 /* If set, it means a call to WindowIdCleanup 488 * has already been scheduled, 0 means it 489 * hasn't. */ 490 491 /* 492 * Information used by tkUnixWm.c and tkWinWm.c only: 493 */ 494 495 struct TkWmInfo *firstWmPtr;/* Points to first top-level window. */ 496 struct TkWmInfo *foregroundWmPtr; 497 /* Points to the foreground window. */ 498 499 /* 500 * Information maintained by tkWindow.c for use later on by tkXId.c: 501 */ 502 503 int destroyCount; /* Number of Tk_DestroyWindow operations in 504 * progress. */ 505 unsigned long lastDestroyRequest; 506 /* Id of most recent XDestroyWindow request; 507 * can re-use ids in windowStackPtr when 508 * server has seen this request and event 509 * queue is empty. */ 510 511 /* 512 * Information used by tkVisual.c only: 513 */ 514 515 TkColormap *cmapPtr; /* First in list of all non-default colormaps 516 * allocated for this display. */ 517 518 /* 519 * Miscellaneous information: 520 */ 521 522#ifdef TK_USE_INPUT_METHODS 523 XIM inputMethod; /* Input method for this display. */ 524 XIMStyle inputStyle; /* Input style selected for this display. */ 525 XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */ 526#endif /* TK_USE_INPUT_METHODS */ 527 Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ 528 529 int refCount; /* Reference count of how many Tk applications 530 * are using this display. Used to clean up 531 * the display when we no longer have any Tk 532 * applications using it. */ 533 534 /* 535 * The following field were all added for Tk8.3 536 */ 537 538 int mouseButtonState; /* Current mouse button state for this 539 * display. */ 540 Window mouseButtonWindow; /* Window the button state was set in, added 541 * in Tk 8.4. */ 542 Window warpWindow; 543 int warpX; 544 int warpY; 545 546 /* 547 * The following field(s) were all added for Tk8.4 548 */ 549 550 unsigned int flags; /* Various flag values: these are all defined 551 * in below. */ 552 TkCaret caret; /* Information about the caret for this 553 * display. This is not a pointer. */ 554 555 int iconDataSize; /* Size of default iconphoto image data. */ 556 unsigned char *iconDataPtr; /* Default iconphoto image data, if set. */ 557} TkDisplay; 558 559/* 560 * Flag values for TkDisplay flags. 561 * TK_DISPLAY_COLLAPSE_MOTION_EVENTS: (default on) 562 * Indicates that we should collapse motion events on this display 563 * TK_DISPLAY_USE_IM: (default on, set via tk.tcl) 564 * Whether to use input methods for this display 565 * TK_DISPLAY_WM_TRACING: (default off) 566 * Whether we should do wm tracing on this display. 567 * TK_DISPLAY_IN_WARP: (default off) 568 * Indicates that we are in a pointer warp 569 */ 570 571#define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) 572#define TK_DISPLAY_USE_IM (1 << 1) 573#define TK_DISPLAY_WM_TRACING (1 << 3) 574#define TK_DISPLAY_IN_WARP (1 << 4) 575 576/* 577 * One of the following structures exists for each error handler created by a 578 * call to Tk_CreateErrorHandler. The structure is managed by tkError.c. 579 */ 580 581typedef struct TkErrorHandler { 582 TkDisplay *dispPtr; /* Display to which handler applies. */ 583 unsigned long firstRequest; /* Only errors with serial numbers >= to this 584 * are considered. */ 585 unsigned long lastRequest; /* Only errors with serial numbers <= to this 586 * are considered. This field is filled in 587 * when XUnhandle is called. -1 means 588 * XUnhandle hasn't been called yet. */ 589 int error; /* Consider only errors with this error_code 590 * (-1 means consider all errors). */ 591 int request; /* Consider only errors with this major 592 * request code (-1 means consider all major 593 * codes). */ 594 int minorCode; /* Consider only errors with this minor 595 * request code (-1 means consider all minor 596 * codes). */ 597 Tk_ErrorProc *errorProc; /* Function to invoke when a matching error 598 * occurs. NULL means just ignore errors. */ 599 ClientData clientData; /* Arbitrary value to pass to errorProc. */ 600 struct TkErrorHandler *nextPtr; 601 /* Pointer to next older handler for this 602 * display, or NULL for end of list. */ 603} TkErrorHandler; 604 605/* 606 * One of the following structures exists for each event handler created by 607 * calling Tk_CreateEventHandler. This information is used by tkEvent.c only. 608 */ 609 610typedef struct TkEventHandler { 611 unsigned long mask; /* Events for which to invoke proc. */ 612 Tk_EventProc *proc; /* Function to invoke when an event in mask 613 * occurs. */ 614 ClientData clientData; /* Argument to pass to proc. */ 615 struct TkEventHandler *nextPtr; 616 /* Next in list of handlers associated with 617 * window (NULL means end of list). */ 618} TkEventHandler; 619 620/* 621 * Tk keeps one of the following data structures for each main window (created 622 * by a call to TkCreateMainWindow). It stores information that is shared by 623 * all of the windows associated with a particular main window. 624 */ 625 626typedef struct TkMainInfo { 627 int refCount; /* Number of windows whose "mainPtr" fields 628 * point here. When this becomes zero, can 629 * free up the structure (the reference count 630 * is zero because windows can get deleted in 631 * almost any order; the main window isn't 632 * necessarily the last one deleted). */ 633 struct TkWindow *winPtr; /* Pointer to main window. */ 634 Tcl_Interp *interp; /* Interpreter associated with application. */ 635 Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow 636 * structs for all windows related to this 637 * main window. Managed by tkWindow.c. */ 638 long deletionEpoch; /* Incremented by window deletions. */ 639 Tk_BindingTable bindingTable; 640 /* Used in conjunction with "bind" command to 641 * bind events to Tcl commands. */ 642 TkBindInfo bindInfo; /* Information used by tkBind.c on a per 643 * application basis. */ 644 struct TkFontInfo *fontInfoPtr; 645 /* Information used by tkFont.c on a per 646 * application basis. */ 647 648 /* 649 * Information used only by tkFocus.c and tk*Embed.c: 650 */ 651 652 struct TkToplevelFocusInfo *tlFocusPtr; 653 /* First in list of records containing focus 654 * information for each top-level in the 655 * application. Used only by tkFocus.c. */ 656 struct TkDisplayFocusInfo *displayFocusPtr; 657 /* First in list of records containing focus 658 * information for each display that this 659 * application has ever used. Used only by 660 * tkFocus.c. */ 661 662 struct ElArray *optionRootPtr; 663 /* Top level of option hierarchy for this main 664 * window. NULL means uninitialized. Managed 665 * by tkOption.c. */ 666 Tcl_HashTable imageTable; /* Maps from image names to Tk_ImageMaster 667 * structures. Managed by tkImage.c. */ 668 int strictMotif; /* This is linked to the tk_strictMotif global 669 * variable. */ 670 int alwaysShowSelection; /* This is linked to the 671 * ::tk::AlwaysShowSelection variable. */ 672 struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by 673 * this process. */ 674} TkMainInfo; 675 676/* 677 * Tk keeps the following data structure for each of it's builtin bitmaps. 678 * This structure is only used by tkBitmap.c and other platform specific 679 * bitmap files. 680 */ 681 682typedef struct { 683 const char *source; /* Bits for bitmap. */ 684 int width, height; /* Dimensions of bitmap. */ 685 int native; /* 0 means generic (X style) bitmap, 1 means 686 * native style bitmap. */ 687} TkPredefBitmap; 688 689/* 690 * Tk keeps one of the following structures for each window. Some of the 691 * information (like size and location) is a shadow of information managed by 692 * the X server, and some is special information used here, such as event and 693 * geometry management information. This information is (mostly) managed by 694 * tkWindow.c. WARNING: the declaration below must be kept consistent with the 695 * Tk_FakeWin structure in tk.h. If you change one, be sure to change the 696 * other! 697 */ 698 699typedef struct TkWindow { 700 /* 701 * Structural information: 702 */ 703 704 Display *display; /* Display containing window. */ 705 TkDisplay *dispPtr; /* Tk's information about display for 706 * window. */ 707 int screenNum; /* Index of screen for window, among all those 708 * for dispPtr. */ 709 Visual *visual; /* Visual to use for window. If not default, 710 * MUST be set before X window is created. */ 711 int depth; /* Number of bits/pixel. */ 712 Window window; /* X's id for window. NULL means window hasn't 713 * actually been created yet, or it's been 714 * deleted. */ 715 struct TkWindow *childList; /* First in list of child windows, or NULL if 716 * no children. List is in stacking order, 717 * lowest window first.*/ 718 struct TkWindow *lastChildPtr; 719 /* Last in list of child windows (highest in 720 * stacking order), or NULL if no children. */ 721 struct TkWindow *parentPtr; /* Pointer to parent window (logical parent, 722 * not necessarily X parent). NULL means 723 * either this is the main window, or the 724 * window's parent has already been deleted. */ 725 struct TkWindow *nextPtr; /* Next higher sibling (in stacking order) in 726 * list of children with same parent. NULL 727 * means end of list. */ 728 TkMainInfo *mainPtr; /* Information shared by all windows 729 * associated with a particular main window. 730 * NULL means this window is a rogue that is 731 * not associated with any application (at 732 * present, this only happens for the dummy 733 * windows used for "send" communication). */ 734 735 /* 736 * Name and type information for the window: 737 */ 738 739 char *pathName; /* Path name of window (concatenation of all 740 * names between this window and its top-level 741 * ancestor). This is a pointer into an entry 742 * in mainPtr->nameTable. NULL means that the 743 * window hasn't been completely created 744 * yet. */ 745 Tk_Uid nameUid; /* Name of the window within its parent 746 * (unique within the parent). */ 747 Tk_Uid classUid; /* Class of the window. NULL means window 748 * hasn't been given a class yet. */ 749 750 /* 751 * Geometry and other attributes of window. This information may not be 752 * updated on the server immediately; stuff that hasn't been reflected in 753 * the server yet is called "dirty". At present, information can be dirty 754 * only if the window hasn't yet been created. 755 */ 756 757 XWindowChanges changes; /* Geometry and other info about window. */ 758 unsigned int dirtyChanges; /* Bits indicate fields of "changes" that are 759 * dirty. */ 760 XSetWindowAttributes atts; /* Current attributes of window. */ 761 unsigned long dirtyAtts; /* Bits indicate fields of "atts" that are 762 * dirty. */ 763 764 unsigned int flags; /* Various flag values: these are all defined 765 * in tk.h (confusing, but they're needed 766 * there for some query macros). */ 767 768 /* 769 * Information kept by the event manager (tkEvent.c): 770 */ 771 772 TkEventHandler *handlerList;/* First in list of event handlers declared 773 * for this window, or NULL if none. */ 774#ifdef TK_USE_INPUT_METHODS 775 XIC inputContext; /* XIM input context. */ 776#endif /* TK_USE_INPUT_METHODS */ 777 778 /* 779 * Information used for event bindings (see "bind" and "bindtags" commands 780 * in tkCmds.c): 781 */ 782 783 ClientData *tagPtr; /* Points to array of tags used for bindings 784 * on this window. Each tag is a Tk_Uid. 785 * Malloc'ed. NULL means no tags. */ 786 int numTags; /* Number of tags at *tagPtr. */ 787 788 /* 789 * Information used by tkOption.c to manage options for the window. 790 */ 791 792 int optionLevel; /* -1 means no option information is currently 793 * cached for this window. Otherwise this 794 * gives the level in the option stack at 795 * which info is cached. */ 796 /* 797 * Information used by tkSelect.c to manage the selection. 798 */ 799 800 struct TkSelHandler *selHandlerList; 801 /* First in list of handlers for returning the 802 * selection in various forms. */ 803 804 /* 805 * Information used by tkGeometry.c for geometry management. 806 */ 807 808 const Tk_GeomMgr *geomMgrPtr; /* Information about geometry manager for this 809 * window. */ 810 ClientData geomData; /* Argument for geometry manager functions. */ 811 int reqWidth, reqHeight; /* Arguments from last call to 812 * Tk_GeometryRequest, or 0's if 813 * Tk_GeometryRequest hasn't been called. */ 814 int internalBorderLeft; /* Width of internal border of window (0 means 815 * no internal border). Geometry managers 816 * should not normally place children on top 817 * of the border. Fields for the other three 818 * sides are found below. */ 819 820 /* 821 * Information maintained by tkWm.c for window manager communication. 822 */ 823 824 struct TkWmInfo *wmInfoPtr; /* For top-level windows (and also for special 825 * Unix menubar and wrapper windows), points 826 * to structure with wm-related info (see 827 * tkWm.c). For other windows, this is NULL. */ 828 829 /* 830 * Information used by widget classes. 831 */ 832 833 Tk_ClassProcs *classProcsPtr; 834 ClientData instanceData; 835 836 /* 837 * Platform specific information private to each port. 838 */ 839 840 struct TkWindowPrivate *privatePtr; 841 842 /* 843 * More information used by tkGeometry.c for geometry management. 844 */ 845 846 /* The remaining fields of internal border. */ 847 int internalBorderRight; 848 int internalBorderTop; 849 int internalBorderBottom; 850 851 int minReqWidth; /* Minimum requested width. */ 852 int minReqHeight; /* Minimum requested height. */ 853} TkWindow; 854 855/* 856 * Real definition of some events. Note that these events come from outside 857 * but have internally generated pieces added to them. 858 */ 859 860typedef struct { 861 XKeyEvent keyEvent; /* The real event from X11. */ 862 char *charValuePtr; /* A pointer to a string that holds the key's 863 * %A substitution text (before backslash 864 * adding), or NULL if that has not been 865 * computed yet. If non-NULL, this string was 866 * allocated with ckalloc(). */ 867 int charValueLen; /* Length of string in charValuePtr when that 868 * is non-NULL. */ 869} TkKeyEvent; 870 871/* 872 * The following structure is used as a two way map between integers and 873 * strings, usually to map between an internal C representation and the 874 * strings used in Tcl. 875 */ 876 877typedef struct TkStateMap { 878 int numKey; /* Integer representation of a value. */ 879 const char *strKey; /* String representation of a value. */ 880} TkStateMap; 881 882/* 883 * This structure is used by the Mac and Window porting layers as the internal 884 * representation of a clip_mask in a GC. 885 */ 886 887typedef struct TkpClipMask { 888 int type; /* TKP_CLIP_PIXMAP or TKP_CLIP_REGION. */ 889 union { 890 Pixmap pixmap; 891 TkRegion region; 892 } value; 893} TkpClipMask; 894 895#define TKP_CLIP_PIXMAP 0 896#define TKP_CLIP_REGION 1 897 898/* 899 * Pointer to first entry in list of all displays currently known. 900 */ 901 902extern TkDisplay *tkDisplayList; 903 904/* 905 * Return values from TkGrabState: 906 */ 907 908#define TK_GRAB_NONE 0 909#define TK_GRAB_IN_TREE 1 910#define TK_GRAB_ANCESTOR 2 911#define TK_GRAB_EXCLUDED 3 912 913/* 914 * Additional flag for TkpMeasureCharsInContext. Coordinate with other flags 915 * for this routine, but don't make public until TkpMeasureCharsInContext is 916 * made public, too. 917 */ 918 919#define TK_ISOLATE_END 32 920 921/* 922 * The macro below is used to modify a "char" value (e.g. by casting it to an 923 * unsigned character) so that it can be used safely with macros such as 924 * isspace(). 925 */ 926 927#define UCHAR(c) ((unsigned char) (c)) 928 929/* 930 * The following symbol is used in the mode field of FocusIn events generated 931 * by an embedded application to request the input focus from its container. 932 */ 933 934#define EMBEDDED_APP_WANTS_FOCUS (NotifyNormal + 20) 935 936/* 937 * The following special modifier mask bits are defined, to indicate logical 938 * modifiers such as Meta and Alt that may float among the actual modifier 939 * bits. 940 */ 941 942#define META_MASK (AnyModifier<<1) 943#define ALT_MASK (AnyModifier<<2) 944#define EXTENDED_MASK (AnyModifier<<3) 945 946/* 947 * Object types not declared in tkObj.c need to be mentioned here so they can 948 * be properly registered with Tcl: 949 */ 950 951MODULE_SCOPE Tcl_ObjType tkBorderObjType; 952MODULE_SCOPE Tcl_ObjType tkBitmapObjType; 953MODULE_SCOPE Tcl_ObjType tkColorObjType; 954MODULE_SCOPE Tcl_ObjType tkCursorObjType; 955MODULE_SCOPE Tcl_ObjType tkFontObjType; 956MODULE_SCOPE Tcl_ObjType tkOptionObjType; 957MODULE_SCOPE Tcl_ObjType tkStateKeyObjType; 958MODULE_SCOPE Tcl_ObjType tkTextIndexType; 959 960/* 961 * Miscellaneous variables shared among Tk modules but not exported to the 962 * outside world: 963 */ 964 965MODULE_SCOPE Tk_SmoothMethod tkBezierSmoothMethod; 966MODULE_SCOPE Tk_ImageType tkBitmapImageType; 967MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtGIF; 968MODULE_SCOPE void (*tkHandleEventProc) (XEvent* eventPtr); 969MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPPM; 970MODULE_SCOPE TkMainInfo *tkMainWindowList; 971MODULE_SCOPE Tk_ImageType tkPhotoImageType; 972MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable; 973 974#include "tkIntDecls.h" 975 976#ifdef BUILD_tk 977#undef TCL_STORAGE_CLASS 978#define TCL_STORAGE_CLASS DLLEXPORT 979#endif 980 981/* 982 * Themed widget set init function: 983 */ 984 985MODULE_SCOPE int Ttk_Init(Tcl_Interp *interp); 986 987/* 988 * Internal functions shared among Tk modules but not exported to the outside 989 * world: 990 */ 991 992MODULE_SCOPE int Tk_BellObjCmd(ClientData clientData, 993 Tcl_Interp *interp, int objc, 994 Tcl_Obj *const objv[]); 995MODULE_SCOPE int Tk_BindObjCmd(ClientData clientData, 996 Tcl_Interp *interp, int objc, 997 Tcl_Obj *const objv[]); 998MODULE_SCOPE int Tk_BindtagsObjCmd(ClientData clientData, 999 Tcl_Interp *interp, int objc, 1000 Tcl_Obj *const objv[]); 1001MODULE_SCOPE int Tk_ButtonObjCmd(ClientData clientData, 1002 Tcl_Interp *interp, int objc, 1003 Tcl_Obj *const objv[]); 1004MODULE_SCOPE int Tk_CanvasObjCmd(ClientData clientData, 1005 Tcl_Interp *interp, int argc, 1006 Tcl_Obj *const objv[]); 1007MODULE_SCOPE int Tk_CheckbuttonObjCmd(ClientData clientData, 1008 Tcl_Interp *interp, int objc, 1009 Tcl_Obj *const objv[]); 1010MODULE_SCOPE int Tk_ClipboardObjCmd(ClientData clientData, 1011 Tcl_Interp *interp, int objc, 1012 Tcl_Obj *const objv[]); 1013MODULE_SCOPE int Tk_ChooseColorObjCmd(ClientData clientData, 1014 Tcl_Interp *interp, int objc, 1015 Tcl_Obj *const objv[]); 1016MODULE_SCOPE int Tk_ChooseDirectoryObjCmd(ClientData clientData, 1017 Tcl_Interp *interp, int objc, 1018 Tcl_Obj *const objv[]); 1019MODULE_SCOPE int Tk_ChooseFontObjCmd(ClientData clientData, 1020 Tcl_Interp *interp, int objc, 1021 Tcl_Obj *const objv[]); 1022MODULE_SCOPE int Tk_DestroyObjCmd(ClientData clientData, 1023 Tcl_Interp *interp, int objc, 1024 Tcl_Obj *const objv[]); 1025MODULE_SCOPE int Tk_EntryObjCmd(ClientData clientData, 1026 Tcl_Interp *interp, int objc, 1027 Tcl_Obj *const objv[]); 1028MODULE_SCOPE int Tk_EventObjCmd(ClientData clientData, 1029 Tcl_Interp *interp, int objc, 1030 Tcl_Obj *const objv[]); 1031MODULE_SCOPE int Tk_FrameObjCmd(ClientData clientData, 1032 Tcl_Interp *interp, int objc, 1033 Tcl_Obj *const objv[]); 1034MODULE_SCOPE int Tk_FocusObjCmd(ClientData clientData, 1035 Tcl_Interp *interp, int objc, 1036 Tcl_Obj *const objv[]); 1037MODULE_SCOPE int Tk_FontObjCmd(ClientData clientData, 1038 Tcl_Interp *interp, int objc, 1039 Tcl_Obj *const objv[]); 1040MODULE_SCOPE int Tk_GetOpenFileObjCmd(ClientData clientData, 1041 Tcl_Interp *interp, int objc, 1042 Tcl_Obj *const objv[]); 1043MODULE_SCOPE int Tk_GetSaveFileObjCmd(ClientData clientData, 1044 Tcl_Interp *interp, int objc, 1045 Tcl_Obj *const objv[]); 1046MODULE_SCOPE int Tk_GrabObjCmd(ClientData clientData, 1047 Tcl_Interp *interp, int objc, 1048 Tcl_Obj *const objv[]); 1049MODULE_SCOPE int Tk_GridObjCmd(ClientData clientData, 1050 Tcl_Interp *interp, int objc, 1051 Tcl_Obj *const objv[]); 1052MODULE_SCOPE int Tk_ImageObjCmd(ClientData clientData, 1053 Tcl_Interp *interp, int objc, 1054 Tcl_Obj *const objv[]); 1055MODULE_SCOPE int Tk_LabelObjCmd(ClientData clientData, 1056 Tcl_Interp *interp, int objc, 1057 Tcl_Obj *const objv[]); 1058MODULE_SCOPE int Tk_LabelframeObjCmd(ClientData clientData, 1059 Tcl_Interp *interp, int objc, 1060 Tcl_Obj *const objv[]); 1061MODULE_SCOPE int Tk_ListboxObjCmd(ClientData clientData, 1062 Tcl_Interp *interp, int objc, 1063 Tcl_Obj *const objv[]); 1064MODULE_SCOPE int Tk_LowerObjCmd(ClientData clientData, 1065 Tcl_Interp *interp, int objc, 1066 Tcl_Obj *const objv[]); 1067MODULE_SCOPE int Tk_MenubuttonObjCmd(ClientData clientData, 1068 Tcl_Interp *interp, int objc, 1069 Tcl_Obj *const objv[]); 1070MODULE_SCOPE int Tk_MessageBoxObjCmd(ClientData clientData, 1071 Tcl_Interp *interp, int objc, 1072 Tcl_Obj *const objv[]); 1073MODULE_SCOPE int Tk_MessageObjCmd(ClientData clientData, 1074 Tcl_Interp *interp, int objc, 1075 Tcl_Obj *const objv[]); 1076MODULE_SCOPE int Tk_PanedWindowObjCmd(ClientData clientData, 1077 Tcl_Interp *interp, int objc, 1078 Tcl_Obj *const objv[]); 1079MODULE_SCOPE int Tk_OptionObjCmd(ClientData clientData, 1080 Tcl_Interp *interp, int objc, 1081 Tcl_Obj *const objv[]); 1082MODULE_SCOPE int Tk_PackObjCmd(ClientData clientData, 1083 Tcl_Interp *interp, int objc, 1084 Tcl_Obj *const objv[]); 1085MODULE_SCOPE int Tk_PlaceObjCmd(ClientData clientData, 1086 Tcl_Interp *interp, int objc, 1087 Tcl_Obj *const objv[]); 1088MODULE_SCOPE int Tk_RadiobuttonObjCmd(ClientData clientData, 1089 Tcl_Interp *interp, int objc, 1090 Tcl_Obj *const objv[]); 1091MODULE_SCOPE int Tk_RaiseObjCmd(ClientData clientData, 1092 Tcl_Interp *interp, int objc, 1093 Tcl_Obj *const objv[]); 1094MODULE_SCOPE int Tk_ScaleObjCmd(ClientData clientData, 1095 Tcl_Interp *interp, int objc, 1096 Tcl_Obj *const objv[]); 1097MODULE_SCOPE int Tk_ScrollbarCmd(ClientData clientData, 1098 Tcl_Interp *interp, int argc, const char **argv); 1099MODULE_SCOPE int Tk_SelectionObjCmd(ClientData clientData, 1100 Tcl_Interp *interp, int objc, 1101 Tcl_Obj *const objv[]); 1102MODULE_SCOPE int Tk_SendCmd(ClientData clientData, 1103 Tcl_Interp *interp, int argc, const char **argv); 1104MODULE_SCOPE int Tk_SendObjCmd(ClientData clientData, 1105 Tcl_Interp *interp, int objc, 1106 Tcl_Obj *const objv[]); 1107MODULE_SCOPE int Tk_SpinboxObjCmd(ClientData clientData, 1108 Tcl_Interp *interp, int objc, 1109 Tcl_Obj *const objv[]); 1110MODULE_SCOPE int Tk_TextObjCmd(ClientData clientData, 1111 Tcl_Interp *interp, int objc, 1112 Tcl_Obj *const objv[]); 1113MODULE_SCOPE int Tk_TkObjCmd(ClientData clientData, 1114 Tcl_Interp *interp, int objc, 1115 Tcl_Obj *const objv[]); 1116MODULE_SCOPE int Tk_TkwaitObjCmd(ClientData clientData, 1117 Tcl_Interp *interp, int objc, 1118 Tcl_Obj *const objv[]); 1119MODULE_SCOPE int Tk_ToplevelObjCmd(ClientData clientData, 1120 Tcl_Interp *interp, int objc, 1121 Tcl_Obj *const objv[]); 1122MODULE_SCOPE int Tk_UpdateObjCmd(ClientData clientData, 1123 Tcl_Interp *interp, int objc, 1124 Tcl_Obj *const objv[]); 1125MODULE_SCOPE int Tk_WinfoObjCmd(ClientData clientData, 1126 Tcl_Interp *interp, int objc, 1127 Tcl_Obj *const objv[]); 1128MODULE_SCOPE int Tk_WmObjCmd(ClientData clientData, Tcl_Interp *interp, 1129 int objc, Tcl_Obj *const objv[]); 1130 1131MODULE_SCOPE int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp, 1132 Tk_Window tkwin, Tcl_Obj *objPtr, 1133 double *doublePtr); 1134 1135MODULE_SCOPE void TkEventInit(void); 1136MODULE_SCOPE void TkRegisterObjTypes(void); 1137MODULE_SCOPE int TkCreateMenuCmd(Tcl_Interp *interp); 1138MODULE_SCOPE int TkDeadAppCmd(ClientData clientData, 1139 Tcl_Interp *interp, int argc, const char **argv); 1140MODULE_SCOPE int TkCanvasGetCoordObj(Tcl_Interp *interp, 1141 Tk_Canvas canvas, Tcl_Obj *obj, 1142 double *doublePtr); 1143MODULE_SCOPE int TkGetDoublePixels(Tcl_Interp *interp, Tk_Window tkwin, 1144 const char *string, double *doublePtr); 1145MODULE_SCOPE int TkPostscriptImage(Tcl_Interp *interp, Tk_Window tkwin, 1146 Tk_PostscriptInfo psInfo, XImage *ximage, 1147 int x, int y, int width, int height); 1148MODULE_SCOPE void TkMapTopFrame(Tk_Window tkwin); 1149MODULE_SCOPE XEvent * TkpGetBindingXEvent(Tcl_Interp *interp); 1150MODULE_SCOPE void TkCreateExitHandler(Tcl_ExitProc *proc, 1151 ClientData clientData); 1152MODULE_SCOPE void TkDeleteExitHandler(Tcl_ExitProc *proc, 1153 ClientData clientData); 1154MODULE_SCOPE Tcl_ExitProc TkFinalize; 1155MODULE_SCOPE Tcl_ExitProc TkFinalizeThread; 1156MODULE_SCOPE void TkpBuildRegionFromAlphaData(TkRegion region, 1157 unsigned x, unsigned y, unsigned width, 1158 unsigned height, unsigned char *dataPtr, 1159 unsigned pixelStride, unsigned lineStride); 1160MODULE_SCOPE void TkPrintPadAmount(Tcl_Interp *interp, 1161 char *buffer, int pad1, int pad2); 1162MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp, 1163 Tk_Window tkwin, Tcl_Obj *objPtr, 1164 int *pad1Ptr, int *pad2Ptr); 1165MODULE_SCOPE void TkFocusSplit(TkWindow *winPtr); 1166MODULE_SCOPE void TkFocusJoin(TkWindow *winPtr); 1167MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin); 1168MODULE_SCOPE void TkpDrawCharsInContext(Display * display, 1169 Drawable drawable, GC gc, Tk_Font tkfont, 1170 const char *source, int numBytes, int rangeStart, 1171 int rangeLength, int x, int y); 1172MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont, 1173 const char *source, int numBytes, int rangeStart, 1174 int rangeLength, int maxLength, int flags, 1175 int *lengthPtr); 1176MODULE_SCOPE void TkUnderlineCharsInContext(Display *display, 1177 Drawable drawable, GC gc, Tk_Font tkfont, 1178 const char *string, int numBytes, int x, int y, 1179 int firstByte, int lastByte); 1180MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont, 1181 Tcl_UniChar c, struct TkFontAttributes *faPtr); 1182MODULE_SCOPE int TkBackgroundEvalObjv(Tcl_Interp *interp, 1183 int objc, Tcl_Obj *const *objv, int flags); 1184 1185/* 1186 * Unsupported commands. 1187 */ 1188 1189MODULE_SCOPE int TkUnsupported1ObjCmd(ClientData clientData, 1190 Tcl_Interp *interp, int objc, 1191 Tcl_Obj *const objv[]); 1192 1193#undef TCL_STORAGE_CLASS 1194#define TCL_STORAGE_CLASS DLLIMPORT 1195 1196#endif /* _TKINT */ 1197 1198/* 1199 * Local Variables: 1200 * mode: c 1201 * c-basic-offset: 4 1202 * fill-column: 78 1203 * End: 1204 */ 1205