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.
15 * RCS: @(#) $Id: tk.h,v 1.103 2007/10/26 15:23:05 dgp Exp $
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
27 * For C++ compilers, use extern "C"
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_BETA_RELEASE
56 #define TK_RELEASE_SERIAL 2
58 #define TK_VERSION "8.5"
59 #define TK_PATCH_LEVEL "8.5b2"
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
67 * Resource compilers don't like all the C stuff, like typedefs and procedure
68 * declarations, that occur below, so block them out.
74 # if defined(MAC_OSX_TK)
75 # include <X11/Xlib.h>
78 # include <X11/Xlib.h>
86 # undef TCL_STORAGE_CLASS
87 # define TCL_STORAGE_CLASS DLLEXPORT
91 * Decide whether or not to use input methods.
94 #ifdef XNQueryInputStyle
95 #define TK_USE_INPUT_METHODS
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.
134 TK_OPTION_STRING_TABLE
,
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
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
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
183 int flags
; /* Any combination of the values defined
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
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
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.
246 #define Tk_Offset(type, field) ((int) offsetof(type, field))
248 #define Tk_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
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
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. */
279 # define TK_NUM_SAVED_OPTIONS 2
281 # define TK_NUM_SAVED_OPTIONS 20
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. */
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
307 * This is a temporary flag used while tkObjConfig and new widgets are in
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
,
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
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
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
352 int specFlags
; /* Any combination of the values defined
353 * below; other bits are used internally by
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
362 * Type values for Tk_ConfigSpec structures. See the user documentation for
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
,
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.
403 char *key
; /* The key string that flags the option in the
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
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.
448 TK_DEFER_EVENT
, TK_PROCESS_EVENT
, TK_DISCARD_EVENT
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
488 #define TK_NOTIFY_SHARE 20
491 * Enumerated type for describing a point by which to anchor something:
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
,
501 * Enumerated type for describing a style of justification:
505 TK_JUSTIFY_LEFT
, TK_JUSTIFY_RIGHT
, TK_JUSTIFY_CENTER
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
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
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. */
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
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
,
555 typedef struct Tk_ClassProcs
{
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. */
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
,
596 typedef void (Tk_GeomLostSlaveProc
) _ANSI_ARGS_((ClientData clientData
,
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. */
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 (LASTEvent)
631 #define ActivateNotify (LASTEvent + 1)
632 #define DeactivateNotify (LASTEvent + 2)
633 #define MouseWheelEvent (LASTEvent + 3)
634 #define TK_LASTEVENT (LASTEvent + 4)
636 #define MouseWheelMask (1L << 28)
638 #define ActivateMask (1L << 29)
639 #define VirtualEventMask (1L << 30)
640 #define TK_LASTEVENT (LASTEvent + 4)
643 * A virtual event shares most of its fields with the XKeyEvent and
644 * XButtonEvent structures. 99% of the time a virtual event will be an
645 * abstraction of a key or button event, so this structure provides the most
646 * information to the user. The only difference is the changing of the detail
647 * field for a virtual event so that it holds the name of the virtual event
650 * When using this structure, you should ensure that you zero out all the
651 * fields first using memset() or bzero().
656 unsigned long serial
; /* # of last request processed by server. */
657 Bool send_event
; /* True if this came from a SendEvent
659 Display
*display
; /* Display the event was read from. */
660 Window event
; /* Window on which event was requested. */
661 Window root
; /* Root window that the event occured on. */
662 Window subwindow
; /* Child window. */
663 Time time
; /* Milliseconds. */
664 int x
, y
; /* Pointer x, y coordinates in event
666 int x_root
, y_root
; /* Coordinates relative to root. */
667 unsigned int state
; /* Key or button mask */
668 Tk_Uid name
; /* Name of virtual event. */
669 Bool same_screen
; /* Same screen flag. */
670 Tcl_Obj
*user_data
; /* Application-specific data reference; Tk
671 * will decrement the reference count *once*
672 * when it has finished processing the
678 unsigned long serial
; /* # of last request processed by server. */
679 Bool send_event
; /* True if this came from a SendEvent
681 Display
*display
; /* Display the event was read from. */
682 Window window
; /* Window in which event occurred. */
683 } XActivateDeactivateEvent
;
684 typedef XActivateDeactivateEvent XActivateEvent
;
685 typedef XActivateDeactivateEvent XDeactivateEvent
;
688 *--------------------------------------------------------------
690 * Macros for querying Tk_Window structures. See the manual entries for
693 *--------------------------------------------------------------
696 #define Tk_Display(tkwin) (((Tk_FakeWin *) (tkwin))->display)
697 #define Tk_ScreenNumber(tkwin) (((Tk_FakeWin *) (tkwin))->screenNum)
698 #define Tk_Screen(tkwin) \
699 (ScreenOfDisplay(Tk_Display(tkwin), Tk_ScreenNumber(tkwin)))
700 #define Tk_Depth(tkwin) (((Tk_FakeWin *) (tkwin))->depth)
701 #define Tk_Visual(tkwin) (((Tk_FakeWin *) (tkwin))->visual)
702 #define Tk_WindowId(tkwin) (((Tk_FakeWin *) (tkwin))->window)
703 #define Tk_PathName(tkwin) (((Tk_FakeWin *) (tkwin))->pathName)
704 #define Tk_Name(tkwin) (((Tk_FakeWin *) (tkwin))->nameUid)
705 #define Tk_Class(tkwin) (((Tk_FakeWin *) (tkwin))->classUid)
706 #define Tk_X(tkwin) (((Tk_FakeWin *) (tkwin))->changes.x)
707 #define Tk_Y(tkwin) (((Tk_FakeWin *) (tkwin))->changes.y)
708 #define Tk_Width(tkwin) (((Tk_FakeWin *) (tkwin))->changes.width)
709 #define Tk_Height(tkwin) \
710 (((Tk_FakeWin *) (tkwin))->changes.height)
711 #define Tk_Changes(tkwin) (&((Tk_FakeWin *) (tkwin))->changes)
712 #define Tk_Attributes(tkwin) (&((Tk_FakeWin *) (tkwin))->atts)
713 #define Tk_IsEmbedded(tkwin) \
714 (((Tk_FakeWin *) (tkwin))->flags & TK_EMBEDDED)
715 #define Tk_IsContainer(tkwin) \
716 (((Tk_FakeWin *) (tkwin))->flags & TK_CONTAINER)
717 #define Tk_IsMapped(tkwin) \
718 (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED)
719 #define Tk_IsTopLevel(tkwin) \
720 (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL)
721 #define Tk_HasWrapper(tkwin) \
722 (((Tk_FakeWin *) (tkwin))->flags & TK_HAS_WRAPPER)
723 #define Tk_WinManaged(tkwin) \
724 (((Tk_FakeWin *) (tkwin))->flags & TK_WIN_MANAGED)
725 #define Tk_TopWinHierarchy(tkwin) \
726 (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY)
727 #define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth)
728 #define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight)
729 /* Tk_InternalBorderWidth is deprecated */
730 #define Tk_InternalBorderWidth(tkwin) \
731 (((Tk_FakeWin *) (tkwin))->internalBorderLeft)
732 #define Tk_InternalBorderLeft(tkwin) \
733 (((Tk_FakeWin *) (tkwin))->internalBorderLeft)
734 #define Tk_InternalBorderRight(tkwin) \
735 (((Tk_FakeWin *) (tkwin))->internalBorderRight)
736 #define Tk_InternalBorderTop(tkwin) \
737 (((Tk_FakeWin *) (tkwin))->internalBorderTop)
738 #define Tk_InternalBorderBottom(tkwin) \
739 (((Tk_FakeWin *) (tkwin))->internalBorderBottom)
740 #define Tk_MinReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->minReqWidth)
741 #define Tk_MinReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->minReqHeight)
742 #define Tk_Parent(tkwin) (((Tk_FakeWin *) (tkwin))->parentPtr)
743 #define Tk_Colormap(tkwin) (((Tk_FakeWin *) (tkwin))->atts.colormap)
746 * The structure below is needed by the macros above so that they can access
747 * the fields of a Tk_Window. The fields not needed by the macros are declared
748 * as "dummyX". The structure has its own type in order to prevent apps from
749 * accessing Tk_Window fields except using official macros. WARNING!! The
750 * structure definition must be kept consistent with the TkWindow structure in
751 * tkInt.h. If you change one, then change the other. See the declaration in
752 * tkInt.h for documentation on what the fields are used for internally.
755 typedef struct Tk_FakeWin
{
757 char *dummy1
; /* dispPtr */
762 char *dummy2
; /* childList */
763 char *dummy3
; /* lastChildPtr */
764 Tk_Window parentPtr
; /* parentPtr */
765 char *dummy4
; /* nextPtr */
766 char *dummy5
; /* mainPtr */
770 XWindowChanges changes
;
771 unsigned int dummy6
; /* dirtyChanges */
772 XSetWindowAttributes atts
;
773 unsigned long dummy7
; /* dirtyAtts */
775 char *dummy8
; /* handlerList */
776 #ifdef TK_USE_INPUT_METHODS
777 XIC dummy9
; /* inputContext */
778 #endif /* TK_USE_INPUT_METHODS */
779 ClientData
*dummy10
; /* tagPtr */
780 int dummy11
; /* numTags */
781 int dummy12
; /* optionLevel */
782 char *dummy13
; /* selHandlerList */
783 char *dummy14
; /* geomMgrPtr */
784 ClientData dummy15
; /* geomData */
785 int reqWidth
, reqHeight
;
786 int internalBorderLeft
;
787 char *dummy16
; /* wmInfoPtr */
788 char *dummy17
; /* classProcPtr */
789 ClientData dummy18
; /* instanceData */
790 char *dummy19
; /* privatePtr */
791 int internalBorderRight
;
792 int internalBorderTop
;
793 int internalBorderBottom
;
799 * Flag values for TkWindow (and Tk_FakeWin) structures are:
801 * TK_MAPPED: 1 means window is currently mapped,
803 * TK_TOP_LEVEL: 1 means this is a top-level widget.
804 * TK_ALREADY_DEAD: 1 means the window is in the process of
805 * being destroyed already.
806 * TK_NEED_CONFIG_NOTIFY: 1 means that the window has been reconfigured
807 * before it was made to exist. At the time of
808 * making it exist a ConfigureNotify event needs
810 * TK_GRAB_FLAG: Used to manage grabs. See tkGrab.c for details
811 * TK_CHECKED_IC: 1 means we've already tried to get an input
812 * context for this window; if the ic field is
813 * NULL it means that there isn't a context for
815 * TK_DONT_DESTROY_WINDOW: 1 means that Tk_DestroyWindow should not
816 * invoke XDestroyWindow to destroy this widget's
817 * X window. The flag is set when the window has
818 * already been destroyed elsewhere (e.g. by
819 * another application) or when it will be
820 * destroyed later (e.g. by destroying its parent)
821 * TK_WM_COLORMAP_WINDOW: 1 means that this window has at some time
822 * appeared in the WM_COLORMAP_WINDOWS property
823 * for its toplevel, so we have to remove it from
824 * that property if the window is deleted and the
826 * TK_EMBEDDED: 1 means that this window (which must be a
827 * toplevel) is not a free-standing window but
828 * rather is embedded in some other application.
829 * TK_CONTAINER: 1 means that this window is a container, and
830 * that some other application (either in this
831 * process or elsewhere) may be embedding itself
833 * TK_BOTH_HALVES: 1 means that this window is used for
834 * application embedding (either as container or
835 * embedded application), and both the containing
836 * and embedded halves are associated with
837 * windows in this particular process.
838 * TK_DEFER_MODAL: 1 means that this window has deferred a modal
839 * loop until all of the bindings for the current
840 * event have been invoked.
841 * TK_WRAPPER: 1 means that this window is the extra wrapper
842 * window created around a toplevel to hold the
843 * menubar under Unix. See tkUnixWm.c for more
845 * TK_REPARENTED: 1 means that this window has been reparented
846 * so that as far as the window system is
847 * concerned it isn't a child of its Tk parent.
848 * Initially this is used only for special Unix
850 * TK_ANONYMOUS_WINDOW: 1 means that this window has no name, and is
851 * thus not accessible from Tk.
852 * TK_HAS_WRAPPER 1 means that this window has a wrapper window
853 * TK_WIN_MANAGED 1 means that this window is a child of the root
854 * window, and is managed by the window manager.
855 * TK_TOP_HIERARCHY 1 means this window is at the top of a physical
856 * window hierarchy within this process, i.e. the
857 * window's parent either doesn't exist or is not
858 * owned by this Tk application.
859 * TK_PROP_PROPCHANGE 1 means that PropertyNotify events in the
860 * window's children should propagate up to this
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
885 *--------------------------------------------------------------
887 * Procedure prototypes and structures used for defining new canvas items:
889 *--------------------------------------------------------------
893 TK_STATE_NULL
= -1, TK_STATE_ACTIVE
, TK_STATE_DISABLED
,
894 TK_STATE_NORMAL
, TK_STATE_HIDDEN
897 typedef struct Tk_SmoothMethod
{
899 int (*coordProc
) _ANSI_ARGS_((Tk_Canvas canvas
,
900 double *pointPtr
, int numPoints
, int numSteps
,
901 XPoint xPoints
[], double dblPoints
[]));
902 void (*postscriptProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
903 Tk_Canvas canvas
, double *coordPtr
,
904 int numPoints
, int numSteps
));
908 * For each item in a canvas widget there exists one record with the following
909 * structure. Each actual item is represented by a record with the following
910 * stuff at its beginning, plus additional type-specific stuff after that.
913 #define TK_TAG_SPACE 3
915 typedef struct Tk_Item
{
916 int id
; /* Unique identifier for this item (also
917 * serves as first tag for item). */
918 struct Tk_Item
*nextPtr
; /* Next in display list of all items in this
919 * canvas. Later items in list are drawn on
920 * top of earlier ones. */
921 Tk_Uid staticTagSpace
[TK_TAG_SPACE
];
922 /* Built-in space for limited # of tags. */
923 Tk_Uid
*tagPtr
; /* Pointer to array of tags. Usually points to
924 * staticTagSpace, but may point to malloc-ed
925 * space if there are lots of tags. */
926 int tagSpace
; /* Total amount of tag space available at
928 int numTags
; /* Number of tag slots actually used at
930 struct Tk_ItemType
*typePtr
;/* Table of procedures that implement this
932 int x1
, y1
, x2
, y2
; /* Bounding box for item, in integer canvas
933 * units. Set by item-specific code and
934 * guaranteed to contain every pixel drawn in
935 * item. Item area includes x1 and y1 but not
937 struct Tk_Item
*prevPtr
; /* Previous in display list of all items in
938 * this canvas. Later items in list are drawn
939 * just below earlier ones. */
940 Tk_State state
; /* State of item. */
941 char *reserved1
; /* reserved for future use */
942 int redraw_flags
; /* Some flags used in the canvas */
945 *------------------------------------------------------------------
946 * Starting here is additional type-specific stuff; see the declarations
947 * for individual types to see what is part of each type. The actual space
948 * below is determined by the "itemInfoSize" of the type's Tk_ItemType
950 *------------------------------------------------------------------
955 * Flag bits for canvases (redraw_flags):
957 * TK_ITEM_STATE_DEPENDANT - 1 means that object needs to be redrawn if the
958 * canvas state changes.
959 * TK_ITEM_DONT_REDRAW - 1 means that the object redraw is already been
960 * prepared, so the general canvas code doesn't
961 * need to do that any more.
964 #define TK_ITEM_STATE_DEPENDANT 1
965 #define TK_ITEM_DONT_REDRAW 2
968 * Records of the following type are used to describe a type of item (e.g.
969 * lines, circles, etc.) that can form part of a canvas widget.
972 #ifdef USE_OLD_CANVAS
973 typedef int Tk_ItemCreateProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
974 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
976 typedef int Tk_ItemConfigureProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
977 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
978 char **argv
, int flags
));
979 typedef int Tk_ItemCoordProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
980 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
983 typedef int Tk_ItemCreateProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
984 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
985 Tcl_Obj
*const objv
[]));
986 typedef int Tk_ItemConfigureProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
987 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
988 Tcl_Obj
*const objv
[], int flags
));
989 typedef int Tk_ItemCoordProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
990 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int argc
,
991 Tcl_Obj
*const argv
[]));
993 typedef void Tk_ItemDeleteProc
_ANSI_ARGS_((Tk_Canvas canvas
,
994 Tk_Item
*itemPtr
, Display
*display
));
995 typedef void Tk_ItemDisplayProc
_ANSI_ARGS_((Tk_Canvas canvas
,
996 Tk_Item
*itemPtr
, Display
*display
, Drawable dst
,
997 int x
, int y
, int width
, int height
));
998 typedef double Tk_ItemPointProc
_ANSI_ARGS_((Tk_Canvas canvas
,
999 Tk_Item
*itemPtr
, double *pointPtr
));
1000 typedef int Tk_ItemAreaProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1001 Tk_Item
*itemPtr
, double *rectPtr
));
1002 typedef int Tk_ItemPostscriptProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
1003 Tk_Canvas canvas
, Tk_Item
*itemPtr
, int prepass
));
1004 typedef void Tk_ItemScaleProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1005 Tk_Item
*itemPtr
, double originX
, double originY
,
1006 double scaleX
, double scaleY
));
1007 typedef void Tk_ItemTranslateProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1008 Tk_Item
*itemPtr
, double deltaX
, double deltaY
));
1009 typedef int Tk_ItemIndexProc
_ANSI_ARGS_((Tcl_Interp
*interp
,
1010 Tk_Canvas canvas
, Tk_Item
*itemPtr
, char *indexString
,
1012 typedef void Tk_ItemCursorProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1013 Tk_Item
*itemPtr
, int index
));
1014 typedef int Tk_ItemSelectionProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1015 Tk_Item
*itemPtr
, int offset
, char *buffer
,
1017 typedef void Tk_ItemInsertProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1018 Tk_Item
*itemPtr
, int beforeThis
, char *string
));
1019 typedef void Tk_ItemDCharsProc
_ANSI_ARGS_((Tk_Canvas canvas
,
1020 Tk_Item
*itemPtr
, int first
, int last
));
1022 #ifndef __NO_OLD_CONFIG
1024 typedef struct Tk_ItemType
{
1025 char *name
; /* The name of this type of item, such as
1027 int itemSize
; /* Total amount of space needed for item's
1029 Tk_ItemCreateProc
*createProc
;
1030 /* Procedure to create a new item of this
1032 Tk_ConfigSpec
*configSpecs
; /* Pointer to array of configuration specs for
1033 * this type. Used for returning configuration
1035 Tk_ItemConfigureProc
*configProc
;
1036 /* Procedure to call to change configuration
1038 Tk_ItemCoordProc
*coordProc
;/* Procedure to call to get and set the item's
1040 Tk_ItemDeleteProc
*deleteProc
;
1041 /* Procedure to delete existing item of this
1043 Tk_ItemDisplayProc
*displayProc
;
1044 /* Procedure to display items of this type. */
1045 int alwaysRedraw
; /* Non-zero means displayProc should be called
1046 * even when the item has been moved
1048 Tk_ItemPointProc
*pointProc
;/* Computes distance from item to a given
1050 Tk_ItemAreaProc
*areaProc
; /* Computes whether item is inside, outside,
1051 * or overlapping an area. */
1052 Tk_ItemPostscriptProc
*postscriptProc
;
1053 /* Procedure to write a Postscript description
1054 * for items of this type. */
1055 Tk_ItemScaleProc
*scaleProc
;/* Procedure to rescale items of this type. */
1056 Tk_ItemTranslateProc
*translateProc
;
1057 /* Procedure to translate items of this
1059 Tk_ItemIndexProc
*indexProc
;/* Procedure to determine index of indicated
1060 * character. NULL if item doesn't support
1062 Tk_ItemCursorProc
*icursorProc
;
1063 /* Procedure to set insert cursor posn to just
1064 * before a given position. */
1065 Tk_ItemSelectionProc
*selectionProc
;
1066 /* Procedure to return selection (in STRING
1067 * format) when it is in this item. */
1068 Tk_ItemInsertProc
*insertProc
;
1069 /* Procedure to insert something into an
1071 Tk_ItemDCharsProc
*dCharsProc
;
1072 /* Procedure to delete characters from an
1074 struct Tk_ItemType
*nextPtr
;/* Used to link types together into a list. */
1075 char *reserved1
; /* Reserved for future extension. */
1076 int reserved2
; /* Carefully compatible with */
1077 char *reserved3
; /* Jan Nijtmans dash patch */
1084 * The following structure provides information about the selection and the
1085 * insertion cursor. It is needed by only a few items, such as those that
1086 * display text. It is shared by the generic canvas code and the item-specific
1087 * code, but most of the fields should be written only by the canvas generic
1091 typedef struct Tk_CanvasTextInfo
{
1092 Tk_3DBorder selBorder
; /* Border and background for selected
1093 * characters. Read-only to items.*/
1094 int selBorderWidth
; /* Width of border around selection. Read-only
1096 XColor
*selFgColorPtr
; /* Foreground color for selected text.
1097 * Read-only to items. */
1098 Tk_Item
*selItemPtr
; /* Pointer to selected item. NULL means
1099 * selection isn't in this canvas. Writable by
1101 int selectFirst
; /* Character index of first selected
1102 * character. Writable by items. */
1103 int selectLast
; /* Character index of last selected character.
1104 * Writable by items. */
1105 Tk_Item
*anchorItemPtr
; /* Item corresponding to "selectAnchor": not
1106 * necessarily selItemPtr. Read-only to
1108 int selectAnchor
; /* Character index of fixed end of selection
1109 * (i.e. "select to" operation will use this
1110 * as one end of the selection). Writable by
1112 Tk_3DBorder insertBorder
; /* Used to draw vertical bar for insertion
1113 * cursor. Read-only to items. */
1114 int insertWidth
; /* Total width of insertion cursor. Read-only
1116 int insertBorderWidth
; /* Width of 3-D border around insert cursor.
1117 * Read-only to items. */
1118 Tk_Item
*focusItemPtr
; /* Item that currently has the input focus, or
1119 * NULL if no such item. Read-only to items. */
1120 int gotFocus
; /* Non-zero means that the canvas widget has
1121 * the input focus. Read-only to items.*/
1122 int cursorOn
; /* Non-zero means that an insertion cursor
1123 * should be displayed in focusItemPtr.
1124 * Read-only to items.*/
1125 } Tk_CanvasTextInfo
;
1128 * Structures used for Dashing and Outline.
1131 typedef struct Tk_Dash
{
1135 char array
[sizeof(char *)];
1139 typedef struct Tk_TSOffset
{
1140 int flags
; /* Flags; see below for possible values */
1141 int xoffset
; /* x offset */
1142 int yoffset
; /* y offset */
1146 * Bit fields in Tk_Offset->flags:
1149 #define TK_OFFSET_INDEX 1
1150 #define TK_OFFSET_RELATIVE 2
1151 #define TK_OFFSET_LEFT 4
1152 #define TK_OFFSET_CENTER 8
1153 #define TK_OFFSET_RIGHT 16
1154 #define TK_OFFSET_TOP 32
1155 #define TK_OFFSET_MIDDLE 64
1156 #define TK_OFFSET_BOTTOM 128
1158 typedef struct Tk_Outline
{
1159 GC gc
; /* Graphics context. */
1160 double width
; /* Width of outline. */
1161 double activeWidth
; /* Width of outline. */
1162 double disabledWidth
; /* Width of outline. */
1163 int offset
; /* Dash offset. */
1164 Tk_Dash dash
; /* Dash pattern. */
1165 Tk_Dash activeDash
; /* Dash pattern if state is active. */
1166 Tk_Dash disabledDash
; /* Dash pattern if state is disabled. */
1167 VOID
*reserved1
; /* Reserved for future expansion. */
1170 Tk_TSOffset tsoffset
; /* Stipple offset for outline. */
1171 XColor
*color
; /* Outline color. */
1172 XColor
*activeColor
; /* Outline color if state is active. */
1173 XColor
*disabledColor
; /* Outline color if state is disabled. */
1174 Pixmap stipple
; /* Outline Stipple pattern. */
1175 Pixmap activeStipple
; /* Outline Stipple pattern if state is
1177 Pixmap disabledStipple
; /* Outline Stipple pattern if state is
1182 *--------------------------------------------------------------
1184 * Procedure prototypes and structures used for managing images:
1186 *--------------------------------------------------------------
1189 typedef struct Tk_ImageType Tk_ImageType
;
1190 #ifdef USE_OLD_IMAGE
1191 typedef int (Tk_ImageCreateProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1192 char *name
, int argc
, char **argv
, Tk_ImageType
*typePtr
,
1193 Tk_ImageMaster master
, ClientData
*masterDataPtr
));
1195 typedef int (Tk_ImageCreateProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1196 char *name
, int objc
, Tcl_Obj
*const objv
[], Tk_ImageType
*typePtr
,
1197 Tk_ImageMaster master
, ClientData
*masterDataPtr
));
1199 typedef ClientData (Tk_ImageGetProc
) _ANSI_ARGS_((Tk_Window tkwin
,
1200 ClientData masterData
));
1201 typedef void (Tk_ImageDisplayProc
) _ANSI_ARGS_((ClientData instanceData
,
1202 Display
*display
, Drawable drawable
, int imageX
, int imageY
,
1203 int width
, int height
, int drawableX
, int drawableY
));
1204 typedef void (Tk_ImageFreeProc
) _ANSI_ARGS_((ClientData instanceData
,
1206 typedef void (Tk_ImageDeleteProc
) _ANSI_ARGS_((ClientData masterData
));
1207 typedef void (Tk_ImageChangedProc
) _ANSI_ARGS_((ClientData clientData
,
1208 int x
, int y
, int width
, int height
, int imageWidth
,
1210 typedef int (Tk_ImagePostscriptProc
) _ANSI_ARGS_((ClientData clientData
,
1211 Tcl_Interp
*interp
, Tk_Window tkwin
, Tk_PostscriptInfo psinfo
,
1212 int x
, int y
, int width
, int height
, int prepass
));
1215 * The following structure represents a particular type of image (bitmap, xpm
1216 * image, etc.). It provides information common to all images of that type,
1217 * such as the type name and a collection of procedures in the image manager
1218 * that respond to various events. Each image manager is represented by one of
1222 struct Tk_ImageType
{
1223 char *name
; /* Name of image type. */
1224 Tk_ImageCreateProc
*createProc
;
1225 /* Procedure to call to create a new image of
1227 Tk_ImageGetProc
*getProc
; /* Procedure to call the first time
1228 * Tk_GetImage is called in a new way (new
1229 * visual or screen). */
1230 Tk_ImageDisplayProc
*displayProc
;
1231 /* Call to draw image, in response to
1232 * Tk_RedrawImage calls. */
1233 Tk_ImageFreeProc
*freeProc
; /* Procedure to call whenever Tk_FreeImage is
1234 * called to release an instance of an
1236 Tk_ImageDeleteProc
*deleteProc
;
1237 /* Procedure to call to delete image. It will
1238 * not be called until after freeProc has been
1239 * called for each instance of the image. */
1240 Tk_ImagePostscriptProc
*postscriptProc
;
1241 /* Procedure to call to produce postscript
1242 * output for the image. */
1243 struct Tk_ImageType
*nextPtr
;
1244 /* Next in list of all image types currently
1245 * known. Filled in by Tk, not by image
1247 char *reserved
; /* reserved for future expansion */
1251 *--------------------------------------------------------------
1253 * Additional definitions used to manage images of type "photo".
1255 *--------------------------------------------------------------
1259 * The following type is used to identify a particular photo image to be
1263 typedef void *Tk_PhotoHandle
;
1266 * The following structure describes a block of pixels in memory:
1269 typedef struct Tk_PhotoImageBlock
{
1270 unsigned char *pixelPtr
; /* Pointer to the first pixel. */
1271 int width
; /* Width of block, in pixels. */
1272 int height
; /* Height of block, in pixels. */
1273 int pitch
; /* Address difference between corresponding
1274 * pixels in successive lines. */
1275 int pixelSize
; /* Address difference between successive
1276 * pixels in the same line. */
1277 int offset
[4]; /* Address differences between the red, green,
1278 * blue and alpha components of the pixel and
1279 * the pixel as a whole. */
1280 } Tk_PhotoImageBlock
;
1283 * The following values control how blocks are combined into photo images when
1284 * the alpha component of a pixel is not 255, a.k.a. the compositing rule.
1287 #define TK_PHOTO_COMPOSITE_OVERLAY 0
1288 #define TK_PHOTO_COMPOSITE_SET 1
1291 * Procedure prototypes and structures used in reading and writing photo
1295 typedef struct Tk_PhotoImageFormat Tk_PhotoImageFormat
;
1296 #ifdef USE_OLD_IMAGE
1297 typedef int (Tk_ImageFileMatchProc
) _ANSI_ARGS_((Tcl_Channel chan
,
1298 char *fileName
, char *formatString
, int *widthPtr
, int *heightPtr
));
1299 typedef int (Tk_ImageStringMatchProc
) _ANSI_ARGS_((char *string
,
1300 char *formatString
, int *widthPtr
, int *heightPtr
));
1301 typedef int (Tk_ImageFileReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1302 Tcl_Channel chan
, char *fileName
, char *formatString
,
1303 Tk_PhotoHandle imageHandle
, int destX
, int destY
,
1304 int width
, int height
, int srcX
, int srcY
));
1305 typedef int (Tk_ImageStringReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1306 char *string
, char *formatString
, Tk_PhotoHandle imageHandle
,
1307 int destX
, int destY
, int width
, int height
, int srcX
, int srcY
));
1308 typedef int (Tk_ImageFileWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1309 char *fileName
, char *formatString
, Tk_PhotoImageBlock
*blockPtr
));
1310 typedef int (Tk_ImageStringWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1311 Tcl_DString
*dataPtr
, char *formatString
,
1312 Tk_PhotoImageBlock
*blockPtr
));
1314 typedef int (Tk_ImageFileMatchProc
) _ANSI_ARGS_((Tcl_Channel chan
,
1315 const char *fileName
, Tcl_Obj
*format
, int *widthPtr
,
1316 int *heightPtr
, Tcl_Interp
*interp
));
1317 typedef int (Tk_ImageStringMatchProc
) _ANSI_ARGS_((Tcl_Obj
*dataObj
,
1318 Tcl_Obj
*format
, int *widthPtr
, int *heightPtr
,
1319 Tcl_Interp
*interp
));
1320 typedef int (Tk_ImageFileReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1321 Tcl_Channel chan
, const char *fileName
, Tcl_Obj
*format
,
1322 Tk_PhotoHandle imageHandle
, int destX
, int destY
,
1323 int width
, int height
, int srcX
, int srcY
));
1324 typedef int (Tk_ImageStringReadProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1325 Tcl_Obj
*dataObj
, Tcl_Obj
*format
, Tk_PhotoHandle imageHandle
,
1326 int destX
, int destY
, int width
, int height
, int srcX
, int srcY
));
1327 typedef int (Tk_ImageFileWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1328 const char *fileName
, Tcl_Obj
*format
, Tk_PhotoImageBlock
*blockPtr
));
1329 typedef int (Tk_ImageStringWriteProc
) _ANSI_ARGS_((Tcl_Interp
*interp
,
1330 Tcl_Obj
*format
, Tk_PhotoImageBlock
*blockPtr
));
1334 * The following structure represents a particular file format for storing
1335 * images (e.g., PPM, GIF, JPEG, etc.). It provides information to allow image
1336 * files of that format to be recognized and read into a photo image.
1339 struct Tk_PhotoImageFormat
{
1340 char *name
; /* Name of image file format */
1341 Tk_ImageFileMatchProc
*fileMatchProc
;
1342 /* Procedure to call to determine whether an
1343 * image file matches this format. */
1344 Tk_ImageStringMatchProc
*stringMatchProc
;
1345 /* Procedure to call to determine whether the
1346 * data in a string matches this format. */
1347 Tk_ImageFileReadProc
*fileReadProc
;
1348 /* Procedure to call to read data from an
1349 * image file into a photo image. */
1350 Tk_ImageStringReadProc
*stringReadProc
;
1351 /* Procedure to call to read data from a
1352 * string into a photo image. */
1353 Tk_ImageFileWriteProc
*fileWriteProc
;
1354 /* Procedure to call to write data from a
1355 * photo image to a file. */
1356 Tk_ImageStringWriteProc
*stringWriteProc
;
1357 /* Procedure to call to obtain a string
1358 * representation of the data in a photo
1360 struct Tk_PhotoImageFormat
*nextPtr
;
1361 /* Next in list of all photo image formats
1362 * currently known. Filled in by Tk, not by
1363 * image format handler. */
1366 #ifdef USE_OLD_IMAGE
1367 #define Tk_CreateImageType Tk_CreateOldImageType
1368 #define Tk_CreatePhotoImageFormat Tk_CreateOldPhotoImageFormat
1372 *--------------------------------------------------------------
1374 * Procedure prototypes and structures used for managing styles:
1376 *--------------------------------------------------------------
1380 * Style support version tag.
1383 #define TK_STYLE_VERSION_1 0x1
1384 #define TK_STYLE_VERSION TK_STYLE_VERSION_1
1387 * The following structures and prototypes are used as static templates to
1388 * declare widget elements.
1391 typedef void (Tk_GetElementSizeProc
) _ANSI_ARGS_((ClientData clientData
,
1392 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
,
1393 int width
, int height
, int inner
, int *widthPtr
, int *heightPtr
));
1394 typedef void (Tk_GetElementBoxProc
) _ANSI_ARGS_((ClientData clientData
,
1395 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
,
1396 int x
, int y
, int width
, int height
, int inner
, int *xPtr
, int *yPtr
,
1397 int *widthPtr
, int *heightPtr
));
1398 typedef int (Tk_GetElementBorderWidthProc
) _ANSI_ARGS_((ClientData clientData
,
1399 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
));
1400 typedef void (Tk_DrawElementProc
) _ANSI_ARGS_((ClientData clientData
,
1401 char *recordPtr
, const Tk_OptionSpec
**optionsPtr
, Tk_Window tkwin
,
1402 Drawable d
, int x
, int y
, int width
, int height
, int state
));
1404 typedef struct Tk_ElementOptionSpec
{
1405 char *name
; /* Name of the required option. */
1406 Tk_OptionType type
; /* Accepted option type. TK_OPTION_END means
1408 } Tk_ElementOptionSpec
;
1410 typedef struct Tk_ElementSpec
{
1411 int version
; /* Version of the style support. */
1412 char *name
; /* Name of element. */
1413 Tk_ElementOptionSpec
*options
;
1414 /* List of required options. Last one's name
1416 Tk_GetElementSizeProc
*getSize
;
1417 /* Compute the external (resp. internal) size
1418 * of the element from its desired internal
1419 * (resp. external) size. */
1420 Tk_GetElementBoxProc
*getBox
;
1421 /* Compute the inscribed or bounding boxes
1422 * within a given area. */
1423 Tk_GetElementBorderWidthProc
*getBorderWidth
;
1424 /* Return the element's internal border width.
1425 * Mostly useful for widgets. */
1426 Tk_DrawElementProc
*draw
; /* Draw the element in the given bounding
1431 * Element state flags. Can be OR'ed.
1434 #define TK_ELEMENT_STATE_ACTIVE 1<<0
1435 #define TK_ELEMENT_STATE_DISABLED 1<<1
1436 #define TK_ELEMENT_STATE_FOCUS 1<<2
1437 #define TK_ELEMENT_STATE_PRESSED 1<<3
1440 *--------------------------------------------------------------
1442 * The definitions below provide backward compatibility for functions and
1443 * types related to event handling that used to be in Tk but have moved to
1446 *--------------------------------------------------------------
1449 #define TK_READABLE TCL_READABLE
1450 #define TK_WRITABLE TCL_WRITABLE
1451 #define TK_EXCEPTION TCL_EXCEPTION
1453 #define TK_DONT_WAIT TCL_DONT_WAIT
1454 #define TK_X_EVENTS TCL_WINDOW_EVENTS
1455 #define TK_WINDOW_EVENTS TCL_WINDOW_EVENTS
1456 #define TK_FILE_EVENTS TCL_FILE_EVENTS
1457 #define TK_TIMER_EVENTS TCL_TIMER_EVENTS
1458 #define TK_IDLE_EVENTS TCL_IDLE_EVENTS
1459 #define TK_ALL_EVENTS TCL_ALL_EVENTS
1461 #define Tk_IdleProc Tcl_IdleProc
1462 #define Tk_FileProc Tcl_FileProc
1463 #define Tk_TimerProc Tcl_TimerProc
1464 #define Tk_TimerToken Tcl_TimerToken
1466 #define Tk_BackgroundError Tcl_BackgroundError
1467 #define Tk_CancelIdleCall Tcl_CancelIdleCall
1468 #define Tk_CreateFileHandler Tcl_CreateFileHandler
1469 #define Tk_CreateTimerHandler Tcl_CreateTimerHandler
1470 #define Tk_DeleteFileHandler Tcl_DeleteFileHandler
1471 #define Tk_DeleteTimerHandler Tcl_DeleteTimerHandler
1472 #define Tk_DoOneEvent Tcl_DoOneEvent
1473 #define Tk_DoWhenIdle Tcl_DoWhenIdle
1474 #define Tk_Sleep Tcl_Sleep
1476 /* Additional stuff that has moved to Tcl: */
1478 #define Tk_EventuallyFree Tcl_EventuallyFree
1479 #define Tk_FreeProc Tcl_FreeProc
1480 #define Tk_Preserve Tcl_Preserve
1481 #define Tk_Release Tcl_Release
1483 /* Removed Tk_Main, use macro instead */
1484 #define Tk_Main(argc, argv, proc) \
1485 Tk_MainEx(argc, argv, proc, Tcl_CreateInterp())
1487 const char * Tk_InitStubs
_ANSI_ARGS_((Tcl_Interp
*interp
,
1488 const char *version
, int exact
));
1489 const char * Tk_PkgInitStubsCheck
_ANSI_ARGS_((Tcl_Interp
*interp
,
1490 const char *version
, int exact
));
1492 #ifndef USE_TK_STUBS
1494 #define Tk_InitStubs(interp, version, exact) \
1495 Tk_PkgInitStubsCheck(interp, version, exact)
1499 #define Tk_InitImageArgs(interp, argc, argv) /**/
1503 *--------------------------------------------------------------
1505 * Additional procedure types defined by Tk.
1507 *--------------------------------------------------------------
1510 typedef int (Tk_ErrorProc
) _ANSI_ARGS_((ClientData clientData
,
1511 XErrorEvent
*errEventPtr
));
1512 typedef void (Tk_EventProc
) _ANSI_ARGS_((ClientData clientData
,
1514 typedef int (Tk_GenericProc
) _ANSI_ARGS_((ClientData clientData
,
1516 typedef int (Tk_ClientMessageProc
) _ANSI_ARGS_((Tk_Window tkwin
,
1518 typedef int (Tk_GetSelProc
) _ANSI_ARGS_((ClientData clientData
,
1519 Tcl_Interp
*interp
, char *portion
));
1520 typedef void (Tk_LostSelProc
) _ANSI_ARGS_((ClientData clientData
));
1521 typedef Tk_RestrictAction (Tk_RestrictProc
) _ANSI_ARGS_((
1522 ClientData clientData
, XEvent
*eventPtr
));
1523 typedef int (Tk_SelectionProc
) _ANSI_ARGS_((ClientData clientData
,
1524 int offset
, char *buffer
, int maxBytes
));
1527 *--------------------------------------------------------------
1529 * Platform independant exported procedures and variables.
1531 *--------------------------------------------------------------
1534 #include "tkDecls.h"
1537 * Allow users to say that they don't want to alter their source to add extra
1538 * arguments to Tk_PhotoPutBlock() et al; DO NOT DEFINE THIS WHEN BUILDING TK.
1540 * This goes after the inclusion of the stubbed-decls so that the declarations
1541 * of what is actually there can be correct.
1544 #ifdef USE_COMPOSITELESS_PHOTO_PUT_BLOCK
1545 # ifdef Tk_PhotoPutBlock
1546 # undef Tk_PhotoPutBlock
1548 # define Tk_PhotoPutBlock Tk_PhotoPutBlock_NoComposite
1549 # ifdef Tk_PhotoPutZoomedBlock
1550 # undef Tk_PhotoPutZoomedBlock
1552 # define Tk_PhotoPutZoomedBlock Tk_PhotoPutZoomedBlock_NoComposite
1553 # define USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1554 #else /* !USE_COMPOSITELESS_PHOTO_PUT_BLOCK */
1555 # ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1556 # ifdef Tk_PhotoPutBlock
1557 # undef Tk_PhotoPutBlock
1559 # define Tk_PhotoPutBlock Tk_PhotoPutBlock_Panic
1560 # ifdef Tk_PhotoPutZoomedBlock
1561 # undef Tk_PhotoPutZoomedBlock
1563 # define Tk_PhotoPutZoomedBlock Tk_PhotoPutZoomedBlock_Panic
1564 # endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */
1565 #endif /* USE_COMPOSITELESS_PHOTO_PUT_BLOCK */
1566 #ifdef USE_PANIC_ON_PHOTO_ALLOC_FAILURE
1567 # ifdef Tk_PhotoExpand
1568 # undef Tk_PhotoExpand
1570 # define Tk_PhotoExpand Tk_PhotoExpand_Panic
1571 # ifdef Tk_PhotoSetSize
1572 # undef Tk_PhotoSetSize
1574 # define Tk_PhotoSetSize Tk_PhotoSetSize_Panic
1575 #endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */
1578 * Tcl commands exported by Tk:
1581 #undef TCL_STORAGE_CLASS
1582 #define TCL_STORAGE_CLASS DLLIMPORT
1584 #endif /* RC_INVOKED */