1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #pragma once
30
31 #include "toolkit.h"
32 #include "../ui/container.h"
33
34 #include <Windows.h>
35 #undef GetCurrentTime
36 #include <winrt/Windows.Foundation.Collections.h>
37 #include <winrt/Windows.UI.Xaml.Interop.h>
38 #include <winrt/Microsoft.UI.Xaml.Controls.h>
39 #include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h>
40 #include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
41 #include <winrt/Microsoft.UI.Xaml.Markup.h>
42
43
44 #define ui_reset_layout(layout) memset(&(layout),
0,
sizeof(UiLayout))
45 #define ui_lb2bool(b) ((b) ==
UI_LAYOUT_TRUE ?
TRUE :
FALSE)
46 #define ui_bool2lb(b) ((b) ?
UI_LAYOUT_TRUE :
UI_LAYOUT_FALSE)
47
48 typedef struct UiLayout UiLayout;
49 typedef enum UiLayoutBool UiLayoutBool;
50
51 using namespace winrt;
52 using namespace Microsoft::
UI::Xaml;
53 using namespace Microsoft::
UI::Xaml::Controls;
54 using namespace Microsoft::
UI::Xaml::XamlTypeInfo;
55 using namespace Microsoft::
UI::Xaml::Markup;
56 using namespace Windows::
UI::Xaml::Interop;
57
58 enum UiLayoutBool {
59 UI_LAYOUT_UNDEFINED =
0,
60 UI_LAYOUT_TRUE,
61 UI_LAYOUT_FALSE,
62 };
63
64 struct UiLayout {
65 UiLayoutBool fill;
66 UiBool newline;
67 char* label;
68 UiBool hexpand;
69 UiBool vexpand;
70 UiBool hfill;
71 UiBool vfill;
72 int width;
73 int height;
74 int colspan;
75 int rowspan;
76 };
77
78 struct UiContainer {
79 UiLayout layout;
80 int close =
0;
81
82 virtual
void Add(FrameworkElement control, UiBool fill) =
0;
83 };
84
85 enum UiBoxContainerType {
86 UI_BOX_CONTAINER_VBOX =
0,
87 UI_BOX_CONTAINER_HBOX
88 };
89
90 enum UiNavigationViewType {
91 UI_NAVIGATIONVIEW_TOP =
0,
92 UI_NAVIGATIONVIEW_SIDE
93 };
94
95 struct UiBoxContainer : UiContainer {
96 Grid grid;
97 enum UiBoxContainerType type;
98 RowDefinition boxRowDef;
99 ColumnDefinition boxColDef;
100
101 UiBoxContainer(Grid grid,
enum UiBoxContainerType type,
int margin,
int spacing);
102
103 void Add(FrameworkElement control, UiBool fill);
104 };
105
106 struct UiGridContainer : UiContainer {
107 Grid grid;
108 int x =
0;
109 int y = -
1;
110 int cols =
0;
111
112 UiGridContainer(Grid grid,
int margin,
int columnspacing,
int rowspacing);
113
114 void Add(FrameworkElement control, UiBool fill);
115 };
116
117 struct UiTabView {
118 UiObject* current;
119 UiSubContainerType subcontainer;
120 int margin;
121 int spacing;
122 int columnspacing;
123 int rowspacing;
124
125 virtual UiObject* AddTab(
const char* label,
int index = -
1) =
0;
126 virtual
void Remove(
int index) =
0;
127 virtual
void Select(
int index) =
0;
128 virtual FrameworkElement GetFrameworkElement() =
0;
129 };
130
131 struct UiTabViewContainer : UiContainer {
132 UiTabView* tabview;
133
134 UiTabViewContainer(UiTabView* tabview);
135
136 void Add(FrameworkElement control, UiBool fill);
137 };
138
139 struct UiPivotTabView : UiTabView {
140 Pivot pivot;
141
142 UiPivotTabView(UiObject *obj, Pivot pivot, UiTabViewArgs args);
143
144 UiObject* AddTab(
const char* label,
int index = -
1);
145 void Remove(
int index);
146 void Select(
int index);
147 FrameworkElement GetFrameworkElement();
148 };
149
150 struct UiMainTabView : UiTabView {
151 TabView tabview;
152
153 UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs args);
154
155 UiObject* AddTab(
const char* label,
int index = -
1);
156 void Remove(
int index);
157 void Select(
int index);
158 FrameworkElement GetFrameworkElement();
159 };
160
161 struct UiNavigationTabView : UiTabView {
162 NavigationView navigationview;
163 UiTabViewType type;
164 std::vector<std::tuple<NavigationViewItem, FrameworkElement> > pages;
165
166 UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs args, UiTabViewType type);
167
168 UiObject* AddTab(
const char* label,
int index = -
1);
169 void Remove(
int index);
170 void Select(
int index);
171 FrameworkElement GetFrameworkElement();
172
173 void SelectionChanged(NavigationView
const& sender, NavigationViewSelectionChangedEventArgs
const& args);
174 };
175
176 struct UiInvisibleTabView : UiTabView {
177 Grid container;
178 std::vector<FrameworkElement> pages;
179 int currentIndex;
180
181 UiInvisibleTabView(UiObject *obj, Grid container, UiTabViewArgs args);
182
183 UiObject* AddTab(
const char* label,
int index = -
1);
184 void Remove(
int index);
185 void Select(
int index);
186 FrameworkElement GetFrameworkElement();
187 };