OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [generic/] [tixDiWin.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.