ui/gtk/container.h

changeset 801
e096c441e874
parent 765
ee08f7859b78
child 804
ce992dbfbc39
equal deleted inserted replaced
800:814d374fb689 801:e096c441e874
43 extern "C" { 43 extern "C" {
44 #endif 44 #endif
45 45
46 #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) 46 #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout))
47 47
48 typedef void (*ui_container_add_f)(UiContainer*, GtkWidget*);
49 48
50 typedef struct UiDocumentView UiDocumentView; 49 typedef struct UiDocumentView UiDocumentView;
51 50
52 51 typedef struct UiContainerPrivate UiContainerPrivate;
53 typedef struct UiLayout UiLayout; 52 struct UiContainerPrivate {
54 struct UiLayout { 53 UiContainerX container;
55 UiBool fill;
56 UiBool newline;
57 char *label;
58 UiBool hexpand;
59 UiBool vexpand;
60 UiBool hfill;
61 UiBool vfill;
62 UiBool override_defaults;
63 int width;
64 int colspan;
65 int rowspan;
66 };
67
68 struct UiContainer {
69 GtkWidget *widget; 54 GtkWidget *widget;
70 UIMENU menu; 55 UIMENU menu;
71 GtkWidget *current; 56 GtkWidget *current; // TODO: remove
72 57
73 void (*add)(UiContainer*, GtkWidget*); 58 void (*add)(UiContainerPrivate*, GtkWidget*, UiLayout *layout);
74 UiLayout layout; 59 UiLayout layout;
75 60
76 int close; 61 int close;
77 }; 62 };
78 63
79 typedef struct UiBoxContainer { 64 typedef struct UiBoxContainer {
80 UiContainer container; 65 UiContainerPrivate container;
81 UiSubContainerType type; 66 UiSubContainerType type;
82 UiBool has_fill; 67 UiBool has_fill;
83 } UiBoxContainer; 68 } UiBoxContainer;
84 69
85 typedef struct UiGridContainer { 70 typedef struct UiGridContainer {
86 UiContainer container; 71 UiContainerPrivate container;
87 UiBool def_hexpand; 72 UiBool def_hexpand;
88 UiBool def_vexpand; 73 UiBool def_vexpand;
89 UiBool def_hfill; 74 UiBool def_hfill;
90 UiBool def_vfill; 75 UiBool def_vfill;
91 int x; 76 int x;
95 int height; 80 int height;
96 #endif 81 #endif
97 } UiGridContainer; 82 } UiGridContainer;
98 83
99 typedef struct UiTabViewContainer { 84 typedef struct UiTabViewContainer {
100 UiContainer container; 85 UiContainerPrivate container;
101 } UiTabViewContainer; 86 } UiTabViewContainer;
102 87
103 typedef void (*ui_select_tab_func)(UIWIDGET widget, int tab); 88 typedef void (*ui_select_tab_func)(UIWIDGET widget, int tab);
104 typedef void (*ui_add_tab_func)(UIWIDGET widget, int index, const char *name, UIWIDGET child); 89 typedef void (*ui_add_tab_func)(UIWIDGET widget, int index, const char *name, UIWIDGET child);
105 90
108 GtkWidget *widget; 93 GtkWidget *widget;
109 ui_select_tab_func select_tab; 94 ui_select_tab_func select_tab;
110 ui_select_tab_func remove_tab; 95 ui_select_tab_func remove_tab;
111 ui_add_tab_func add_tab; 96 ui_add_tab_func add_tab;
112 UiSubContainerType subcontainer; 97 UiSubContainerType subcontainer;
113 int margin; 98 int padding;
114 int spacing; 99 int spacing;
115 int columnspacing; 100 int columnspacing;
116 int rowspacing; 101 int rowspacing;
117 ui_callback onchange; 102 ui_callback onchange;
118 void *onchangedata; 103 void *onchangedata;
119 } UiGtkTabView; 104 } UiGtkTabView;
120 105
121 106
122 typedef struct UiSplitPaneContainer { 107 typedef struct UiSplitPaneContainer {
123 UiContainer container; 108 UiContainerPrivate container;
124 GtkWidget *current_pane; 109 GtkWidget *current_pane;
125 CxList *children; 110 CxList *children;
126 UiOrientation orientation; 111 UiOrientation orientation;
127 int pos; 112 int pos;
128 int max; 113 int max;
129 int nchildren; 114 int nchildren;
130 int initial_position; 115 int initial_position;
131 } UiSplitPaneContainer; 116 } UiSplitPaneContainer;
132 117
133 typedef struct UiHeaderbarContainer { 118 typedef struct UiHeaderbarContainer {
134 UiContainer container; 119 UiContainerPrivate container;
135 GtkWidget *centerbox; 120 GtkWidget *centerbox;
136 int part; 121 int part;
137 UiHeaderbarAlternative alternative; /* only used by fallback headerbar */ 122 UiHeaderbarAlternative alternative; /* only used by fallback headerbar */
138 } UiHeaderbarContainer; 123 } UiHeaderbarContainer;
139 124
140 typedef struct UiGtkItemListContainer { 125 typedef struct UiGtkItemListContainer {
141 UiObject *parent; 126 UiObject *parent;
142 GtkWidget *widget; 127 GtkWidget *widget;
143 UiContainer *container; 128 UiContainerPrivate *container;
144 void (*create_ui)(UiObject *, int, void *, void *); 129 void (*create_ui)(UiObject *, int, void *, void *);
145 void *userdata; 130 void *userdata;
146 UiSubContainerType subcontainer; 131 UiSubContainerType subcontainer;
147 CxMap *current_items; 132 CxMap *current_items;
148 int margin; 133 int margin;
161 int spacing, 146 int spacing,
162 int columnspacing, 147 int columnspacing,
163 int rowspacing, 148 int rowspacing,
164 int margin); 149 int margin);
165 150
166 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame);
167 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget);
168
169 GtkWidget* ui_box_set_margin(GtkWidget *box, int margin); 151 GtkWidget* ui_box_set_margin(GtkWidget *box, int margin);
170 UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, UiSubContainerType type); 152 UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, UiSubContainerType type);
171 153
172 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type); 154 UiContainerX* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type);
173 void ui_box_container_add(UiContainer *ct, GtkWidget *widget); 155 void ui_box_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
174 156
175 GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing); 157 GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing);
176 UiContainer* ui_grid_container( 158 UiContainerX* ui_grid_container(
177 UiObject *obj, 159 UiObject *obj,
178 GtkWidget *grid, 160 GtkWidget *grid,
179 UiBool def_hexpand, 161 UiBool def_hexpand,
180 UiBool def_vexpand, 162 UiBool def_vexpand,
181 UiBool def_hfill, 163 UiBool def_hfill,
182 UiBool def_vfill); 164 UiBool def_vfill);
183 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget); 165 void ui_grid_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
184 166
185 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame); 167 UiContainerX* ui_frame_container(UiObject *obj, GtkWidget *frame);
186 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget); 168 void ui_frame_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
187 169
188 UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander); 170 UiContainerX* ui_expander_container(UiObject *obj, GtkWidget *expander);
189 void ui_expander_container_add(UiContainer *ct, GtkWidget *widget); 171 void ui_expander_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
190 172
191 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow); 173 UiContainerX* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow);
192 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget); 174 void ui_scrolledwindow_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
193 175
194 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview); 176 UiContainerX* ui_tabview_container(UiObject *obj, GtkWidget *tabview);
195 void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget); 177 void ui_tabview_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
196 178
197 UiContainer* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiOrientation orientation, int max, int init); 179 UiContainerX* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiOrientation orientation, int max, int init);
198 void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget); 180 void ui_splitpane_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
199 181
200 int64_t ui_splitpane_get(UiInteger *i); 182 int64_t ui_splitpane_get(UiInteger *i);
201 void ui_splitpane_set(UiInteger *i, int64_t value); 183 void ui_splitpane_set(UiInteger *i, int64_t value);
202 184
203 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview); 185 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview);
204 186
205 void ui_gtk_notebook_select_tab(GtkWidget *widget, int tab); 187 void ui_gtk_notebook_select_tab(GtkWidget *widget, int tab);
206 188
207 #if GTK_CHECK_VERSION(3, 10, 0) 189 #if GTK_CHECK_VERSION(3, 10, 0)
208 UiContainer* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar); 190 UiContainerX* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar);
209 void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget); 191 void ui_headerbar_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
210 #endif 192 #endif
211 193
212 UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar); 194 UiContainerX* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar);
213 void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget); 195 void ui_headerbar_fallback_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
214 196
215 #ifdef __cplusplus 197 #ifdef __cplusplus
216 } 198 }
217 #endif 199 #endif
218 200

mercurial