4 * Declarations for Tk-related things that are visible outside of the Tk
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.
20 #if (TCL_MAJOR_VERSION != 8) || (TCL_MINOR_VERSION != 5)
21 # error Tk 8.5 must be compiled with tcl.h from Tcl 8.5
25 * For C++ compilers, use extern "C"
33 * When version numbers change here, you must also go into the following files
34 * and update the version numbers:
36 * library/tk.tcl (2 LOC patch)
37 * unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch)
38 * win/configure.in (as above)
39 * README (sections 0 and 1)
40 * macosx/Wish.xcode/project.pbxproj (not patchlevel) 1 LOC
41 * macosx/Wish-Common.xcconfig (not patchlevel) 1 LOC
42 * win/README (not patchlevel)
43 * unix/README (not patchlevel)
44 * unix/tk.spec (1 LOC patch)
45 * win/tcl.m4 (not patchlevel)
47 * You may also need to update some of these files when the numbers change for
48 * the version of Tcl that this release of Tk is compiled against.
51 #define TK_MAJOR_VERSION 8
52 #define TK_MINOR_VERSION 5
53 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE
54 #define TK_RELEASE_SERIAL 11
56 #define TK_VERSION "8.5"
57 #define TK_PATCH_LEVEL "8.5.11"
60 * A special definition used to allow this header file to be included from
61 * windows or mac resource files so that they can obtain version information.
62 * RC_INVOKED is defined by default by the windows RC tool and manually set
65 * Resource compilers don't like all the C stuff, like typedefs and procedure
66 * declarations, that occur below, so block them out.
72 # if defined(MAC_OSX_TK)
73 # include <X11/Xlib.h>
76 # include <X11/Xlib.h>
84 # undef TCL_STORAGE_CLASS
85 # define TCL_STORAGE_CLASS DLLEXPORT
89 * Decide whether or not to use input methods.
92 #ifdef XNQueryInputStyle
93 #define TK_USE_INPUT_METHODS
97 * Dummy types that are used by clients:
100 typedef struct Tk_BindingTable_
*Tk_BindingTable
;
101 typedef struct Tk_Canvas_
*Tk_Canvas
;
102 typedef struct Tk_Cursor_
*Tk_Cursor
;
103 typedef struct Tk_ErrorHandler_
*Tk_ErrorHandler
;
104 typedef struct Tk_Font_
*Tk_Font
;
105 typedef struct Tk_Image__
*Tk_Image
;
106 typedef struct Tk_ImageMaster_
*Tk_ImageMaster
;
107 typedef struct Tk_OptionTable_
*Tk_OptionTable
;
108 typedef struct Tk_PostscriptInfo_
*Tk_PostscriptInfo
;
109 typedef struct Tk_TextLayout_
*Tk_TextLayout
;
110 typedef struct Tk_Window_
*Tk_Window
;
111 typedef struct Tk_3DBorder_
*Tk_3DBorder
;
112 typedef struct Tk_Style_
*Tk_Style
;
113 typedef struct Tk_StyleEngine_
*Tk_StyleEngine
;
114 typedef struct Tk_StyledElement_
*Tk_StyledElement
;
117 * Additional types exported to clients.
120 typedef const char *Tk_Uid
;
123 * The enum below defines the valid types for Tk configuration options as
124 * implemented by Tk_InitOptions, Tk_SetOptions, etc.
132 TK_OPTION_STRING_TABLE
,
150 * Structures of the following type are used by widgets to specify their
151 * configuration options. Typically each widget has a static array of these
152 * structures, where each element of the array describes a single
153 * configuration option. The array is passed to Tk_CreateOptionTable.
156 typedef struct Tk_OptionSpec
{
157 Tk_OptionType type
; /* Type of option, such as TK_OPTION_COLOR;
158 * see definitions above. Last option in table
159 * must have type TK_OPTION_END. */
160 const char *optionName
; /* Name used to specify option in Tcl
162 const char *dbName
; /* Name for option in option database. */
163 const char *dbClass
; /* Class for option in database. */
164 const char *defValue
; /* Default value for option if not specified
165 * in command line, the option database, or
167 int objOffset
; /* Where in record to store a Tcl_Obj * that
168 * holds the value of this option, specified
169 * as an offset in bytes from the start of the
170 * record. Use the Tk_Offset macro to generate
171 * values for this. -1 means don't store the
172 * Tcl_Obj in the record. */
173 int internalOffset
; /* Where in record to store the internal
174 * representation of the value of this option,
175 * such as an int or XColor *. This field is
176 * specified as an offset in bytes from the
177 * start of the record. Use the Tk_Offset
178 * macro to generate values for it. -1 means
179 * don't store the internal representation in
181 int flags
; /* Any combination of the values defined
183 ClientData clientData
; /* An alternate place to put option-specific
184 * data. Used for the monochrome default value
185 * for colors, etc. */
186 int typeMask
; /* An arbitrary bit mask defined by the class
187 * manager; typically bits correspond to
188 * certain kinds of options such as all those
189 * that require a redisplay when they change.
190 * Tk_SetOptions returns the bit-wise OR of
191 * the typeMasks of all options that were
196 * Flag values for Tk_OptionSpec structures. These flags are shared by
197 * Tk_ConfigSpec structures, so be sure to coordinate any changes carefully.
200 #define TK_OPTION_NULL_OK (1 << 0)
201 #define TK_OPTION_DONT_SET_DEFAULT (1 << 3)
204 * The following structure and function types are used by TK_OPTION_CUSTOM
205 * options; the structure holds pointers to the functions needed by the Tk
206 * option config code to handle a custom option.
209 typedef int (Tk_CustomOptionSetProc
) _ANSI_ARGS_((ClientData clientData
,
210 Tcl_Interp
*interp
, Tk_Window tkwin
, Tcl_Obj
**value
, char *widgRec
,
211 int offset
, char *saveInternalPtr
, int flags
));
212 typedef Tcl_Obj
*(Tk_CustomOptionGetProc
) _ANSI_ARGS_((ClientData clientData
,
213 Tk_Window tkwin
, char *widgRec
, int offset
));
214 typedef void (Tk_CustomOptionRestoreProc
) _ANSI_ARGS_((ClientData clientData
,
215 Tk_Window tkwin
, char *internalPtr
, char *saveInternalPtr
));
216 typedef void (Tk_CustomOptionFreeProc
) _ANSI_ARGS_((ClientData clientData
,
217 Tk_Window tkwin
, char *internalPtr
));
219 typedef struct Tk_ObjCustomOption
{
220 const char *name
; /* Name of the custom option. */
221 Tk_CustomOptionSetProc
*setProc
;
222 /* Function to use to set a record's option
223 * value from a Tcl_Obj */
224 Tk_CustomOptionGetProc
*getProc
;
225 /* Function to use to get a Tcl_Obj
226 * representation from an internal
227 * representation of an option. */
228 Tk_CustomOptionRestoreProc
*restoreProc
;
229 /* Function to use to restore a saved value
230 * for the internal representation. */
231 Tk_CustomOptionFreeProc
*freeProc
;
232 /* Function to use to free the internal
233 * representation of an option. */
234 ClientData clientData
; /* Arbitrary one-word value passed to the
236 } Tk_ObjCustomOption
;
239 * Macro to use to fill in "offset" fields of the Tk_OptionSpec structure.
240 * Computes number of bytes from beginning of structure to a given field.
244 #define Tk_Offset(type, field) ((int) offsetof(type, field))
246 #define Tk_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
250 * The following two structures are used for error handling. When config
251 * options are being modified, the old values are saved in a Tk_SavedOptions
252 * structure. If an error occurs, then the contents of the structure can be
253 * used to restore all of the old values. The contents of this structure are
254 * for the private use Tk. No-one outside Tk should ever read or write any of
255 * the fields of these structures.
258 typedef struct Tk_SavedOption
{
259 struct TkOption
*optionPtr
; /* Points to information that describes the
261 Tcl_Obj
*valuePtr
; /* The old value of the option, in the form of
262 * a Tcl object; may be NULL if the value was
263 * not saved as an object. */
264 double internalForm
; /* The old value of the option, in some
265 * internal representation such as an int or
266 * (XColor *). Valid only if the field
267 * optionPtr->specPtr->objOffset is < 0. The
268 * space must be large enough to accommodate a
269 * double, a long, or a pointer; right now it
270 * looks like a double (i.e., 8 bytes) is big
271 * enough. Also, using a double guarantees
272 * that the field is properly aligned for
273 * storing large values. */
277 # define TK_NUM_SAVED_OPTIONS 2
279 # define TK_NUM_SAVED_OPTIONS 20
282 typedef struct Tk_SavedOptions
{
283 char *recordPtr
; /* The data structure in which to restore
284 * configuration options. */
285 Tk_Window tkwin
; /* Window associated with recordPtr; needed to
286 * restore certain options. */
287 int numItems
; /* The number of valid items in items field. */
288 Tk_SavedOption items
[TK_NUM_SAVED_OPTIONS
];
289 /* Items used to hold old values. */
290 struct Tk_SavedOptions
*nextPtr
;
291 /* Points to next structure in list; needed if
292 * too many options changed to hold all the
293 * old values in a single structure. NULL
294 * means no more structures. */
298 * Structure used to describe application-specific configuration options:
299 * indicates procedures to call to parse an option and to return a text string
300 * describing an option. THESE ARE DEPRECATED; PLEASE USE THE NEW STRUCTURES
305 * This is a temporary flag used while tkObjConfig and new widgets are in
309 #ifndef __NO_OLD_CONFIG
311 typedef int (Tk_OptionParseProc
) _ANSI_ARGS_((ClientData clientData
,
312 Tcl_Interp
*interp
, Tk_Window tkwin
, CONST84
char *value
, char *widgRec
,
314 typedef char *(Tk_OptionPrintProc
) _ANSI_ARGS_((ClientData clientData
,
315 Tk_Window tkwin
, char *widgRec
, int offset
,
316 Tcl_FreeProc
**freeProcPtr
));
318 typedef struct Tk_CustomOption
{
319 Tk_OptionParseProc
*parseProc
;
320 /* Procedure to call to parse an option and
321 * store it in converted form. */
322 Tk_OptionPrintProc
*printProc
;
323 /* Procedure to return a printable string
324 * describing an existing option. */
325 ClientData clientData
; /* Arbitrary one-word value used by option
326 * parser: passed to parseProc and
331 * Structure used to specify information for Tk_ConfigureWidget. Each
332 * structure gives complete information for one option, including how the
333 * option is specified on the command line, where it appears in the option
337 typedef struct Tk_ConfigSpec
{
338 int type
; /* Type of option, such as TK_CONFIG_COLOR;
339 * see definitions below. Last option in table
340 * must have type TK_CONFIG_END. */
341 char *argvName
; /* Switch used to specify option in argv. NULL
342 * means this spec is part of a group. */
343 Tk_Uid dbName
; /* Name for option in option database. */
344 Tk_Uid dbClass
; /* Class for option in database. */
345 Tk_Uid defValue
; /* Default value for option if not specified
346 * in command line or database. */
347 int offset
; /* Where in widget record to store value; use
348 * Tk_Offset macro to generate values for
350 int specFlags
; /* Any combination of the values defined
351 * below; other bits are used internally by
353 Tk_CustomOption
*customPtr
; /* If type is TK_CONFIG_CUSTOM then this is a
354 * pointer to info about how to parse and
355 * print the option. Otherwise it is
360 * Type values for Tk_ConfigSpec structures. See the user documentation for
365 TK_CONFIG_BOOLEAN
, TK_CONFIG_INT
, TK_CONFIG_DOUBLE
, TK_CONFIG_STRING
,
366 TK_CONFIG_UID
, TK_CONFIG_COLOR
, TK_CONFIG_FONT
, TK_CONFIG_BITMAP
,
367 TK_CONFIG_BORDER
, TK_CONFIG_RELIEF
, TK_CONFIG_CURSOR
,
368 TK_CONFIG_ACTIVE_CURSOR
, TK_CONFIG_JUSTIFY
, TK_CONFIG_ANCHOR
,
369 TK_CONFIG_SYNONYM
, TK_CONFIG_CAP_STYLE
, TK_CONFIG_JOIN_STYLE
,
370 TK_CONFIG_PIXELS
, TK_CONFIG_MM
, TK_CONFIG_WINDOW
, TK_CONFIG_CUSTOM
,
375 * Possible values for flags argument to Tk_ConfigureWidget:
378 #define TK_CONFIG_ARGV_ONLY 1
379 #define TK_CONFIG_OBJS 0x80
382 * Possible flag values for Tk_ConfigSpec structures. Any bits at or above
383 * TK_CONFIG_USER_BIT may be used by clients for selecting certain entries.
384 * Before changing any values here, coordinate with tkOldConfig.c
385 * (internal-use-only flags are defined there).
388 #define TK_CONFIG_NULL_OK (1 << 0)
389 #define TK_CONFIG_COLOR_ONLY (1 << 1)
390 #define TK_CONFIG_MONO_ONLY (1 << 2)
391 #define TK_CONFIG_DONT_SET_DEFAULT (1 << 3)
392 #define TK_CONFIG_OPTION_SPECIFIED (1 << 4)
393 #define TK_CONFIG_USER_BIT 0x100
394 #endif /* __NO_OLD_CONFIG */
397 * Structure used to specify how to handle argv options.
401 char *key
; /* The key string that flags the option in the
403 int type
; /* Indicates option type; see below. */
404 char *src
; /* Value to be used in setting dst; usage
405 * depends on type. */
406 char *dst
; /* Address of value to be modified; usage
407 * depends on type. */
408 char *help
; /* Documentation message describing this
413 * Legal values for the type field of a Tk_ArgvInfo: see the user
414 * documentation for details.
417 #define TK_ARGV_CONSTANT 15
418 #define TK_ARGV_INT 16
419 #define TK_ARGV_STRING 17
420 #define TK_ARGV_UID 18
421 #define TK_ARGV_REST 19
422 #define TK_ARGV_FLOAT 20
423 #define TK_ARGV_FUNC 21
424 #define TK_ARGV_GENFUNC 22
425 #define TK_ARGV_HELP 23
426 #define TK_ARGV_CONST_OPTION 24
427 #define TK_ARGV_OPTION_VALUE 25
428 #define TK_ARGV_OPTION_NAME_VALUE 26
429 #define TK_ARGV_END 27
432 * Flag bits for passing to Tk_ParseArgv:
435 #define TK_ARGV_NO_DEFAULTS 0x1
436 #define TK_ARGV_NO_LEFTOVERS 0x2
437 #define TK_ARGV_NO_ABBREV 0x4
438 #define TK_ARGV_DONT_SKIP_FIRST_ARG 0x8
441 * Enumerated type for describing actions to be taken in response to a
442 * restrictProc established by Tk_RestrictEvents.
446 TK_DEFER_EVENT
, TK_PROCESS_EVENT
, TK_DISCARD_EVENT
450 * Priority levels to pass to Tk_AddOption:
453 #define TK_WIDGET_DEFAULT_PRIO 20
454 #define TK_STARTUP_FILE_PRIO 40
455 #define TK_USER_DEFAULT_PRIO 60
456 #define TK_INTERACTIVE_PRIO 80
457 #define TK_MAX_PRIO 100
460 * Relief values returned by Tk_GetRelief:
463 #define TK_RELIEF_NULL -1
464 #define TK_RELIEF_FLAT 0
465 #define TK_RELIEF_GROOVE 1
466 #define TK_RELIEF_RAISED 2
467 #define TK_RELIEF_RIDGE 3
468 #define TK_RELIEF_SOLID 4
469 #define TK_RELIEF_SUNKEN 5
472 * "Which" argument values for Tk_3DBorderGC:
475 #define TK_3D_FLAT_GC 1
476 #define TK_3D_LIGHT_GC 2
477 #define TK_3D_DARK_GC 3
480 * Special EnterNotify/LeaveNotify "mode" for use in events generated by
481 * tkShare.c. Pick a high enough value that it's unlikely to conflict with
482 * existing values (like NotifyNormal) or any new values defined in the
486 #define TK_NOTIFY_SHARE 20
489 * Enumerated type for describing a point by which to anchor something:
493 TK_ANCHOR_N
, TK_ANCHOR_NE
, TK_ANCHOR_E
, TK_ANCHOR_SE
,
494 TK_ANCHOR_S
, TK_ANCHOR_SW
, TK_ANCHOR_W
, TK_ANCHOR_NW
,
499 * Enumerated type for describing a style of justification:
503 TK_JUSTIFY_LEFT
, TK_JUSTIFY_RIGHT
, TK_JUSTIFY_CENTER
507 * The following structure is used by Tk_GetFontMetrics() to return
508 * information about the properties of a Tk_Font.
511 typedef struct Tk_FontMetrics
{
512 int ascent
; /* The amount in pixels that the tallest
513 * letter sticks up above the baseline, plus
514 * any extra blank space added by the designer
516 int descent
; /* The largest amount in pixels that any
517 * letter sticks below the baseline, plus any
518 * extra blank space added by the designer of
520 int linespace
; /* The sum of the ascent and descent. How far
521 * apart two lines of text in the same font
522 * should be placed so that none of the
523 * characters in one line overlap any of the
524 * characters in the other line. */
528 * Flags passed to Tk_MeasureChars:
531 #define TK_WHOLE_WORDS 1
532 #define TK_AT_LEAST_ONE 2
533 #define TK_PARTIAL_OK 4
536 * Flags passed to Tk_ComputeTextLayout:
539 #define TK_IGNORE_TABS 8
540 #define TK_IGNORE_NEWLINES 16
543 * Widget class procedures used to implement platform specific widget
547 typedef Window (Tk_ClassCreateProc
) _ANSI_ARGS_((Tk_Window tkwin
,
548 Window parent
, ClientData instanceData
));
549 typedef void (Tk_ClassWorldChangedProc
) _ANSI_ARGS_((ClientData instanceData
));
550 typedef void (Tk_ClassModalProc
) _ANSI_ARGS_((Tk_Window tkwin
,
553 typedef struct Tk_ClassProcs
{
555 Tk_ClassWorldChangedProc
*worldChangedProc
;
556 /* Procedure to invoke when the widget needs
557 * to respond in some way to a change in the
558 * world (font changes, etc.) */
559 Tk_ClassCreateProc
*createProc
;
560 /* Procedure to invoke when the platform-
561 * dependent window needs to be created. */
562 Tk_ClassModalProc
*modalProc
;
563 /* Procedure to invoke after all bindings on a
564 * widget have been triggered in order to
565 * handle a modal loop. */
569 * Simple accessor for Tk_ClassProcs structure. Checks that the structure is
570 * not NULL, then checks the size field and returns either the requested
571 * field, if present, or NULL if the structure is too small to have the field
572 * (or NULL if the structure is NULL).
574 * A more general version of this function may be useful if other
575 * size-versioned structure pop up in the future:
577 * #define Tk_GetField(name, who, which) \
578 * (((who) == NULL) ? NULL :
579 * (((who)->size <= Tk_Offset(name, which)) ? NULL :(name)->which))
582 #define Tk_GetClassProc(procs, which) \
583 (((procs) == NULL) ? NULL : \
584 (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))
587 * Each geometry manager (the packer, the placer, etc.) is represented by a
588 * structure of the following form, which indicates procedures to invoke in
589 * the geometry manager to carry out certain functions.
592 typedef void (Tk_GeomRequestProc
) _ANSI_ARGS_((ClientData clientData
,
594 typedef void (Tk_GeomLostSlaveProc
) _ANSI_ARGS_((ClientData clientData
,
597 typedef struct Tk_GeomMgr
{
598 const char *name
; /* Name of the geometry manager (command used
599 * to invoke it, or name of widget class that
600 * allows embedded widgets). */
601 Tk_GeomRequestProc
*requestProc
;
602 /* Procedure to invoke when a slave's
603 * requested geometry changes. */
604 Tk_GeomLostSlaveProc
*lostSlaveProc
;
605 /* Procedure to invoke when a slave is taken
606 * away from one geometry manager by another.
607 * NULL means geometry manager doesn't care
608 * when slaves are lost. */
612 * Result values returned by Tk_GetScrollInfo:
615 #define TK_SCROLL_MOVETO 1
616 #define TK_SCROLL_PAGES 2
617 #define TK_SCROLL_UNITS 3
618 #define TK_SCROLL_ERROR 4
621 *---------------------------------------------------------------------------
623 * Extensions to the X event set
625 *---------------------------------------------------------------------------
628 #define VirtualEvent (MappingNotify + 1)
629 #define ActivateNotify (MappingNotify + 2)
630 #define DeactivateNotify (MappingNotify + 3)
631 #define MouseWheelEvent (MappingNotify + 4)
632 #define TK_LASTEVENT (MappingNotify + 5)
634 #define MouseWheelMask (1L << 28)
635 #define ActivateMask (1L << 29)
636 #define VirtualEventMask (1L << 30)
639 * A virtual event shares most of its fields with the XKeyEvent and
640 * XButtonEvent structures. 99% of the time a virtual event will be an
641 * abstraction of a key or button event, so this structure provides the most
642 * information to the user. The only difference is the changing of the detail
643 * field for a virtual event so that it holds the name of the virtual event
646 * When using this structure, you should ensure that you zero out all the
647 * fields first using memset() or bzero().
652 unsigned long serial
; /* # of last request processed by server. */
653 Bool send_event
; /* True if this came from a SendEvent
655 Display
*display
; /* Display the event was read from. */
656 Window event
; /* Window on which event was requested. */
657 Window root
; /* Root window that the event occured on. */
658 Window subwindow
; /* Child window. */
659 Time time
; /* Milliseconds. */
660 int x
, y
; /* Pointer x, y coordinates in event
662 int x_root
, y_root
; /* Coordinates relative to root. */
663 unsigned int state
; /* Key or button mask */
664 Tk_Uid name
; /* Name of virtual event. */
665 Bool same_screen
; /* Same screen flag. */
666 Tcl_Obj
*user_data
; /* Application-specific data reference; Tk
667 * will decrement the reference count *once*
668 * when it has finished processing the
674 unsigned long serial
; /* # of last request processed by server. */
675 Bool send_event
; /* True if this came from a SendEvent
677 Display
*display
; /* Display the event was read from. */
678 Window window
; /* Window in which event occurred. */
679 } XActivateDeactivateEvent
;
680 typedef XActivateDeactivateEvent XActivateEvent
;
681 typedef XActivateDeactivateEvent XDeactivateEvent
;
684 *--------------------------------------------------------------
686 * Macros for querying Tk_Window structures. See the manual entries for
689 *--------------------------------------------------------------
692 #define Tk_Display(tkwin) (((Tk_FakeWin *) (tkwin))->display)
693 #define Tk_ScreenNumber(tkwin) (((Tk_FakeWin *) (tkwin))->screenNum)
694 #define Tk_Screen(tkwin) \
695 (ScreenOfDisplay(Tk_Display(tkwin), Tk_ScreenNumber(tkwin)))
696 #define Tk_Depth(tkwin) (((Tk_FakeWin *) (tkwin))->depth)
697 #define Tk_Visual(tkwin) (((Tk_FakeWin *) (tkwin))->visual)
698 #define Tk_WindowId(tkwin) (((Tk_FakeWin *) (tkwin))->window)
699 #define Tk_PathName(tkwin) (((Tk_FakeWin *) (tkwin))->pathName)
700 #define Tk_Name(tkwin) (((Tk_FakeWin *) (tkwin))->nameUid)
701 #define Tk_Class(tkwin) (((Tk_FakeWin *) (tkwin))->classUid)
702 #define Tk_X(tkwin) (((Tk_FakeWin *) (tkwin))->changes.x)
703 #define Tk_Y(tkwin) (((Tk_FakeWin *) (tkwin))->changes.y)
704 #define Tk_Width(tkwin) (((Tk_FakeWin *) (tkwin))->changes.width)
705 #define Tk_Height(tkwin) \
706 (((Tk_FakeWin *) (tkwin))->changes.height)
707 #define Tk_Changes(tkwin) (&((Tk_FakeWin *) (tkwin))->changes)
708 #define Tk_Attributes(tkwin) (&((Tk_FakeWin *) (tkwin))->atts)
709 #define Tk_IsEmbedded(tkwin) \
710 (((Tk_FakeWin *) (tkwin))->flags & TK_EMBEDDED)
711 #define Tk_IsContainer(tkwin) \
712 (((Tk_FakeWin *) (tkwin))->flags & TK_CONTAINER)
713 #define Tk_IsMapped(tkwin) \
714 (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED)
715 #define Tk_IsTopLevel(tkwin) \
716 (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL)
717 #define Tk_HasWrapper(tkwin) \
718 (((Tk_FakeWin *) (tkwin))->flags & TK_HAS_WRAPPER)
719 #define Tk_WinManaged(tkwin) \
720 (((Tk_FakeWin *) (tkwin))->flags & TK_WIN_MANAGED)
721 #define Tk_TopWinHierarchy(tkwin) \
722 (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY)
723 #define Tk_IsManageable(tkwin) \
724 (((Tk_FakeWin *) (tkwin))->flags & TK_WM_MANAGEABLE)
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
{
755 char *dummy1
; /* dispPtr */
760 char *dummy2
; /* childList */
761 char *dummy3
; /* lastChildPtr */
762 Tk_Window parentPtr
; /* parentPtr */
763 char *dummy4
; /* nextPtr */
764 char *dummy5
; /* mainPtr */
768 XWindowChanges changes
;
769 unsigned int dummy6
; /* dirtyChanges */
770 XSetWindowAttributes atts
;
771 unsigned long dummy7
; /* dirtyAtts */
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
;
797 * Flag values for TkWindow (and Tk_FakeWin) structures are:
799 * TK_MAPPED: 1 means window is currently mapped,
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
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
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
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
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
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
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
860 * TK_WM_MANAGEABLE 1 marks a window as capable of being converted
861 * into a toplevel using [wm manage].
865 #define TK_TOP_LEVEL 2
866 #define TK_ALREADY_DEAD 4
867 #define TK_NEED_CONFIG_NOTIFY 8
868 #define TK_GRAB_FLAG 0x10
869 #define TK_CHECKED_IC 0x20
870 #define TK_DONT_DESTROY_WINDOW 0x40
871 #define TK_WM_COLORMAP_WINDOW 0x80
872 #define TK_EMBEDDED 0x100
873 #define TK_CONTAINER 0x200
874 #define TK_BOTH_HALVES 0x400
875 #define TK_DEFER_MODAL 0x800
876 #define TK_WRAPPER 0x1000
877 #define TK_REPARENTED 0x2000
878 #define TK_ANONYMOUS_WINDOW 0x4000
879 #define TK_HAS_WRAPPER 0x8000
880 #define TK_WIN_MANAGED 0x10000
881 #define TK_TOP_HIERARCHY 0x20000
882 #define TK_PROP_PROPCHANGE 0x40000
883 #define TK_WM_MANAGEABLE 0x80000
886 *--------------------------------------------------------------
888 * Procedure prototypes and structures used for defining new canvas items:
890 *--------------------------------------------------------------
894 TK_STATE_NULL
= -1, TK_STATE_ACTIVE
, TK_STATE_DISABLED
,
895 TK_STATE_NORMAL
, TK_STATE_HIDDEN
898 typedef struct Tk_SmoothMethod
{
900 int (*coordProc
) _ANSI_ARGS_((Tk_Canvas canvas
,
901 double *pointPtr
, int numPoints
, int numSteps
,
902 XPoint xPoints
[], double dblPoints
[]));
903 void (*postscriptProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
904 Tk_Canvas canvas
, double *coordPtr
,
905 int numPoints
, int numSteps
));
909 * For each item in a canvas widget there exists one record with the following
910 * structure. Each actual item is represented by a record with the following
911 * stuff at its beginning, plus additional type-specific stuff after that.
914 #define TK_TAG_SPACE 3
916 typedef struct Tk_Item
{
917 int id
; /* Unique identifier for this item (also
918 * serves as first tag for item). */
919 struct Tk_Item
*nextPtr
; /* Next in display list of all items in this
920 * canvas. Later items in list are drawn on
921 * top of earlier ones. */
922 Tk_Uid staticTagSpace
[TK_TAG_SPACE
];
923 /* Built-in space for limited # of tags. */
924 Tk_Uid
*tagPtr
; /* Pointer to array of tags. Usually points to
925 * staticTagSpace, but may point to malloc-ed
926 * space if there are lots of tags. */
927 int tagSpace
; /* Total amount of tag space available at
929 int numTags
; /* Number of tag slots actually used at
931 struct Tk_ItemType
*typePtr
;/* Table of procedures that implement this
933 int x1
, y1
, x2
, y2
; /* Bounding box for item, in integer canvas
934 * units. Set by item-specific code and
935 * guaranteed to contain every pixel drawn in
936 * item. Item area includes x1 and y1 but not
938 struct Tk_Item
*prevPtr
; /* Previous in display list of all items in
939 * this canvas. Later items in list are drawn
940 * just below earlier ones. */
941 Tk_State state
; /* State of item. */
942 char *reserved1
; /* reserved for future use */
943 int redraw_flags
; /* Some flags used in the canvas */
946 *------------------------------------------------------------------
947 * Starting here is additional type-specific stuff; see the declarations
948 * for individual types to see what is part of each type. The actual space
949 * below is determined by the "itemInfoSize" of the type's Tk_ItemType
951 *------------------------------------------------------------------
956 * Flag bits for canvases (redraw_flags):
958 * TK_ITEM_STATE_DEPENDANT - 1 means that object needs to be redrawn if the
959 * canvas state changes.
960 * TK_ITEM_DONT_REDRAW - 1 means that the object redraw is already been
961 * prepared, so the general canvas code doesn't
962 * need to do that any more.
965 #define TK_ITEM_STATE_DEPENDANT 1
966 #define TK_ITEM_DONT_REDRAW 2
969 * Records of the following type are used to describe a type of item (e.g.
970 * lines, circles, etc.) that can form part of a canvas widget.
973 #ifdef USE_OLD_CANVAS
974 typedef int Tk_ItemCreateProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
975 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
977 typedef int Tk_ItemConfigureProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
978 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
979 char **argv
, int flags
));
980 typedef int Tk_ItemCoordProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
981 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
984 typedef int Tk_ItemCreateProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
985 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
986 Tcl_Obj
*const objv
[]));
987 typedef int Tk_ItemConfigureProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
988 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
989 Tcl_Obj
*const objv
[], int flags
));
990 typedef int Tk_ItemCoordProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
991 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
992 Tcl_Obj
*const argv
[]));
994 typedef void Tk_ItemDeleteProc
_ANSI_ARGS_((Tk_Canvas canvas
,
995 Tk_Item
*itemPtr
, Display
*display
));
996 typedef void Tk_ItemDisplayProc
_ANSI_ARGS_((Tk_Canvas canvas
,
997 Tk_Item
*itemPtr
, Display
*display
, Drawable dst
,
998 int x
, int y
, int width
, int height
));
999 typedef double Tk_ItemPointProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1000 Tk_Item
*itemPtr
, double *pointPtr
));
1001 typedef int Tk_ItemAreaProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1002 Tk_Item
*itemPtr
, double *rectPtr
));
1003 typedef int Tk_ItemPostscriptProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
1004 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int prepass
));
1005 typedef void Tk_ItemScaleProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1006 Tk_Item
*itemPtr
, double originX
, double originY
,
1007 double scaleX
, double scaleY
));
1008 typedef void Tk_ItemTranslateProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1009 Tk_Item
*itemPtr
, double deltaX
, double deltaY
));
1010 typedef int Tk_ItemIndexProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
1011 Tk_Canvas canvas
, Tk_Item
*itemPtr
, char *indexString
,
1013 typedef void Tk_ItemCursorProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1014 Tk_Item
*itemPtr
, int index
));
1015 typedef int Tk_ItemSelectionProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1016 Tk_Item
*itemPtr
, int offset
, char *buffer
,
1018 typedef void Tk_ItemInsertProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1019 Tk_Item
*itemPtr
, int beforeThis
, char *string
));
1020 typedef void Tk_ItemDCharsProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1021 Tk_Item
*itemPtr
, int first
, int last
));
1023 #ifndef __NO_OLD_CONFIG
1025 typedef struct Tk_ItemType
{
1026 char *name
; /* The name of this type of item, such as
1028 int itemSize
; /* Total amount of space needed for item's
1030 Tk_ItemCreateProc
*createProc
;
1031 /* Procedure to create a new item of this
1033 Tk_ConfigSpec
*configSpecs
; /* Pointer to array of configuration specs for
1034 * this type. Used for returning configuration
1036 Tk_ItemConfigureProc
*configProc
;
1037 /* Procedure to call to change configuration
1039 Tk_ItemCoordProc
*coordProc
;/* Procedure to call to get and set the item's
1041 Tk_ItemDeleteProc
*deleteProc
;
1042 /* Procedure to delete existing item of this
1044 Tk_ItemDisplayProc
*displayProc
;
1045 /* Procedure to display items of this type. */
1046 int alwaysRedraw
; /* Non-zero means displayProc should be called
1047 * even when the item has been moved
1049 Tk_ItemPointProc
*pointProc
;/* Computes distance from item to a given
1051 Tk_ItemAreaProc
*areaProc
; /* Computes whether item is inside, outside,
1052 * or overlapping an area. */
1053 Tk_ItemPostscriptProc
*postscriptProc
;
1054 /* Procedure to write a Postscript description
1055 * for items of this type. */
1056 Tk_ItemScaleProc
*scaleProc
;/* Procedure to rescale items of this type. */
1057 Tk_ItemTranslateProc
*translateProc
;
1058 /* Procedure to translate items of this
1060 Tk_ItemIndexProc
*indexProc
;/* Procedure to determine index of indicated
1061 * character. NULL if item doesn't support
1063 Tk_ItemCursorProc
*icursorProc
;
1064 /* Procedure to set insert cursor posn to just
1065 * before a given position. */
1066 Tk_ItemSelectionProc
*selectionProc
;
1067 /* Procedure to return selection (in STRING
1068 * format) when it is in this item. */
1069 Tk_ItemInsertProc
*insertProc
;
1070 /* Procedure to insert something into an
1072 Tk_ItemDCharsProc
*dCharsProc
;
1073 /* Procedure to delete characters from an
1075 struct Tk_ItemType
*nextPtr
;/* Used to link types together into a list. */
1076 char *reserved1
; /* Reserved for future extension. */
1077 int reserved2
; /* Carefully compatible with */
1078 char *reserved3
; /* Jan Nijtmans dash patch */
1085 * The following structure provides information about the selection and the
1086 * insertion cursor. It is needed by only a few items, such as those that
1087 * display text. It is shared by the generic canvas code and the item-specific
1088 * code, but most of the fields should be written only by the canvas generic
1092 typedef struct Tk_CanvasTextInfo
{
1093 Tk_3DBorder selBorder
; /* Border and background for selected
1094 * characters. Read-only to items.*/
1095 int selBorderWidth
; /* Width of border around selection. Read-only
1097 XColor
*selFgColorPtr
; /* Foreground color for selected text.
1098 * Read-only to items. */
1099 Tk_Item
*selItemPtr
; /* Pointer to selected item. NULL means
1100 * selection isn't in this canvas. Writable by
1102 int selectFirst
; /* Character index of first selected
1103 * character. Writable by items. */
1104 int selectLast
; /* Character index of last selected character.
1105 * Writable by items. */
1106 Tk_Item
*anchorItemPtr
; /* Item corresponding to "selectAnchor": not
1107 * necessarily selItemPtr. Read-only to
1109 int selectAnchor
; /* Character index of fixed end of selection
1110 * (i.e. "select to" operation will use this
1111 * as one end of the selection). Writable by
1113 Tk_3DBorder insertBorder
; /* Used to draw vertical bar for insertion
1114 * cursor. Read-only to items. */
1115 int insertWidth
; /* Total width of insertion cursor. Read-only
1117 int insertBorderWidth
; /* Width of 3-D border around insert cursor.
1118 * Read-only to items. */
1119 Tk_Item
*focusItemPtr
; /* Item that currently has the input focus, or
1120 * NULL if no such item. Read-only to items. */
1121 int gotFocus
; /* Non-zero means that the canvas widget has
1122 * the input focus. Read-only to items.*/
1123 int cursorOn
; /* Non-zero means that an insertion cursor
1124 * should be displayed in focusItemPtr.
1125 * Read-only to items.*/
1126 } Tk_CanvasTextInfo
;
1129 * Structures used for Dashing and Outline.
1132 typedef struct Tk_Dash
{
1136 char array
[sizeof(char *)];
1140 typedef struct Tk_TSOffset
{
1141 int flags
; /* Flags; see below for possible values */
1142 int xoffset
; /* x offset */
1143 int yoffset
; /* y offset */
1147 * Bit fields in Tk_Offset->flags:
1150 #define TK_OFFSET_INDEX 1
1151 #define TK_OFFSET_RELATIVE 2
1152 #define TK_OFFSET_LEFT 4
1153 #define TK_OFFSET_CENTER 8
1154 #define TK_OFFSET_RIGHT 16
1155 #define TK_OFFSET_TOP 32
1156 #define TK_OFFSET_MIDDLE 64
1157 #define TK_OFFSET_BOTTOM 128
1159 typedef struct Tk_Outline
{
1160 GC gc
; /* Graphics context. */
1161 double width
; /* Width of outline. */
1162 double activeWidth
; /* Width of outline. */
1163 double disabledWidth
; /* Width of outline. */
1164 int offset
; /* Dash offset. */
1165 Tk_Dash dash
; /* Dash pattern. */
1166 Tk_Dash activeDash
; /* Dash pattern if state is active. */
1167 Tk_Dash disabledDash
; /* Dash pattern if state is disabled. */
1168 VOID
*reserved1
; /* Reserved for future expansion. */
1171 Tk_TSOffset tsoffset
; /* Stipple offset for outline. */
1172 XColor
*color
; /* Outline color. */
1173 XColor
*activeColor
; /* Outline color if state is active. */
1174 XColor
*disabledColor
; /* Outline color if state is disabled. */
1175 Pixmap stipple
; /* Outline Stipple pattern. */
1176 Pixmap activeStipple
; /* Outline Stipple pattern if state is
1178 Pixmap disabledStipple
; /* Outline Stipple pattern if state is
1183 *--------------------------------------------------------------
1185 * Procedure prototypes and structures used for managing images:
1187 *--------------------------------------------------------------
1190 typedef struct Tk_ImageType Tk_ImageType
;
1191 #ifdef USE_OLD_IMAGE
1192 typedef int (Tk_ImageCreateProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1193 char *name
, int argc
, char **argv
, Tk_ImageType
*typePtr
,
1194 Tk_ImageMaster master
, ClientData
*masterDataPtr
));
1196 typedef int (Tk_ImageCreateProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1197 char *name
, int objc
, Tcl_Obj
*const objv
[], Tk_ImageType
*typePtr
,
1198 Tk_ImageMaster master
, ClientData
*masterDataPtr
));
1200 typedef ClientData (Tk_ImageGetProc
) _ANSI_ARGS_((Tk_Window tkwin
,
1201 ClientData masterData
));
1202 typedef void (Tk_ImageDisplayProc
) _ANSI_ARGS_((ClientData instanceData
,
1203 Display
*display
, Drawable drawable
, int imageX
, int imageY
,
1204 int width
, int height
, int drawableX
, int drawableY
));
1205 typedef void (Tk_ImageFreeProc
) _ANSI_ARGS_((ClientData instanceData
,
1207 typedef void (Tk_ImageDeleteProc
) _ANSI_ARGS_((ClientData masterData
));
1208 typedef void (Tk_ImageChangedProc
) _ANSI_ARGS_((ClientData clientData
,
1209 int x
, int y
, int width
, int height
, int imageWidth
,
1211 typedef int (Tk_ImagePostscriptProc
) _ANSI_ARGS_((ClientData clientData
,
1212 Tcl_Interp
*interp
, Tk_Window tkwin
, Tk_PostscriptInfo psinfo
,
1213 int x
, int y
, int width
, int height
, int prepass
));
1216 * The following structure represents a particular type of image (bitmap, xpm
1217 * image, etc.). It provides information common to all images of that type,
1218 * such as the type name and a collection of procedures in the image manager
1219 * that respond to various events. Each image manager is represented by one of
1223 struct Tk_ImageType
{
1224 char *name
; /* Name of image type. */
1225 Tk_ImageCreateProc
*createProc
;
1226 /* Procedure to call to create a new image of
1228 Tk_ImageGetProc
*getProc
; /* Procedure to call the first time
1229 * Tk_GetImage is called in a new way (new
1230 * visual or screen). */
1231 Tk_ImageDisplayProc
*displayProc
;
1232 /* Call to draw image, in response to
1233 * Tk_RedrawImage calls. */
1234 Tk_ImageFreeProc
*freeProc
; /* Procedure to call whenever Tk_FreeImage is
1235 * called to release an instance of an
1237 Tk_ImageDeleteProc
*deleteProc
;
1238 /* Procedure to call to delete image. It will
1239 * not be called until after freeProc has been
1240 * called for each instance of the image. */
1241 Tk_ImagePostscriptProc
*postscriptProc
;
1242 /* Procedure to call to produce postscript
1243 * output for the image. */
1244 struct Tk_ImageType
*nextPtr
;
1245 /* Next in list of all image types currently
1246 * known. Filled in by Tk, not by image
1248 char *reserved
; /* reserved for future expansion */
1252 *--------------------------------------------------------------
1254 * Additional definitions used to manage images of type "photo".
1256 *--------------------------------------------------------------
1260 * The following type is used to identify a particular photo image to be
1264 typedef void *Tk_PhotoHandle
;
1267 * The following structure describes a block of pixels in memory:
1270 typedef struct Tk_PhotoImageBlock
{
1271 unsigned char *pixelPtr
; /* Pointer to the first pixel. */
1272 int width
; /* Width of block, in pixels. */
1273 int height
; /* Height of block, in pixels. */
1274 int pitch
; /* Address difference between corresponding
1275 * pixels in successive lines. */
1276 int pixelSize
; /* Address difference between successive
1277 * pixels in the same line. */
1278 int offset
[4]; /* Address differences between the red, green,
1279 * blue and alpha components of the pixel and
1280 * the pixel as a whole. */
1281 } Tk_PhotoImageBlock
;
1284 * The following values control how blocks are combined into photo images when
1285 * the alpha component of a pixel is not 255, a.k.a. the compositing rule.
1288 #define TK_PHOTO_COMPOSITE_OVERLAY 0
1289 #define TK_PHOTO_COMPOSITE_SET 1
1292 * Procedure prototypes and structures used in reading and writing photo
1296 typedef struct Tk_PhotoImageFormat Tk_PhotoImageFormat
;
1297 #ifdef USE_OLD_IMAGE
1298 typedef int (Tk_ImageFileMatchProc
) _ANSI_ARGS_((Tcl_Channel chan
,
1299 char *fileName
, char *formatString
, int *widthPtr
, int *heightPtr
));
1300 typedef int (Tk_ImageStringMatchProc
) _ANSI_ARGS_((char *string
,
1301 char *formatString
, int *widthPtr
, int *heightPtr
));
1302 typedef int (Tk_ImageFileReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1303 Tcl_Channel chan
, char *fileName
, char *formatString
,
1304 Tk_PhotoHandle imageHandle
, int destX
, int destY
,
1305 int width
, int height
, int srcX
, int srcY
));
1306 typedef int (Tk_ImageStringReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1307 char *string
, char *formatString
, Tk_PhotoHandle imageHandle
,
1308 int destX
, int destY
, int width
, int height
, int srcX
, int srcY
));
1309 typedef int (Tk_ImageFileWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1310 char *fileName
, char *formatString
, Tk_PhotoImageBlock
*blockPtr
));
1311 typedef int (Tk_ImageStringWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1312 Tcl_DString
*dataPtr
, char *formatString
,
1313 Tk_PhotoImageBlock
*blockPtr
));
1315 typedef int (Tk_ImageFileMatchProc
) _ANSI_ARGS_((Tcl_Channel chan
,
1316 const char *fileName
, Tcl_Obj
*format
, int *widthPtr
,
1317 int *heightPtr
, Tcl_Interp
*interp
));
1318 typedef int (Tk_ImageStringMatchProc
) _ANSI_ARGS_((Tcl_Obj
*dataObj
,
1319 Tcl_Obj
*format
, int *widthPtr
, int *heightPtr
,
1320 Tcl_Interp
*interp
));
1321 typedef int (Tk_ImageFileReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1322 Tcl_Channel chan
, const char *fileName
, Tcl_Obj
*format
,
1323 Tk_PhotoHandle imageHandle
, int destX
, int destY
,
1324 int width
, int height
, int srcX
, int srcY
));
1325 typedef int (Tk_ImageStringReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1326 Tcl_Obj
*dataObj
, Tcl_Obj
*format
, Tk_PhotoHandle imageHandle
,
1327 int destX
, int destY
, int width
, int height
, int srcX
, int srcY
));
1328 typedef int (Tk_ImageFileWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1329 const char *fileName
, Tcl_Obj
*format
, Tk_PhotoImageBlock
*blockPtr
));
1330 typedef int (Tk_ImageStringWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1331 Tcl_Obj
*format
, Tk_PhotoImageBlock
*blockPtr
));
1335 * The following structure represents a particular file format for storing
1336 * images (e.g., PPM, GIF, JPEG, etc.). It provides information to allow image
1337 * files of that format to be recognized and read into a photo image.
1340 struct Tk_PhotoImageFormat
{
1341 char *name
; /* Name of image file format */
1342 Tk_ImageFileMatchProc
*fileMatchProc
;
1343 /* Procedure to call to determine whether an
1344 * image file matches this format. */
1345 Tk_ImageStringMatchProc
*stringMatchProc
;
1346 /* Procedure to call to determine whether the
1347 * data in a string matches this format. */
1348 Tk_ImageFileReadProc
*fileReadProc
;
1349 /* Procedure to call to read data from an
1350 * image file into a photo image. */
1351 Tk_ImageStringReadProc
*stringReadProc
;
1352 /* Procedure to call to read data from a
1353 * string into a photo image. */
1354 Tk_ImageFileWriteProc
*fileWriteProc
;
1355 /* Procedure to call to write data from a
1356 * photo image to a file. */
1357 Tk_ImageStringWriteProc
*stringWriteProc
;
1358 /* Procedure to call to obtain a string
1359 * representation of the data in a photo
1361 struct Tk_PhotoImageFormat
*nextPtr
;
1362 /* Next in list of all photo image formats
1363 * currently known. Filled in by Tk, not by
1364 * image format handler. */
1367 #ifdef USE_OLD_IMAGE
1368 #define Tk_CreateImageType Tk_CreateOldImageType
1369 #define Tk_CreatePhotoImageFormat Tk_CreateOldPhotoImageFormat
1373 *--------------------------------------------------------------
1375 * Procedure prototypes and structures used for managing styles:
1377 *--------------------------------------------------------------
1381 * Style support version tag.
1384 #define TK_STYLE_VERSION_1 0x1
1385 #define TK_STYLE_VERSION TK_STYLE_VERSION_1
1388 * The following structures and prototypes are used as static templates to
1389 * declare widget elements.
1392 typedef void (Tk_GetElementSizeProc
) _ANSI_ARGS_((ClientData clientData
,
1393 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
,
1394 int width
, int height
, int inner
, int *widthPtr
, int *heightPtr
));
1395 typedef void (Tk_GetElementBoxProc
) _ANSI_ARGS_((ClientData clientData
,
1396 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
,
1397 int x
, int y
, int width
, int height
, int inner
, int *xPtr
, int *yPtr
,
1398 int *widthPtr
, int *heightPtr
));
1399 typedef int (Tk_GetElementBorderWidthProc
) _ANSI_ARGS_((ClientData clientData
,
1400 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
));
1401 typedef void (Tk_DrawElementProc
) _ANSI_ARGS_((ClientData clientData
,
1402 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
,
1403 Drawable d
, int x
, int y
, int width
, int height
, int state
));
1405 typedef struct Tk_ElementOptionSpec
{
1406 char *name
; /* Name of the required option. */
1407 Tk_OptionType type
; /* Accepted option type. TK_OPTION_END means
1409 } Tk_ElementOptionSpec
;
1411 typedef struct Tk_ElementSpec
{
1412 int version
; /* Version of the style support. */
1413 char *name
; /* Name of element. */
1414 Tk_ElementOptionSpec
*options
;
1415 /* List of required options. Last one's name
1417 Tk_GetElementSizeProc
*getSize
;
1418 /* Compute the external (resp. internal) size
1419 * of the element from its desired internal
1420 * (resp. external) size. */
1421 Tk_GetElementBoxProc
*getBox
;
1422 /* Compute the inscribed or bounding boxes
1423 * within a given area. */
1424 Tk_GetElementBorderWidthProc
*getBorderWidth
;
1425 /* Return the element's internal border width.
1426 * Mostly useful for widgets. */
1427 Tk_DrawElementProc
*draw
; /* Draw the element in the given bounding
1432 * Element state flags. Can be OR'ed.
1435 #define TK_ELEMENT_STATE_ACTIVE 1<<0
1436 #define TK_ELEMENT_STATE_DISABLED 1<<1
1437 #define TK_ELEMENT_STATE_FOCUS 1<<2
1438 #define TK_ELEMENT_STATE_PRESSED 1<<3
1441 *--------------------------------------------------------------
1443 * The definitions below provide backward compatibility for functions and
1444 * types related to event handling that used to be in Tk but have moved to
1447 *--------------------------------------------------------------
1450 #define TK_READABLE TCL_READABLE
1451 #define TK_WRITABLE TCL_WRITABLE
1452 #define TK_EXCEPTION TCL_EXCEPTION
1454 #define TK_DONT_WAIT TCL_DONT_WAIT
1455 #define TK_X_EVENTS TCL_WINDOW_EVENTS
1456 #define TK_WINDOW_EVENTS TCL_WINDOW_EVENTS
1457 #define TK_FILE_EVENTS TCL_FILE_EVENTS
1458 #define TK_TIMER_EVENTS TCL_TIMER_EVENTS
1459 #define TK_IDLE_EVENTS TCL_IDLE_EVENTS
1460 #define TK_ALL_EVENTS TCL_ALL_EVENTS
1462 #define Tk_IdleProc Tcl_IdleProc
1463 #define Tk_FileProc Tcl_FileProc
1464 #define Tk_TimerProc Tcl_TimerProc
1465 #define Tk_TimerToken Tcl_TimerToken
1467 #define Tk_BackgroundError Tcl_BackgroundError
1468 #define Tk_CancelIdleCall Tcl_CancelIdleCall
1469 #define Tk_CreateFileHandler Tcl_CreateFileHandler
1470 #define Tk_CreateTimerHandler Tcl_CreateTimerHandler
1471 #define Tk_DeleteFileHandler Tcl_DeleteFileHandler
1472 #define Tk_DeleteTimerHandler Tcl_DeleteTimerHandler
1473 #define Tk_DoOneEvent Tcl_DoOneEvent
1474 #define Tk_DoWhenIdle Tcl_DoWhenIdle
1475 #define Tk_Sleep Tcl_Sleep
1477 /* Additional stuff that has moved to Tcl: */
1479 #define Tk_EventuallyFree Tcl_EventuallyFree
1480 #define Tk_FreeProc Tcl_FreeProc
1481 #define Tk_Preserve Tcl_Preserve
1482 #define Tk_Release Tcl_Release
1484 /* Removed Tk_Main, use macro instead */
1485 #define Tk_Main(argc, argv, proc) \
1486 Tk_MainEx(argc, argv, proc, Tcl_CreateInterp())
1488 const char * Tk_InitStubs
_ANSI_ARGS_((Tcl_Interp
*interp
,
1489 const char *version
, int exact
));
1490 EXTERN
const char * Tk_PkgInitStubsCheck
_ANSI_ARGS_((Tcl_Interp
*interp
,
1491 const char *version
, int exact
));
1493 #ifndef USE_TK_STUBS
1495 #define Tk_InitStubs(interp, version, exact) \
1496 Tk_PkgInitStubsCheck(interp, version, exact)
1500 #define Tk_InitImageArgs(interp, argc, argv) /**/
1504 *--------------------------------------------------------------
1506 * Additional procedure types defined by Tk.
1508 *--------------------------------------------------------------
1511 typedef int (Tk_ErrorProc
) _ANSI_ARGS_((ClientData clientData
,
1512 XErrorEvent
*errEventPtr
));
1513 typedef void (Tk_EventProc
) _ANSI_ARGS_((ClientData clientData
,
1515 typedef int (Tk_GenericProc
) _ANSI_ARGS_((ClientData clientData
,
1517 typedef int (Tk_ClientMessageProc
) _ANSI_ARGS_((Tk_Window tkwin
,
1519 typedef int (Tk_GetSelProc
) _ANSI_ARGS_((ClientData clientData
,
1520 Tcl_Interp
*interp
, char *portion
));
1521 typedef void (Tk_LostSelProc
) _ANSI_ARGS_((ClientData clientData
));
1522 typedef Tk_RestrictAction (Tk_RestrictProc
) _ANSI_ARGS_((
1523 ClientData clientData
, XEvent
*eventPtr
));
1524 typedef int (Tk_SelectionProc
) _ANSI_ARGS_((ClientData clientData
,
1525 int offset
, char *buffer
, int maxBytes
));
1528 *--------------------------------------------------------------
1530 * Platform independant exported procedures and variables.
1532 *--------------------------------------------------------------
1535 #include "tkDecls.h"
1538 * Allow users to say that they don't want to alter their source to add extra
1539 * arguments to Tk_PhotoPutBlock() et al; DO NOT DEFINE THIS WHEN BUILDING TK.
1541 * This goes after the inclusion of the stubbed-decls so that the declarations
1542 * of what is actually there can be correct.
1545 #ifdef USE_COMPOSITELESS_PHOTO_PUT_BLOCK
1546 # ifdef Tk_PhotoPutBlock
1547 # undef Tk_PhotoPutBlock
1549 # define Tk_PhotoPutBlock Tk_PhotoPutBlock_NoComposite
1550 # ifdef Tk_PhotoPutZoomedBlock
1551 # undef Tk_PhotoPutZoomedBlock
1553 # define Tk_PhotoPutZoomedBlock Tk_PhotoPutZoomedBlock_NoComposite
1554 # define USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1555 #else /* !USE_COMPOSITELESS_PHOTO_PUT_BLOCK */
1556 # ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1557 # ifdef Tk_PhotoPutBlock
1558 # undef Tk_PhotoPutBlock
1560 # define Tk_PhotoPutBlock Tk_PhotoPutBlock_Panic
1561 # ifdef Tk_PhotoPutZoomedBlock
1562 # undef Tk_PhotoPutZoomedBlock
1564 # define Tk_PhotoPutZoomedBlock Tk_PhotoPutZoomedBlock_Panic
1565 # endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */
1566 #endif /* USE_COMPOSITELESS_PHOTO_PUT_BLOCK */
1567 #ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1568 # ifdef Tk_PhotoExpand
1569 # undef Tk_PhotoExpand
1571 # define Tk_PhotoExpand Tk_PhotoExpand_Panic
1572 # ifdef Tk_PhotoSetSize
1573 # undef Tk_PhotoSetSize
1575 # define Tk_PhotoSetSize Tk_PhotoSetSize_Panic
1576 #endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */
1579 * Tcl commands exported by Tk:
1582 #undef TCL_STORAGE_CLASS
1583 #define TCL_STORAGE_CLASS DLLIMPORT
1585 #endif /* RC_INVOKED */