ui/winui/container.cpp

branch
newapi
changeset 199
84e0a24bab4a
parent 198
f2332d0d3318
child 200
f40dadf3498f
equal deleted inserted replaced
198:f2332d0d3318 199:84e0a24bab4a
485 UiPivotTabView* tabview = new UiPivotTabView(obj, pivot, args); 485 UiPivotTabView* tabview = new UiPivotTabView(obj, pivot, args);
486 486
487 return tabview; 487 return tabview;
488 } 488 }
489 489
490 UiMainTabView::UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs args) {
491 this->current = obj;
492 this->tabview = tabview;
493 this->margin = args.margin;
494 this->spacing = args.spacing;
495 this->columnspacing = args.columnspacing;
496 this->rowspacing = args.rowspacing;
497 }
498
499 UiObject* UiMainTabView::AddTab(const char* label) {
500 TextBlock text = TextBlock();
501 wchar_t* wlabel = str2wstr(label, nullptr);
502 winrt::hstring hstr(wlabel);
503 text.Text(hstr);
504 free(wlabel);
505
506 TabViewItem item = TabViewItem();
507 item.Header(text);
508 item.CanDrag(false);
509 item.IsClosable(false);
510
511 // sub container
512 Grid subcontainer = Grid();
513 item.Content(subcontainer);
514 tabview.TabItems().Append(item);
515
516 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
517 }
518
519 FrameworkElement UiMainTabView::GetFrameworkElement() {
520 return tabview;
521 }
522
523 static UiTabView* tabview_doc_create(UiObject* obj, UiTabViewArgs args) {
524 TabView tabview = TabView();
525 tabview.IsAddTabButtonVisible(false);
526 tabview.CanDragTabs(false);
527 tabview.CanReorderTabs(false);
528 UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args);
529
530 return uitabview;
531 }
532
490 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) { 533 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) {
491 UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview; 534 UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview;
492 UiTabView *tabview = tabview_pivot_create(obj, args); 535 UiTabView *tabview = tabview_doc_create(obj, args);
493 UiTabViewContainer* ctn = new UiTabViewContainer(tabview); 536 UiTabViewContainer* ctn = new UiTabViewContainer(tabview);
494 537
495 // add frame to the parent container 538 // add frame to the parent container
496 UiObject* current = uic_current_obj(obj); 539 UiObject* current = uic_current_obj(obj);
497 UI_APPLY_LAYOUT1(current, args); 540 UI_APPLY_LAYOUT1(current, args);

mercurial