]> git.zerfleddert.de Git - micropolis/blob - src/tk/tkint.h
shrink game window to fit on screen if necessary
[micropolis] / src / tk / tkint.h
1 /*
2 * tkInt.h --
3 *
4 * Declarations for things used internally by the Tk
5 * procedures but not exported outside the module.
6 *
7 * Copyright 1990-1992 Regents of the University of California.
8 * Permission to use, copy, modify, and distribute this
9 * software and its documentation for any purpose and without
10 * fee is hereby granted, provided that the above copyright
11 * notice appear in all copies. The University of California
12 * makes no representations about the suitability of this
13 * software for any purpose. It is provided "as is" without
14 * express or implied warranty.
15 *
16 * $Header: /user6/ouster/wish/RCS/tkInt.h,v 1.65 92/08/21 11:42:27 ouster Exp $ SPRITE (Berkeley)
17 */
18
19 #ifndef _TKINT
20 #define _TKINT
21
22 #ifndef _XLIB_H_
23 #include <X11/Xlib.h>
24 #ifdef IS_LINUX
25 #include <X11/Xlibint.h>
26 #endif
27 #endif
28 #ifndef _XUTIL_H
29 #include <X11/Xutil.h>
30 #endif
31 #ifndef _TK
32 #include "tk.h"
33 #endif
34 #ifndef _TCL
35 #include "tcl.h"
36 #endif
37 #ifndef _TCLHASH
38 #include "tclhash.h"
39 #endif
40
41 /*
42 * One of the following structures is maintained for each display
43 * containing a window managed by Tk:
44 */
45
46 typedef struct TkDisplay {
47 Display *display; /* Xlib's info about display. */
48 struct TkDisplay *nextPtr; /* Next in list of all displays. */
49 char *name; /* Name of display (with any screen
50 * identifier removed). Malloc-ed. */
51 Time lastEventTime; /* Time of last event received for this
52 * display. */
53
54 /*
55 * Information used by tkEvent.c only:
56 */
57
58 struct TkWindow *mouseMainPtr;
59 /* Pointer to the main window of this
60 * display that currently contains the
61 * mouse pointer. NULL means the pointer
62 * isn't in a main window managed by
63 * this process. */
64
65 /*
66 * Information used by tkBind.c only:
67 */
68
69 int firstKeycode; /* First keycode supported by
70 * display. */
71 int lastKeycode; /* Last keycode supported by
72 * display. */
73 int symsPerCode; /* Number of KeySyms in "keySyms"
74 * for each keycode. 0 means the
75 * keysym information hasn't been
76 * retrieved from the server yet. */
77 KeySym *keySyms; /* Array of KeySyms, returned by
78 * XGetKeyboardMapping. */
79
80 /*
81 * Information used by tkError.c only:
82 */
83
84 struct TkErrorHandler *errorPtr;
85 /* First in list of error handlers
86 * for this display. NULL means
87 * no handlers exist at present. */
88 int deleteCount; /* Counts # of handlers deleted since
89 * last time inactive handlers were
90 * garbage-collected. When this number
91 * gets big, handlers get cleaned up. */
92
93 /*
94 * Information used by tkSend.c only:
95 */
96
97 Tk_Window commWindow; /* Window used for communication
98 * between interpreters during "send"
99 * commands. NULL means send info hasn't
100 * been initialized yet. */
101 Atom commProperty; /* X's name for comm property. */
102 Atom registryProperty; /* X's name for property containing
103 * registry of interpreter names. */
104
105 /*
106 * Information used by tkSelect.c only:
107 */
108
109 Tk_Window selectionOwner; /* Current owner of selection, or
110 * NULL if selection isn't owned by
111 * a window in this process. */
112 int selectionSerial; /* Serial number of last XSelectionSetOwner
113 * request we made to server (used to
114 * filter out redundant SelectionClear
115 * events. */
116 Time selectionTime; /* Timestamp used to acquire selection. */
117 Atom multipleAtom; /* Atom for MULTIPLE. None means
118 * selection stuff isn't initialized. */
119 Atom incrAtom; /* Atom for INCR. */
120 Atom targetsAtom; /* Atom for TARGETS. */
121 Atom timestampAtom; /* Atom for TIMESTAMP. */
122 Atom textAtom; /* Atom for TEXT. */
123 Atom compoundTextAtom; /* Atom for COMPOUND_TEXT. */
124
125 /*
126 * Information used by tkAtom.c only:
127 */
128
129 int atomInit; /* 0 means stuff below hasn't been
130 * initialized yet. */
131 Tcl_HashTable nameTable; /* Maps from names to Atom's. */
132 Tcl_HashTable atomTable; /* Maps from Atom's back to names. */
133
134 /*
135 * Information used by tkCursor.c only:
136 */
137
138 Font cursorFont; /* Font to use for standard cursors.
139 * None means font not loaded yet. */
140
141 /*
142 * Information used by tkGrab.c only:
143 */
144
145 struct TkWindow *grabWinPtr;
146 /* Window in which the pointer is currently
147 * grabbed, or NULL if none. */
148 struct TkWindow *ungrabWinPtr;
149 /* Window to which pointer should be returned
150 * when the current grab ends (i.e. the
151 * window that the mouse is really on top
152 * of). */
153 struct TkWindow *buttonWinPtr;
154 /* Window in which first mouse button was
155 * pressed while grab was in effect, or NULL
156 * if no such press in effect. */
157 struct TkWindow *pointerWinPtr;
158 /* The window that officially contains the
159 * pointer, as far as this application is
160 * concerned. If a grab is in effect then
161 * this may not be the window that's underneath
162 * the pointer. NULL means the application
163 * doesn't consider the pointer to be in any
164 * window. */
165 struct TkWindow *serverWinPtr;
166 /* The window that contains the pointer, as
167 * far as the X server is concerned. This
168 * field gets set on every Enter or Leave
169 * event even if the grab code eventually
170 * discards the event. NULL means the server
171 * thinks the pointer is outside any window
172 * of any application on this screen. */
173 int grabFlags; /* Miscellaneous flag values. See definitions
174 * in tkGrab.c. */
175 /* XXX: FOCUS */
176 struct TkWindow *focusPtr; /* Identifies window that currently has the
177 * focus (or that will get the focus the next
178 * time the pointer enters any of the top-level
179 * windows associated with this display).
180 * NULL means nobody has the focus.
181 * Managed by tkEvent.c. */
182 } TkDisplay;
183
184 /*
185 * One of the following structures exists for each error handler
186 * created by a call to Tk_CreateErrorHandler. The structure
187 * is managed by tkError.c.
188 */
189
190 typedef struct TkErrorHandler {
191 TkDisplay *dispPtr; /* Display to which handler applies. */
192 unsigned long firstRequest; /* Only errors with serial numbers
193 * >= to this are considered. */
194 unsigned long lastRequest; /* Only errors with serial numbers
195 * <= to this are considered. This
196 * field is filled in when XUnhandle
197 * is called. -1 means XUnhandle
198 * hasn't been called yet. */
199 int error; /* Consider only errors with this
200 * error_code (-1 means consider
201 * all errors). */
202 int request; /* Consider only errors with this
203 * major request code (-1 means
204 * consider all major codes). */
205 int minorCode; /* Consider only errors with this
206 * minor request code (-1 means
207 * consider all minor codes). */
208 Tk_ErrorProc *errorProc; /* Procedure to invoke when a matching
209 * error occurs. NULL means just ignore
210 * errors. */
211 ClientData clientData; /* Arbitrary value to pass to
212 * errorProc. */
213 struct TkErrorHandler *nextPtr;
214 /* Pointer to next older handler for
215 * this display, or NULL for end of
216 * list. */
217 } TkErrorHandler;
218
219 /*
220 * One of the following structures exists for each event handler
221 * created by calling Tk_CreateEventHandler. This information
222 * is used by tkEvent.c only.
223 */
224
225 typedef struct TkEventHandler {
226 unsigned long mask; /* Events for which to invoke
227 * proc. */
228 Tk_EventProc *proc; /* Procedure to invoke when an event
229 * in mask occurs. */
230 ClientData clientData; /* Argument to pass to proc. */
231 struct TkEventHandler *nextPtr;
232 /* Next in list of handlers
233 * associated with window (NULL means
234 * end of list). */
235 } TkEventHandler;
236
237 /*
238 * One of the following structures exists for each selection
239 * handler created by calling Tk_CreateSelHandler. This
240 * information is used by tkSelect.c only.
241 */
242
243 typedef struct TkSelHandler {
244 Atom target; /* Target type for selection
245 * conversion, such as TARGETS or
246 * STRING. */
247 Atom format; /* Format in which selection
248 * info will be returned, such
249 * as STRING or ATOM. */
250 Tk_SelectionProc *proc; /* Procedure to generate selection
251 * in this format. */
252 ClientData clientData; /* Argument to pass to proc. */
253 int size; /* Size of units returned by proc
254 * (8 for STRING, 32 for almost
255 * anything else). */
256 struct TkSelHandler *nextPtr;
257 /* Next selection handler associated
258 * with same window (NULL for end of
259 * list). */
260 } TkSelHandler;
261
262 /*
263 * Tk keeps one of the following data structures for each main
264 * window (created by a call to Tk_CreateMainWindow). It stores
265 * information that is shared by all of the windows associated
266 * with a particular main window.
267 */
268
269 typedef struct TkMainInfo {
270 struct TkWindow *winPtr; /* Pointer to main window. */
271 Tcl_Interp *interp; /* Interpreter associated with application. */
272 Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow
273 * structs for all windows related to this
274 * main window. Managed by tkWindow.c. */
275 Tk_BindingTable bindingTable;
276 /* Used in conjunction with "bind" command
277 * to bind events to Tcl commands. */
278 /* XXX: FOCUS */
279 /* struct TkWindow *focusPtr; */ /* Identifies window that currently has the
280 * focus (or that will get the focus the next
281 * time the pointer enters any of the top-level
282 * windows associated with this display).
283 * NULL means nobody has the focus.
284 * Managed by tkEvent.c. */
285 struct ElArray *optionRootPtr;
286 /* Top level of option hierarchy for this
287 * main window. NULL means uninitialized.
288 * Managed by tkOption.c. */
289 } TkMainInfo;
290
291 /*
292 * Tk keeps one of the following structures for each window.
293 * Some of the information (like size and location) is a shadow
294 * of information managed by the X server, and some is special
295 * information used here, such as event and geometry management
296 * information. This information is (mostly) managed by tkWindow.c.
297 * WARNING: the declaration below must be kept consistent with the
298 * Tk_ClientWindow structure in tk.h. If you change one, be sure to
299 * change the other!!
300 */
301
302 typedef struct TkWindow {
303
304 /*
305 * Structural information:
306 */
307
308 Display *display; /* Display containing window. */
309 TkDisplay *dispPtr; /* Tk's information about display
310 * for window. */
311 int screenNum; /* Index of screen for window, among all
312 * those for dispPtr. */
313 Window window; /* X's id for window. NULL means window
314 * hasn't actually been created yet, or it's
315 * been deleted. */
316 struct TkWindow *childList; /* First in list of child windows,
317 * or NULL if no children. */
318 struct TkWindow *parentPtr; /* Pointer to parent window (logical
319 * parent, not necessarily X parent), or
320 * NULL if this is a main window. */
321 struct TkWindow *nextPtr; /* Next in list of children with
322 * same parent (NULL if end of
323 * list). */
324 TkMainInfo *mainPtr; /* Information shared by all windows
325 * associated with a particular main
326 * window. NULL means this window is
327 * a rogue that isn't associated with
328 * any application (at present, there
329 * should never be any rogues). */
330
331 /*
332 * Name and type information for the window:
333 */
334
335 char *pathName; /* Path name of window (concatenation
336 * of all names between this window and
337 * its top-level ancestor). This is a
338 * pointer into an entry in
339 * mainPtr->nameTable or NULL if mainPtr
340 * is NULL. */
341 Tk_Uid nameUid; /* Name of the window within its parent
342 * (unique within the parent). */
343 Tk_Uid classUid; /* Class of the window. NULL means window
344 * hasn't been given a class yet. */
345
346 /*
347 * Geometry and other attributes of window. This information
348 * may not be updated on the server immediately; stuff that
349 * hasn't been reflected in the server yet is called "dirty".
350 * At present, information can be dirty only if the window
351 * hasn't yet been created.
352 */
353
354 XWindowChanges changes; /* Geometry and other info about
355 * window. */
356 unsigned int dirtyChanges; /* Bits indicate fields of "changes"
357 * that are dirty. */
358 XSetWindowAttributes atts; /* Current attributes of window. */
359 unsigned long dirtyAtts; /* Bits indicate fields of "atts"
360 * that are dirty. */
361
362 unsigned int flags; /* Various flag values: these are all
363 * defined in tk.h (confusing, but they're
364 * needed there for some query macros). */
365
366 /*
367 * Information kept by the event manager (tkEvent.c):
368 */
369
370 TkEventHandler *handlerList;/* First in list of event handlers
371 * declared for this window, or
372 * NULL if none. */
373 /*
374 * Information related to input focussing (tkEvent.c):
375 */
376
377 Tk_FocusProc *focusProc; /* Procedure to invoke when this window
378 * gets or loses the input focus. NULL
379 * means this window is not prepared to
380 * receive the focus. */
381 ClientData focusData; /* Arbitrary value to pass to focusProc. */
382
383 /*
384 * Information used by tkOption.c to manage options for the
385 * window.
386 */
387
388 int optionLevel; /* -1 means no option information is
389 * currently cached for this window.
390 * Otherwise this gives the level in
391 * the option stack at which info is
392 * cached. */
393 /*
394 * Information used by tkSelect.c to manage the selection.
395 */
396
397 TkSelHandler *selHandlerList;
398 /* First in list of handlers for
399 * returning the selection in various
400 * forms. */
401 Tk_LostSelProc *selClearProc;
402 ClientData selClearData; /* Info to pass to selClearProc. */
403
404 /*
405 * Information used by tkGeometry.c for geometry management.
406 */
407
408 Tk_GeometryProc *geomProc; /* Procedure to handle geometry
409 * requests (NULL means no window is
410 * unmanaged). */
411 ClientData geomData; /* Argument for geomProc. */
412 int reqWidth, reqHeight; /* Arguments from last call to
413 * Tk_GeometryRequest, or 0's if
414 * Tk_GeometryRequest hasn't been
415 * called. */
416 int internalBorderWidth; /* Width of internal border of window
417 * (0 means no internal border). Geom.
418 * mgr. should not place children on top
419 * of the border. */
420
421 /*
422 * Information maintained by tkWm.c for window manager communication.
423 */
424
425 struct TkWmInfo *wmInfoPtr; /* For top-level windows, points to
426 * structure with wm-related info (see
427 * tkWm.c). For other windows, this
428 * is NULL. */
429 } TkWindow;
430
431 /*
432 * The context below is used to map from an X window id to
433 * the TkWindow structure associated with the window.
434 */
435
436 extern XContext tkWindowContext;
437
438 /*
439 * Pointer to first entry in list of all displays currently known.
440 */
441
442 extern TkDisplay *tkDisplayList;
443
444 /*
445 * Flags passed to TkMeasureChars:
446 */
447
448 #define TK_WHOLE_WORDS 1
449 #define TK_AT_LEAST_ONE 2
450 #define TK_PARTIAL_OK 4
451 #define TK_NEWLINES_NOT_SPECIAL 8
452
453 /*
454 * Location of library directory containing Tk scripts. This value
455 * is put in the $tkLibrary variable for each application.
456 */
457
458 #ifndef TK_LIBRARY
459 #ifdef MSDOS
460 #define TK_LIBRARY "res/tk"
461 #else
462 #define TK_LIBRARY "/usr/local/lib/tk"
463 #endif
464 #endif
465
466 /*
467 * See tkShare.c for explanation of following disgusting variable:
468 */
469
470 extern XEvent *tkShareEventPtr;
471
472 /*
473 * Secret way to inhibit event collapsing. -deh
474 */
475
476 extern int tkCollapseMotion;
477
478 /*
479 * Secret way to break out to Tk_MainLoop. -deh
480 */
481
482 extern int tkMustExit;
483
484 /*
485 * Miscellaneous variables shared among Tk modules but not exported
486 * to the outside world:
487 */
488
489 extern Tk_Uid tkActiveUid;
490 extern Tk_Uid tkDisabledUid;
491 extern Tk_Uid tkNormalUid;
492
493 /*
494 * Internal procedures shared among Tk modules but not exported
495 * to the outside world:
496 */
497
498 extern int TkAreaToPolygon _ANSI_ARGS_((double *polyPtr,
499 int numPoints, double *rectPtr));
500 extern void TkBezierPoints _ANSI_ARGS_((double control[],
501 int numSteps, double *coordPtr));
502 extern void TkBindError _ANSI_ARGS_((Tcl_Interp *interp));
503 extern void TkBindEventProc _ANSI_ARGS_((TkWindow *winPtr,
504 XEvent *eventPtr));
505 extern Time TkCurrentTime _ANSI_ARGS_((TkDisplay *dispPtr));
506 extern int TkDeadAppCmd _ANSI_ARGS_((ClientData clientData,
507 Tcl_Interp *interp, int argc, char **argv));
508 extern void TkDisplayChars _ANSI_ARGS_((Display *display,
509 Drawable drawable, GC gc,
510 XFontStruct *fontStructPtr, char *string,
511 int numChars, int x, int y, int flags));
512 extern void TkEventDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
513 extern void TkFocusEventProc _ANSI_ARGS_((TkWindow *winPtr,
514 XEvent *eventPtr));
515 extern void TkGetButtPoints _ANSI_ARGS_((double p1[], double p2[],
516 double width, int project, double m1[],
517 double m2[]));
518 extern int TkGetInterpNames _ANSI_ARGS_((Tcl_Interp *interp,
519 Tk_Window tkwin));
520 extern int TkGetMiterPoints _ANSI_ARGS_((double p1[], double p2[],
521 double p3[], double width, double m1[],
522 double m2[]));
523 extern void TkGrabDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
524 extern int TkLineToArea _ANSI_ARGS_((double end1Ptr[2],
525 double end2Ptr[2], double rectPtr[4]));
526 extern double TkLineToPoint _ANSI_ARGS_((double end1Ptr[2],
527 double end2Ptr[2], double pointPtr[2]));
528 extern int TkMeasureChars _ANSI_ARGS_((XFontStruct *fontStructPtr,
529 char *source, int maxChars, int startX, int maxX,
530 int flags, int *nextXPtr));
531 extern void TkOptionDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
532 extern int TkOvalToArea _ANSI_ARGS_((double *ovalPtr,
533 double *rectPtr));
534 extern double TkOvalToPoint _ANSI_ARGS_((double ovalPtr[4],
535 double width, int filled, double pointPtr[2]));
536 extern int TkPointerEvent _ANSI_ARGS_((XEvent *eventPtr,
537 TkWindow *winPtr));
538 extern int TkPolygonToArea _ANSI_ARGS_((double *polyPtr,
539 int numPoints, double *rectPtr));
540 extern double TkPolygonToPoint _ANSI_ARGS_((double *polyPtr,
541 int numPoints, double *pointPtr));
542 extern void TkSelDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
543 extern void TkSelEventProc _ANSI_ARGS_((Tk_Window tkwin,
544 XEvent *eventPtr));
545 extern void TkSelPropProc _ANSI_ARGS_((XEvent *eventPtr));
546 extern void TkUnderlineChars _ANSI_ARGS_((Display *display,
547 Drawable drawable, GC gc,
548 XFontStruct *fontStructPtr, char *string,
549 int x, int y, int flags, int firstChar,
550 int lastChar));
551 extern void TkWmDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
552 extern int TkWmMapWindow _ANSI_ARGS_((TkWindow *winPtr));
553 extern void TkWmSetClass _ANSI_ARGS_((TkWindow *winPtr));
554 extern void TkWmNewWindow _ANSI_ARGS_((TkWindow *winPtr));
555
556 #endif /* _TKINT */
Impressum, Datenschutz