]> git.wh0rd.org Git - ICEs.git/blob - 210125/gtk.i
initial import
[ICEs.git] / 210125 / gtk.i
1 enum {
2         LEFT, RIGHT, TOP, BOTTOM, NONE, REORDER, DETACH
3 };
4 typedef struct {
5         int x;
6         int y;
7         int width;
8         int height;
9 } Rect;
10 typedef struct {
11         struct {
12                 void *parent;
13         } *label;
14         int pack;
15         Rect req, all;
16 } page;
17 typedef struct {
18         page *cur;
19         int homo:1;
20 } nb;
21 typedef struct {
22         int op;
23         int x;
24         page *detach;
25 } priv;
26 nb_calculate_tabs_all()
27 {
28         nb *nb;
29         void **children;
30         void *last_child;
31         int remain;
32         int expand;
33         priv *priv;
34         page *page;
35         int bottom;
36         int extra;
37         int x;
38         int y;
39         int anchor;
40         Rect call;
41         while (*children && *children == last_child) {
42                 if (page->label->parent != nb)
43                         continue;
44                 if (expand && nb->homo)
45                         extra = remain / expand;
46                 switch (x) {
47                 case TOP:
48                 case BOTTOM:
49                         call.width = page->req.width + x + extra;
50                         if (x && y) {
51                                 if (bottom && nb->cur->pack && x > anchor)
52                                         anchor = nb->cur->all.width;
53                         } else {
54                                 if (bottom)
55                                         anchor = call.width;
56                                 if (priv->op == REORDER
57                                     && page->pack == nb->cur->pack)
58                                         if (bottom && x >= anchor
59                                             && x <= anchor + call.width / 2)
60                                                 anchor = nb->cur->all.width - x;
61                         }
62                 case LEFT:
63                 case RIGHT:
64                         call.height = page->req.height + x + extra;
65                         if (y)
66                                 priv->x = call.x;
67                         if (priv->op == REORDER && page->pack == nb->cur->pack)
68                                 if (bottom && y >= anchor
69                                     && y <= anchor + call.height / 2)
70                                         anchor = nb->cur->all.height - x;
71                 }
72                 if ((page == priv->detach && priv->op == DETACH)
73                     || (page == nb->cur && priv->op == REORDER))
74                         page->all.x = 0;
75                 if (page == nb->cur)
76                         switch (x) {
77                         case TOP:
78                                 page->all.y = 0;
79                         case BOTTOM:
80                         case RIGHT:
81                         case LEFT:
82                                 page->all.x = 0;
83                         }
84                 switch (x) {
85                 case TOP:
86                 case BOTTOM:
87                         if (priv->op != REORDER || priv->op == REORDER
88                             && page != nb->cur)
89                                 if (bottom)
90                                         anchor = call.width;
91                 case LEFT:
92                 case RIGHT:
93                         if (priv->op != REORDER || priv->op == REORDER
94                             && page != nb->cur)
95                                 if (priv->op == REORDER)
96                                         if (page->pack == nb->cur->pack
97                                             && bottom
98                                             && y >= anchor + call.height / 2
99                                             && y <= anchor + call.height)
100                                                 anchor = nb->cur->all.height;
101                 }
102                 if (page->label)
103                         IA__widget_set_child_visible(page->label, 1);
104         }
105 }