ui/gtk/container.h

changeset 112
c3f2f16fa4b8
parent 110
c00e968d018b
equal deleted inserted replaced
111:81c4f73236a4 112:c3f2f16fa4b8
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 typedef struct UiSplitPane {
122 typedef struct UiSplitPaneContainer {
123 UiContainer container;
124 GtkWidget *current_pane; 107 GtkWidget *current_pane;
125 CxList *children; 108 CxList *children;
126 UiOrientation orientation; 109 UiOrientation orientation;
127 int pos; 110 int pos;
128 int max; 111 int max;
129 int nchildren; 112 int nchildren;
130 int initial_position; 113 int initial_position;
114 } UiSplitPane;
115
116 typedef struct UiSplitPaneContainer {
117 UiContainerPrivate container;
118 UiSplitPane *splitpane;
131 } UiSplitPaneContainer; 119 } UiSplitPaneContainer;
132 120
133 typedef struct UiHeaderbarContainer { 121 typedef struct UiHeaderbarContainer {
134 UiContainer container; 122 UiContainerPrivate container;
135 GtkWidget *centerbox; 123 GtkWidget *centerbox;
136 int part; 124 int part;
137 UiHeaderbarAlternative alternative; /* only used by fallback headerbar */ 125 UiHeaderbarAlternative alternative; /* only used by fallback headerbar */
138 } UiHeaderbarContainer; 126 } UiHeaderbarContainer;
139 127
140 typedef struct UiGtkItemListContainer { 128 typedef struct UiGtkItemListContainer {
141 UiObject *parent; 129 UiObject *parent;
142 GtkWidget *widget; 130 GtkWidget *widget;
143 UiContainer *container; 131 UiContainerPrivate *container;
144 void (*create_ui)(UiObject *, int, void *, void *); 132 void (*create_ui)(UiObject *, int, void *, void *);
145 void *userdata; 133 void *userdata;
146 UiSubContainerType subcontainer; 134 UiSubContainerType subcontainer;
147 CxMap *current_items; 135 CxMap *current_items;
148 int margin; 136 int margin;
161 int spacing, 149 int spacing,
162 int columnspacing, 150 int columnspacing,
163 int rowspacing, 151 int rowspacing,
164 int margin); 152 int margin);
165 153
166 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame); 154 GtkWidget* ui_gtk_set_margin(GtkWidget *widget, int margin, int margin_left, int margin_right, int margin_top, int margin_bottom);
167 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget);
168
169 GtkWidget* ui_box_set_margin(GtkWidget *box, int margin);
170 UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, UiSubContainerType type); 155 UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, UiSubContainerType type);
171 156
172 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type); 157 UiContainerX* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type);
173 void ui_box_container_add(UiContainer *ct, GtkWidget *widget); 158 void ui_box_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
174 159
175 GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing); 160 GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing);
176 UiContainer* ui_grid_container( 161 UiContainerX* ui_grid_container(
177 UiObject *obj, 162 UiObject *obj,
178 GtkWidget *grid, 163 GtkWidget *grid,
179 UiBool def_hexpand, 164 UiBool def_hexpand,
180 UiBool def_vexpand, 165 UiBool def_vexpand,
181 UiBool def_hfill, 166 UiBool def_hfill,
182 UiBool def_vfill); 167 UiBool def_vfill);
183 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget); 168 void ui_grid_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
184 169
185 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame); 170 UiContainerX* ui_frame_container(UiObject *obj, GtkWidget *frame);
186 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget); 171 void ui_frame_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
187 172
188 UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander); 173 UiContainerX* ui_expander_container(UiObject *obj, GtkWidget *expander);
189 void ui_expander_container_add(UiContainer *ct, GtkWidget *widget); 174 void ui_expander_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
190 175
191 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow); 176 UiContainerX* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow);
192 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget); 177 void ui_scrolledwindow_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
193 178
194 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview); 179 UiContainerX* ui_tabview_container(UiObject *obj, GtkWidget *tabview);
195 void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget); 180 void ui_tabview_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
196 181
197 UiContainer* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiOrientation orientation, int max, int init); 182 UiSplitPane* ui_create_splitpane_data(GtkWidget *pane, UiOrientation orientation, int max, int init);
198 void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget); 183 UiContainerX* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiSplitPane *data);
184 void ui_splitpane_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
199 185
200 int64_t ui_splitpane_get(UiInteger *i); 186 int64_t ui_splitpane_get(UiInteger *i);
201 void ui_splitpane_set(UiInteger *i, int64_t value); 187 void ui_splitpane_set(UiInteger *i, int64_t value);
202 188
203 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview); 189 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview);
204 190
205 void ui_gtk_notebook_select_tab(GtkWidget *widget, int tab); 191 void ui_gtk_notebook_select_tab(GtkWidget *widget, int tab);
206 192
207 #if GTK_CHECK_VERSION(3, 10, 0) 193 #if GTK_CHECK_VERSION(3, 10, 0)
208 UiContainer* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar); 194 UiContainerX* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar);
209 void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget); 195 void ui_headerbar_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
210 #endif 196 #endif
211 197
212 UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar); 198 UiContainerX* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar);
213 void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget); 199 void ui_headerbar_fallback_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout);
214 200
215 #ifdef __cplusplus 201 #ifdef __cplusplus
216 } 202 }
217 #endif 203 #endif
218 204

mercurial