| 27 */ |
27 */ |
| 28 |
28 |
| 29 #import "Container.h" |
29 #import "Container.h" |
| 30 #import "GridLayout.h" |
30 #import "GridLayout.h" |
| 31 #import "BoxContainer.h" |
31 #import "BoxContainer.h" |
| |
32 #import "TabView.h" |
| 32 |
33 |
| 33 /* -------------------- public container functions --------------------- */ |
34 /* -------------------- public container functions --------------------- */ |
| 34 |
35 |
| 35 static UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, NSUserInterfaceLayoutOrientation orientation) { |
36 static UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs *args, NSUserInterfaceLayoutOrientation orientation) { |
| 36 BoxContainer *box = [[BoxContainer alloc] init:orientation spacing:args->spacing]; |
37 BoxContainer *box = [[BoxContainer alloc] init:orientation spacing:args->spacing]; |
| 37 box.translatesAutoresizingMaskIntoConstraints = false; |
38 box.translatesAutoresizingMaskIntoConstraints = false; |
| 38 UiContainerX *container = ui_create_container(obj, box); |
39 UiContainerX *container = ui_create_container(obj, box); |
| 39 box.container = container; |
|
| 40 |
40 |
| 41 // add box to the parent |
41 // add box to the parent |
| 42 UiLayout layout = UI_INIT_LAYOUT(args); |
42 UiLayout layout = UI_INIT_LAYOUT(args); |
| 43 ui_container_add(obj, box, &layout); |
43 ui_container_add(obj, box, &layout); |
| 44 |
44 |
| 117 uic_object_push_container(obj, container); |
117 uic_object_push_container(obj, container); |
| 118 |
118 |
| 119 return (__bridge void*)frame; |
119 return (__bridge void*)frame; |
| 120 } |
120 } |
| 121 |
121 |
| |
122 UIWIDGET ui_expander_create(UiObject *obj, UiFrameArgs *args) { |
| |
123 return ui_frame_create(obj, args); // TODO |
| |
124 } |
| |
125 |
| 122 UIWIDGET ui_scrolledwindow_create(UiObject *obj, UiFrameArgs *args) { |
126 UIWIDGET ui_scrolledwindow_create(UiObject *obj, UiFrameArgs *args) { |
| 123 int colspacing = args->spacing; |
127 int colspacing = args->spacing; |
| 124 int rowspacing = args->spacing; |
128 int rowspacing = args->spacing; |
| 125 if(args->subcontainer == UI_CONTAINER_GRID) { |
129 if(args->subcontainer == UI_CONTAINER_GRID) { |
| 126 colspacing = args->columnspacing; |
130 colspacing = args->columnspacing; |
| 136 UiContainerX *container = ui_create_container(obj, scrollview); |
140 UiContainerX *container = ui_create_container(obj, scrollview); |
| 137 uic_object_push_container(obj, container); |
141 uic_object_push_container(obj, container); |
| 138 |
142 |
| 139 return (__bridge void*)scrollview; |
143 return (__bridge void*)scrollview; |
| 140 } |
144 } |
| |
145 |
| |
146 UIWIDGET ui_tabview_create(UiObject *obj, UiTabViewArgs *args) { |
| |
147 NSView<TabView, Container> *tabview; |
| |
148 switch(args->tabview) { |
| |
149 default: tabview = [[UiTopTabView alloc]init:obj args:args]; break; |
| |
150 } |
| |
151 |
| |
152 UiLayout layout = UI_ARGS2LAYOUT(args); |
| |
153 ui_container_add(obj, tabview, &layout); |
| |
154 |
| |
155 UiContainerX *container = ui_create_container(obj, tabview); |
| |
156 uic_object_push_container(obj, container); |
| |
157 |
| |
158 return (__bridge void*)tabview; |
| |
159 } |
| |
160 |
| |
161 void ui_tab_create(UiObject *obj, const char* title) { |
| |
162 UiContainerX *ctn = obj->container_end; |
| |
163 id<TabView> tabview = (__bridge id<TabView>)ctn->container; |
| |
164 NSString *s = title ? [[NSString alloc]initWithUTF8String:title] : @""; |
| |
165 NSView<Container> *sub = [tabview createTab:-1 title:s]; |
| |
166 |
| |
167 UiContainerX *container = ui_create_container(obj, sub); |
| |
168 uic_object_push_container(obj, container); |
| |
169 } |
| |
170 |
| |
171 void ui_tabview_select(UIWIDGET tabview, int tab) { |
| |
172 id<TabView> tabv = (__bridge id<TabView>)tabview; |
| |
173 [tabv selectTab:tab]; |
| |
174 } |
| |
175 |
| |
176 void ui_tabview_remove(UIWIDGET tabview, int tab) { |
| |
177 id<TabView> tabv = (__bridge id<TabView>)tabview; |
| |
178 [tabv removeTab:tab]; |
| |
179 } |
| |
180 |
| |
181 UiObject* ui_tabview_add(UIWIDGET tabview, const char *name, int tab_index) { |
| |
182 id<TabView> tabv = (__bridge id<TabView>)tabview; |
| |
183 NSString *s = name ? [[NSString alloc]initWithUTF8String:name] : @""; |
| |
184 return [tabv addTab:tab_index title:s]; |
| |
185 } |
| |
186 |
| |
187 |
| |
188 |
| 141 |
189 |
| 142 void ui_container_begin_close(UiObject *obj) { |
190 void ui_container_begin_close(UiObject *obj) { |
| 143 UiContainerX *ct = obj->container_end; |
191 UiContainerX *ct = obj->container_end; |
| 144 ct->close = 1; |
192 ct->close = 1; |
| 145 } |
193 } |