ui/winui/list.cpp

branch
newapi
changeset 222
1121b61f8828
parent 221
a82d9beaa94a
child 225
097f45f9c1fa
equal deleted inserted replaced
221:a82d9beaa94a 222:1121b61f8828
281 UiPathBar* uipathbar = new UiPathBar; 281 UiPathBar* uipathbar = new UiPathBar;
282 ui_context_add_pathbar_destructor(current->ctx, uipathbar); 282 ui_context_add_pathbar_destructor(current->ctx, uipathbar);
283 uipathbar->grid = content; 283 uipathbar->grid = content;
284 uipathbar->buttons = buttons; 284 uipathbar->buttons = buttons;
285 uipathbar->textbox = pathTextBox; 285 uipathbar->textbox = pathTextBox;
286 uipathbar->obj = obj;
286 uipathbar->enabledrag = args.enabledrag; 287 uipathbar->enabledrag = args.enabledrag;
287 uipathbar->enabledrop = args.enabledrop; 288 uipathbar->enabledrop = args.enabledrop;
288 uipathbar->getvalue = args.getvalue; 289 uipathbar->getvalue = args.getvalue;
289 uipathbar->model = args.model; 290 uipathbar->model = args.model;
290 uipathbar->onactivate = args.onactivate; 291 uipathbar->onactivate = args.onactivate;
413 // clear old buttons 414 // clear old buttons
414 ui_pathbar_clear(pb->buttons); 415 ui_pathbar_clear(pb->buttons);
415 416
416 // add new buttons 417 // add new buttons
417 void* elm = list->first(list); 418 void* elm = list->first(list);
419 int j = 0;
418 while (elm) { 420 while (elm) {
419 char* value = (char*)getvalue(elm, 0); 421 char* value = (char*)getvalue(elm, 0);
420 wchar_t* wstr = str2wstr(value, nullptr); 422 wchar_t* wstr = str2wstr(value, nullptr);
421 Button button = Button(); 423 Button button = Button();
422 button.Content(box_value(wstr)); 424 button.Content(box_value(wstr));
423 free(wstr); 425 free(wstr);
424 426
427 if (pb->onactivate) {
428 button.Click([pb, j](IInspectable const& sender, RoutedEventArgs) {
429 UiEvent evt;
430 evt.obj = pb->obj;
431 evt.window = evt.obj->window;
432 evt.document = evt.obj->ctx->document;
433 evt.eventdata = nullptr;
434 evt.intval = j;
435 pb->onactivate(&evt, pb->onactivatedata);
436 });
437 }
438
425 Thickness t = { 0, 0, 1, 0 }; 439 Thickness t = { 0, 0, 1, 0 };
426 CornerRadius c = { 0 ,0, 0, 0 }; 440 CornerRadius c = { 0 ,0, 0, 0 };
427 button.BorderThickness(t); 441 button.BorderThickness(t);
428 button.CornerRadius(c); 442 button.CornerRadius(c);
429 443
430 pb->buttons.Children().Append(button); 444 pb->buttons.Children().Append(button);
431 445
446 j++;
432 elm = list->next(list); 447 elm = list->next(list);
433 } 448 }
434 } 449 }
435 450
436 451

mercurial