#pragma once
#include "toolkit.h"
#include "../ui/container.h"
#include <Windows.h>
#undef GetCurrentTime
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Microsoft.UI.Xaml.Controls.h>
#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h>
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
#include <winrt/Microsoft.UI.Xaml.Markup.h>
#define ui_reset_layout(layout) memset(&(layout),
0,
sizeof(UiLayout))
#define ui_lb2bool(b) ((b) ==
UI_LAYOUT_TRUE ?
TRUE :
FALSE)
#define ui_bool2lb(b) ((b) ?
UI_LAYOUT_TRUE :
UI_LAYOUT_FALSE)
typedef struct UiLayout UiLayout;
typedef enum UiLayoutBool UiLayoutBool;
using namespace winrt;
using namespace Microsoft::
UI::Xaml;
using namespace Microsoft::
UI::Xaml::Controls;
using namespace Microsoft::
UI::Xaml::XamlTypeInfo;
using namespace Microsoft::
UI::Xaml::Markup;
using namespace Windows::
UI::Xaml::Interop;
enum UiLayoutBool {
UI_LAYOUT_UNDEFINED =
0,
UI_LAYOUT_TRUE,
UI_LAYOUT_FALSE,
};
struct UiLayout {
UiLayoutBool fill;
UiBool newline;
char* label;
UiBool hexpand;
UiBool vexpand;
UiBool hfill;
UiBool vfill;
int width;
int height;
int colspan;
int rowspan;
};
struct UiContainer {
UiLayout layout;
int close =
0;
virtual
void Add(FrameworkElement control, UiBool fill) =
0;
};
enum UiBoxContainerType {
UI_BOX_CONTAINER_VBOX =
0,
UI_BOX_CONTAINER_HBOX
};
enum UiNavigationViewType {
UI_NAVIGATIONVIEW_TOP =
0,
UI_NAVIGATIONVIEW_SIDE
};
struct UiBoxContainer : UiContainer {
Grid grid;
enum UiBoxContainerType type;
RowDefinition boxRowDef;
ColumnDefinition boxColDef;
UiBoxContainer(Grid grid,
enum UiBoxContainerType type,
int margin,
int spacing);
void Add(FrameworkElement control, UiBool fill);
};
struct UiGridContainer : UiContainer {
Grid grid;
int x =
0;
int y = -
1;
int cols =
0;
UiGridContainer(Grid grid,
int margin,
int columnspacing,
int rowspacing);
void Add(FrameworkElement control, UiBool fill);
};
struct UiTabView {
UiObject* current;
UiSubContainerType subcontainer;
int margin;
int spacing;
int columnspacing;
int rowspacing;
virtual UiObject* AddTab(
const char* label,
int index = -
1) =
0;
virtual
void Remove(
int index) =
0;
virtual
void Select(
int index) =
0;
virtual FrameworkElement GetFrameworkElement() =
0;
};
struct UiTabViewContainer : UiContainer {
UiTabView* tabview;
UiTabViewContainer(UiTabView* tabview);
void Add(FrameworkElement control, UiBool fill);
};
struct UiPivotTabView : UiTabView {
Pivot pivot;
UiPivotTabView(UiObject *obj, Pivot pivot, UiTabViewArgs args);
UiObject* AddTab(
const char* label,
int index = -
1);
void Remove(
int index);
void Select(
int index);
FrameworkElement GetFrameworkElement();
};
struct UiMainTabView : UiTabView {
TabView tabview;
UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs args);
UiObject* AddTab(
const char* label,
int index = -
1);
void Remove(
int index);
void Select(
int index);
FrameworkElement GetFrameworkElement();
};
struct UiNavigationTabView : UiTabView {
NavigationView navigationview;
UiTabViewType type;
std::vector<std::tuple<NavigationViewItem, FrameworkElement> > pages;
UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs args, UiTabViewType type);
UiObject* AddTab(
const char* label,
int index = -
1);
void Remove(
int index);
void Select(
int index);
FrameworkElement GetFrameworkElement();
void SelectionChanged(NavigationView
const& sender, NavigationViewSelectionChangedEventArgs
const& args);
};
struct UiInvisibleTabView : UiTabView {
Grid container;
std::vector<FrameworkElement> pages;
int currentIndex;
UiInvisibleTabView(UiObject *obj, Grid container, UiTabViewArgs args);
UiObject* AddTab(
const char* label,
int index = -
1);
void Remove(
int index);
void Select(
int index);
FrameworkElement GetFrameworkElement();
};