Debian Codegraph @

pTk/mTk/tixGeneric/tixDiWin.c

raw symbols SCIP
1
2 /* $Id: tixDiWin.c,v 1.1.1.1 2000/05/17 11:08:41 idiscovery Exp $ */
3
4 /*
5 * tixDiWin.c --
6 *
7 * This file implements one of the "Display Items" in the Tix library :
8 * WindowItem display items.
9 *
10 * Copyright (c) 1996, Expert Interface Technologies
11 *
12 * See the file "license.terms" for information on usage and redistribution
13 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 *
15 */
16 #include "tixPort.h"
17 #include "tixInt.h"
18 #include "tixDef.h"
19
20 /*----------------------------------------------------------------------
21 *
22 * Data structures used by this file
23 *
24 *----------------------------------------------------------------------
25 */
26
27 /*----------------------------------------------------------------------
28 *
29 * Private data definition
30 *
31 *----------------------------------------------------------------------
32 */
33
34 static Tix_ListInfo mapWinListInfo = {
35 Tk_Offset(TixWindowItem, next),
36 TIX_UNDEFINED,
37 };
38
39 #define DEF_WINDOWITEM_WINDOW ""
40 #define DEF_WINDOWITEM_STYLE ""
41 #define DEF_WINDOWITEM_TYPE "window"
42
43 static Tk_ConfigSpec windowItemConfigSpecs[] = {
44 {TK_CONFIG_CUSTOM, "-itemtype", "itemType", "ItemType",
45 DEF_WINDOWITEM_TYPE, Tk_Offset(TixWindowItem, diTypePtr),
46 0, &tixConfigItemType},
47
48 {TK_CONFIG_CUSTOM, "-style", "windowStyle", "WindowStyle",
49 DEF_WINDOWITEM_STYLE, Tk_Offset(TixWindowItem, stylePtr),
50 TK_CONFIG_NULL_OK, &tixConfigItemStyle},
51
52 {TK_CONFIG_SYNONYM, "-widget", "window", (char *) NULL,
53 (char *)NULL, 0, 0},
54
55 {TK_CONFIG_WINDOW, "-window", "window", "Window",
56 DEF_WINDOWITEM_WINDOW, Tk_Offset(TixWindowItem, tkwin), 0},
57
58 {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
59 (char *) NULL, 0, 0}
60 };
61 /*----------------------------------------------------------------------
62 *
63 * Configuration options for Window Styles
64 *
65 *----------------------------------------------------------------------
66 */
67 #define DEF_WINDOWSTYLE_PADX "0"
68 #define DEF_WINDOWSTYLE_PADY "0"
69 #define DEF_WINDOWSTYLE_ANCHOR "w"
70
71 static Tk_ConfigSpec windowStyleConfigSpecs[] = {
72 {TK_CONFIG_ANCHOR, "-anchor", "anchor", "Anchor",
73 DEF_WINDOWSTYLE_ANCHOR, Tk_Offset(TixWindowStyle, anchor), 0},
74
75 {TK_CONFIG_PIXELS, "-padx", "padX", "Pad",
76 DEF_WINDOWSTYLE_PADX, Tk_Offset(TixWindowStyle, pad[0]), 0},
77
78 {TK_CONFIG_PIXELS, "-pady", "padY", "Pad",
79 DEF_WINDOWSTYLE_PADY, Tk_Offset(TixWindowStyle, pad[1]), 0},
80
81 {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
82 (char *) NULL, 0, 0}
83 };
84
85 /*----------------------------------------------------------------------
86 * Forward declarations for procedures defined later in this file:
87 *----------------------------------------------------------------------
88 */
89 static void SubWindowLostSlaveProc _ANSI_ARGS_((
90 ClientData clientData, Tk_Window tkwin));
91 static void SubWindowRequestProc _ANSI_ARGS_((
92 ClientData clientData, Tk_Window tkwin));
93 static void SubWindowStructureProc _ANSI_ARGS_((
94 ClientData clientData, XEvent *eventPtr));
95 static char * Tix_WindowItemComponent _ANSI_ARGS_((
96 Tix_DItem * iPtr, int x, int y));
97 static void Tix_WindowItemCalculateSize _ANSI_ARGS_((
98 Tix_DItem * iPtr));
99 static int Tix_WindowItemConfigure _ANSI_ARGS_((
100 Tix_DItem * iPtr, int argc, char ** argv,
101 int flags));
102 static Tix_DItem * Tix_WindowItemCreate _ANSI_ARGS_((
103 Tix_DispData * ddPtr, Tix_DItemInfo * diTypePtr));
104 static void Tix_WindowItemDisplay _ANSI_ARGS_((
105 Pixmap pixmap, GC gc, Tix_DItem * iPtr,
106 int x, int y, int width, int height, int flags));
107 static void Tix_WindowItemFree _ANSI_ARGS_((
108 Tix_DItem * iPtr));
109 static void Tix_WindowItemLostStyle _ANSI_ARGS_((
110 Tix_DItem * iPtr));
111 static void Tix_WindowItemStyleChanged _ANSI_ARGS_((
112 Tix_DItem * iPtr));
113 static void Tix_WindowItemUnmap _ANSI_ARGS_((
114 TixWindowItem *itPtr));
115 static int Tix_WindowStyleConfigure _ANSI_ARGS_((
116 Tix_DItemStyle* style, int argc, char ** argv,
117 int flags));
118 static Tix_DItemStyle * Tix_WindowStyleCreate _ANSI_ARGS_((
119 Tcl_Interp *interp, Tk_Window tkwin,
120 Tix_DItemInfo * diTypePtr, char * name));
121 static void Tix_WindowStyleFree _ANSI_ARGS_((
122 Tix_DItemStyle* style));
123 static void Tix_WindowStyleSetTemplate _ANSI_ARGS_((
124 Tix_DItemStyle* style,
125 Tix_StyleTemplate * tmplPtr));
126 static void UnmanageWindow _ANSI_ARGS_((Tix_DItem * iPtr,
127 Tk_Window tkwin));
128 static void ManageWindow _ANSI_ARGS_((Tix_DItem * iPtr,
129 Tk_Window tkwin));
130
131 Tix_DItemInfo tix_WindowItemType = {
132 "window", /* type */
133 TIX_DITEM_WINDOW,
134 Tix_WindowItemCreate, /* createProc */
135 Tix_WindowItemConfigure,
136 Tix_WindowItemCalculateSize,
137 Tix_WindowItemComponent,
138 Tix_WindowItemDisplay,
139 Tix_WindowItemFree,
140 Tix_WindowItemStyleChanged,
141 Tix_WindowItemLostStyle,
142
143 Tix_WindowStyleCreate,
144 Tix_WindowStyleConfigure,
145 Tix_WindowStyleFree,
146 Tix_WindowStyleSetTemplate,
147
148 windowItemConfigSpecs,
149 windowStyleConfigSpecs,
150
151 NULL, /*next */
152 };
153
154 /*
155 * The structure below defines the official type record for the
156 * placer:
157 */
158 static Tk_GeomMgr windowItemGeomType = {
159 "tixWindowItem", /* name */
160 SubWindowRequestProc, /* requestProc */
161 SubWindowLostSlaveProc, /* lostSlaveProc */
162 };
163
164 /*----------------------------------------------------------------------
165 * Tix_WindowItemCreate --
166 *
167 *
168 *----------------------------------------------------------------------
169 */
170 static Tix_DItem * Tix_WindowItemCreate(ddPtr, diTypePtr)
171 Tix_DispData * ddPtr;
172 Tix_DItemInfo * diTypePtr;
173 {
174 TixWindowItem * itPtr;
175
176 itPtr = (TixWindowItem*) ckalloc(sizeof(TixWindowItem));
177
178 itPtr->diTypePtr = diTypePtr;
179 itPtr->ddPtr = ddPtr;
180 itPtr->stylePtr = NULL;
181 itPtr->clientData = 0;
182 itPtr->size[0] = 0;
183 itPtr->size[1] = 0;
184
185 itPtr->tkwin = NULL;
186
187 return (Tix_DItem *)itPtr;
188 }
189
190 /* %% */
191 static void Tix_WindowItemFree(iPtr)
192 Tix_DItem * iPtr;
193 {
194 TixWindowItem * itPtr = (TixWindowItem *) iPtr;
195
196 if (itPtr->tkwin) {
197 Tk_DeleteEventHandler(itPtr->tkwin, StructureNotifyMask,
198 SubWindowStructureProc, (ClientData) itPtr);
199 Tk_ManageGeometry(itPtr->tkwin, (Tk_GeomMgr *)NULL,
200 (ClientData) NULL);
201 Tk_UnmapWindow(itPtr->tkwin);
202 }
203 if (itPtr->stylePtr) {
204 TixDItemStyleFree(iPtr, (Tix_DItemStyle*)itPtr->stylePtr);
205 }
206
207 Tk_FreeOptions(windowItemConfigSpecs, (char *)itPtr,
208 itPtr->ddPtr->display, 0);
209
210 ckfree((char*)itPtr);
211 }
212
213 /*----------------------------------------------------------------------
214 * ManageWindow --
215 *
216 * Associate this sub-window with the window item.
217 *
218 * Side effect:
219 * itPtr->tkwin is changed.
220 *----------------------------------------------------------------------
221 */
222
223 static void
224 ManageWindow(iPtr, tkwin)
225 Tix_DItem * iPtr;
226 Tk_Window tkwin;
227 {
228 TixWindowItem * itPtr = (TixWindowItem *) iPtr;
229
230 Tk_CreateEventHandler(tkwin, StructureNotifyMask,
231 SubWindowStructureProc, (ClientData) itPtr);
232 Tk_ManageGeometry(tkwin, &windowItemGeomType,
233 (ClientData) itPtr);
234
235 itPtr->tkwin = tkwin;
236 }
237
238 /*----------------------------------------------------------------------
239 * UnmanageWindow --
240 *
241 * Disassociate this sub-window from the window item.
242 *
243 * Note:
244 * the tkwin parameter may not equal to itPtr->tkwin.
245 *----------------------------------------------------------------------
246 */
247
248 static void
249 UnmanageWindow(iPtr, tkwin)
250 Tix_DItem * iPtr;
251 Tk_Window tkwin;
252 {
253 TixWindowItem * itPtr = (TixWindowItem *) iPtr;
254
255 Tk_DeleteEventHandler(tkwin, StructureNotifyMask,
256 SubWindowStructureProc, (ClientData) itPtr);
257 Tk_ManageGeometry(tkwin, (Tk_GeomMgr *)NULL,
258 (ClientData) NULL);
259 Tk_UnmapWindow(tkwin);
260 }
261
262 static int Tix_WindowItemConfigure(iPtr, argc, argv, flags)
263 Tix_DItem * iPtr;
264 int argc;
265 char ** argv;
266 int flags;
267 {
268 TixWindowItem * itPtr = (TixWindowItem *) iPtr;
269 TixWindowStyle * oldStyle = itPtr->stylePtr;
270 Tk_Window oldWindow;
271
272 oldWindow = itPtr->tkwin;
273
274 if (Tk_ConfigureWidget(itPtr->ddPtr->interp, itPtr->ddPtr->tkwin,
275 windowItemConfigSpecs,
276 argc, argv, (char *)itPtr, flags) != TCL_OK) {
277 return TCL_ERROR;
278 }
279 if (itPtr->stylePtr == NULL) {
280 itPtr->stylePtr = (TixWindowStyle*)TixGetDefaultDItemStyle(
281 itPtr->ddPtr, &tix_WindowItemType, iPtr, NULL);
282 }
283
284 if (oldWindow != itPtr->tkwin) {
285 if (oldWindow != NULL) {
286 UnmanageWindow(iPtr, oldWindow);
287 }
288 if (itPtr->tkwin != NULL) {
289 /*
290 * Make sure that the master window is the parent of the
291 * window associated with the item.
292 * Also, don't allow a top-level window to be
293 * managed inside a master window.
294 */
295 if (Tk_Parent(itPtr->tkwin) != itPtr->ddPtr->tkwin) {
296 Tcl_AppendResult(itPtr->ddPtr->interp, "can't use ",
297 Tk_PathName(itPtr->tkwin),
298 " in a window item of the master widget: must be a child",
299 " of ", Tk_PathName(itPtr->ddPtr->tkwin), (char *) NULL);
300 goto badWindow;
301 }
302 if (((Tk_FakeWin *) (itPtr->tkwin))->flags & TK_TOP_LEVEL) {
303 Tcl_AppendResult(itPtr->ddPtr->interp,
304 "can't manage toplevel window",
305 Tk_PathName(itPtr->tkwin),
306 " as a window item of ", Tk_PathName(itPtr->ddPtr->tkwin),
307 (char *) NULL);
308 goto badWindow;
309 }
310 ManageWindow(iPtr, itPtr->tkwin);
311 }
312 }
313
314 if (oldStyle != NULL && itPtr->stylePtr != oldStyle) {
315 Tix_WindowItemStyleChanged(iPtr);
316 }
317 else {
318 Tix_WindowItemCalculateSize((Tix_DItem*)itPtr);
319 }
320
321 return TCL_OK;
322
323 badWindow:
324
325 itPtr->tkwin = NULL;
326 return TCL_ERROR;
327 }
328
329 static void Tix_WindowItemDisplay(pixmap, gc, iPtr, x, y, width, height, flag)
330 Pixmap pixmap;
331 GC gc;
332 Tix_DItem * iPtr;
333 int x;
334 int y;
335 int width;
336 int height;
337 int flag;
338 {
339 TixWindowItem *itPtr = (TixWindowItem *)iPtr;
340
341 if (itPtr->tkwin == NULL) {
342 return;
343 }
344
345 TixDItemGetAnchor(itPtr->stylePtr->anchor, x, y, width, height,
346 itPtr->size[0], itPtr->size[1], &x, &y);
347
348 x += itPtr->stylePtr->pad[0];
349 y += itPtr->stylePtr->pad[1];
350 width -= 2*itPtr->stylePtr->pad[0];
351 height -= 2*itPtr->stylePtr->pad[1];
352
353 if (width < 1 || height < 1) {
354 if (itPtr->ddPtr->tkwin != Tk_Parent(itPtr->tkwin)) {
355 Tk_UnmaintainGeometry(itPtr->tkwin, itPtr->ddPtr->tkwin);
356 }
357 Tk_UnmapWindow(itPtr->tkwin);
358 return;
359 }
360
361 if (itPtr->ddPtr->tkwin == Tk_Parent(itPtr->tkwin)) {
362 Tk_MapWindow(itPtr->tkwin);
363 Tk_MoveResizeWindow(itPtr->tkwin, x, y, width, height);
364 }
365 else {
366 Tk_MaintainGeometry(itPtr->tkwin, itPtr->ddPtr->tkwin,
367 x, y, width, height);
368 }
369 }
370
371 static void Tix_WindowItemCalculateSize(iPtr)
372 Tix_DItem * iPtr;
373 {
374 TixWindowItem *itPtr = (TixWindowItem*)iPtr;
375
376 if (itPtr->tkwin != NULL) {
377 itPtr->size[0] = Tk_ReqWidth (itPtr->tkwin);
378 itPtr->size[1] = Tk_ReqHeight(itPtr->tkwin);
379 } else {
380 itPtr->size[0] = 0;
381 itPtr->size[1] = 0;
382 }
383
384 itPtr->size[0] += 2*itPtr->stylePtr->pad[0];
385 itPtr->size[1] += 2*itPtr->stylePtr->pad[1];
386 }
387
388 static char * Tix_WindowItemComponent(iPtr, x, y)
389 Tix_DItem * iPtr;
390 int x;
391 int y;
392 {
393 #if 0
394 TixWindowItem *itPtr = (TixWindowItem *)iPtr;
395 #endif
396 static char * body = "body";
397
398 return body;
399 }
400
401
402 static void Tix_WindowItemStyleChanged(iPtr)
403 Tix_DItem * iPtr;
404 {
405 TixWindowItem *itPtr = (TixWindowItem *)iPtr;
406
407 if (itPtr->stylePtr == NULL) {
408 /* Maybe we haven't set the style to default style yet */
409 return;
410 }
411 Tix_WindowItemCalculateSize(iPtr);
412 if (itPtr->ddPtr->sizeChangedProc != NULL) {
413 itPtr->ddPtr->sizeChangedProc(iPtr);
414 }
415 }
416 static void Tix_WindowItemLostStyle(iPtr)
417 Tix_DItem * iPtr;
418 {
419 TixWindowItem *itPtr = (TixWindowItem *)iPtr;
420
421 itPtr->stylePtr = (TixWindowStyle*)TixGetDefaultDItemStyle(
422 itPtr->ddPtr, &tix_WindowItemType, iPtr, NULL);
423
424 Tix_WindowItemStyleChanged(iPtr);
425 }
426
427 /*
428 *--------------------------------------------------------------
429 *
430 * SubWindowStructureProc --
431 *
432 * This procedure is invoked whenever StructureNotify events
433 * occur for a window that's managed as part of a display
434 * item. This procudure's only purpose is to clean up when
435 * windows are deleted.
436 *
437 * Results:
438 * None.
439 *
440 * Side effects:
441 * The window is disassociated from the window item when it is
442 * deleted.
443 *
444 *--------------------------------------------------------------
445 */
446 static void
447 SubWindowStructureProc(clientData, eventPtr)
448 ClientData clientData; /* Pointer to record describing window item. */
449 XEvent *eventPtr; /* Describes what just happened. */
450 {
451 TixWindowItem * itPtr = (TixWindowItem *)clientData;
452 int oldWidth, oldHeight;
453
454 if (eventPtr->type == DestroyNotify) {
455 itPtr->tkwin = NULL;
456 }
457 oldWidth = itPtr->size[0];
458 oldHeight = itPtr->size[1];
459 Tix_WindowItemCalculateSize((Tix_DItem*)itPtr);
460
461 if (oldWidth != itPtr->size[0] || oldHeight != itPtr->size[1]) {
462 if (itPtr->ddPtr->sizeChangedProc != NULL) {
463 itPtr->ddPtr->sizeChangedProc((Tix_DItem*)itPtr);
464 }
465 }
466 }
467
468 /*
469 *--------------------------------------------------------------
470 *
471 * SubWindowRequestProc --
472 *
473 * This procedure is invoked whenever a window that's associated
474
475 * with a display item changes its requested dimensions.
476 *
477 * Results:
478 * None.
479 *
480 * Side effects:
481 * The size and location on the screen of the window may change,
482 * depending on the options specified for the window item.
483 *
484 *--------------------------------------------------------------
485 */
486 static void
487 SubWindowRequestProc(clientData, tkwin)
488 ClientData clientData; /* Pointer to record for window item.*/
489 Tk_Window tkwin; /* Window that changed its desired
490 * size. */
491 {
492 TixWindowItem *itPtr = (TixWindowItem *) clientData;
493
494 Tix_WindowItemCalculateSize((Tix_DItem*)itPtr);
495 if (itPtr->ddPtr->sizeChangedProc != NULL) {
496 itPtr->ddPtr->sizeChangedProc((Tix_DItem*)itPtr);
497 }
498 }
499
500 /*
501 *--------------------------------------------------------------
502 *
503 * SubWindowLostSlaveProc --
504 *
505 * This procedure is invoked by Tk whenever some other geometry
506 * claims control over a slave that used to be managed by us.
507 *
508 * Results:
509 * None.
510 *
511 * Side effects:
512 * Forgets all information about the slave.
513 *
514 *--------------------------------------------------------------
515 */
516 /* ARGSUSED */
517 static void
518 SubWindowLostSlaveProc(clientData, tkwin)
519 ClientData clientData; /* TixWindowItem structure for slave
520 * window that was stolen away. */
521 Tk_Window tkwin; /* Tk's handle for the slave window. */
522 {
523 TixWindowItem *itPtr = (TixWindowItem *) clientData;
524
525 if (itPtr->tkwin == NULL) {
526 return;
527 } else {
528 itPtr->tkwin = NULL;
529 }
530
531 Tk_DeleteEventHandler(tkwin, StructureNotifyMask,
532 SubWindowStructureProc, (ClientData) itPtr);
533 Tk_ManageGeometry(tkwin, (Tk_GeomMgr *)NULL,
534 (ClientData) NULL);
535 if (itPtr->ddPtr->tkwin != Tk_Parent(tkwin)) {
536 Tk_UnmaintainGeometry(tkwin, itPtr->ddPtr->tkwin);
537 }
538 Tk_UnmapWindow(tkwin);
539
540 /*
541 * Inform the owner that the size has changed
542 */
543 Tix_WindowItemCalculateSize((Tix_DItem*)itPtr);
544 if (itPtr->ddPtr->sizeChangedProc != NULL) {
545 itPtr->ddPtr->sizeChangedProc((Tix_DItem*)itPtr);
546 }
547 }
548 /*----------------------------------------------------------------------
549 * Tix_WindowItemUnmap --
550 *
551 *
552 *----------------------------------------------------------------------
553 */
554 static void
555 Tix_WindowItemUnmap(itPtr)
556 TixWindowItem *itPtr;
557 {
558 Tk_Window tkwin = itPtr->tkwin;
559
560 if (tkwin == NULL) {
561 return;
562 }
563
564 if (itPtr->ddPtr->tkwin != Tk_Parent(tkwin)) {
565 Tk_UnmaintainGeometry(tkwin, itPtr->ddPtr->tkwin);
566 }
567 Tk_UnmapWindow(tkwin);
568 }
569
570 /*----------------------------------------------------------------------
571 *
572 *
573 * Display styles
574 *
575 *
576 *----------------------------------------------------------------------
577 */
578 static Tix_DItemStyle *
579 Tix_WindowStyleCreate(interp, tkwin, diTypePtr, name)
580 Tcl_Interp * interp;
581 Tk_Window tkwin;
582 char * name;
583 Tix_DItemInfo * diTypePtr;
584 {
585 TixWindowStyle * stylePtr =
586 (TixWindowStyle *)ckalloc(sizeof(TixWindowStyle));
587
588 stylePtr->pad[0] = 0;
589 stylePtr->pad[1] = 0;
590 stylePtr->anchor = TK_ANCHOR_CENTER;
591
592 return (Tix_DItemStyle *)stylePtr;
593 }
594
595 static int
596 Tix_WindowStyleConfigure(style, argc, argv, flags)
597 Tix_DItemStyle *style;
598 int argc;
599 char ** argv;
600 int flags;
601 {
602 TixWindowStyle * stylePtr = (TixWindowStyle *)style;
603 int oldPadX;
604 int oldPadY;
605
606 oldPadX = stylePtr->pad[0];
607 oldPadY = stylePtr->pad[1];
608
609 if (!(flags &TIX_DONT_CALL_CONFIG)) {
610 if (Tk_ConfigureWidget(stylePtr->interp, stylePtr->tkwin,
611 windowStyleConfigSpecs,
612 argc, argv, (char *)stylePtr, flags) != TCL_OK) {
613 return TCL_ERROR;
614 }
615 }
616
617 if (oldPadX != stylePtr->pad[0] || oldPadY != stylePtr->pad[1]) {
618 TixDItemStyleChanged(stylePtr->diTypePtr, (Tix_DItemStyle *)stylePtr);
619 }
620
621 return TCL_OK;
622 }
623
624 static void Tix_WindowStyleFree(style)
625 Tix_DItemStyle *style;
626 {
627 TixWindowStyle * stylePtr = (TixWindowStyle *)style;
628
629 Tk_FreeOptions(windowStyleConfigSpecs, (char *)stylePtr,
630 Tk_Display(stylePtr->tkwin), 0);
631 ckfree((char *)stylePtr);
632 }
633
634 static void
635 Tix_WindowStyleSetTemplate(style, tmplPtr)
636 Tix_DItemStyle* style;
637 Tix_StyleTemplate * tmplPtr;
638 {
639 TixWindowStyle * stylePtr = (TixWindowStyle *)style;
640
641
642 if (tmplPtr->flags & TIX_DITEM_PADX) {
643 stylePtr->pad[0] = tmplPtr->pad[0];
644 }
645 if (tmplPtr->flags & TIX_DITEM_PADY) {
646 stylePtr->pad[1] = tmplPtr->pad[1];
647 }
648
649 Tix_WindowStyleConfigure(style, 0, 0, TIX_DONT_CALL_CONFIG);
650 }
651
652 /*----------------------------------------------------------------------
653 *
654 *
655 * Mapped Window List Handling
656 *
657 *
658 * Maintaining a list of mapped window items. Every host widgets should
659 * call these functions so that unwanted window items will not appear
660 * on the screen.
661 *
662 *
663 *----------------------------------------------------------------------
664 */
665
666 void Tix_SetWindowItemSerial(lPtr, iPtr, serial)
667 Tix_LinkList * lPtr;
668 Tix_DItem * iPtr;
669 int serial;
670 {
671 TixWindowItem * itPtr = (TixWindowItem *)iPtr;
672 TixWindowItem * curr;
673 Tix_ListIterator li;
674 Tix_LinkListIteratorInit(&li);
675
676 itPtr->serial = serial;
677
678 for (Tix_LinkListStart(&mapWinListInfo, lPtr, &li);
679 !Tix_LinkListDone(&li);
680 Tix_LinkListNext (&mapWinListInfo, lPtr, &li)) {
681
682 curr = (TixWindowItem*)li.curr;
683
684 if (curr == itPtr) {
685 /* Don't want any duplication */
686 return;
687 }
688 }
689 Tix_LinkListAppend(&mapWinListInfo, lPtr, (char*)itPtr, 0);
690 }
691
692 /*
693 *----------------------------------------------------------------------
694 * UnmapWindows --
695 *
696 * We need to unmap all those windows that were displayed last time
697 * but should be now invisible.
698 * Otherwise we will have some unwanted child windows floating
699 * around.
700 *----------------------------------------------------------------------
701 */
702 void Tix_UnmapInvisibleWindowItems(lPtr, serial)
703 Tix_LinkList * lPtr;
704 int serial;
705 {
706 TixWindowItem * curr;
707 Tix_ListIterator li;
708 Tix_LinkListIteratorInit(&li);
709
710 for (Tix_LinkListStart(&mapWinListInfo, lPtr, &li);
711 !Tix_LinkListDone(&li);
712 Tix_LinkListNext (&mapWinListInfo, lPtr, &li)) {
713
714 curr = (TixWindowItem*)li.curr;
715 if (curr->serial != serial) {
716 Tix_WindowItemUnmap(curr);
717 Tix_LinkListDelete(&mapWinListInfo, lPtr, &li);
718 }
719 }
720 }
721
722 void
723 Tix_WindowItemListRemove(lPtr, iPtr)
724 Tix_LinkList * lPtr;
725 Tix_DItem * iPtr;
726 {
727 TixWindowItem * curr;
728 Tix_ListIterator li;
729 Tix_LinkListIteratorInit(&li);
730
731 for (Tix_LinkListStart(&mapWinListInfo, lPtr, &li);
732 !Tix_LinkListDone(&li);
733 Tix_LinkListNext (&mapWinListInfo, lPtr, &li)) {
734
735 curr = (TixWindowItem*)li.curr;
736 if (curr == (TixWindowItem*)iPtr) {
737 Tix_WindowItemUnmap(curr);
738 Tix_LinkListDelete(&mapWinListInfo, lPtr, &li);
739 return;
740 }
741 }
742 }