ui/winui/container.cpp

Thu, 05 Dec 2024 08:40:37 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 05 Dec 2024 08:40:37 +0100
branch
newapi
changeset 408
b06e43f1edd4
parent 378
d41b1ffc5f77
permissions
-rw-r--r--

fix grid colspan/rowspan

182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
3 *
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
5 *
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
6 * Redistribution and use in source and binary forms, with or without
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
7 * modification, are permitted provided that the following conditions are met:
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
8 *
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
10 * notice, this list of conditions and the following disclaimer.
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
11 *
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
14 * documentation and/or other materials provided with the distribution.
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
15 *
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
27 */
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
205
b1ac0dd1d38b new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
29 #include "pch.h"
b1ac0dd1d38b new winui vs project, add toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 202
diff changeset
30
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include "container.h"
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
33 #include "../common/context.h"
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
34 #include "../common/object.h"
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
35
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
36 #include "util.h"
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
37
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
38
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
39 void ui_container_begin_close(UiObject* obj) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
40 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
41 ct->close = 1;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
42 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
43
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
44 int ui_container_finish(UiObject* obj) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
45 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
46 if (ct->close) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
47 ui_end(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
48 return 0;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
49 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
50 return 1;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
51 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
52
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
53
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
54 // --------------------- UiBoxContainer ---------------------
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
56 static UIWIDGET ui_box(UiObject* obj, UiContainerArgs args, UiBoxContainerType type) {
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
57 UiObject* current = uic_current_obj(obj);
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
58 UI_APPLY_LAYOUT1(current, args);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
59
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
60 Grid grid = Grid();
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
61 current->container->Add(grid, true);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
62
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
63 UIElement elm = grid;
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
64 UiWidget* widget = new UiWidget(elm);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
65 ui_context_add_widget_destructor(current->ctx, widget);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
66
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
67 UiObject* newobj = uic_object_new(obj, widget);
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
68 newobj->container = new UiBoxContainer(grid, type, args.margin, args.spacing);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
69 ui_context_add_container_destructor(current->ctx, newobj->container);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
70 uic_obj_add(obj, newobj);
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
71
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
72 return widget;
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
73 }
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
74
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
75 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs args) {
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
76 return ui_box(obj, args, UI_BOX_CONTAINER_VBOX);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
77 }
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
78
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
79 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs args) {
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
80 return ui_box(obj, args, UI_BOX_CONTAINER_HBOX);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
81 }
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
82
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
83 UiBoxContainer::UiBoxContainer(Grid grid, enum UiBoxContainerType type, int margin, int spacing) {
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 this->grid = grid;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 this->type = type;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
87 Thickness t = { (double)margin, (double)margin, (double)margin, (double)margin };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
88 grid.Margin(t);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
89 grid.ColumnSpacing((double)spacing);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
90 grid.RowSpacing((double)spacing);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
91
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
92 GridLength gl;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
93 gl.Value = 1;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
94 gl.GridUnitType = GridUnitType::Star;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
95
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 // hbox needs one row def, vbox needs one col def
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 // all other col/row defs are created when elements are added
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
98 if (type == UI_BOX_CONTAINER_HBOX) {
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
99 boxRowDef = RowDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
100 boxRowDef.Height(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
101 grid.RowDefinitions().Append(boxRowDef);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 } else {
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
103 boxColDef = ColumnDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
104 boxColDef.Width(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
105 grid.ColumnDefinitions().Append(boxColDef);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 }
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
107
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
108 ui_reset_layout(layout);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
111 void UiBoxContainer::Add(FrameworkElement control, UiBool fill) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
112 if (this->layout.fill != UI_LAYOUT_UNDEFINED) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
113 fill = ui_lb2bool(this->layout.fill);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
114 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
115
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 GridLength gl;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 if (fill) {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 gl.Value = 1;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 gl.GridUnitType = GridUnitType::Star;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 else {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 gl.Value = 0;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 gl.GridUnitType = GridUnitType::Auto;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 }
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
125
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
126 control.HorizontalAlignment(HorizontalAlignment::Stretch);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
127 control.VerticalAlignment(VerticalAlignment::Stretch);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
128
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 if (type == UI_CONTAINER_HBOX) {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 ColumnDefinition coldef = ColumnDefinition();
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 coldef.Width(gl);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 grid.ColumnDefinitions().Append(coldef);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 grid.SetColumn(control, grid.Children().Size());
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
134 grid.SetRow(control, 0);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 } else {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 RowDefinition rowdef = RowDefinition();
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 rowdef.Height(gl);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 grid.RowDefinitions().Append(rowdef);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 grid.SetRow(control, grid.Children().Size());
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
140 grid.SetColumn(control, 0);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 grid.Children().Append(control);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
144
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
145 ui_reset_layout(layout);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
146 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
147
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
148
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
149 // --------------------- UiGridContainer ---------------------
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
150
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
151 UIWIDGET ui_grid_create(UiObject* obj, UiContainerArgs args) {
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
152 UiObject* current = uic_current_obj(obj);
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
153 UI_APPLY_LAYOUT1(current, args);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
154
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
155 Grid grid = Grid();
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
156 current->container->Add(grid, true);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
157
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
158 UIElement elm = grid;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
159 UiWidget* widget = new UiWidget(elm);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
160 ui_context_add_widget_destructor(current->ctx, widget);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
161
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
162 UiObject* newobj = uic_object_new(obj, widget);
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
163 newobj->container = new UiGridContainer(grid, args.margin, args.columnspacing, args.rowspacing);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
164 ui_context_add_container_destructor(current->ctx, newobj->container);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
165 uic_obj_add(obj, newobj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
166
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
167 return widget;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
168 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
169
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
170 UiGridContainer::UiGridContainer(Grid grid, int margin, int columnspacing, int rowspacing) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
171 this->grid = grid;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
172 Thickness t = { (double)margin, (double)margin, (double)margin, (double)margin };
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
173 grid.Margin(t);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
174 grid.ColumnSpacing((double)columnspacing);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
175 grid.RowSpacing((double)rowspacing);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
176 ui_reset_layout(layout);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
179 void UiGridContainer::Add(FrameworkElement control, UiBool fill) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
180 GridLength gl;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
181
377
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
182 bool hexpand = false;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
183 bool vexpand = false;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
184 bool hfill = false;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
185 bool vfill = false;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
186 if(layout.fill != UI_LAYOUT_UNDEFINED) {
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
187 fill = ui_lb2bool(layout.fill);
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
188 }
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
189 if (layout.hexpand != UI_LAYOUT_UNDEFINED) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
190 hexpand = layout.hexpand;
377
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
191 hfill = true;
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
192 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
193 if (layout.vexpand != UI_LAYOUT_UNDEFINED) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
194 vexpand = layout.vexpand;
377
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
195 vfill = true;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
196 }
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
197 if (fill) {
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
198 hfill = true;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
199 vfill = true;
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
200 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
201
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
202 // create new RowDefinition for the new line
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
203 if (layout.newline || y == -1) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
204 x = 0;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
205 y++;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
206 RowDefinition rowdef = RowDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
207 if (vexpand) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
208 gl.GridUnitType = GridUnitType::Star;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
209 gl.Value = 1;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
210 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
211 else {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
212 gl.GridUnitType = GridUnitType::Auto;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
213 gl.Value = 0;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
214 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
215 rowdef.Height(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
216 grid.RowDefinitions().Append(rowdef);
377
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
217 } else if (vexpand) {
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
218 // adjust row
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
219 gl.GridUnitType = GridUnitType::Star;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
220 gl.Value = 1;
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
221 grid.RowDefinitions().GetAt(y).Height(gl);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
222 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
223
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
224 // create new columndefinition, if a new column is added
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
225 if (x == cols) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
226 if (hexpand) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
227 gl.GridUnitType = GridUnitType::Star;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
228 gl.Value = 1;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
229 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
230 else {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
231 gl.GridUnitType = GridUnitType::Auto;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
232 gl.Value = 0;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
233 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
234 ColumnDefinition coldef = ColumnDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
235 coldef.Width(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
236 grid.ColumnDefinitions().Append(coldef);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
237 cols++;
377
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
238 } else if(hexpand) {
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
239 // adjust column
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
240 if (layout.colspan == 0) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
241 gl.GridUnitType = GridUnitType::Star;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
242 gl.Value = 1;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
243 grid.ColumnDefinitions().GetAt(x).Width(gl);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
244 } else {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
245 int adjust_col = x;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
246 bool adjust = true;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
247 for (int i = 0; i < layout.colspan; i++) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
248 if (grid.ColumnDefinitions().Size() == x + i) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
249 break;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
250 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
251 adjust_col = x + i;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
252 GridLength w = grid.ColumnDefinitions().GetAt(adjust_col).Width();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
253 if (w.GridUnitType == GridUnitType::Star) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
254 adjust = false;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
255 break;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
256 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
257 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
258
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
259 if (adjust) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
260 gl.GridUnitType = GridUnitType::Star;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
261 gl.Value = 1;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
262 grid.ColumnDefinitions().GetAt(adjust_col).Width(gl);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
263 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
264 }
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
265 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
266
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
267 // add control
377
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
268 if (hfill) {
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
269 control.HorizontalAlignment(HorizontalAlignment::Stretch);
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
270 }
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
271 if (vfill) {
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
272 control.VerticalAlignment(VerticalAlignment::Stretch);
3a60db9ebb5d implement hfill/vfill (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
273 }
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
274
186
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
275 if (layout.colspan > 0) {
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
276 grid.SetColumnSpan(control, layout.colspan);
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
277 }
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
278 if (layout.rowspan > 0) {
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
279 grid.SetRowSpan(control, layout.rowspan);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
280 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
281
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
282 grid.SetRow(control, y);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
283 grid.SetColumn(control, x);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
284 grid.Children().Append(control);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
285
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
286 x++;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
287
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
288 ui_reset_layout(layout);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
289 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
290
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
291 // --------------------- UI Frame ---------------------
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
292
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
293 UIWIDGET ui_frame_create(UiObject* obj, UiFrameArgs args) {
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
294 // create a grid for the frame, that contains the label and a sub-frame
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
295 Grid frame = Grid();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
296
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
297 GridLength gl;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
298 gl.GridUnitType = GridUnitType::Star;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
299 gl.Value = 1;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
300
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
301 ColumnDefinition coldef = ColumnDefinition();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
302 coldef.Width(gl);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
303 frame.ColumnDefinitions().Append(coldef);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
304
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
305 RowDefinition rowdefFrame = RowDefinition();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
306 rowdefFrame.Height(gl);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
307
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
308 // label
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
309 int row = 0;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
310 if (args.label) {
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
311 RowDefinition rowdefLabel = RowDefinition();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
312 gl.GridUnitType = GridUnitType::Auto;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
313 gl.Value = 0;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
314 rowdefLabel.Height(gl);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
315 frame.RowDefinitions().Append(rowdefLabel);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
316
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
317 TextBlock label = TextBlock();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
318 wchar_t* wlabel = str2wstr(args.label, nullptr);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
319 winrt::hstring hstr(wlabel);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
320 label.Text(hstr);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
321 free(wlabel);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
322
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
323 frame.SetRow(label, row++);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
324 frame.SetColumn(label, 0);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
325 frame.Children().Append(label);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
326 }
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
327
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
328 // workarea frame
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
329 frame.RowDefinitions().Append(rowdefFrame);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
330
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
331 Grid workarea = Grid();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
332 frame.SetRow(workarea, row);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
333 frame.SetColumn(workarea, 0);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
334 frame.Children().Append(workarea);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
335
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
336 // some styling for the workarea
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
337 winrt::Microsoft::UI::Xaml::Media::SolidColorBrush brush{ winrt::Microsoft::UI::ColorHelper::FromArgb(150, 150, 150, 150) };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
338 workarea.BorderBrush(brush);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
339 CornerRadius radius{ 8, 8, 8, 8 };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
340 Thickness t = { 1, 1, 1, 1 };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
341 workarea.CornerRadius(radius);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
342 workarea.BorderThickness(t);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
343
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
344 Thickness padding = { 10, 10, 10, 10 };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
345 workarea.Padding(padding);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
346
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
347 // add frame to the parent container
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
348 UiObject* current = uic_current_obj(obj);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
349 UI_APPLY_LAYOUT1(current, args);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
350 current->container->Add(frame, true);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
351
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
352 UIElement elm = frame;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
353 UiWidget* widget = new UiWidget(elm);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
354 ui_context_add_widget_destructor(current->ctx, widget);
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
355
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
356 // sub container
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
357 UiContainer* ctn = nullptr;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
358 switch (args.subcontainer) {
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
359 default:
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
360 case UI_CONTAINER_VBOX: {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
361 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
362 break;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
363 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
364 case UI_CONTAINER_HBOX: {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
365 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
366 break;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
367 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
368 case UI_CONTAINER_GRID: {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
369 ctn = new UiGridContainer(workarea, args.margin, args.columnspacing, args.rowspacing);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
370 break;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
371 }
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
372 }
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
373 ui_context_add_container_destructor(current->ctx, ctn);
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
374
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
375 UiObject* newobj = uic_object_new(obj, widget);
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
376 newobj->container = ctn;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
377 uic_obj_add(obj, newobj);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
378
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
379 return widget;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
380 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
381
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
382 // --------------------- UI Expander ---------------------
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
383
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
384 UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs args) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
385 Expander expander = Expander();
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
386 if (args.label) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
387 wchar_t* wlabel = str2wstr(args.label, nullptr);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
388 expander.Header(box_value(wlabel));
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
389 free(wlabel);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
390 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
391 expander.IsExpanded(args.isexpanded);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
392
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
393 // add frame to the parent container
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
394 UiObject* current = uic_current_obj(obj);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
395 UI_APPLY_LAYOUT1(current, args);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
396 current->container->Add(expander, true);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
397
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
398 UIElement elm = expander;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
399 UiWidget* widget = new UiWidget(elm);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
400 ui_context_add_widget_destructor(current->ctx, widget);
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
401
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
402 Grid content = Grid();
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
403 expander.Content(content);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
404
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
405 UiContainer* ctn = nullptr;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
406 switch (args.subcontainer) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
407 default:
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
408 case UI_CONTAINER_VBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
409 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
410 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
411 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
412 case UI_CONTAINER_HBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
413 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
414 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
415 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
416 case UI_CONTAINER_GRID: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
417 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
418 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
419 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
420 }
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
421 ui_context_add_container_destructor(current->ctx, ctn);
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
422
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
423 UiObject* newobj = uic_object_new(obj, widget);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
424 newobj->container = ctn;
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
425 uic_obj_add(obj, newobj);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
426
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
427 return widget;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
428 }
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
429
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
430 // --------------------- UI ScrolledWindow ---------------------
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
431
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
432 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) {
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
433 ScrollViewer scrollW = ScrollViewer();
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
434
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
435 // add frame to the parent container
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
436 UiObject* current = uic_current_obj(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
437 UI_APPLY_LAYOUT1(current, args);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
438 current->container->Add(scrollW, true);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
439
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
440 UIElement elm = scrollW;
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
441 UiWidget* widget = new UiWidget(elm);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
442 ui_context_add_widget_destructor(current->ctx, widget);
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
443
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
444 // create child container
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
445 Grid content = Grid();
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
446 scrollW.Content(content);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
447
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
448 UiContainer* ctn = nullptr;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
449 switch (args.subcontainer) {
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
450 default:
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
451 case UI_CONTAINER_VBOX: {
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
452 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing);
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
453 break;
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
454 }
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
455 case UI_CONTAINER_HBOX: {
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
456 ctn = new UiBoxContainer(content, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing);
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
457 break;
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
458 }
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
459 case UI_CONTAINER_GRID: {
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
460 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing);
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
461 break;
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
462 }
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
463 }
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
464 ui_context_add_container_destructor(current->ctx, ctn);
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
465
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
466 UiObject* newobj = uic_object_new(obj, widget);
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
467 newobj->container = ctn;
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
468 uic_obj_add(obj, newobj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
469
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
470 return widget;
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
471 }
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
472
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
473 // --------------------- UI TabView ---------------------
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
474
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
475 UiTabViewContainer::UiTabViewContainer(UiTabView* tabview) {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
476 this->tabview = tabview;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
477 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
478
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
479 void UiTabViewContainer::Add(FrameworkElement control, UiBool fill) {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
480 // noop
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
481 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
482
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
483 static UiObject* create_subcontainer_obj(UiObject* current, Grid subcontainer, UiSubContainerType type, int margin, int spacing, int columnspacing, int rowspacing) {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
484 UiContainer* ctn = nullptr;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
485 switch (type) {
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
486 default:
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
487 case UI_CONTAINER_VBOX: {
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
488 ctn = new UiBoxContainer(subcontainer, UI_BOX_CONTAINER_VBOX, margin, spacing);
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
489 break;
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
490 }
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
491 case UI_CONTAINER_HBOX: {
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
492 ctn = new UiBoxContainer(subcontainer, UI_BOX_CONTAINER_HBOX, margin, spacing);
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
493 break;
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
494 }
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
495 case UI_CONTAINER_GRID: {
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
496 ctn = new UiGridContainer(subcontainer, margin, columnspacing, rowspacing);
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
497 break;
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
498 }
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
499 }
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
500 ui_context_add_container_destructor(current->ctx, ctn);
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
501
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
502 UIElement elm = subcontainer;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
503 UiWidget* widget = new UiWidget(elm);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
504 ui_context_add_widget_destructor(current->ctx, widget);
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
505 UiObject* newobj = uic_object_new(current, widget);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
506 newobj->container = ctn;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
507 return newobj;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
508 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
509
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
510 static UiTabView* tabview_pivot_create(UiObject* obj, UiTabViewArgs args) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
511 Pivot pivot = Pivot();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
512 UiPivotTabView* tabview = new UiPivotTabView(obj, pivot, args);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
513
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
514 return tabview;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
515 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
516
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
517 UiPivotTabView::UiPivotTabView(UiObject* obj, Pivot pivot, UiTabViewArgs args) {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
518 this->current = obj;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
519 this->pivot = pivot;
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
520 this->subcontainer = args.subcontainer;
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
521 this->margin = args.margin;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
522 this->spacing = args.spacing;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
523 this->columnspacing = args.columnspacing;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
524 this->rowspacing = args.rowspacing;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
525 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
526
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
527 UiObject* UiPivotTabView::AddTab(const char* label, int index) {
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
528 TextBlock text = TextBlock();
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
529 wchar_t* wlabel = str2wstr(label, nullptr);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
530 winrt::hstring hstr(wlabel);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
531 text.Text(hstr);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
532 free(wlabel);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
533
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
534 PivotItem item = PivotItem();
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
535 item.Header(text);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
536
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
537 // sub container
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
538 Grid subcontainer = Grid();
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
539 item.Content(subcontainer);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
540 pivot.Items().Append(item);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
541
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
542 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
543 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
544
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
545 void UiPivotTabView::Remove(int index) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
546 pivot.Items().RemoveAt(index);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
547 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
548
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
549 void UiPivotTabView::Select(int index) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
550
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
551 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
552
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
553 FrameworkElement UiPivotTabView::GetFrameworkElement() {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
554 return pivot;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
555 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
556
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
557
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
558 static UiTabView* tabview_invisible_create(UiObject *obj, UiTabViewArgs args) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
559 Grid container = Grid();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
560 container.HorizontalAlignment(HorizontalAlignment::Stretch);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
561 container.VerticalAlignment(VerticalAlignment::Stretch);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
562 UiInvisibleTabView *tabview = new UiInvisibleTabView(obj, container, args);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
563 return tabview;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
564 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
565
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
566 UiInvisibleTabView::UiInvisibleTabView(UiObject* obj, Grid container, UiTabViewArgs args) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
567 this->current = obj;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
568 this->container = container;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
569 this->subcontainer = args.subcontainer;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
570 this->margin = args.margin;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
571 this->spacing = args.spacing;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
572 this->columnspacing = args.columnspacing;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
573 this->rowspacing = args.rowspacing;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
574 this->currentIndex = -1;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
575
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
576 GridLength gl;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
577 gl.GridUnitType = GridUnitType::Star;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
578 gl.Value = 1;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
579
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
580 ColumnDefinition coldef = ColumnDefinition();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
581 coldef.Width(gl);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
582 container.ColumnDefinitions().Append(coldef);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
583
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
584 RowDefinition rowdef = RowDefinition();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
585 rowdef.Height(gl);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
586 container.RowDefinitions().Append(rowdef);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
587 }
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
588
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
589 UiObject* UiInvisibleTabView::AddTab(const char* label, int index) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
590 Grid subcontainer = Grid();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
591 subcontainer.HorizontalAlignment(HorizontalAlignment::Stretch);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
592 subcontainer.VerticalAlignment(VerticalAlignment::Stretch);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
593
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
594 if (pages.size() == 0) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
595 container.Children().Append(subcontainer);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
596 currentIndex = 0;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
597 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
598
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
599 if (index < 0) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
600 pages.push_back(subcontainer);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
601 } else {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
602 pages.insert(pages.begin() + index, subcontainer);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
603 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
604
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
605 // sub container
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
606 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
607 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
608
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
609 void UiInvisibleTabView::Remove(int index) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
610
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
611 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
612
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
613 void UiInvisibleTabView::Select(int index) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
614 if (index >= 0 && index < pages.size()) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
615 if (currentIndex != -1) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
616 container.Children().RemoveAt(0);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
617 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
618
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
619 container.Children().Append(pages.at(index));
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
620 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
621 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
622
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
623 FrameworkElement UiInvisibleTabView::GetFrameworkElement() {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
624 return container;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
625 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
626
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
627
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
628 static UiTabView* tabview_main_create(UiObject* obj, UiTabViewArgs args) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
629 TabView tabview = TabView();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
630 tabview.IsAddTabButtonVisible(false);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
631 //tabview.CanDragTabs(false);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
632 //tabview.CanReorderTabs(false);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
633 UiMainTabView* uitabview = new UiMainTabView(obj, tabview, args);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
634
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
635 return uitabview;
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
636 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
637
199
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
638 UiMainTabView::UiMainTabView(UiObject* obj, TabView tabview, UiTabViewArgs args) {
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
639 this->current = obj;
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
640 this->tabview = tabview;
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
641 this->subcontainer = args.subcontainer;
199
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
642 this->margin = args.margin;
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
643 this->spacing = args.spacing;
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
644 this->columnspacing = args.columnspacing;
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
645 this->rowspacing = args.rowspacing;
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
646 }
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
647
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
648 UiObject* UiMainTabView::AddTab(const char* label, int index) {
199
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
649 TextBlock text = TextBlock();
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
650 wchar_t* wlabel = str2wstr(label, nullptr);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
651 winrt::hstring hstr(wlabel);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
652 text.Text(hstr);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
653 free(wlabel);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
654
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
655 TabViewItem item = TabViewItem();
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
656 item.Header(text);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
657 item.CanDrag(false);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
658 item.IsClosable(false);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
659
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
660 // sub container
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
661 Grid subcontainer = Grid();
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
662 item.Content(subcontainer);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
663 tabview.TabItems().Append(item);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
664
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
665 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
666 }
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
667
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
668 void UiMainTabView::Remove(int index) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
669 this->tabview.TabItems().RemoveAt(index);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
670 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
671
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
672 void UiMainTabView::Select(int index) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
673
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
674 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
675
199
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
676 FrameworkElement UiMainTabView::GetFrameworkElement() {
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
677 return tabview;
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
678 }
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
679
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
680
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
681 static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args, UiTabViewType type) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
682 NavigationView navigationview = NavigationView();
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
683 UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, type);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
684 navigationview.IsBackButtonVisible(NavigationViewBackButtonVisible::Collapsed);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
685 navigationview.IsSettingsVisible(false);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
686
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
687 return tabview;
199
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
688 }
84e0a24bab4a add main tabview based on WinUI TabView
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 198
diff changeset
689
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
690 UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs args, UiTabViewType type) {
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
691 this->current = obj;
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
692 this->navigationview = navigationview;
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
693 this->type = type;
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
694 this->margin = args.margin;
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
695 this->spacing = args.spacing;
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
696 this->columnspacing = args.columnspacing;
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
697 this->rowspacing = args.rowspacing;
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
698
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
699 if (type == UI_TABVIEW_NAVIGATION_TOP) {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
700 navigationview.PaneDisplayMode(NavigationViewPaneDisplayMode::Top);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
701 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
702
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
703 navigationview.SelectionChanged({ this, &UiNavigationTabView::SelectionChanged });
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
704 }
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
705
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
706 UiObject* UiNavigationTabView::AddTab(const char* label, int index1) {
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
707 TextBlock text = TextBlock();
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
708 wchar_t* wlabel = str2wstr(label, nullptr);
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
709 winrt::hstring hstr(wlabel);
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
710 text.Text(hstr);
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
711 free(wlabel);
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
712
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
713 NavigationViewItem item = NavigationViewItem();
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
714 item.Content(text);
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
715
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
716 // sub container
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
717 Grid subcontainer = Grid();
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
718 if (pages.size() == 0) {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
719 navigationview.Content(subcontainer);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
720 navigationview.SelectedItem(item);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
721 }
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
722
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
723 navigationview.MenuItems().Append(item);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
724 auto page = std::tuple<NavigationViewItem, FrameworkElement>{ item, subcontainer };
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
725 pages.push_back(page);
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
726
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
727 return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing);
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
728 }
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
729
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
730 void UiNavigationTabView::Remove(int index) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
731 navigationview.MenuItems().RemoveAt(index);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
732 pages.erase(pages.begin() + index);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
733 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
734
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
735 void UiNavigationTabView::Select(int index) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
736
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
737 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
738
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
739 FrameworkElement UiNavigationTabView::GetFrameworkElement() {
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
740 return navigationview;
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
741 }
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
742
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
743 void UiNavigationTabView::SelectionChanged(NavigationView const& sender, NavigationViewSelectionChangedEventArgs const& args) {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
744 for (auto page : pages) {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
745 NavigationViewItem item = std::get<0>(page);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
746 FrameworkElement elm = std::get<1>(page);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
747 if (item == navigationview.SelectedItem()) {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
748 navigationview.Content(elm);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
749 break;
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
750 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
751 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
752 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
753
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
754 static int64_t ui_tabview_get(UiInteger *i) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
755 return 0;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
756 }
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
757
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
758 static void ui_tabview_set(UiInteger *i, int64_t value) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
759 UiTabView *tabview = (UiTabView*)i->obj;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
760 tabview->Select(value);
200
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
761 }
f40dadf3498f add unfinished navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
762
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
763 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
764 UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview;
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
765 UiTabView* tabview = nullptr;
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
766 switch (type) {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
767 default: {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
768 tabview = tabview_pivot_create(obj, args);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
769 break;
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
770 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
771 case UI_TABVIEW_DOC: {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
772 tabview = tabview_main_create(obj, args);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
773 break;
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
774 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
775 case UI_TABVIEW_NAVIGATION_SIDE: {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
776 tabview = tabview_navigationview_create(obj, args, type);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
777 break;
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
778 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
779 case UI_TABVIEW_NAVIGATION_TOP: {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
780 tabview = tabview_navigationview_create(obj, args, type);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
781 break;
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
782 }
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
783 case UI_TABVIEW_NAVIGATION_TOP2: {
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
784 tabview = tabview_pivot_create(obj, args);
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
785 break;
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
786 }
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
787 case UI_TABVIEW_INVISIBLE: {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
788 tabview = tabview_invisible_create(obj, args);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
789 break;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
790 }
202
9f309d1914a2 finish navigationview (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 200
diff changeset
791 }
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
792 UiTabViewContainer* ctn = new UiTabViewContainer(tabview);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
793
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
794 // add frame to the parent container
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
795 UiObject* current = uic_current_obj(obj);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
796 UI_APPLY_LAYOUT1(current, args);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
797 current->container->Add(tabview->GetFrameworkElement(), true);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
798
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
799 UIElement elm = tabview->GetFrameworkElement();
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
800 UiWidget* widget = new UiWidget(elm);
212
ad5c74af14c4 add cleanup code for wrapper objects (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 205
diff changeset
801 ui_context_add_widget_destructor(current->ctx, widget);
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
802 widget->data1 = tabview;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
803
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
804 // TODO: add tabview destructor
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
805
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
806 // bind variable
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
807 UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_INTEGER);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
808 if (var) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
809 UiInteger *i = (UiInteger*)var->value;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
810 i->obj = tabview;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
811 i->get = ui_tabview_get;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
812 i->set = ui_tabview_set;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
813 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
814
198
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
815 UiObject* newobj = uic_object_new(obj, widget);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
816 newobj->container = ctn;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
817 uic_obj_add(obj, newobj);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
818
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
819 return widget;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
820 }
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
821
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
822 void ui_tab_create(UiObject* obj, const char* title) {
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
823 UiObject* current = uic_current_obj(obj);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
824 UiTabView* tabview = (UiTabView*)current->widget->data1;
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
825 UiObject* newobj = tabview->AddTab(title);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
826 uic_obj_add(current, newobj);
f2332d0d3318 add tabview based on winui the pivot control
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 195
diff changeset
827 }
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
828
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
829 UIEXPORT void ui_tabview_select(UIWIDGET tabview, int tab) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
830 UiTabView* t = (UiTabView*)tabview->data1;
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
831 t->Select(tab);
374
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
832 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
833
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
834 UIEXPORT void ui_tabview_remove(UIWIDGET tabview, int tab) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
835 UiTabView* t = (UiTabView*)tabview->data1;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
836 t->Remove(tab);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
837 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
838
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
839 UIEXPORT UiObject* ui_tabview_add(UIWIDGET tabview, const char *name, int tab_index) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
840 UiTabView* t = (UiTabView*)tabview->data1;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
841 UiObject* newobj = t->AddTab(name, tab_index);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
842 return newobj;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
843 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
844
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
845
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
846
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
847 // --------------------- UI Headerbar ---------------------
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
848
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
849 // TODO: replace placeholder implementation
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
850
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
851 UIEXPORT UIWIDGET ui_headerbar_create(UiObject *obj, UiHeaderbarArgs args) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
852 UiContainerArgs boxargs = { };
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
853 boxargs.fill = UI_OFF;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
854 return ui_hbox_create(obj, boxargs);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
855 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
856
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
857 UIEXPORT void ui_headerbar_start_create(UiObject *obj) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
858 UiContainerArgs boxargs = { };
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
859 boxargs.fill = UI_OFF;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
860 ui_hbox_create(obj, boxargs);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
861 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
862
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
863 UIEXPORT void ui_headerbar_center_create(UiObject *obj) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
864 UiContainerArgs boxargs = { };
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
865 boxargs.fill = UI_OFF;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
866 ui_hbox_create(obj, boxargs);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
867 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
868
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
869 UIEXPORT void ui_headerbar_end_create(UiObject *obj) {
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
870 UiContainerArgs boxargs = { };
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
871 boxargs.fill = UI_OFF;
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
872 ui_hbox_create(obj, boxargs);
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
873 }
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
874
eae5d6623fd3 add textarea (WINUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
875
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
876 /*
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
877 * -------------------- Layout Functions --------------------
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
878 *
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
879 * functions for setting layout attributes for the current container
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
880 *
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
881 */
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
882
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
883 void ui_layout_fill(UiObject* obj, UiBool fill) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
884 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
885 ct->layout.fill = ui_bool2lb(fill);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
886 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
887
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
888 void ui_layout_hexpand(UiObject* obj, UiBool expand) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
889 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
890 ct->layout.hexpand = expand;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
891 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
892
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
893 void ui_layout_vexpand(UiObject* obj, UiBool expand) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
894 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
895 ct->layout.vexpand = expand;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
896 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
897
378
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
898 void ui_layout_hfill(UiObject* obj, UiBool fill) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
899 UiContainer* ct = uic_get_current_container(obj);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
900 ct->layout.hfill = fill;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
901 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
902
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
903 void ui_layout_vfill(UiObject* obj, UiBool fill) {
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
904 UiContainer* ct = uic_get_current_container(obj);
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
905 ct->layout.vfill = fill;
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
906 }
d41b1ffc5f77 implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 377
diff changeset
907
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
908 void ui_layout_width(UiObject* obj, int width) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
909 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
910 ct->layout.width = width;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
911 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
912
186
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
913 void ui_layout_height(UiObject* obj, int height) {
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
914 UiContainer* ct = uic_get_current_container(obj);
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
915 ct->layout.height = height;
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
916 }
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
917
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
918 void ui_layout_colspan(UiObject* obj, int cols) {
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
919 UiContainer* ct = uic_get_current_container(obj);
186
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
920 ct->layout.colspan = cols;
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
921 }
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
922
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
923 void ui_layout_rowspan(UiObject* obj, int rows) {
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
924 UiContainer* ct = uic_get_current_container(obj);
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
925 ct->layout.rowspan = rows;
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
926 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
927
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
928 void ui_newline(UiObject* obj) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
929 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
930 ct->layout.newline = TRUE;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
931 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
932

mercurial