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 UiBool override_defaults;
73 int width;
74 int height;
75 int colspan;
76 int rowspan;
77 };
78
79 struct UiContainer {
80 UiLayout layout;
81 int close =
0;
82
83 virtual
void Add(FrameworkElement control, UiBool fill) =
0;
84 };
85
86 enum UiBoxContainerType {
87 UI_BOX_CONTAINER_VBOX =
0,
88 UI_BOX_CONTAINER_HBOX
89 };
90
91 enum UiNavigationViewType {
92 UI_NAVIGATIONVIEW_TOP =
0,
93 UI_NAVIGATIONVIEW_SIDE
94 };
95
96 struct UiBoxContainer : UiContainer {
97 Grid grid;
98 enum UiBoxContainerType type;
99 RowDefinition boxRowDef;
100 ColumnDefinition boxColDef;
101
102 UiBoxContainer(Grid grid,
enum UiBoxContainerType type,
int margin,
int spacing);
103
104 void Add(FrameworkElement control, UiBool fill);
105 };
106
107 struct UiGridContainer : UiContainer {
108 Grid grid;
109 int x =
0;
110 int y =
-1;
111 int cols =
0;
112
113 UiGridContainer(Grid grid,
int margin,
int columnspacing,
int rowspacing);
114
115 void Add(FrameworkElement control, UiBool fill);
116 };
117
118 struct UiTabView {
119 UiObject* current;
120 UiSubContainerType subcontainer;
121 int margin;
122 int spacing;
123 int columnspacing;
124 int rowspacing;
125
126 virtual UiObject* AddTab(
const char* label,
int index =
-1) =
0;
127 virtual
void Remove(
int index) =
0;
128 virtual
void Select(
int index) =
0;
129 virtual FrameworkElement GetFrameworkElement() =
0;
130 };
131
132 struct UiTabViewContainer : UiContainer {
133 UiTabView* tabview;
134
135 UiTabViewContainer(UiTabView* tabview);
136
137 void Add(FrameworkElement control, UiBool fill);
138 };
139
140 struct UiPivotTabView : UiTabView {
141 Pivot pivot;
142
143 UiPivotTabView(UiObject *obj, Pivot pivot, UiTabViewArgs *args);
144
145 UiObject* AddTab(
const char* label,
int index =
-1);
146 void Remove(
int index);
147 void Select(
int index);
148 FrameworkElement GetFrameworkElement();
149 };
150
151 struct UiMainTabView : UiTabView {
152 TabView tabview;
153
154 UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs *args);
155
156 UiObject* AddTab(
const char* label,
int index =
-1);
157 void Remove(
int index);
158 void Select(
int index);
159 FrameworkElement GetFrameworkElement();
160 };
161
162 struct UiNavigationTabView : UiTabView {
163 NavigationView navigationview;
164 UiTabViewType type;
165 std::vector<std::tuple<NavigationViewItem, FrameworkElement> > pages;
166
167 UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs *args, UiTabViewType type);
168
169 UiObject* AddTab(
const char* label,
int index =
-1);
170 void Remove(
int index);
171 void Select(
int index);
172 FrameworkElement GetFrameworkElement();
173
174 void SelectionChanged(NavigationView
const& sender, NavigationViewSelectionChangedEventArgs
const& args);
175 };
176
177 struct UiInvisibleTabView : UiTabView {
178 Grid container;
179 std::vector<FrameworkElement> pages;
180 int currentIndex;
181
182 UiInvisibleTabView(UiObject *obj, Grid container, UiTabViewArgs *args);
183
184 UiObject* AddTab(
const char* label,
int index =
-1);
185 void Remove(
int index);
186 void Select(
int index);
187 FrameworkElement GetFrameworkElement();
188 };