ui/common/context.c

changeset 49
2f71f4ee247a
parent 42
9af327d0e0e4
child 51
e324291ca9f8
equal deleted inserted replaced
48:ae61523bce20 49:2f71f4ee247a
89 89
90 // check if any parent context has an unbound variable with the same name 90 // check if any parent context has an unbound variable with the same name
91 // as any document variable 91 // as any document variable
92 UiContext *var_ctx = ctx; 92 UiContext *var_ctx = ctx;
93 while(var_ctx) { 93 while(var_ctx) {
94 if(var_ctx->vars_unbound && var_ctx->vars_unbound->size > 0) { 94 if(var_ctx->vars_unbound && cxMapSize(var_ctx->vars_unbound) > 0) {
95 CxIterator i = cxMapIterator(var_ctx->vars_unbound); 95 CxIterator i = cxMapIterator(var_ctx->vars_unbound);
96 cx_foreach(CxMapEntry*, entry, i) { 96 cx_foreach(CxMapEntry*, entry, i) {
97 UiVar *var = entry->value; 97 UiVar *var = entry->value;
98 UiVar *docvar = cxMapGet(doc_ctx->vars, *entry->key); 98 UiVar *docvar = cxMapGet(doc_ctx->vars, *entry->key);
99 if(docvar) { 99 if(docvar) {
399 UiVar *var = ui_malloc(ctx, sizeof(UiVar)); 399 UiVar *var = ui_malloc(ctx, sizeof(UiVar));
400 var->type = type; 400 var->type = type;
401 var->value = value; 401 var->value = value;
402 var->from = NULL; 402 var->from = NULL;
403 var->from_ctx = ctx; 403 var->from_ctx = ctx;
404 size_t oldcount = ctx->vars->size; 404 size_t oldcount = cxMapSize(ctx->vars);
405 cxMapPut(ctx->vars, name, var); 405 cxMapPut(ctx->vars, name, var);
406 if(ctx->vars->size != oldcount + 1) { 406 if(cxMapSize(ctx->vars) != oldcount + 1) {
407 fprintf(stderr, "UiError: var '%s' already exists\n", name); 407 fprintf(stderr, "UiError: var '%s' already exists\n", name);
408 } 408 }
409 409
410 // TODO: remove? 410 // TODO: remove?
411 // a widget is already bound to a var with this name 411 // a widget is already bound to a var with this name
460 // enable/disable group widgets 460 // enable/disable group widgets
461 uic_check_group_widgets(ctx); 461 uic_check_group_widgets(ctx);
462 } 462 }
463 463
464 int* ui_active_groups(UiContext *ctx, int *ngroups) { 464 int* ui_active_groups(UiContext *ctx, int *ngroups) {
465 *ngroups = ctx->groups->size; 465 *ngroups = cxListSize(ctx->groups);
466 return cxListAt(ctx->groups, 0); 466 return cxListAt(ctx->groups, 0);
467 } 467 }
468 468
469 void uic_check_group_widgets(UiContext *ctx) { 469 void uic_check_group_widgets(UiContext *ctx) {
470 int ngroups = 0; 470 int ngroups = 0;
514 const CxAllocator *a = ctx->allocator; 514 const CxAllocator *a = ctx->allocator;
515 UiGroupWidget gw; 515 UiGroupWidget gw;
516 516
517 gw.widget = widget; 517 gw.widget = widget;
518 gw.enable = enable; 518 gw.enable = enable;
519 gw.numgroups = groups->size; 519 gw.numgroups = cxListSize(groups);
520 gw.groups = cxCalloc(a, gw.numgroups, sizeof(int)); 520 gw.groups = cxCalloc(a, gw.numgroups, sizeof(int));
521 521
522 // copy groups 522 // copy groups
523 int *intgroups = cxListAt(groups, 0); 523 int *intgroups = cxListAt(groups, 0);
524 if(intgroups) { 524 if(intgroups) {

mercurial