]> cvs.zerfleddert.de Git - micropolis/blob - src/tk/tkcvwind.c
Fixes for compilation with gcc 15
[micropolis] / src / tk / tkcvwind.c
1 /*
2 * tkCanvWind.c --
3 *
4 * This file implements window items for canvas widgets.
5 *
6 * Copyright 1992 Regents of the University of California.
7 * Permission to use, copy, modify, and distribute this
8 * software and its documentation for any purpose and without
9 * fee is hereby granted, provided that the above copyright
10 * notice appear in all copies. The University of California
11 * makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without
13 * express or implied warranty.
14 */
15
16 #ifndef lint
17 static char rcsid[] = "$Header: /user6/ouster/wish/RCS/tkCanvWind.c,v 1.4 92/08/24 09:24:22 ouster Exp $ SPRITE (Berkeley)";
18 #endif
19
20 #include <stdio.h>
21 #include <math.h>
22 #include "tkint.h"
23 #include "tkcanvas.h"
24
25 /*
26 * The structure below defines the record for each window item.
27 */
28
29 typedef struct WindowItem {
30 Tk_Item header; /* Generic stuff that's the same for all
31 * types. MUST BE FIRST IN STRUCTURE. */
32 double x, y; /* Coordinates of positioning point for
33 * window. */
34 Tk_Window tkwin; /* Window associated with item. NULL means
35 * window has been destroyed. */
36 int width; /* Width to use for window (<= 0 means use
37 * window's requested width). */
38 int height; /* Width to use for window (<= 0 means use
39 * window's requested width). */
40 Tk_Anchor anchor; /* Where to anchor window relative to
41 * (x,y). */
42 Tk_Canvas *canvasPtr; /* Canvas containing this item. */
43 } WindowItem;
44
45 /*
46 * Information used for parsing configuration specs:
47 */
48
49 static Tk_ConfigSpec configSpecs[] = {
50 {TK_CONFIG_ANCHOR, "-anchor", (char *) NULL, (char *) NULL,
51 "center", Tk_Offset(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT},
52 {TK_CONFIG_PIXELS, "-height", (char *) NULL, (char *) NULL,
53 "0", Tk_Offset(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT},
54 {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
55 (char *) NULL, 0, TK_CONFIG_NULL_OK, &tkCanvasTagsOption},
56 {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
57 "0", Tk_Offset(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT},
58 {TK_CONFIG_WINDOW, "-window", (char *) NULL, (char *) NULL,
59 (char *) NULL, Tk_Offset(WindowItem, tkwin), TK_CONFIG_NULL_OK},
60 {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
61 (char *) NULL, 0, 0}
62 };
63
64 /*
65 * Prototypes for procedures defined in this file:
66 */
67
68 static void ComputeWindowBbox _ANSI_ARGS_((Tk_Canvas *canvasPtr,
69 WindowItem *winItemPtr));
70 static int ConfigureWinItem _ANSI_ARGS_((
71 Tk_Canvas *canvasPtr, Tk_Item *itemPtr, int argc,
72 char **argv, int flags));
73 static int CreateWinItem _ANSI_ARGS_((Tk_Canvas *canvasPtr,
74 struct Tk_Item *itemPtr, int argc, char **argv));
75 static void DeleteWinItem _ANSI_ARGS_((Tk_Item *itemPtr));
76 static void DisplayWinItem _ANSI_ARGS_((Tk_Canvas *canvasPtr,
77 Tk_Item *itemPtr, Drawable dst));
78 static void ScaleWinItem _ANSI_ARGS_((Tk_Canvas *canvasPtr,
79 Tk_Item *itemPtr, double originX, double originY,
80 double scaleX, double scaleY));
81 static void TranslateWinItem _ANSI_ARGS_((Tk_Canvas *canvasPtr,
82 Tk_Item *itemPtr, double deltaX, double deltaY));
83 static int WinItemCoords _ANSI_ARGS_((Tk_Canvas *canvasPtr,
84 Tk_Item *itemPtr, int argc, char **argv));
85 static void WinItemRequestProc _ANSI_ARGS_((ClientData clientData,
86 Tk_Window tkwin));
87 static void WinItemStructureProc _ANSI_ARGS_((
88 ClientData clientData, XEvent *eventPtr));
89 static int WinItemToArea _ANSI_ARGS_((Tk_Canvas *canvasPtr,
90 Tk_Item *itemPtr, double *rectPtr));
91 static double WinItemToPoint _ANSI_ARGS_((Tk_Canvas *canvasPtr,
92 Tk_Item *itemPtr, double *pointPtr));
93
94 /*
95 * The structures below defines the rectangle and oval item types
96 * by means of procedures that can be invoked by generic item code.
97 */
98
99 Tk_ItemType TkWindowType = {
100 "window", /* name */
101 sizeof(WindowItem), /* itemSize */
102 CreateWinItem, /* createProc */
103 configSpecs, /* configSpecs */
104 ConfigureWinItem, /* configureProc */
105 WinItemCoords, /* coordProc */
106 DeleteWinItem, /* deleteProc */
107 DisplayWinItem, /* displayProc */
108 1, /* alwaysRedraw */
109 WinItemToPoint, /* pointProc */
110 WinItemToArea, /* areaProc */
111 (Tk_ItemPostscriptProc *) NULL, /* postscriptProc */
112 ScaleWinItem, /* scaleProc */
113 TranslateWinItem, /* translateProc */
114 (Tk_ItemIndexProc *) NULL, /* indexProc */
115 (Tk_ItemCursorProc *) NULL, /* cursorProc */
116 (Tk_ItemSelectionProc *) NULL, /* selectionProc */
117 (Tk_ItemInsertProc *) NULL, /* insertProc */
118 (Tk_ItemDCharsProc *) NULL, /* dTextProc */
119 (Tk_ItemType *) NULL /* nextPtr */
120 };
121 \f
122 /*
123 *--------------------------------------------------------------
124 *
125 * CreateWinItem --
126 *
127 * This procedure is invoked to create a new window
128 * item in a canvas.
129 *
130 * Results:
131 * A standard Tcl return value. If an error occurred in
132 * creating the item, then an error message is left in
133 * canvasPtr->interp->result; in this case itemPtr is
134 * left uninitialized, so it can be safely freed by the
135 * caller.
136 *
137 * Side effects:
138 * A new window item is created.
139 *
140 *--------------------------------------------------------------
141 */
142
143 static int
144 CreateWinItem (
145 register Tk_Canvas *canvasPtr, /* Canvas to hold new item. */
146 Tk_Item *itemPtr, /* Record to hold new item; header
147 * has been initialized by caller. */
148 int argc, /* Number of arguments in argv. */
149 char **argv /* Arguments describing rectangle. */
150 )
151 {
152 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
153
154 if (argc < 2) {
155 Tcl_AppendResult(canvasPtr->interp, "wrong # args: should be \"",
156 Tk_PathName(canvasPtr->tkwin), "\" create ",
157 itemPtr->typePtr->name, " x y ?options?",
158 (char *) NULL);
159 return TCL_ERROR;
160 }
161
162 /*
163 * Initialize item's record.
164 */
165
166 winItemPtr->tkwin = NULL;
167 winItemPtr->width = 0;
168 winItemPtr->height = 0;
169 winItemPtr->anchor = TK_ANCHOR_CENTER;
170 winItemPtr->canvasPtr = canvasPtr;
171
172 /*
173 * Process the arguments to fill in the item record.
174 */
175
176 if ((TkGetCanvasCoord(canvasPtr, argv[0], &winItemPtr->x) != TCL_OK)
177 || (TkGetCanvasCoord(canvasPtr, argv[1],
178 &winItemPtr->y) != TCL_OK)) {
179 return TCL_ERROR;
180 }
181
182 if (ConfigureWinItem(canvasPtr, itemPtr, argc-2, argv+2, 0) != TCL_OK) {
183 DeleteWinItem(itemPtr);
184 return TCL_ERROR;
185 }
186 return TCL_OK;
187 }
188 \f
189 /*
190 *--------------------------------------------------------------
191 *
192 * WinItemCoords --
193 *
194 * This procedure is invoked to process the "coords" widget
195 * command on window items. See the user documentation for
196 * details on what it does.
197 *
198 * Results:
199 * Returns TCL_OK or TCL_ERROR, and sets canvasPtr->interp->result.
200 *
201 * Side effects:
202 * The coordinates for the given item may be changed.
203 *
204 *--------------------------------------------------------------
205 */
206
207 static int
208 WinItemCoords (
209 register Tk_Canvas *canvasPtr, /* Canvas containing item. */
210 Tk_Item *itemPtr, /* Item whose coordinates are to be
211 * read or modified. */
212 int argc, /* Number of coordinates supplied in
213 * argv. */
214 char **argv /* Array of coordinates: x1, y1,
215 * x2, y2, ... */
216 )
217 {
218 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
219
220 if (argc == 0) {
221 sprintf(canvasPtr->interp->result, "%g %g", winItemPtr->x,
222 winItemPtr->y);
223 } else if (argc == 2) {
224 if ((TkGetCanvasCoord(canvasPtr, argv[0], &winItemPtr->x) != TCL_OK)
225 || (TkGetCanvasCoord(canvasPtr, argv[1],
226 &winItemPtr->y) != TCL_OK)) {
227 return TCL_ERROR;
228 }
229 ComputeWindowBbox(canvasPtr, winItemPtr);
230 } else {
231 sprintf(canvasPtr->interp->result,
232 "wrong # coordinates: expected 0 or 2, got %d",
233 argc);
234 return TCL_ERROR;
235 }
236 return TCL_OK;
237 }
238 \f
239 /*
240 *--------------------------------------------------------------
241 *
242 * ConfigureWinItem --
243 *
244 * This procedure is invoked to configure various aspects
245 * of a window item, such as its anchor position.
246 *
247 * Results:
248 * A standard Tcl result code. If an error occurs, then
249 * an error message is left in canvasPtr->interp->result.
250 *
251 * Side effects:
252 * Configuration information may be set for itemPtr.
253 *
254 *--------------------------------------------------------------
255 */
256
257 static int
258 ConfigureWinItem (
259 Tk_Canvas *canvasPtr, /* Canvas containing itemPtr. */
260 Tk_Item *itemPtr, /* Window item to reconfigure. */
261 int argc, /* Number of elements in argv. */
262 char **argv, /* Arguments describing things to configure. */
263 int flags /* Flags to pass to Tk_ConfigureWidget. */
264 )
265 {
266 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
267 Tk_Window oldWindow;
268
269 oldWindow = winItemPtr->tkwin;
270 if (Tk_ConfigureWidget(canvasPtr->interp, canvasPtr->tkwin,
271 configSpecs, argc, argv, (char *) winItemPtr, flags) != TCL_OK) {
272 return TCL_ERROR;
273 }
274
275 /*
276 * A few of the options require additional processing.
277 */
278
279 if (oldWindow != winItemPtr->tkwin) {
280 if (oldWindow != NULL) {
281 Tk_DeleteEventHandler(oldWindow, StructureNotifyMask,
282 WinItemStructureProc, (ClientData) winItemPtr);
283 Tk_ManageGeometry(oldWindow, (Tk_GeometryProc *) NULL,
284 (ClientData) NULL);
285 Tk_UnmapWindow(oldWindow);
286 }
287 if (winItemPtr->tkwin != NULL) {
288 Tk_Window ancestor, parent;
289
290 /*
291 * Make sure that the canvas is either the parent of the
292 * window associated with the item or a descendant of that
293 * parent. Also, don't allow a top-level window to be
294 * managed inside a canvas.
295 */
296
297 parent = Tk_Parent(winItemPtr->tkwin);
298 for (ancestor = canvasPtr->tkwin; ;
299 ancestor = Tk_Parent(ancestor)) {
300 if (ancestor == parent) {
301 break;
302 }
303 if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) {
304 badWindow:
305 Tcl_AppendResult(canvasPtr->interp, "can't use ",
306 Tk_PathName(winItemPtr->tkwin),
307 " in a window item of this canvas", (char *) NULL);
308 winItemPtr->tkwin = NULL;
309 return TCL_ERROR;
310 }
311 }
312 if (((Tk_FakeWin *) (winItemPtr->tkwin))->flags & TK_TOP_LEVEL) {
313 goto badWindow;
314 }
315 if (winItemPtr->tkwin == canvasPtr->tkwin) {
316 goto badWindow;
317 }
318 Tk_CreateEventHandler(winItemPtr->tkwin, StructureNotifyMask,
319 WinItemStructureProc, (ClientData) winItemPtr);
320 Tk_ManageGeometry(winItemPtr->tkwin, WinItemRequestProc,
321 (ClientData) winItemPtr);
322 }
323 }
324
325 ComputeWindowBbox(canvasPtr, winItemPtr);
326
327 return TCL_OK;
328 }
329 \f
330 /*
331 *--------------------------------------------------------------
332 *
333 * DeleteWinItem --
334 *
335 * This procedure is called to clean up the data structure
336 * associated with a window item.
337 *
338 * Results:
339 * None.
340 *
341 * Side effects:
342 * Resources associated with itemPtr are released.
343 *
344 *--------------------------------------------------------------
345 */
346
347 static void
348 DeleteWinItem (
349 Tk_Item *itemPtr /* Item that is being deleted. */
350 )
351 {
352 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
353
354 if (winItemPtr->tkwin != NULL) {
355 Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
356 WinItemStructureProc, (ClientData) winItemPtr);
357 Tk_ManageGeometry(winItemPtr->tkwin, (Tk_GeometryProc *) NULL,
358 (ClientData) NULL);
359 Tk_UnmapWindow(winItemPtr->tkwin);
360 }
361 }
362 \f
363 /*
364 *--------------------------------------------------------------
365 *
366 * ComputeWindowBbox --
367 *
368 * This procedure is invoked to compute the bounding box of
369 * all the pixels that may be drawn as part of a window item.
370 * This procedure is where the child window's placement is
371 * computed.
372 *
373 * Results:
374 * None.
375 *
376 * Side effects:
377 * The fields x1, y1, x2, and y2 are updated in the header
378 * for itemPtr.
379 *
380 *--------------------------------------------------------------
381 */
382
383 /* ARGSUSED */
384 static void
385 ComputeWindowBbox (
386 Tk_Canvas *canvasPtr, /* Canvas that contains item. */
387 register WindowItem *winItemPtr /* Item whose bbox is to be
388 * recomputed. */
389 )
390 {
391 int width, height, x, y;
392
393 x = winItemPtr->x + 0.5;
394 y = winItemPtr->y + 0.5;
395
396 if (winItemPtr->tkwin == NULL) {
397 winItemPtr->header.x1 = winItemPtr->header.x2 = x;
398 winItemPtr->header.y1 = winItemPtr->header.y2 = y;
399 return;
400 }
401
402 /*
403 * Compute dimensions of window.
404 */
405
406 width = winItemPtr->width;
407 if (width <= 0) {
408 width = Tk_ReqWidth(winItemPtr->tkwin);
409 if (width <= 0) {
410 width = 1;
411 }
412 }
413 height = winItemPtr->height;
414 if (height <= 0) {
415 height = Tk_ReqHeight(winItemPtr->tkwin);
416 if (height <= 0) {
417 height = 1;
418 }
419 }
420
421 /*
422 * Compute location of window, using anchor information.
423 */
424
425 switch (winItemPtr->anchor) {
426 case TK_ANCHOR_N:
427 x -= width/2;
428 break;
429 case TK_ANCHOR_NE:
430 x -= width;
431 break;
432 case TK_ANCHOR_E:
433 x -= width;
434 y -= height/2;
435 break;
436 case TK_ANCHOR_SE:
437 x -= width;
438 y -= height;
439 break;
440 case TK_ANCHOR_S:
441 x -= width/2;
442 y -= height;
443 break;
444 case TK_ANCHOR_SW:
445 y -= height;
446 break;
447 case TK_ANCHOR_W:
448 y -= height/2;
449 break;
450 case TK_ANCHOR_NW:
451 break;
452 case TK_ANCHOR_CENTER:
453 x -= width/2;
454 y -= height/2;
455 break;
456 }
457
458 /*
459 * Store the information in the item header.
460 */
461
462 winItemPtr->header.x1 = x;
463 winItemPtr->header.y1 = y;
464 winItemPtr->header.x2 = x + width;
465 winItemPtr->header.y2 = y + height;
466 }
467 \f
468 /*
469 *--------------------------------------------------------------
470 *
471 * DisplayWinItem --
472 *
473 * This procedure is invoked to "draw" a window item in a given
474 * drawable. Since the window draws itself, we needn't do any
475 * actual redisplay here. However, this procedure takes care
476 * of actually repositioning the child window so that it occupies
477 * the correct screen position.
478 *
479 * Results:
480 * None.
481 *
482 * Side effects:
483 * The child window's position may get changed.
484 *
485 *--------------------------------------------------------------
486 */
487
488 /* ARGSUSED */
489 static void
490 DisplayWinItem (
491 register Tk_Canvas *canvasPtr, /* Canvas that contains item. */
492 Tk_Item *itemPtr, /* Item to be displayed. */
493 Drawable drawable /* Pixmap or window in which to draw
494 * item. */
495 )
496 {
497 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
498 int x,y, width, height;
499 Tk_Window ancestor, parent;
500
501 if (winItemPtr->tkwin == NULL) {
502 return;
503 }
504 x = winItemPtr->header.x1 - canvasPtr->xOrigin;
505 y = winItemPtr->header.y1 - canvasPtr->yOrigin;
506 width = winItemPtr->header.x2 - winItemPtr->header.x1;
507 height = winItemPtr->header.y2 - winItemPtr->header.y1;
508
509 /*
510 * If the canvas isn't the parent of the window, then translate the
511 * coordinates from those of the canvas to those of the window's
512 * parent.
513 */
514
515 parent = Tk_Parent(winItemPtr->tkwin);
516 for (ancestor = canvasPtr->tkwin; ancestor != parent;
517 ancestor = Tk_Parent(ancestor)) {
518 x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width;
519 y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width;
520 }
521
522 /*
523 * Reconfigure the window if it isn't already in the correct place.
524 */
525
526 if ((x != Tk_X(winItemPtr->tkwin)) || (y != Tk_Y(winItemPtr->tkwin))
527 || (width != Tk_Width(winItemPtr->tkwin))
528 || (height != Tk_Height(winItemPtr->tkwin))) {
529 Tk_MoveResizeWindow(winItemPtr->tkwin, x, y, (unsigned int) width,
530 (unsigned int) height);
531 }
532 if (!Tk_IsMapped(winItemPtr->tkwin)) {
533 Tk_MapWindow(winItemPtr->tkwin);
534 }
535 }
536 \f
537 /*
538 *--------------------------------------------------------------
539 *
540 * WinItemToPoint --
541 *
542 * Computes the distance from a given point to a given
543 * rectangle, in canvas units.
544 *
545 * Results:
546 * The return value is 0 if the point whose x and y coordinates
547 * are coordPtr[0] and coordPtr[1] is inside the window. If the
548 * point isn't inside the window then the return value is the
549 * distance from the point to the window.
550 *
551 * Side effects:
552 * None.
553 *
554 *--------------------------------------------------------------
555 */
556
557 /* ARGSUSED */
558 static double
559 WinItemToPoint (
560 Tk_Canvas *canvasPtr, /* Canvas containing item. */
561 Tk_Item *itemPtr, /* Item to check against point. */
562 double *pointPtr /* Pointer to x and y coordinates. */
563 )
564 {
565 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
566 double x1, x2, y1, y2, xDiff, yDiff;
567
568 x1 = winItemPtr->header.x1;
569 y1 = winItemPtr->header.y1;
570 x2 = winItemPtr->header.x2;
571 y2 = winItemPtr->header.y2;
572
573 /*
574 * Point is outside rectangle.
575 */
576
577 if (pointPtr[0] < x1) {
578 xDiff = x1 - pointPtr[0];
579 } else if (pointPtr[0] > x2) {
580 xDiff = pointPtr[0] - x2;
581 } else {
582 xDiff = 0;
583 }
584
585 if (pointPtr[1] < y1) {
586 yDiff = y1 - pointPtr[1];
587 } else if (pointPtr[1] > y2) {
588 yDiff = pointPtr[1] - y2;
589 } else {
590 yDiff = 0;
591 }
592
593 return hypot(xDiff, yDiff);
594 }
595 \f
596 /*
597 *--------------------------------------------------------------
598 *
599 * WinItemToArea --
600 *
601 * This procedure is called to determine whether an item
602 * lies entirely inside, entirely outside, or overlapping
603 * a given rectangle.
604 *
605 * Results:
606 * -1 is returned if the item is entirely outside the area
607 * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
608 * inside the given area.
609 *
610 * Side effects:
611 * None.
612 *
613 *--------------------------------------------------------------
614 */
615
616 /* ARGSUSED */
617 static int
618 WinItemToArea (
619 Tk_Canvas *canvasPtr, /* Canvas containing item. */
620 Tk_Item *itemPtr, /* Item to check against rectangle. */
621 double *rectPtr /* Pointer to array of four coordinates
622 * (x1, y1, x2, y2) describing rectangular
623 * area. */
624 )
625 {
626 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
627
628 if ((rectPtr[2] <= winItemPtr->header.x1)
629 || (rectPtr[0] >= winItemPtr->header.x2)
630 || (rectPtr[3] <= winItemPtr->header.y1)
631 || (rectPtr[1] >= winItemPtr->header.y2)) {
632 return -1;
633 }
634 if ((rectPtr[0] <= winItemPtr->header.x1)
635 && (rectPtr[1] <= winItemPtr->header.y1)
636 && (rectPtr[2] >= winItemPtr->header.x2)
637 && (rectPtr[3] >= winItemPtr->header.y2)) {
638 return 1;
639 }
640 return 0;
641 }
642 \f
643 /*
644 *--------------------------------------------------------------
645 *
646 * ScaleWinItem --
647 *
648 * This procedure is invoked to rescale a rectangle or oval
649 * item.
650 *
651 * Results:
652 * None.
653 *
654 * Side effects:
655 * The rectangle or oval referred to by itemPtr is rescaled
656 * so that the following transformation is applied to all
657 * point coordinates:
658 * x' = originX + scaleX*(x-originX)
659 * y' = originY + scaleY*(y-originY)
660 *
661 *--------------------------------------------------------------
662 */
663
664 static void
665 ScaleWinItem (
666 Tk_Canvas *canvasPtr, /* Canvas containing rectangle. */
667 Tk_Item *itemPtr, /* Rectangle to be scaled. */
668 double originX,
669 double originY, /* Origin about which to scale rect. */
670 double scaleX, /* Amount to scale in X direction. */
671 double scaleY /* Amount to scale in Y direction. */
672 )
673 {
674 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
675
676 winItemPtr->x = originX + scaleX*(winItemPtr->x - originX);
677 winItemPtr->y = originY + scaleY*(winItemPtr->y - originY);
678 if (winItemPtr->width > 0) {
679 winItemPtr->width = scaleY*winItemPtr->width;
680 }
681 if (winItemPtr->height > 0) {
682 winItemPtr->height = scaleY*winItemPtr->height;
683 }
684 ComputeWindowBbox(canvasPtr, winItemPtr);
685 }
686 \f
687 /*
688 *--------------------------------------------------------------
689 *
690 * TranslateWinItem --
691 *
692 * This procedure is called to move a rectangle or oval by a
693 * given amount.
694 *
695 * Results:
696 * None.
697 *
698 * Side effects:
699 * The position of the rectangle or oval is offset by
700 * (xDelta, yDelta), and the bounding box is updated in the
701 * generic part of the item structure.
702 *
703 *--------------------------------------------------------------
704 */
705
706 static void
707 TranslateWinItem (
708 Tk_Canvas *canvasPtr, /* Canvas containing item. */
709 Tk_Item *itemPtr, /* Item that is being moved. */
710 double deltaX,
711 double deltaY /* Amount by which item is to be
712 * moved. */
713 )
714 {
715 register WindowItem *winItemPtr = (WindowItem *) itemPtr;
716
717 winItemPtr->x += deltaX;
718 winItemPtr->y += deltaY;
719 ComputeWindowBbox(canvasPtr, winItemPtr);
720 }
721 \f
722 /*
723 *--------------------------------------------------------------
724 *
725 * WinItemStructureProc --
726 *
727 * This procedure is invoked whenever StructureNotify events
728 * occur for a window that's managed as part of a canvas window
729 * item. This procudure's only purpose is to clean up when
730 * windows are deleted.
731 *
732 * Results:
733 * None.
734 *
735 * Side effects:
736 * The window is disassociated from the window item when it is
737 * deleted.
738 *
739 *--------------------------------------------------------------
740 */
741
742 static void
743 WinItemStructureProc (
744 ClientData clientData, /* Pointer to record describing window item. */
745 XEvent *eventPtr /* Describes what just happened. */
746 )
747 {
748 register WindowItem *winItemPtr = (WindowItem *) clientData;
749
750 if (eventPtr->type == DestroyNotify) {
751 winItemPtr->tkwin = NULL;
752 }
753 }
754 \f
755 /*
756 *--------------------------------------------------------------
757 *
758 * WinItemRequestProc --
759 *
760 * This procedure is invoked whenever a window that's associated
761 * with a window canvas item changes its requested dimensions.
762 *
763 * Results:
764 * None.
765 *
766 * Side effects:
767 * The size and location on the screen of the window may change,
768 * depending on the options specified for the window item.
769 *
770 *--------------------------------------------------------------
771 */
772
773 /* ARGSUSED */
774 static void
775 WinItemRequestProc (
776 ClientData clientData, /* Pointer to record for window item. */
777 Tk_Window tkwin /* Window that changed its desired
778 * size. */
779 )
780 {
781 WindowItem *winItemPtr = (WindowItem *) clientData;
782
783 ComputeWindowBbox(winItemPtr->canvasPtr, winItemPtr);
784 DisplayWinItem(winItemPtr->canvasPtr, (Tk_Item *) winItemPtr,
785 (Drawable) None);
786 }
Impressum, Datenschutz