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