ui/gtk/container.h

changeset 431
bb7da585debc
parent 422
c1354a29a7e9
equal deleted inserted replaced
169:fe49cff3c571 431:bb7da585debc
31 31
32 #include "../ui/toolkit.h" 32 #include "../ui/toolkit.h"
33 #include "../ui/container.h" 33 #include "../ui/container.h"
34 #include <string.h> 34 #include <string.h>
35 35
36 #include <cx/allocator.h>
37 #include <cx/hash_map.h>
38
36 #ifdef __cplusplus 39 #ifdef __cplusplus
37 extern "C" { 40 extern "C" {
38 #endif 41 #endif
39 42
40 #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) 43 #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout))
58 UiLayoutBool fill; 61 UiLayoutBool fill;
59 UiBool newline; 62 UiBool newline;
60 char *label; 63 char *label;
61 UiBool hexpand; 64 UiBool hexpand;
62 UiBool vexpand; 65 UiBool vexpand;
66 UiBool hfill;
67 UiBool vfill;
63 int width; 68 int width;
64 int gridwidth; 69 int colspan;
70 int rowspan;
65 }; 71 };
66 72
67 struct UiContainer { 73 struct UiContainer {
68 GtkWidget *widget; 74 GtkWidget *widget;
69 GtkMenu *menu; 75 UIMENU menu;
70 GtkWidget *current; 76 GtkWidget *current;
71 77
72 void (*add)(UiContainer*, GtkWidget*, UiBool); 78 void (*add)(UiContainer*, GtkWidget*, UiBool);
73 UiLayout layout; 79 UiLayout layout;
74 80
75 int close; 81 int close;
76 }; 82 };
77 83
78 typedef struct UiBoxContainer { 84 typedef struct UiBoxContainer {
79 UiContainer container; 85 UiContainer container;
86 UiSubContainerType type;
80 UiBool has_fill; 87 UiBool has_fill;
81 } UiBoxContainer; 88 } UiBoxContainer;
82 89
83 typedef struct UiGridContainer { 90 typedef struct UiGridContainer {
84 UiContainer container; 91 UiContainer container;
88 int width; 95 int width;
89 int height; 96 int height;
90 #endif 97 #endif
91 } UiGridContainer; 98 } UiGridContainer;
92 99
100 /*
93 typedef struct UiPanedContainer { 101 typedef struct UiPanedContainer {
94 UiContainer container; 102 UiContainer container;
95 GtkWidget *current_pane; 103 GtkWidget *current_pane;
96 int orientation; 104 int orientation;
97 int max; 105 int max;
98 int cur; 106 int cur;
99 } UiPanedContainer; 107 } UiPanedContainer;
108 */
100 109
101 typedef struct UiTabViewContainer { 110 typedef struct UiTabViewContainer {
102 UiContainer container; 111 UiContainer container;
103 } UiTabViewContainer; 112 } UiTabViewContainer;
113
114 typedef void (*ui_select_tab_func)(UIWIDGET widget, int tab);
115 typedef void (*ui_add_tab_func)(UIWIDGET widget, int index, const char *name, UIWIDGET child);
116
117 typedef struct UiGtkTabView {
118 UiObject *obj;
119 GtkWidget *widget;
120 ui_select_tab_func select_tab;
121 ui_select_tab_func remove_tab;
122 ui_add_tab_func add_tab;
123 UiSubContainerType subcontainer;
124 int margin;
125 int spacing;
126 int columnspacing;
127 int rowspacing;
128 } UiGtkTabView;
129
130 typedef struct UiHeaderbarContainer {
131 UiContainer container;
132 GtkWidget *centerbox;
133 int part;
134 UiHeaderbarAlternative alternative; /* only used by fallback headerbar */
135 } UiHeaderbarContainer;
136
137 typedef struct UiGtkItemListContainer {
138 UiObject *parent;
139 GtkWidget *widget;
140 UiContainer *container;
141 void (*create_ui)(UiObject *, int, void *, void *);
142 void *userdata;
143 UiSubContainerType subcontainer;
144 CxMap *current_items;
145 int margin;
146 int spacing;
147 int columnspacing;
148 int rowspacing;
149 bool remove_items;
150 } UiGtkItemListContainer;
104 151
105 GtkWidget* ui_gtk_vbox_new(int spacing); 152 GtkWidget* ui_gtk_vbox_new(int spacing);
106 GtkWidget* ui_gtk_hbox_new(int spacing); 153 GtkWidget* ui_gtk_hbox_new(int spacing);
107 154
155 GtkWidget* ui_subcontainer_create(
156 UiSubContainerType type,
157 UiObject *newobj,
158 int spacing,
159 int columnspacing,
160 int rowspacing,
161 int margin);
162
108 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame); 163 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame);
109 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); 164 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
110 165
111 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box); 166 GtkWidget* ui_box_set_margin(GtkWidget *box, int margin);
167 UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs args, UiSubContainerType type);
168
169 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type);
112 void ui_box_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); 170 void ui_box_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
113 171
172 GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing);
114 UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid); 173 UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid);
115 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); 174 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
116 175
176 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame);
177 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
178
179 UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander);
180 void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
181
117 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow); 182 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow);
118 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); 183 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
119 184
120 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview); 185 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview);
121 void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); 186 void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
123 void ui_paned_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill); 188 void ui_paned_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
124 189
125 void ui_split_container_add1(UiContainer *ct, GtkWidget *widget, UiBool fill); 190 void ui_split_container_add1(UiContainer *ct, GtkWidget *widget, UiBool fill);
126 void ui_split_container_add2(UiContainer *ct, GtkWidget *widget, UiBool fill); 191 void ui_split_container_add2(UiContainer *ct, GtkWidget *widget, UiBool fill);
127 192
128 193 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview);
129 UiObject* ui_add_document_tab(UiDocumentView *view); 194
130 void ui_tab_set_document(UiContext *ctx, void *document); 195 void ui_gtk_notebook_select_tab(GtkWidget *widget, int tab);
131 void ui_tab_detach_document(UiContext *ctx); 196
197 #if GTK_CHECK_VERSION(3, 10, 0)
198 UiContainer* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar);
199 void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
200 #endif
201
202 UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar);
203 void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
132 204
133 #ifdef __cplusplus 205 #ifdef __cplusplus
134 } 206 }
135 #endif 207 #endif
136 208

mercurial