1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297 | /* GATE PROJECT LICENSE:
+----------------------------------------------------------------------------+
| Copyright(c) 2018-2025, Stefan Meislinger |
| All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions are met:|
| |
| 1. Redistributions of source code must retain the above copyright notice, |
| this list of conditions and the following disclaimer. |
| 2. Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimer in the |
| documentation and/or other materials provided with the distribution. |
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| THE POSSIBILITY OF SUCH DAMAGE. |
+----------------------------------------------------------------------------+
*/
#include "gate/gatemain.h"
#include "gate/results.h"
#include "gate/applications.hpp"
#include "gate/maps.hpp"
#include "gate/strings.hpp"
#include "gate/streams.hpp"
#include "gate/times.hpp"
#include "gate/files.hpp"
#include "gate/wrappers.hpp"
#include "gate/utilities.hpp"
#include "gate/ui/gateui.hpp"
#include "gate/ui/forms.hpp"
#include "gate/ui/buttons.hpp"
#include "gate/ui/labels.hpp"
#include "gate/ui/panels.hpp"
#include "gate/ui/textboxes.hpp"
#include "gate/ui/treeviews.hpp"
#include "gate/ui/listviews.hpp"
#include "gate/ui/splitters.hpp"
#include "gate/ui/dialogs.hpp"
#include "gate/ui/toolbars.hpp"
#include "gate/ui/statusbars.hpp"
#include "gate/ui/checkboxes.hpp"
#include "gate/ui/comboboxes.hpp"
#include "gate/ui/tabs.hpp"
#include "gate/numbers.hpp"
#include "gate/system/os.hpp"
#include "gate/graphics/pixmapimages.hpp"
#include "gate/icons/refresh.xpm"
#include "gate/icons/folder.xpm"
#include "gate/icons/cut.xpm"
#include "gate/icons/copy.xpm"
#include "gate/icons/paste.xpm"
#include "gate/icons/cancel.xpm"
#if defined(GATE_COMPILER_MSVC) && defined(GATE_LEAK_DETECTION) && defined(GATE_SYS_WIN) && !defined(GATE_SYS_WINCE) && (GATE_ARCH != GATE_ARCH_ARM32) && (GATE_ARCH != GATE_ARCH_ARM64)
# include <vld.h>
#endif
namespace gate
{
namespace apps
{
class GATE_API_LOCAL VTest : public App
{
private:
Optional<ui::Host> uihost;
ui::Form form;
ui::Menu menu;
ui::Menu menuFile;
ui::Menu menuHelp;
ui::Toolbar tb;
ui::Treeview treeview;
ui::Listview listview;
ui::TabControl tabs;
ui::Listbox lstbox;
ui::Textbox txtMulti;
ui::Statusbar sbStatus;
ui::Label lbl;
ui::Button btn;
ui::Textbox txtSimple;
ui::Checkbox chk;
ui::Combobox cmb;
ui::Progressbar pgb;
ui::FramePanel frame;
ui::Button btn2;
ui::Layout layout;
ui::Layout tabLayout;
ui::Layout tabLayout2;
static gate_uint16_t const MenuKey_FileInfo = 0x01;
static gate_uint16_t const MenuKey_FileExit = 0x0f;
static gate_uint16_t const MenuKey_HelpAbout = 0x91;
void commandExit()
{
this->uihost->quit();
}
void commandHelp()
{
ui::MessageDialog msg;
msg.show(this->form, "Sample message text", "Sample title");
}
void Form_Closed(ui::Form* sender, ui::EventArg* arg)
{
this->commandExit();
}
void btn_Clicked(ui::Button* sender, ui::EventArg* arg)
{
String txt = this->txtSimple.getText();
this->btn.setText(txt);
}
void handleMenuAction(gate_uint16_t menuid)
{
if (menuid == MenuKey_FileExit) { this->commandExit(); }
else if (menuid == MenuKey_FileInfo) { this->commandHelp(); }
else if (menuid == MenuKey_HelpAbout) { this->commandHelp(); }
}
void Form_Menu(ui::Form* sender, ui::MenuArg* arg)
{
this->handleMenuAction(arg->MenuEntry.id);
}
public:
VTest()
{
menuFile.add("Info", MenuKey_FileInfo);
menuFile.addSeparator();
menuFile.add("Exit", MenuKey_FileExit);
menuHelp.add("About", MenuKey_HelpAbout);
menu.add("File", 0, 0, &menuFile);
menu.add("Help", 0, 0, &menuHelp);
this->form.MenuEvent += ui::Form::MenuEventHandler(this, &VTest::Form_Menu);
this->btn.ClickEvent += ui::Button::ClickEventHandler(this, &VTest::btn_Clicked);
}
~VTest() noexcept
{
}
virtual void onInit()
{
this->uihost.emplace<uintptr_t const>(this->getHandle());
uint32_t lineHeight = this->uihost->getLineHeight();<--- Variable 'lineHeight' is assigned a value that is never used.
//uint32_t ctrlHeight = this->uihost->getControlHeight();
this->layout.clear();
this->layout.setBorder(1);
this->layout.setRowSpace(3);
this->layout.setColumnSpace(3);
uint32_t colLeft = this->layout.addColumn(ui::Layout::Type_UnitScale, 8.0f);
uint32_t colMid = this->layout.addColumn();
uint32_t colRight = this->layout.addColumn(ui::Layout::Type_Percent, 25.0f);
uint32_t rowTop = this->layout.addRow(ui::Layout::Type_UnitScale, 2.00f);
uint32_t rowData1 = this->layout.addRow();
uint32_t rowData2 = this->layout.addRow();
uint32_t rowBottom = this->layout.addRow(ui::Layout::Type_UnitScale, 1.00f);
this->layout.setControl(this->tb, rowTop, colLeft, 1, 3);
this->layout.setControl(this->treeview, rowData1, colLeft);
this->layout.setControl(this->listview, rowData2, colLeft);
this->layout.setControl(this->tabs, rowData1, colMid, 2, 1);
this->layout.setControl(this->lstbox, rowData1, colRight);
this->layout.setControl(this->txtMulti, rowData2, colRight);
this->layout.setControl(this->sbStatus, rowBottom, colLeft, 1, 3);
this->form.CloseEvent += ui::Form::CloseEventHandler(this, &VTest::Form_Closed);
this->form.create(*this->uihost, NULL, String::createStaticFrom("vTest"),
ui::Form::Flag_Enabled | ui::Form::Flag_Resizable | ui::Form::Flag_Maximizable | ui::Form::Flag_Minimizable
//| ui::Form::Flag_Visible
);
this->form.setMenu(&this->menu);
ui::Position stdPos(10, 10, 10, 10);
this->tb.create(this->form, stdPos);
this->txtMulti.create(this->form, stdPos, "Hello\nworld",
ui::Textbox::Flag_Enabled | ui::Textbox::Flag_Visible | ui::Textbox::Flag_Multiline);
this->lstbox.create(this->form, stdPos);
this->lstbox.addItem("Hello");
this->lstbox.addItem("World");
for (uint32_t n = 0; n < 20; ++n)
{
this->lstbox.addItem("Entry #" + numbers::to_string(n));
}
this->treeview.create(this->form, ui::Position(10, 10, 10, 10));
ui::Treeview::item_t root = this->treeview.addItem(NULL, "MyRoot");
this->treeview.addItem(&root, "Sub1");
this->treeview.addItem(&root, "Sub2");
this->listview.create(this->form, ui::Position(10, 10, 10, 10));
ArrayList<ui::Listview::Column> cols;
cols.add(ui::Listview::Column("First", 60));
cols.add(ui::Listview::Column("Second", 100));
cols.add(ui::Listview::Column("Third", 200));
this->listview.setColumns(cols.toArray());
for (uint32_t n = 0; n < 20; ++n)
{
this->listview.addItem("Entry #" + numbers::to_string(n));
}
this->tabs.create(this->form, ui::Position(10, 10, 10, 10));
this->tabs.addTab("Tab1");
this->tabs.addTab("Tab2");
this->tabs.addTab("Tab3");
ui::TabPanel panel1 = this->tabs.getTabPanel(0);
this->lbl.create(panel1, ui::Position(0, 0, 128, 28), "Label");
this->chk.create(panel1, ui::Position(0, 32, 128, 32), "CheckMe", true);
ui::TabPanel panel2 = this->tabs.getTabPanel(1);
this->tabLayout.clear();
uint32_t tabLeft = this->tabLayout.addColumn();
uint32_t tabRight = this->tabLayout.addColumn();
uint32_t tabTop = this->tabLayout.addRow(ui::Layout::Type_UnitScale, 1.0f);
this->tabLayout.setControl(this->txtSimple, tabTop, tabLeft);
this->tabLayout.setControl(this->btn, tabTop, tabRight);
this->btn.create(panel2, ui::Position(0, 0, 120, 28), "PushButton");
this->txtSimple.create(panel2, ui::Position(0, 32, 120, 32), "TextField");
panel2.setLayout(&this->tabLayout);
ui::TabPanel panel3 = this->tabs.getTabPanel(2);
this->tabLayout2.clear();
this->tabLayout2.addColumn();
this->tabLayout2.addRow();
this->tabLayout2.setControl(this->frame, 0, 0);
this->frame.create(panel3, ui::Position(0, 0, 140, 96), "Frame");
this->btn2.create(this->frame, ui::Position(0, 0, 120, 64), "Test");
this->cmb.create(this->frame, ui::Position(0, 64, 128, 32));
this->pgb.create(this->frame, ui::Position(0, 100, 128, 24));
size_t index = this->cmb.addItem("entry_1");
this->cmb.addItem("entry_2");
this->cmb.setSelectedItem(index);
this->pgb.setMinMax(0, 100);
this->pgb.setValue(75);
this->pgb.setValue(33);
panel3.setLayout(&this->tabLayout2);
this->sbStatus.create(this->form, ui::Position(10, 10, 10, 10), "StatusBAR");
this->form.setLayout(&this->layout);
this->form.setVisible(true);
}
void onUninit()
{
this->form.destroy();
this->uihost.reset();
}
virtual void run()
{
this->uihost->run();
this->onUninit();
}
};
} // end of namespace apps
} // end of namespace gate
int gate_main(char const* program, char const* const* arguments, gate_size_t argcount, gate_uintptr_t apphandle)
{
gate::apps::VTest vtest;
return gate::App::runApp(vtest, program, arguments, argcount, apphandle);
}
|