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