| 92 } |
95 } |
| 93 } |
96 } |
| 94 |
97 |
| 95 /* --------------------------- UiList --------------------------- */ |
98 /* --------------------------- UiList --------------------------- */ |
| 96 |
99 |
| 97 UiList* ui_list_new(UiContext *ctx, char *name) { |
100 void uic_ucx_list_init(UiContext *ctx, UiList *list, void *unused) { |
| 98 UiList *list = malloc(sizeof(UiList)); |
101 list->data = cxArrayListCreate(ctx->mp->allocator, NULL, CX_STORE_POINTERS, 32); |
| 99 list->first = ui_list_first; |
102 list->first = ui_list_first; |
| 100 list->next = ui_list_next; |
103 list->next = ui_list_next; |
| 101 list->get = ui_list_get; |
104 list->get = ui_list_get; |
| 102 list->count = ui_list_count; |
105 list->count = ui_list_count; |
| 103 list->observers = NULL; |
106 } |
| 104 |
107 |
| 105 list->data = cxArrayListCreate(cxDefaultAllocator, NULL, CX_STORE_POINTERS, 32); |
108 UiList* ui_list_new(UiContext *ctx, const char *name) { |
| 106 list->iter = NULL; |
109 return ui_list_new2(ctx, name, default_list_init ? default_list_init : uic_ucx_list_init, default_list_init_userdata); |
| 107 |
110 } |
| 108 list->update = NULL; |
111 |
| 109 list->getselection = NULL; |
112 UiList* ui_list_new2(UiContext *ctx, const char *name, ui_list_init_func listinit, void *userdata) { |
| 110 list->obj = NULL; |
113 UiList *list = cxMalloc(ctx->mp->allocator, sizeof(UiList)); |
| |
114 memset(list, 0, sizeof(UiList)); |
| |
115 listinit(ctx, list, userdata); |
| 111 |
116 |
| 112 if(name) { |
117 if(name) { |
| 113 uic_reg_var(ctx, name, UI_VAR_LIST, list); |
118 uic_reg_var(ctx, name, UI_VAR_LIST, list); |
| 114 } |
119 } |
| 115 |
120 |
| 246 } |
251 } |
| 247 |
252 |
| 248 // types |
253 // types |
| 249 |
254 |
| 250 // public functions |
255 // public functions |
| 251 UiInteger* ui_int_new(UiContext *ctx, char *name) { |
256 UiInteger* ui_int_new(UiContext *ctx, const char *name) { |
| 252 UiInteger *i = ui_malloc(ctx, sizeof(UiInteger)); |
257 UiInteger *i = ui_malloc(ctx, sizeof(UiInteger)); |
| 253 memset(i, 0, sizeof(UiInteger)); |
258 memset(i, 0, sizeof(UiInteger)); |
| 254 if(name) { |
259 if(name) { |
| 255 uic_reg_var(ctx, name, UI_VAR_INTEGER, i); |
260 uic_reg_var(ctx, name, UI_VAR_INTEGER, i); |
| 256 } |
261 } |
| 257 return i; |
262 return i; |
| 258 } |
263 } |
| 259 |
264 |
| 260 UiDouble* ui_double_new(UiContext *ctx, char *name) { |
265 UiDouble* ui_double_new(UiContext *ctx, const char *name) { |
| 261 UiDouble *d = ui_malloc(ctx, sizeof(UiDouble)); |
266 UiDouble *d = ui_malloc(ctx, sizeof(UiDouble)); |
| 262 memset(d, 0, sizeof(UiDouble)); |
267 memset(d, 0, sizeof(UiDouble)); |
| 263 if(name) { |
268 if(name) { |
| 264 uic_reg_var(ctx, name, UI_VAR_DOUBLE, d); |
269 uic_reg_var(ctx, name, UI_VAR_DOUBLE, d); |
| 265 } |
270 } |
| 266 return d; |
271 return d; |
| 267 } |
272 } |
| 268 |
273 |
| 269 UiString* ui_string_new(UiContext *ctx, char *name) { |
274 UiString* ui_string_new(UiContext *ctx, const char *name) { |
| 270 UiString *s = ui_malloc(ctx, sizeof(UiString)); |
275 UiString *s = ui_malloc(ctx, sizeof(UiString)); |
| 271 memset(s, 0, sizeof(UiString)); |
276 memset(s, 0, sizeof(UiString)); |
| 272 if(name) { |
277 if(name) { |
| 273 uic_reg_var(ctx, name, UI_VAR_STRING, s); |
278 uic_reg_var(ctx, name, UI_VAR_STRING, s); |
| 274 } |
279 } |
| 275 return s; |
280 return s; |
| 276 } |
281 } |
| 277 |
282 |
| 278 UiText* ui_text_new(UiContext *ctx, char *name) { |
283 UiText* ui_text_new(UiContext *ctx, const char *name) { |
| 279 UiText *t = ui_malloc(ctx, sizeof(UiText)); |
284 UiText *t = ui_malloc(ctx, sizeof(UiText)); |
| 280 memset(t, 0, sizeof(UiText)); |
285 memset(t, 0, sizeof(UiText)); |
| 281 if(name) { |
286 if(name) { |
| 282 uic_reg_var(ctx, name, UI_VAR_TEXT, t); |
287 uic_reg_var(ctx, name, UI_VAR_TEXT, t); |
| 283 } |
288 } |
| 284 return t; |
289 return t; |
| 285 } |
290 } |
| 286 |
291 |
| 287 UiRange* ui_range_new(UiContext *ctx, char *name) { |
292 UiRange* ui_range_new(UiContext *ctx, const char *name) { |
| 288 UiRange *r = ui_malloc(ctx, sizeof(UiRange)); |
293 UiRange *r = ui_malloc(ctx, sizeof(UiRange)); |
| 289 memset(r, 0, sizeof(UiRange)); |
294 memset(r, 0, sizeof(UiRange)); |
| 290 if(name) { |
295 if(name) { |
| 291 uic_reg_var(ctx, name, UI_VAR_RANGE, r); |
296 uic_reg_var(ctx, name, UI_VAR_RANGE, r); |
| 292 } |
297 } |
| 293 return r; |
298 return r; |
| 294 } |
299 } |
| 295 |
300 |
| 296 UIEXPORT UiGeneric* ui_generic_new(UiContext *ctx, char *name) { |
301 UIEXPORT UiGeneric* ui_generic_new(UiContext *ctx, const char *name) { |
| 297 UiGeneric *g = ui_malloc(ctx, sizeof(UiGeneric)); |
302 UiGeneric *g = ui_malloc(ctx, sizeof(UiGeneric)); |
| 298 memset(g, 0, sizeof(UiGeneric)); |
303 memset(g, 0, sizeof(UiGeneric)); |
| 299 if(name) { |
304 if(name) { |
| 300 uic_reg_var(ctx, name, UI_VAR_GENERIC, g); |
305 uic_reg_var(ctx, name, UI_VAR_GENERIC, g); |
| 301 } |
306 } |