ui/winui/container.cpp

Sun, 10 Nov 2024 15:30:46 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 10 Nov 2024 15:30:46 +0100
changeset 76
641dcc79e0ef
parent 75
73c8a3780c72
permissions
-rw-r--r--

update toolkit

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

mercurial