ui/winui/container.cpp

Mon, 02 Oct 2023 19:56:18 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 02 Oct 2023 19:56:18 +0200
branch
newapi
changeset 197
8a82ebe23822
parent 195
0f2e69873875
child 198
f2332d0d3318
permissions
-rw-r--r--

add combobox (WinUI3)

182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include "container.h"
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
31 #include "../common/context.h"
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
32 #include "../common/object.h"
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
33
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
34 #include "util.h"
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
35
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
36 #include <winrt/Windows.UI.Xaml.Media.h>
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
37 #include <winrt/Microsoft.UI.Xaml.Media.h>
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
38
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
39
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
40 void ui_container_begin_close(UiObject* obj) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
41 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
42 ct->close = 1;
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
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
45 int ui_container_finish(UiObject* obj) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
46 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
47 if (ct->close) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
48 ui_end(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
49 return 0;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
50 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
51 return 1;
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
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
55 // --------------------- UiBoxContainer ---------------------
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
57 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
58 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
59 UI_APPLY_LAYOUT1(current, args);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
60
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
61 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
62 current->container->Add(grid, true);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
63
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
64 UIElement elm = grid;
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
65 UiWidget* widget = new UiWidget(elm);
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);
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
69 uic_obj_add(obj, newobj);
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
70
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
71 return widget;
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
72 }
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
73
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
74 UIWIDGET ui_vbox_create(UiObject* obj, UiContainerArgs args) {
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
75 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
76 }
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
77
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
78 UIWIDGET ui_hbox_create(UiObject* obj, UiContainerArgs args) {
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
79 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
80 }
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
81
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
82 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
83 this->grid = grid;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 this->type = type;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
86 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
87 grid.Margin(t);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
88 grid.ColumnSpacing((double)spacing);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
89 grid.RowSpacing((double)spacing);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
90
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
91 GridLength gl;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
92 gl.Value = 1;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
93 gl.GridUnitType = GridUnitType::Star;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
94
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 // hbox needs one row def, vbox needs one col def
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 // 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
97 if (type == UI_BOX_CONTAINER_HBOX) {
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
98 boxRowDef = RowDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
99 boxRowDef.Height(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
100 grid.RowDefinitions().Append(boxRowDef);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 } else {
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
102 boxColDef = ColumnDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
103 boxColDef.Width(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
104 grid.ColumnDefinitions().Append(boxColDef);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 }
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
106
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
107 ui_reset_layout(layout);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
110 void UiBoxContainer::Add(FrameworkElement control, UiBool fill) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
111 if (this->layout.fill != UI_LAYOUT_UNDEFINED) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
112 fill = ui_lb2bool(this->layout.fill);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
113 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
114
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 GridLength gl;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 if (fill) {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 gl.Value = 1;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 gl.GridUnitType = GridUnitType::Star;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 else {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 gl.Value = 0;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 gl.GridUnitType = GridUnitType::Auto;
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
125 control.HorizontalAlignment(HorizontalAlignment::Stretch);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
126 control.VerticalAlignment(VerticalAlignment::Stretch);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
127
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 if (type == UI_CONTAINER_HBOX) {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 ColumnDefinition coldef = ColumnDefinition();
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 coldef.Width(gl);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 grid.ColumnDefinitions().Append(coldef);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 grid.SetColumn(control, grid.Children().Size());
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
133 grid.SetRow(control, 0);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 } else {
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 RowDefinition rowdef = RowDefinition();
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 rowdef.Height(gl);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 grid.RowDefinitions().Append(rowdef);
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 grid.SetRow(control, grid.Children().Size());
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
139 grid.SetColumn(control, 0);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 }
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 grid.Children().Append(control);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
143
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
144 ui_reset_layout(layout);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
145 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
146
188
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
147
fbbae6738252 implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
148 // --------------------- UiGridContainer ---------------------
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
149
190
70fd1b24e395 implement new api style for box and grid containers (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 188
diff changeset
150 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
151 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
152 UI_APPLY_LAYOUT1(current, args);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
153
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
154 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
155 current->container->Add(grid, true);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
156
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
157 UIElement elm = grid;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
158 UiWidget* widget = new UiWidget(elm);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
159
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
160 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
161 newobj->container = new UiGridContainer(grid, args.margin, args.columnspacing, args.rowspacing);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
162 uic_obj_add(obj, newobj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
163
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
164 return widget;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
165 }
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 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
168 this->grid = grid;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
169 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
170 grid.Margin(t);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
171 grid.ColumnSpacing((double)columnspacing);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
172 grid.RowSpacing((double)rowspacing);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
173 ui_reset_layout(layout);
182
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 }
6cf690e042bd add window container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
176 void UiGridContainer::Add(FrameworkElement control, UiBool fill) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
177 GridLength gl;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
178
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
179 int hexpand = FALSE;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
180 int vexpand = FALSE;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
181 if (layout.hexpand != UI_LAYOUT_UNDEFINED) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
182 hexpand = layout.hexpand;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
183 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
184 if (layout.vexpand != UI_LAYOUT_UNDEFINED) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
185 vexpand = layout.vexpand;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
186 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
187
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
188 // create new RowDefinition for the new line
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
189 if (layout.newline || y == -1) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
190 x = 0;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
191 y++;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
192 RowDefinition rowdef = RowDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
193 if (vexpand) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
194 gl.GridUnitType = GridUnitType::Star;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
195 gl.Value = 1;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
196 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
197 else {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
198 gl.GridUnitType = GridUnitType::Auto;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
199 gl.Value = 0;
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 rowdef.Height(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
202 grid.RowDefinitions().Append(rowdef);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
203 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
204
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
205 // create new columndefinition, if a new column is added
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
206 if (x == cols) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
207 if (hexpand) {
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 ColumnDefinition coldef = ColumnDefinition();
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
216 coldef.Width(gl);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
217 grid.ColumnDefinitions().Append(coldef);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
218 cols++;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
219 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
220
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
221 // add control
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
222 control.HorizontalAlignment(HorizontalAlignment::Stretch);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
223 control.VerticalAlignment(VerticalAlignment::Stretch);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
224
186
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
225 if (layout.colspan > 0) {
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
226 grid.SetColumnSpan(control, layout.colspan);
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
227 }
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
228 if (layout.rowspan > 0) {
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
229 grid.SetRowSpan(control, layout.rowspan);
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
230 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
231
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
232 grid.SetRow(control, y);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
233 grid.SetColumn(control, x);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
234 grid.Children().Append(control);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
235
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
236 x++;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
237
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
238 ui_reset_layout(layout);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
239 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
240
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
241 // --------------------- UI Frame ---------------------
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
242
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
243 UIWIDGET ui_frame_create(UiObject* obj, UiFrameArgs args) {
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
244 // 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
245 Grid frame = Grid();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
246
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
247 GridLength gl;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
248 gl.GridUnitType = GridUnitType::Star;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
249 gl.Value = 1;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
250
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
251 ColumnDefinition coldef = ColumnDefinition();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
252 coldef.Width(gl);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
253 frame.ColumnDefinitions().Append(coldef);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
254
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
255 RowDefinition rowdefFrame = RowDefinition();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
256 rowdefFrame.Height(gl);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
257
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
258 // label
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
259 int row = 0;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
260 if (args.label) {
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
261 RowDefinition rowdefLabel = RowDefinition();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
262 gl.GridUnitType = GridUnitType::Auto;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
263 gl.Value = 0;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
264 rowdefLabel.Height(gl);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
265 frame.RowDefinitions().Append(rowdefLabel);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
266
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
267 TextBlock label = TextBlock();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
268 wchar_t* wlabel = str2wstr(args.label, nullptr);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
269 winrt::hstring hstr(wlabel);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
270 label.Text(hstr);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
271 free(wlabel);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
272
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
273 frame.SetRow(label, row++);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
274 frame.SetColumn(label, 0);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
275 frame.Children().Append(label);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
276 }
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
277
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
278 // workarea frame
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
279 frame.RowDefinitions().Append(rowdefFrame);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
280
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
281 Grid workarea = Grid();
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
282 frame.SetRow(workarea, row);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
283 frame.SetColumn(workarea, 0);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
284 frame.Children().Append(workarea);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
285
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
286 // some styling for the workarea
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
287 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
288 workarea.BorderBrush(brush);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
289 CornerRadius radius{ 8, 8, 8, 8 };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
290 Thickness t = { 1, 1, 1, 1 };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
291 workarea.CornerRadius(radius);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
292 workarea.BorderThickness(t);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
293
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
294 Thickness padding = { 10, 10, 10, 10 };
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
295 workarea.Padding(padding);
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 // add frame to the parent container
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
298 UiObject* current = uic_current_obj(obj);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
299 UI_APPLY_LAYOUT1(current, args);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
300 current->container->Add(frame, true);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
301
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
302 UIElement elm = frame;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
303 UiWidget* widget = new UiWidget(elm);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
304
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
305 // sub container
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
306 UiContainer* ctn = nullptr;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
307 switch (args.subcontainer) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
308 default:
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
309 case UI_CONTAINER_VBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
310 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_VBOX, args.margin, args.spacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
311 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
312 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
313 case UI_CONTAINER_HBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
314 ctn = new UiBoxContainer(workarea, UI_BOX_CONTAINER_HBOX, args.margin, args.spacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
315 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
316 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
317 case UI_CONTAINER_GRID: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
318 ctn = new UiGridContainer(workarea, args.margin, args.columnspacing, args.rowspacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
319 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
320 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
321 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
322
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
323 UiObject* newobj = uic_object_new(obj, widget);
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
324 newobj->container = ctn;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
325 uic_obj_add(obj, newobj);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
326
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
327 return widget;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
328 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
329
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
330 // --------------------- UI Expander ---------------------
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
331
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
332 UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs args) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
333 Expander expander = Expander();
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
334 if (args.label) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
335 wchar_t* wlabel = str2wstr(args.label, nullptr);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
336 expander.Header(box_value(wlabel));
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
337 free(wlabel);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
338 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
339 expander.IsExpanded(args.isexpanded);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
340
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
341 // add frame to the parent container
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
342 UiObject* current = uic_current_obj(obj);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
343 UI_APPLY_LAYOUT1(current, args);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
344 current->container->Add(expander, true);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
345
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
346 UIElement elm = expander;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
347 UiWidget* widget = new UiWidget(elm);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
348
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
349 Grid content = Grid();
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
350 expander.Content(content);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
351
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
352 UiContainer* ctn = nullptr;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
353 switch (args.subcontainer) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
354 default:
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
355 case UI_CONTAINER_VBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
356 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
357 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
358 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
359 case UI_CONTAINER_HBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
360 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
361 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
362 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
363 case UI_CONTAINER_GRID: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
364 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
365 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
366 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
367 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
368
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
369 UiObject* newobj = uic_object_new(obj, widget);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
370 newobj->container = ctn;
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
371 uic_obj_add(obj, newobj);
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
372
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
373 return widget;
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
374 }
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
375
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
376 // --------------------- UI ScrolledWindow ---------------------
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
377
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
378 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) {
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
379 ScrollViewer scrollW = ScrollViewer();
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
380
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
381 // add frame to the parent container
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
382 UiObject* current = uic_current_obj(obj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
383 UI_APPLY_LAYOUT1(current, args);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
384 current->container->Add(scrollW, true);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
385
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
386 UIElement elm = scrollW;
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
387 UiWidget* widget = new UiWidget(elm);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
388
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
389 // create child container
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
390 Grid content = Grid();
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
391 scrollW.Content(content);
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 UiContainer* ctn = nullptr;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
394 switch (args.subcontainer) {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
395 default:
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
396 case UI_CONTAINER_VBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
397 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
398 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
399 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
400 case UI_CONTAINER_HBOX: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
401 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
402 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
403 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
404 case UI_CONTAINER_GRID: {
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
405 ctn = new UiGridContainer(content, args.margin, args.columnspacing, args.rowspacing);
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
406 break;
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
407 }
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
408 }
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
409
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
410 UiObject* newobj = uic_object_new(obj, widget);
195
0f2e69873875 add expander (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 194
diff changeset
411 newobj->container = ctn;
194
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
412 uic_obj_add(obj, newobj);
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
413
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
414 return widget;
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
415 }
e2281ace0769 add scrolledwindow (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
416
193
74c688cc1839 add frame container (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 190
diff changeset
417
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
418 /*
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
419 * -------------------- Layout Functions --------------------
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
420 *
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
421 * functions for setting layout attributes for the current container
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
422 *
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
423 */
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
424
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
425 void ui_layout_fill(UiObject* obj, UiBool fill) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
426 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
427 ct->layout.fill = ui_bool2lb(fill);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
428 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
429
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
430 void ui_layout_hexpand(UiObject* obj, UiBool expand) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
431 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
432 ct->layout.hexpand = expand;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
433 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
434
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
435 void ui_layout_vexpand(UiObject* obj, UiBool expand) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
436 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
437 ct->layout.vexpand = expand;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
438 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
439
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
440 void ui_layout_width(UiObject* obj, int width) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
441 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
442 ct->layout.width = width;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
443 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
444
186
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
445 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
446 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
447 ct->layout.height = height;
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
448 }
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
449
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
450 void ui_layout_colspan(UiObject* obj, int cols) {
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
451 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
452 ct->layout.colspan = cols;
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
453 }
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
454
5db4979bf482 implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
455 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
456 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
457 ct->layout.rowspan = rows;
185
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
458 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
459
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
460 void ui_newline(UiObject* obj) {
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
461 UiContainer* ct = uic_get_current_container(obj);
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
462 ct->layout.newline = TRUE;
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
463 }
4a8b1a748f09 implement grid container (WinUI)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 182
diff changeset
464

mercurial