ui/common/context.c

branch
newapi
changeset 343
54f5d7eb1335
parent 342
99f83fbf48e9
equal deleted inserted replaced
342:99f83fbf48e9 343:54f5d7eb1335
521 uic_add_group_widget(ctx, widget, enable, groups); 521 uic_add_group_widget(ctx, widget, enable, groups);
522 522
523 cxListDestroy(groups); 523 cxListDestroy(groups);
524 } 524 }
525 525
526 size_t uic_group_array_size(const int *groups) {
527 int i;
528 for(i=0;groups[i] >= 0;i++) { }
529 return i;
530 }
531
526 void uic_add_group_widget(UiContext *ctx, void *widget, ui_enablefunc enable, CxList *groups) { 532 void uic_add_group_widget(UiContext *ctx, void *widget, ui_enablefunc enable, CxList *groups) {
533 uic_add_group_widget_i(ctx, widget, enable, cxListAt(groups, 0), cxListSize(groups));
534 }
535
536 void uic_add_group_widget_i(UiContext *ctx, void *widget, ui_enablefunc enable, const int *groups, size_t numgroups) {
527 const CxAllocator *a = ctx->allocator; 537 const CxAllocator *a = ctx->allocator;
528 UiGroupWidget gw; 538 UiGroupWidget gw;
529 539
530 gw.widget = widget; 540 gw.widget = widget;
531 gw.enable = enable; 541 gw.enable = enable;
532 gw.numgroups = cxListSize(groups); 542 gw.numgroups = numgroups;
533 gw.groups = cxCalloc(a, gw.numgroups, sizeof(int)); 543 gw.groups = cxCalloc(a, numgroups, sizeof(int));
534 544
535 // copy groups 545 // copy groups
536 int *intgroups = cxListAt(groups, 0); 546 if(groups) {
537 if(intgroups) { 547 memcpy(gw.groups, groups, gw.numgroups * sizeof(int));
538 memcpy(gw.groups, intgroups, gw.numgroups * sizeof(int));
539 } 548 }
540 549
541 cxListAdd(ctx->group_widgets, &gw); 550 cxListAdd(ctx->group_widgets, &gw);
542 } 551 }
543 552

mercurial