ui/common/args.c

changeset 599
54012d674e07
child 601
9f67b662f694
equal deleted inserted replaced
598:7b03db81caf8 599:54012d674e07
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2025 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 "args.h"
30
31 #include <string.h>
32 #include <stdlib.h>
33
34 #include "../ui/container.h"
35
36 /* ---------------------------- UiContainerArgs ---------------------------- */
37
38 UIEXPORT UiContainerArgs* ui_container_args_new(void) {
39 UiContainerArgs *args = malloc(sizeof(UiContainerArgs));
40 memset(args, 0, sizeof(UiContainerArgs));
41 return args;
42 }
43
44 void ui_container_args_set_fill(UiContainerArgs *args, UiBool fill) {
45 args->fill = fill ? UI_ON : UI_OFF;
46 }
47
48 void ui_container_args_set_hexpand(UiContainerArgs *args, UiBool value) {
49 args->hexpand = value;
50 }
51
52
53 void ui_container_args_set_vexpand(UiContainerArgs *args, UiBool value) {
54 args->vexpand = value;
55 }
56
57
58 void ui_container_args_set_hfill(UiContainerArgs *args, UiBool value) {
59 args->hfill = value;
60 }
61
62
63 void ui_container_args_set_vfill(UiContainerArgs *args, UiBool value) {
64 args->vfill = value;
65 }
66
67
68 void ui_container_args_set_override_defaults(UiContainerArgs *args, UiBool value) {
69 args->override_defaults = value;
70 }
71
72
73 void ui_container_args_set_colspan(UiContainerArgs *args, int colspan) {
74 args->colspan = colspan;
75 }
76
77
78 void ui_container_args_set_rolspan(UiContainerArgs *args, int rowspan) {
79 args->rowspan = rowspan;
80 }
81
82
83 void ui_container_args_set_def_hexpand(UiContainerArgs *args, UiBool value) {
84 args->def_hexpand = value;
85 }
86
87
88 void ui_container_args_set_def_vexpand(UiContainerArgs *args, UiBool value) {
89 args->def_vexpand = value;
90 }
91
92
93 void ui_container_args_set_def_hfill(UiContainerArgs *args, UiBool value) {
94 args->def_hfill = value;
95 }
96
97
98 void ui_container_args_set_def_vfill(UiContainerArgs *args, UiBool value) {
99 args->def_vfill = value;
100 }
101
102
103 void ui_container_args_set_name(UiContainerArgs *args, const char *name) {
104 args->name = strdup(name);
105 }
106
107
108 void ui_container_args_set_style_class(UiContainerArgs *args, const char *classname) {
109 args->style_class = strdup(classname);
110 }
111
112
113 void ui_container_args_set_margin(UiContainerArgs *args, int value) {
114 args->margin = value;
115 }
116
117
118 void ui_container_args_set_spacing(UiContainerArgs *args, int value) {
119 args->spacing = value;
120 }
121
122
123 void ui_container_args_set_columnspacing(UiContainerArgs *args, int value) {
124 args->columnspacing = value;
125 }
126
127
128 void ui_container_args_set_rowspacing(UiContainerArgs *args, int value) {
129 args->rowspacing = value;
130 }
131
132
133 void ui_container_args_free(UiContainerArgs *args) {
134 free((void*)args->name);
135 free((void*)args->style_class);
136 free(args);
137 }
138
139
140 /* ------------------------------- UiFrameArgs ------------------------------*/
141
142 UIEXPORT UiFrameArgs* ui_frame_args_new(void) {
143 UiFrameArgs *args = malloc(sizeof(UiFrameArgs));
144 memset(args, 0, sizeof(UiContainerArgs));
145 return args;
146 }
147
148
149 void ui_frame_args_set_fill(UiFrameArgs *args, UiBool fill) {
150 args->fill = fill ? UI_ON : UI_OFF;
151 }
152
153
154 void ui_frame_args_set_hexpand(UiFrameArgs *args, UiBool value) {
155 args->hexpand = value;
156 }
157
158
159 void ui_frame_args_set_vexpand(UiFrameArgs *args, UiBool value) {
160 args->vexpand = value;
161 }
162
163
164 void ui_frame_args_set_hfill(UiFrameArgs *args, UiBool value) {
165 args->hfill = value;
166 }
167
168
169 void ui_frame_args_set_vfill(UiFrameArgs *args, UiBool value) {
170 args->vfill = value;
171 }
172
173
174 void ui_frame_args_set_override_defaults(UiFrameArgs *args, UiBool value) {
175 args->override_defaults = value;
176 }
177
178
179 void ui_frame_args_set_colspan(UiFrameArgs *args, int colspan) {
180 args->colspan = colspan;
181 }
182
183
184 void ui_frame_args_set_rolspan(UiFrameArgs *args, int rowspan) {
185 args->rowspan = rowspan;
186 }
187
188
189 void ui_frame_args_set_name(UiFrameArgs *args, const char *name) {
190 args->name = strdup(name);
191 }
192
193
194 void ui_frame_args_set_style_class(UiFrameArgs *args, const char *classname) {
195 args->style_class = strdup(classname);
196 }
197
198
199 void ui_frame_args_set_margin(UiFrameArgs *args, int value) {
200 args->margin = value;
201 }
202
203
204 void ui_frame_args_set_spacing(UiFrameArgs *args, int value) {
205 args->spacing = value;
206 }
207
208
209 void ui_frame_args_set_columnspacing(UiFrameArgs *args, int value) {
210 args->columnspacing = value;
211 }
212
213
214 void ui_frame_args_set_rowspacing(UiFrameArgs *args, int value) {
215 args->rowspacing = value;
216 }
217
218
219 void ui_frame_args_set_expanded(UiFrameArgs *args, UiBool value) {
220 args->isexpanded = value;
221 }
222
223
224 void ui_frame_args_set_label(UiFrameArgs *args, const char *label) {
225 args->label = strdup(label);
226 }
227
228
229 void ui_frame_args_free(UiFrameArgs *args) {
230 free((void*)args->name);
231 free((void*)args->style_class);
232 free((void*)args->label);
233 free(args);
234 }
235

mercurial