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