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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844 | /* GATE PROJECT LICENSE:
+----------------------------------------------------------------------------+
| Copyright(c) 2018-2026, 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/numbers.hpp"
#include "gate/system/os.hpp"
#include "gate/threading.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/paintsurfaces.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/timers.hpp"
#include "gate/ui/spinners.hpp"
#include "gate/ui/splitters.hpp"
#include "gate/ui/tabs.hpp"
#include "gate/ui/dialogs.hpp"
#include "gate/graphics/pixmapimages.hpp"
#include "gate/icons/application.xpm"
#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
static gate::bool_t run_app_tests = false;
static gate::bool_t run_app_tests_no_close = false;
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::Itemview iv;
ui::Combobox cmb;
ui::Progressbar pgb;
ui::Spinbox spin;
ui::PaintSurface painter;
ui::Splitter split;
ui::Textbox splitText1;
ui::Textbox splitText2;
ui::FramePanel frame;
ui::Button btn2;
ui::Layout layout;
ui::Layout tabLayout;
ui::Layout tabLayout2;
ui::Layout tabLayout2Frame;
ui::Layout tabLayoutSplitter;
ui::Timer testTimer1;
gate::enumint_t testState;
graph::RasterImage imageApplication;
graph::RasterImage imageFolder;
static gate::uint16_t const MenuKey_FileInfo = 0x01;
static gate::uint16_t const MenuKey_FileExit = 0x0f;
static gate::uint16_t const MenuKey_HelpAbout = 0x91;
graph::RasterImage& getAppImage()
{
if (this->imageApplication.empty())
{
graph::PixmapImages::parse(this->imageApplication, gate_icon_application_xpm);
}
return this->imageApplication;
}
graph::RasterImage& getFolderImage()
{
if (this->imageFolder.empty())
{
graph::PixmapImages::parse(this->imageFolder, gate_icon_folder_xpm);
}
return this->imageFolder;
}
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 oldText = this->btn.getText();
String txt = this->txtSimple.getText();
if (txt != oldText)
{
this->btn.setText(txt);
}
}
void chk_Clicked(ui::Checkbox* sender, ui::EventArg* arg)
{
static StaticString const checkedText = "Checkbox is checked";
static StaticString const uncheckedText = "Checkbox is unchecked";
bool_t const checked = this->chk.isChecked();
String const newText = checked ? checkedText : uncheckedText;
String oldText = this->chk.getText();
if (oldText != newText)
{
this->chk.setText(newText);
}
}
void btn2_Clicked(ui::Button* sender, ui::EventArg* arg)
{
ui::MessageDialog msgDlg;
ui::InputDialog inDlg;
Optional<String> inputText = inDlg.show(this->form, "Tell me:", "Input Dialog");
if(inputText.empty())
{
msgDlg.show(this->form, "No Input!", "Warning");
}
else
{
msgDlg.show(this->form, *inputText, "Your Input:");
}
}
void tb_Clicked(ui::Toolbar* sender, ui::Toolbar::ToolbarEventArg* arg)
{
}
void treeview_Select(ui::Treeview* sender, ui::Treeview::ItemArg* arg)
{
String text = this->treeview.getItemText(arg->Item);
this->treeview.getItemParam(arg->Item);
this->sbStatus.setText(text);
}
void listview_Select(ui::Listview* sender, ui::Listview::IndexArg* arg)
{
String text = this->listview.getItemText(arg->ListIndex);
this->listview.getItemParam(arg->ListIndex);
this->sbStatus.setText(text);
}
void painter_Paint(ui::PaintSurface* sender, ui::PaintSurface::PaintEventArg* arg)
{
arg->Context.rect(arg->DrawRectangle, ui::Color::Blue, 0, ui::Color::Blue);
int32_t w = arg->DrawRectangle.getWidth();
int32_t h = arg->DrawRectangle.getHeight();
int32_t mx = w / 2;
int32_t my = h / 2;
ArrayList<ui::Point> points;
points
<< ui::Point(0, my)
<< ui::Point(mx, 0)
<< ui::Point(w, my)
<< ui::Point(mx, h)
<< ui::Point(0, my)
;
arg->Context.polygon(points.toArray(), ui::Color::Yellow, 2);
GATEXX_TRY_IGNORE(arg->Context.getPixel(ui::Point(mx, my)));
arg->Context.setPixel(ui::Point(mx, my), ui::Color::White);
arg->Context.line(ui::Point(0, my), ui::Point(w, my), ui::Color::Yellow, 2);
arg->Context.line(ui::Point(mx, 0), ui::Point(mx, h), ui::Color::Yellow, 2);
graph::RasterImage& image = this->getAppImage();
{
ui::Graphics imageGraph(*this->uihost, image);
ui::Graphics virtualGraph(*this->uihost,
static_cast<uint32_t>(imageGraph.getWidth()),
static_cast<uint32_t>(imageGraph.getHeight()));
virtualGraph.drawEx(imageGraph);
arg->Context.draw(imageGraph, ui::Point(mx, my));
}
{
ui::Graphics controlGraph(*sender);
}
ui::Font font = this->uihost->getDefaultFont(ui::Host::FontType_Standard);
font.setColor(ui::Color::White);
static const StaticString text = "Hello";
static const char_32_t c32 = 'A';
arg->Context.getCharWidths(font, &c32, 1);
ui::Size sz = arg->Context.getTextSize(font, text);
ui::Position pos(mx - sz.width, my - sz.height, sz.width, sz.height);
arg->Context.print(font, text, pos);
{
ui::Graphics virtualGraph(*this->uihost, image.getWidth(), image.getHeight(), 24);
virtualGraph.drawImage(image);
virtualGraph.rect(ui::Position(0, 0, image.getWidth() - 1, image.getHeight() - 1), ui::Color::Red, 2);
virtualGraph.polygon(points.toArray(), ui::Color::Red, 1, ui::Color::Yellow);
}
}
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);
}
void useControlProperties(ui::Control& ctrl)
{
if (ctrl.isCreated())
{
ui::Position pos = ctrl.getPosition();
ui::Size sz = ctrl.getSize();
ctrl.setPosition(pos);
ctrl.setEnabled(ctrl.isEnabled());
ctrl.isVisible();
ctrl.setVisible(true);
if (ctrl.isFocused())
{
ctrl.setFocus();
}
}
}
static void asyncCallback()
{
ThisThread::sleep(1);
}
void timer1_Elapsed(ui::Timer* sender, ui::Timer::TimerArg* arg)
{
gate::enumint_t const state = ++this->testState;
if (state == 1)
{
useControlProperties(this->txtSimple);
useControlProperties(this->btn);
useControlProperties(this->chk);
this->txtSimple.setText("Hello");
String lblText = this->lbl.getText();
this->lbl.setText(lblText);
this->lbl.performAction(ui::Label::Action_Activate);
this->btn.performAction(ui::Button::Action_Activate);
this->txtMulti.setText("Hello World");
this->txtMulti.getLineCount();
this->txtMulti.getCurrentColumn();
this->txtMulti.getCurrentLine();
this->txtMulti.setSelection(2, 5);
gate_uint32_t l = 0, r = 0;
this->txtMulti.getSelection(l, r);
this->txtMulti.getSelectionText();
this->txtMulti.replaceSelection("110_");
{
uint32_t mini, maxi;
mini = this->pgb.getMinimum();
maxi = this->pgb.getMaximum();
this->pgb.getMinMax(mini, maxi);
this->pgb.getValue();
this->pgb.setValue((mini + maxi) / 2);
this->pgb.setPercent(50.0f);
}
{
this->chk.setChecked(!this->chk.isChecked());
this->chk.performAction(ui::Checkbox::Action_Activate);
}
{
size_t const cnt = this->cmb.getItemCount();
this->cmb.setSelectedItem(cnt - 1);
gate_size_t selIndex = 0;
String selText;
void* selParam = NULL;
this->cmb.getSelectedItem(&selIndex, &selText, &selParam);
selParam = this->cmb.getItemParam(selIndex);
selText = this->cmb.getItemText(selIndex);
String const newText = selText + "!";
this->cmb.setItemText(selIndex, newText);
this->cmb.setSelectedItem(cnt - 1);
this->cmb.performAction(ui::Combobox::Action_Activate);
gate_size_t foundIndex = 0;
this->cmb.findItemParam(selParam, foundIndex);
}
{
gate_size_t index = this->lstbox.getItemCount();
this->lstbox.setSelectedItem(1);
this->lstbox.getSelectedItem(index);
String const text = this->lstbox.getItemText(index);
String const newText = text + "!";
this->lstbox.setItemText(index, newText);
void* const param = this->lstbox.getItemParam(index);
this->lstbox.findItemParam(param);
}
{
if (this->listview.getItemCount() > 0)
{
size_t ndx = 0;
this->listview.setItemSelected(ndx, true);
this->listview.getSelectedItem(ndx);
String oldText = this->listview.getItemText(ndx, 1);
String newText = oldText + "!";
this->listview.setItemText(ndx, newText, 1);
this->listview.getSelectedItems();
this->listview.setItemChecked(ndx, false);
this->listview.getCheckedItems();
void* param = this->listview.getItemParam(ndx);
this->listview.findItemParam(param);
this->listview.insertItem(0, "Prequel");
}
}
{
this->treeview.setFocus();
Array<ui::Treeview::item_t> children = this->treeview.getItemChildren(0);
for(size_t ndx = 0; ndx != children.length(); ++ndx)
{
ui::Treeview::item_t parent = 0;
ui::Treeview::item_t child = children[ndx];
String oldText = this->treeview.getItemText(child);
String newText = oldText + "!";
this->treeview.setItemText(child, newText);
this->treeview.getItemParam(child);
this->treeview.getParentItem(child, parent);
this->treeview.isItemExpanded(child);
this->treeview.selectItem(child);
this->treeview.getSelectedItem(child);
this->treeview.performAction(ui::Treeview::Action_Activate);
this->treeview.performAction(ui::Treeview::Action_ContextMenu);
}
}
{
this->iv.setFocus();
size_t cnt = this->iv.getItemCount();
for (size_t ndx = 0; ndx != cnt; ++ndx)
{
this->iv.getItemTitle(ndx);
this->iv.getItemSubtitle(ndx);
this->iv.getItemAddiontialText(ndx);
void* param = this->iv.getItemParam(ndx);
gate::size_t index = this->iv.findItemParam(param);
}
}
this->form.refresh();
}
else if (state == 2)
{
size_t const tabCount = this->tabs.getTabCount();
if (tabCount > 0)
{
this->tabs.setSelected(0);
for (size_t ndx = 0; ndx != tabCount; ++ndx)
{
String oldText = this->tabs.getTabText(ndx);
String newText = oldText + "!";
this->tabs.setTabText(ndx, newText);
}
size_t selected = this->tabs.getSelected();
if (selected < tabCount)
{
this->tabs.setSelected(selected + 1);
}
}
}
else if (state == 3)
{
this->tabs.setSelected(3);
this->painter.redraw();
}
else if (state == 4)
{
this->painter.performAction(ui::PaintSurface::Action_Activate);
this->painter.performAction(ui::PaintSurface::Action_ContextMenu);
this->painter.performAction(ui::PaintSurface::Action_KeyPress, 13); // send enter key
Runnable asyncFunc = RunnableFunction::create(&asyncCallback);
this->uihost->execute(asyncFunc);
this->uihost->processEvents();
}
else
{
sender->stop();
if (!run_app_tests_no_close)
{
this->uihost->quit();
}
}
}
public:
VTest()
: testState(0)
{
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);
this->chk.ClickEvent += ui::Checkbox::ClickEventHandler(this, &VTest::chk_Clicked);
this->btn2.ClickEvent += ui::Button::ClickEventHandler(this, &VTest::btn2_Clicked);
this->tb.ClickEvent += ui::Toolbar::ClickEventHandler(this, &VTest::tb_Clicked);
this->treeview.SelectEvent += ui::Treeview::SelectEventHandler(this, &VTest::treeview_Select);
this->listview.SelectEvent += ui::Listview::SelectEventHandler(this, &VTest::listview_Select);
this->painter.PaintEvent += ui::PaintSurface::PaintEventHandler(this, &VTest::painter_Paint);
this->testTimer1.IntervalEvent += ui::Timer::IntervalEventHandler(this, &VTest::timer1_Elapsed);
}
~VTest() noexcept
{
}
virtual void onInit()
{
this->uihost.emplace<uintptr_t const>(this->getHandle());
const int32_t pixels = this->uihost->getPixelsOfPoints(10.0f);<--- Shadowed declaration
const real32_t points = this->uihost->getPointsOfPixels(pixels);
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);
this->layout.setColumn(colLeft, 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.0f);
this->layout.setRow(rowTop, ui::Layout::Type_UnitScale, 2.0f);
uint32_t rowData1 = this->layout.addRow();
uint32_t rowData2 = this->layout.addRow();
uint32_t rowBottom = this->layout.addRow(ui::Layout::Type_UnitScale, 1.0f);
this->layout.setControl(this->tb, rowTop, colLeft, 1, 3);
{
uint32_t rowTest, colTest;
this->layout.findControl(this->tb, rowTest, colTest);
}
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::Host::getHost(this->form);
const String formText = this->form.getText();
this->uihost->getLineHeight();
this->uihost->getControlHeight();
this->uihost->getUnitLength();
ui::Position stdPos(10, 10, 10, 10);
this->tb.create(this->form, stdPos);
{
ui::RasterImage& image = this->getAppImage();
this->tb.add(image, NULL);
this->tb.addSeparator();
const int32_t pixels = this->tb.getIdealHeight();<--- Shadow variable
if (pixels > 0)
{
uint32_t rowTb = 0, colTb = 0;
if (this->layout.findControl(this->tb, rowTb, colTb))
{
this->layout.setRow(rowTb, ui::Layout::Type_Pixel, static_cast<real32_t>(pixels));
}
}
}
this->sbStatus.create(this->form, ui::Position(10, 10, 10, 10), "StatusBAR");
this->txtMulti.create(this->form, stdPos, "Hello" GATE_STR_NEWLINE "world",
ui::Textbox::Flag_Enabled | ui::Textbox::Flag_Visible | ui::Textbox::Flag_Multiline);
{
this->lstbox.create(this->form, stdPos);
this->lstbox.removeAllItems();
this->lstbox.addItem("Hello");
this->lstbox.addItem("World");
for (uint32_t n = 0; n < 25; ++n)
{
this->lstbox.addItem("Entry #" + numbers::to_string(n));
}
for (uint32_t n = 0; n < 5; ++n)
{
size_t count = this->lstbox.getItemCount();
this->lstbox.removeItem(count - 1);
}
}
{
this->treeview.create(this->form,
ui::Position(10, 10, 10, 10),
gate::ui::Treeview::Flag_Visible | gate::ui::Treeview::Flag_Enabled | gate::ui::Treeview::Flag_Icons
);
graph::RasterImage& folderImage = this->getFolderImage();
intptr_t folderIconIndex = this->treeview.addIcon(folderImage);
ui::Treeview::item_t root = this->treeview.addItem(NULL, "MyRoot", NULL, folderIconIndex);
this->treeview.addItem(&root, "Sub1");
this->treeview.addItem(&root, "Sub2");
ui::Treeview::item_t s3 = this->treeview.addItem(&root, "Sub3");
this->treeview.removeItem(s3);
this->treeview.collapseItem(root);
this->treeview.expandItem(root);
}
{
this->listview.create(this->form,
ui::Position(10, 10, 10, 10),
gate::ui::Listview::Flag_Visible | gate::ui::Listview::Flag_Enabled | gate::ui::Listview::Flag_Icons
);
this->listview.removeAllItems();
ui::RasterImage& appImage = this->getAppImage();
gate::intptr_t appIconIndex = this->listview.addIcon(appImage);
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());
this->listview.beginTransaction();
for (uint32_t n = 0; n < 25; ++n)
{
void* param = reinterpret_cast<void*>(static_cast<uintptr_t>(n));
intptr_t const iconIndex = (n % 2 == 0) ? appIconIndex : gate::ui::Listview::InvalidIcon;
size_t const index = this->listview.addItem("Entry #" + numbers::to_string(n), param, iconIndex);
this->listview.setItemText(index, "SubItem " + numbers::to_string(n), 1);
}
this->listview.endTransaction();
size_t cntCols = this->listview.getColumnCount();
for (size_t n = 0; n != cntCols; ++n)
{
String text;
uint32_t width = 0;
this->listview.getColumn(n, text, width);
}
this->listview.setItemSelected(0, true);
this->listview.isItemSelected(0);
for (uint32_t n = 0; n < 5; ++n)
{
size_t count = this->listview.getItemCount();
this->listview.removeItem(count - 1);
}
}
{
this->tabs.create(this->form, ui::Position(10, 10, 10, 10));
this->tabs.addTab("Tab1");
this->tabs.addTab("Tab2");
this->tabs.addTab("Tab3");
this->tabs.addTab("Tab4");
this->tabs.addTab("Tab5");
this->tabs.removeTab(this->tabs.getTabCount() - 1);
this->tabs.addTab("Tab5");
}
{
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);
this->iv.create(panel1, ui::Position(0, 70, 128, 256));
this->iv.addItem("Hello", "World", "from Me");
this->iv.removeAllItems();
gate::size_t ndx1 = this->iv.addItem("Hello", "World", "from Me", ui::Itemview::InvalidIcon, (void*)111);
gate::size_t ndx2 = this->iv.addItem("This", "is a", "test", ui::Itemview::InvalidIcon, (void*)222);
gate::size_t ndx3 = this->iv.addItem("To", "be", "removed");
this->iv.setItemTitle(ndx3, "TO");
this->iv.setItemSubtitle(ndx3, "BE");
this->iv.setItemAdditionalText(ndx3, "DELETED");
this->iv.removeItem(ndx3);
this->iv.setItemSelected(ndx2);
gate::size_t selIndex = 10;
if(this->iv.getSelectedItem(selIndex))
{
this->iv.isItemSelected(selIndex);
}
}
{
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->tabs.getTabParam(2);
ui::TabPanel panel3Copy(panel3);
}
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 Input Dialog");
{
this->cmb.create(this->frame, ui::Position(0, 64, 128, 32));
//this->cmb.removeAllItems();
this->cmb.removeAllItems();
size_t index1 = this->cmb.addItem("entry_1");
size_t index2 = this->cmb.addItem("entry_2");
size_t index3 = this->cmb.addItem("entry_3");
this->cmb.getItemParam(index2);
this->cmb.removeItem(index3);
this->cmb.setSelectedItem(index1);
this->cmb.getSelectedIndex();
}
{
this->pgb.create(this->frame, ui::Position(0, 100, 128, 24));
this->pgb.setMinMax(0, 100);
this->pgb.setValue(75);
this->pgb.setValue(33);
}
{
this->spin.create(this->frame, ui::Position(0, 130, 128, 24));
this->spin.setMinimum(0);
this->spin.setMaximum(32);
gate::int64_t spinMin = this->spin.getMinimum();
gate::int64_t spinMax = this->spin.getMaximum();
this->spin.setMinMax(spinMin, spinMax);
gate::int64_t a, b;
this->spin.getMinMax(a, b);
this->spin.setValue(16);
gate::int64_t v = this->spin.getValue();
}
panel3.setLayout(&this->tabLayout2);
{
this->tabLayout2Frame.clear();
const size_t c = this->tabLayout2Frame.addColumn();
const size_t r1 = this->tabLayout2Frame.addRow(ui::Layout::Type_UnitScale, 1.5);
this->tabLayout2Frame.addRow(ui::Layout::Type_UnitScale, 0.5);
const size_t r2 = this->tabLayout2Frame.addRow(ui::Layout::Type_UnitScale, 1.5);
this->tabLayout2Frame.addRow(ui::Layout::Type_UnitScale, 0.5);
const size_t r3 = this->tabLayout2Frame.addRow(ui::Layout::Type_UnitScale, 1.5);
this->tabLayout2Frame.addRow(ui::Layout::Type_UnitScale, 0.5);
const size_t r4 = this->tabLayout2Frame.addRow(ui::Layout::Type_UnitScale, 1.5);
this->tabLayout2Frame.setControl(this->btn2, r1, c);
this->tabLayout2Frame.setControl(this->cmb, r2, c);
this->tabLayout2Frame.setControl(this->pgb, r3, c);
this->tabLayout2Frame.setControl(this->spin, r4, c);
this->frame.setLayout(&this->tabLayout2Frame);
}
}
{
ui::TabPanel panel3 = this->tabs.getTabPanel(3);
this->painter.create(panel3, ui::Position(0, 0, 160, 120));
ui::Cursor cur(*this->uihost, ui::Cursor::StockId_Busy);
ui::Cursor cur2(cur);
this->painter.setCursor(cur2);
}
{
ui::TabPanel panel4 = this->tabs.getTabPanel(4);
this->split.create(panel4, ui::Position(0, 0, 200, 200));
this->split.setMinimum(32);
this->splitText1.create(this->split, ui::Position(0, 0, 200, 200), "Text1");
this->splitText2.create(this->split, ui::Position(0, 0, 200, 200), "Text2");
this->split.setFirst(this->splitText1);
this->split.setSecond(this->splitText2);
this->tabLayoutSplitter.clear();
const uint32_t c = this->tabLayoutSplitter.addColumn();
const uint32_t r = this->tabLayoutSplitter.addRow();
this->tabLayoutSplitter.setControl(this->split, r, c);
panel4.setLayout(&this->tabLayoutSplitter);
ui::Control* ptrParent = this->splitText1.getParent();<--- Variable 'ptrParent' is assigned a value that is never used.
const uint32_t txtLen = this->splitText1.getTextLength();<--- Variable 'txtLen' is assigned a value that is never used.
}
this->form.setLayout(&this->layout);
this->form.setVisible(true);
this->form.getChildren();
if(run_app_tests)
{
this->testTimer1.isStarted();
this->testTimer1.create(this->form);
this->testTimer1.start(1000);
this->testTimer1.isStarted();
}
}
void onUninit()
{
if(this->testTimer1.isCreated())
{
this->testTimer1.destroy();
}
this->tabs.clear();
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;
if (argcount > 0)
{
if (0 == gate_str_comp_ic(arguments[0], "--runtests"))
{
run_app_tests = true;
}
if (argcount > 1)
{
if (0 == gate_str_comp_ic(arguments[1], "--noclose"))
{
run_app_tests_no_close = true;
}
}
}
int exitcode = gate::App::runApp(vtest, program, arguments, argcount, apphandle);
return exitcode;
}
|