ui/wpf/container.c

changeset 0
804d8803eade
equal deleted inserted replaced
-1:000000000000 0:804d8803eade
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2015 Olaf Wintermann. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <stdio.h>
30 #include <stdlib.h>
31
32 #include "container.h"
33 #include "../common/object.h"
34
35 UIWIDGET ui_vbox(UiObject *obj) {
36 return ui_vbox_sp(obj, 0, 0);
37 }
38
39 UIWIDGET ui_hbox(UiObject *obj) {
40 return ui_hbox_sp(obj, 0, 0);
41 }
42
43 UIWIDGET ui_vbox_sp(UiObject *obj, int margin, int spacing) {
44 UiContainer *ct = uic_get_current_container(obj);
45
46 UIWIDGET vbox = UIvbox(ct, margin, spacing);
47
48 UiObject *newobj = uic_object_new(obj, vbox);
49 newobj->container = (UiContainer*)vbox;
50 uic_obj_add(obj, newobj);
51
52 return vbox;
53 }
54
55 UIWIDGET ui_hbox_sp(UiObject *obj, int margin, int spacing) {
56 UiContainer *ct = uic_get_current_container(obj);
57
58 UIWIDGET hbox = UIhbox(ct, margin, spacing);
59
60 UiObject *newobj = uic_object_new(obj, hbox);
61 newobj->container = (UiContainer*)hbox;
62 uic_obj_add(obj, newobj);
63
64 return hbox;
65 }
66
67 UIWIDGET ui_grid(UiObject *obj) {
68 return ui_grid_sp(obj, 0, 0, 0);
69 }
70
71 UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) {
72 UiContainer *ct = uic_get_current_container(obj);
73
74 UIWIDGET grid = UIgrid(ct, margin, columnspacing, rowspacing);
75
76 UiObject *newobj = uic_object_new(obj, grid);
77 newobj->container = (UiContainer*)grid;
78 uic_obj_add(obj, newobj);
79
80 return grid;
81 }
82
83 UIWIDGET ui_scrolledwindow(UiObject *obj) {
84 UiContainer *ct = uic_get_current_container(obj);
85
86 UIWIDGET scrolledwindow = UIscrolledwindow(ct);
87
88 UiObject *newobj = uic_object_new(obj, scrolledwindow);
89 newobj->container = (UiContainer*)scrolledwindow;
90 uic_obj_add(obj, newobj);
91
92 return scrolledwindow;
93 }
94
95 /*
96 * TODO: sidebar
97 */
98
99 UIWIDGET ui_tabview(UiObject *obj) {
100 UiContainer *ct = uic_get_current_container(obj);
101
102 UIWIDGET tabview = UItabview(ct);
103
104 UiObject *newobj = uic_object_new(obj, tabview);
105 newobj->container = (UiContainer*)tabview;
106 uic_obj_add(obj, newobj);
107
108 return tabview;
109 }
110
111 void ui_tab(UiObject *obj, char *title) {
112 UiContainer *ct = uic_get_current_container(obj);
113 UItab(ct, title);
114 }
115
116
117 /*
118 * -------------------- Layout Functions --------------------
119 *
120 * functions for setting layout attributes for the current container
121 *
122 */
123
124 void ui_layout_fill(UiObject *obj, UiBool fill) {
125 UiContainer *ct = uic_get_current_container(obj);
126 UIlayout_fill(ct, fill);
127 }
128
129 void ui_layout_hexpand(UiObject *obj, UiBool expand) {
130 UiContainer *ct = uic_get_current_container(obj);
131 UIlayout_hexpand(ct, expand);
132 }
133
134 void ui_layout_vexpand(UiObject *obj, UiBool expand) {
135 UiContainer *ct = uic_get_current_container(obj);
136 UIlayout_vexpand(ct, expand);
137 }
138
139 void ui_layout_gridwidth(UiObject *obj, int width) {
140 UiContainer *ct = uic_get_current_container(obj);
141 UIlayout_gridwidth(ct, width);
142 }
143
144 void ui_newline(UiObject *obj) {
145 UiContainer *ct = uic_get_current_container(obj);
146 UIlayout_newline(ct);
147 }

mercurial