initial import
[ICEs.git] / 210125 / gtk.i.8
1 typedef struct _GList GList;
2 typedef struct _GdkRectangle GdkRectangle;
3 struct _GdkRectangle {
4 int x;
5 int y;
6 int width;
7 int height;
8 };
9 typedef enum { GTK_PACK_END } GtkPathType;
10 typedef enum {
11 GTK_POS_LEFT, GTK_POS_RIGHT, GTK_POS_TOP, GTK_POS_BOTTOM
12 } GtkPreviewType;
13 typedef struct _GtkWidget GtkWidget;
14 struct _GtkWidget {
15 GtkWidget *parent;
16 };
17 typedef struct _GtkNotebook GtkNotebook;
18 typedef struct _GtkNotebookPage GtkNotebookPage;
19 struct _GtkNotebook {
20 GtkNotebookPage *cur_page;
21 unsigned int homogeneous:1;
22 };
23 typedef enum {
24 DRAG_OPERATION_NONE, DRAG_OPERATION_REORDER, DRAG_OPERATION_DETACH
25 } GtkNotebookDragOperation;
26 struct _GtkNotebookPage {
27 GtkWidget *tab_label;
28 unsigned int pack:1;
29 GdkRectangle requisition, allocation;
30 };
31 typedef struct _GtkNotebookPrivate GtkNotebookPrivate;
32 struct _GtkNotebookPrivate {
33 GtkNotebookDragOperation operation;
34 int x;
35 int y;
36 GtkNotebookPage *detached_tab;
37 };
38 int gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook,
39 GList ** children,
40 GList * last_child, int showarrow,
41 int *remaining_space,
42 int *expanded_tabs, int min, int max)
43 {
44 GtkNotebookPrivate *priv;
45 GtkNotebookPage *page;
46 int allocate_at_bottom;
47 int tab_overlap;
48 int tab_pos;
49 int tab_extra_space;
50 int left_x;
51 int right_x;
52 int top_y;
53 int anchor;
54 int xthickness;
55 int ythickness;
56 int gap_left;
57 int packing_changed;
58 GdkRectangle child_allocation;
59 while (
60 *children
61 && *children != last_child
62 ) {
63 if (!
64 (((GtkNotebookPage *) (page))->tab_label->parent
65 ==
66 ((GtkWidget *) (notebook)))
67 )
68 continue;
69 if (*expanded_tabs && (notebook->homogeneous)) {
70 tab_extra_space = *remaining_space / *expanded_tabs;
71 *remaining_space -= tab_extra_space;
72 }
73 switch (tab_pos) {
74 case GTK_POS_TOP:
75 case GTK_POS_BOTTOM:
76 child_allocation.width =
77 page->requisition.width +
78 tab_overlap +
79 tab_extra_space;
80 if (gap_left && packing_changed) {
81 if (allocate_at_bottom) {
82 left_x = priv->x =
83 anchor;
84 anchor +=
85 notebook->cur_page->
86 allocation.width -
87 tab_overlap;
88 if (notebook->cur_page->pack
89 && right_x > anchor) {
90 anchor -=
91 notebook->cur_page->
92 allocation.width;
93 priv->x = anchor;
94 }
95 }
96 } else {
97 if (allocate_at_bottom)
98 anchor -= child_allocation.width;
99 if (priv->operation
100 == DRAG_OPERATION_REORDER
101 && page->pack == notebook->cur_page->pack) {
102 if (!allocate_at_bottom
103 && left_x >= anchor
104 && left_x <=
105 anchor + child_allocation.width / 2)
106 anchor +=
107 notebook->cur_page->
108 allocation.width -
109 tab_overlap;
110 else if (allocate_at_bottom
111 && right_x >=
112 anchor +
113 child_allocation.width / 2
114 && right_x <=
115 anchor +
116 child_allocation.width)
117 anchor -=
118 notebook->cur_page->
119 allocation.width -
120 tab_overlap;
121 }
122 child_allocation.x = anchor;
123 }
124 break;
125 case GTK_POS_LEFT:
126 case GTK_POS_RIGHT:
127 child_allocation.height =
128 page->requisition.height + tab_overlap +
129 tab_extra_space;
130 if (packing_changed) {
131 priv->x = child_allocation.x;
132 priv->y = top_y;
133 if (priv->operation == DRAG_OPERATION_REORDER
134 && page->pack == notebook->cur_page->pack) {
135 if (!allocate_at_bottom
136 && top_y >= anchor
137 && top_y <=
138 anchor +
139 child_allocation.height / 2)
140 anchor +=
141 notebook->cur_page->
142 allocation.height -
143 tab_overlap;
144 }
145 }
146 }
147 if ((page == priv->detached_tab
148 && priv->operation == DRAG_OPERATION_DETACH)
149 || (page == notebook->cur_page
150 && priv->operation == DRAG_OPERATION_REORDER)) {
151 page->allocation.x = 0;
152 }
153 if (page != notebook->cur_page) {
154 switch (tab_pos) {
155 case GTK_POS_TOP:
156 page->allocation.y += ythickness;
157 case GTK_POS_BOTTOM:
158 page->allocation.height =
159 1 > page->allocation.height - ythickness ? 1 : page->allocation.
160 height -
161 ythickness;
162 break;
163 case GTK_POS_LEFT:
164 page->allocation.x += xthickness;
165 case GTK_POS_RIGHT:
166 page->allocation.width =
167 1 > page->allocation.width - xthickness ? 1 : page->allocation.width - xthickness;
168 }
169 }
170 switch (tab_pos) {
171 case GTK_POS_TOP:
172 case GTK_POS_BOTTOM:
173 if (
174 priv->operation != DRAG_OPERATION_REORDER ||
175 priv->operation == DRAG_OPERATION_REORDER
176 && page != notebook->cur_page
177 )
178 if (!allocate_at_bottom)
179 anchor +=
180 child_allocation.width -
181 tab_overlap;
182 case GTK_POS_LEFT:
183 case GTK_POS_RIGHT:
184 if (priv->operation != DRAG_OPERATION_REORDER
185 || priv->operation == DRAG_OPERATION_REORDER
186 && page != notebook->cur_page)
187 if (priv->operation == DRAG_OPERATION_REORDER)
188 if (page->pack ==
189 notebook->cur_page->pack
190 && !allocate_at_bottom
191 && top_y >=
192 anchor + child_allocation.height / 2
193 && top_y <=
194 anchor + child_allocation.height)
195 anchor +=
196 notebook->cur_page->
197 allocation.height -
198 tab_overlap;
199 }
200 if (page->tab_label)
201 IA__gtk_widget_set_child_visible(page->tab_label, 1);
202 }
203 }