| 523 UiContext* ui_context_parent(UiContext *ctx) { |
523 UiContext* ui_context_parent(UiContext *ctx) { |
| 524 return ctx->parent; |
524 return ctx->parent; |
| 525 } |
525 } |
| 526 |
526 |
| 527 |
527 |
| 528 void ui_set_group(UiContext *ctx, int group) { |
528 void ui_set_state(UiContext *ctx, int state) { |
| 529 if(!cxListIndexValid(ctx->states, cxListFind(ctx->states, &group))) { |
529 if(!cxListIndexValid(ctx->states, cxListFind(ctx->states, &state))) { |
| 530 cxListAdd(ctx->states, &group); |
530 cxListAdd(ctx->states, &state); |
| 531 } |
531 } |
| 532 |
532 |
| 533 // enable/disable group widgets |
533 // enable/disable group widgets |
| 534 uic_check_state_widgets(ctx); |
534 uic_check_state_widgets(ctx); |
| 535 } |
535 } |
| 536 |
536 |
| 537 void ui_unset_group(UiContext *ctx, int group) { |
537 void ui_unset_state(UiContext *ctx, int state) { |
| 538 int i = cxListFind(ctx->states, &group); |
538 int i = cxListFind(ctx->states, &state); |
| 539 if(i != -1) { |
539 if(i != -1) { |
| 540 cxListRemove(ctx->states, i); |
540 cxListRemove(ctx->states, i); |
| 541 } |
541 } |
| 542 |
542 |
| 543 // enable/disable group widgets |
543 // enable/disable group widgets |
| 544 uic_check_state_widgets(ctx); |
544 uic_check_state_widgets(ctx); |
| 545 } |
545 } |
| 546 |
546 |
| 547 int* ui_active_groups(UiContext *ctx, int *ngroups) { |
547 int* ui_active_states(UiContext *ctx, int *nstates) { |
| 548 *ngroups = cxListSize(ctx->states); |
548 *nstates = cxListSize(ctx->states); |
| 549 return cxListAt(ctx->states, 0); |
549 return cxListAt(ctx->states, 0); |
| 550 } |
550 } |
| 551 |
551 |
| 552 void uic_check_state_widgets(UiContext *ctx) { |
552 void uic_check_state_widgets(UiContext *ctx) { |
| 553 int ngroups = 0; |
553 int ngroups = 0; |
| 554 int *groups = ui_active_groups(ctx, &ngroups); |
554 int *groups = ui_active_states(ctx, &ngroups); |
| 555 |
555 |
| 556 CxIterator i = cxListIterator(ctx->state_widgets); |
556 CxIterator i = cxListIterator(ctx->state_widgets); |
| 557 cx_foreach(UiStateWidget *, gw, i) { |
557 cx_foreach(UiStateWidget *, gw, i) { |
| 558 char *check = calloc(1, gw->numstates); |
558 char *check = calloc(1, gw->numstates); |
| 559 |
559 |