]>
Commit | Line | Data |
---|---|---|
45516216 | 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 | if (1) { | |
83 | left_x = priv->x = | |
84 | anchor; | |
85 | anchor += | |
86 | notebook->cur_page-> | |
87 | allocation.width - | |
88 | tab_overlap; | |
89 | } | |
90 | if ((notebook->cur_page->pack == | |
91 | GTK_PACK_END | |
92 | && right_x > anchor)) { | |
93 | anchor -= | |
94 | notebook->cur_page-> | |
95 | allocation.width; | |
96 | left_x = priv->x = | |
97 | anchor; | |
98 | } | |
99 | } | |
100 | } else { | |
101 | if (allocate_at_bottom) | |
102 | anchor -= child_allocation.width; | |
103 | if (priv->operation == DRAG_OPERATION_REORDER | |
104 | && page->pack == notebook->cur_page->pack) { | |
105 | if (!allocate_at_bottom | |
106 | && left_x >= anchor | |
107 | && left_x <= | |
108 | anchor + child_allocation.width / 2) | |
109 | anchor += | |
110 | notebook->cur_page-> | |
111 | allocation.width - | |
112 | tab_overlap; | |
113 | else if (allocate_at_bottom | |
114 | && right_x >= | |
115 | anchor + | |
116 | child_allocation.width / 2 | |
117 | && right_x <= | |
118 | anchor + | |
119 | child_allocation.width) | |
120 | anchor -= | |
121 | notebook->cur_page-> | |
122 | allocation.width - | |
123 | tab_overlap; | |
124 | } | |
125 | child_allocation.x = anchor; | |
126 | } | |
127 | break; | |
128 | case GTK_POS_LEFT: | |
129 | case GTK_POS_RIGHT: | |
130 | child_allocation.height = | |
131 | page->requisition.height + tab_overlap + | |
132 | tab_extra_space; | |
133 | if (packing_changed) { | |
134 | priv->x = child_allocation.x; | |
135 | priv->y = top_y; | |
136 | if (priv->operation == DRAG_OPERATION_REORDER | |
137 | && page->pack == notebook->cur_page->pack) { | |
138 | if (!allocate_at_bottom | |
139 | && top_y >= anchor | |
140 | && top_y <= | |
141 | anchor + | |
142 | child_allocation.height / 2) | |
143 | anchor += | |
144 | notebook->cur_page-> | |
145 | allocation.height - | |
146 | tab_overlap; | |
147 | } | |
148 | } | |
149 | } | |
150 | if ((page == priv->detached_tab | |
151 | && priv->operation == DRAG_OPERATION_DETACH) | |
152 | || (page == notebook->cur_page | |
153 | && priv->operation == DRAG_OPERATION_REORDER)) { | |
154 | page->allocation.x = 0; | |
155 | } | |
156 | if (page != notebook->cur_page) { | |
157 | switch (tab_pos) { | |
158 | case GTK_POS_TOP: | |
159 | page->allocation.y += ythickness; | |
160 | case GTK_POS_BOTTOM: | |
161 | page->allocation.height = | |
162 | (((1) > | |
163 | (page->allocation.height - | |
164 | ythickness)) ? (1) : (page->allocation. | |
165 | height - | |
166 | ythickness)); | |
167 | break; | |
168 | case GTK_POS_LEFT: | |
169 | page->allocation.x += xthickness; | |
170 | case GTK_POS_RIGHT: | |
171 | page->allocation.width = | |
172 | (((1) > | |
173 | (page->allocation.width - | |
174 | xthickness)) ? (1) : (page->allocation. | |
175 | width - | |
176 | xthickness)); | |
177 | } | |
178 | } | |
179 | switch (tab_pos) { | |
180 | case GTK_POS_TOP: | |
181 | case GTK_POS_BOTTOM: | |
182 | if (priv->operation != DRAG_OPERATION_REORDER | |
183 | || (priv->operation == DRAG_OPERATION_REORDER | |
184 | && page != notebook->cur_page)) | |
185 | if (!allocate_at_bottom) | |
186 | anchor += | |
187 | child_allocation.width - | |
188 | tab_overlap; | |
189 | case GTK_POS_LEFT: | |
190 | case GTK_POS_RIGHT: | |
191 | if (priv->operation != DRAG_OPERATION_REORDER | |
192 | || (priv->operation == DRAG_OPERATION_REORDER | |
193 | && page != notebook->cur_page)) | |
194 | if (priv->operation == DRAG_OPERATION_REORDER) | |
195 | if (page->pack == | |
196 | notebook->cur_page->pack | |
197 | && !allocate_at_bottom | |
198 | && top_y >= | |
199 | anchor + child_allocation.height / 2 | |
200 | && top_y <= | |
201 | anchor + child_allocation.height) | |
202 | anchor += | |
203 | notebook->cur_page-> | |
204 | allocation.height - | |
205 | tab_overlap; | |
206 | } | |
207 | if (page->tab_label) | |
208 | IA__gtk_widget_set_child_visible(page->tab_label, | |
209 | (!(0))); | |
210 | } | |
211 | } |