-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgui.h
More file actions
1526 lines (1298 loc) · 38.8 KB
/
gui.h
File metadata and controls
1526 lines (1298 loc) · 38.8 KB
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
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// gui.h - cui framework gui interface
//
// cui framework, part of the liblec library
// Copyright (c) 2016 Alec Musasa (alecmus at live dot com)
//
// Released under the MIT license. For full details see the
// file LICENSE.txt
//
#pragma once
#if defined(CUI_EXPORTS)
#include "cui.h"
#include "cui_raw/cui_raw.h"
#else
#include <liblec/cui.h>
#include <liblec/cui/gui_raw/cui_raw.h>
#endif
#include <string>
#include <vector>
#include <functional>
namespace liblec
{
namespace cui
{
/// <summary>
/// Color object. Values for each element range from 0 to 255.
/// </summary>
struct color
{
unsigned short red = 0;
unsigned short green = 0;
unsigned short blue = 0;
};
/// <summary>
/// Rectangle object.
/// </summary>
class cui_api rect
{
public:
long left = 0;
long right = 0;
long top = 0;
long bottom = 0;
long width() { return right - left; }
long height() { return bottom - top; }
void set_width(long width) { right = left + width; }
void set_height(long height) { bottom = top + height; }
}; // rect
struct point
{
long x = 0;
long y = 0;
};
struct size
{
long width = 0;
long height = 0;
};
enum class month
{
january = 1,
february,
march,
april,
may,
june,
july,
august,
september,
october,
november,
december,
}; // month
struct date
{
unsigned short day = 1;
liblec::cui::month month = liblec::cui::month::january;
short year = 2019;
};
struct time
{
unsigned short hour = 0;
unsigned short minute = 0;
unsigned short second = 0;
};
enum class image_format
{
png,
bmp,
jpeg,
none,
};
enum class window_position
{
// offset members use 10 pixels
center_to_working_area,
center_to_parent,
top_left,
top_left_offset,
bottom_left,
bottom_left_offset,
top_right,
top_right_offset,
bottom_right,
bottom_right_offset,
}; // window_position
namespace tools
{
enum class snap
{
bottom_left,
bottom,
bottom_right,
top_left,
top,
top_right,
right_top,
right,
right_bottom,
left_top,
left,
left_bottom,
};
void cui_api snap_to(const liblec::cui::rect &rect_reference,
snap snap_type,
const size_t &clearance,
liblec::cui::rect &rect);
void cui_api pos_rect(const liblec::cui::rect &rect_reference,
liblec::cui::rect &rect,
const size_t &perc_h,
const size_t &perc_v);
} // namespace tools
namespace widgets
{
/// <summary>
/// Action on resize.
/// </summary>
struct on_resize
{
/// <summary>
/// The percentage rate for following the parent's right border.
/// 0 = doesn't move horizontally, 100 = moves same number of pixels horizontally
/// that the parent's right border has moved.
/// </summary>
int perc_h = 0;
/// <summary>The percentage rate for following the parent's bottom border.
/// 0 = doesn't move vertically, 100 = moves same number of pixels vertically
/// that the parent's bottom border has moved.
/// </summary>
int perc_v = 0;
/// <summary>
/// The percentage rate for following the parent's change in width. 0 = doesn't
/// follow change in parent's width, 100 = width changes at same rate as that of
/// parent.
/// </summary>
int perc_width = 0;
/// <summary>
/// The percentage rate for following the parent's change in height. 0 = doesn't
/// follow change in parent's height, 100 = height changes at same rate as that of
/// parent.
/// </summary>
int perc_height = 0;
}; // on_resize
/// <summary>
/// Text alignment.
/// </summary>
enum class text_alignment
{
top_left,
center,
top_right,
/// <summary>
/// Place text on the middle (vertically) left.
/// </summary>
middle_left,
/// <summary>
/// Place text in the middle (vertically and horizontally).
/// </summary>
middle,
/// <summary>
/// Place text on the middle (vertically) right.
/// </summary>
middle_right,
bottom_left,
/// <summary>
/// Place text on the bottom middle (vertically).
/// </summary>
bottom_middle,
bottom_right,
}; // text_alignment
struct text
{
std::string text_value;
/// <summary>
/// Alias to uniquely identify the control within the current page. It is needed
/// to manipulate the control after it has been created. When referring to it
/// later, use the following format "page name/alias" since it is only required to
/// be unique in the current page. This allows controls in different pages can
/// to safely have different "aliases" because each alias is married to a page.
/// </summary>
std::string alias;
liblec::cui::color color = { 0, 0, 0 };
liblec::cui::color color_hot = { 255, 180, 0 };
std::string tooltip;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::text_alignment alignment =
liblec::cui::widgets::text_alignment::top_left;
liblec::cui::widgets::on_resize on_resize;
bool multiline = false;
std::function<void()> on_click = nullptr;
}; // text
struct button
{
std::string caption;
std::string alias;
bool is_default = true;
std::string tooltip;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
std::function<void()> on_click = nullptr;
}; // button
struct combobox
{
std::string alias;
std::vector<std::string> items;
std::string selected_item;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
bool auto_complete = false;
bool read_only = true;
std::function<void()> on_selection = nullptr;
}; // combobox
struct editbox
{
std::string alias;
std::string cue_banner;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
bool multiline = false;
bool scrollbar = false;
bool password = false;
bool read_only = false;
size_t limit = 0;
std::string allowed_set;
std::string forbidden_set;
std::string control_to_invoke_alias;
std::function<void()> on_type = nullptr;
}; // editbox
/// <summary>
/// Position of text in image control.
/// </summary>
enum class image_text_placement
{
bottom,
top,
right,
right_top,
right_bottom,
left,
left_top,
left_bottom,
};
/// <summary>
/// Toggle action when mouse moves over.
/// </summary>
enum class on_toggle
{
left,
right,
up,
down,
}; // on_toggle
struct image_colors
{
liblec::cui::color color_text = { 100, 100, 100 };
liblec::cui::color color_text_hot = { 21, 79, 139 };
liblec::cui::color color = { 0, 0, 0 };
liblec::cui::color color_hot = { 21, 79, 139 };
liblec::cui::color color_border = { 255, 255, 255 };
liblec::cui::color color_border_hot = { 240, 240, 240 };
}; // image_colors
struct image
{
std::string alias;
std::string text;
std::string tooltip;
std::string filename;
size_t png_resource = 0;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
/// <param name="tight_fit">
/// Whether to display only the image (no border, no toggling).
/// </param>
bool tight_fit = false;
bool change_color = false;
image_colors color;
liblec::cui::color color_background = { 255, 255, 255 };
liblec::cui::color color_background_hot = { 250, 250, 250 };
bool bar = false;
liblec::cui::color color_bar = { 255, 0, 0 };
liblec::cui::widgets::image_text_placement text_position =
liblec::cui::widgets::image_text_placement::bottom;
bool toggle = false;
liblec::cui::widgets::on_toggle on_toggle =
liblec::cui::widgets::on_toggle::up;
std::function<void()> on_click = nullptr;
}; // image
struct icon
{
std::string alias;
std::string text;
std::string description;
std::string tooltip;
std::string filename;
size_t png_resource = 0;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
bool change_color = false;
image_colors color;
liblec::cui::color color_background = { 255, 255, 255 };
liblec::cui::color color_background_hot = { 245, 245, 255 };
bool bar = false;
liblec::cui::color color_bar = { 255, 0, 0 };
liblec::cui::widgets::image_text_placement text_position =
liblec::cui::widgets::image_text_placement::right_top;
bool toggle = true;
liblec::cui::widgets::on_toggle on_toggle =
liblec::cui::widgets::on_toggle::up;
liblec::cui::size size = { 48, 48 };
std::function<void()> on_click = nullptr;
}; // icon
struct toggle_button
{
std::string alias;
std::string text_on;
std::string text_off;
std::string tooltip;
std::string font;
double font_size = 9;
liblec::cui::color color_text = { 100, 100, 100 };
liblec::cui::color color_on = { 21, 79, 139 };
liblec::cui::color color_off = { 200, 200, 200 };
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
bool on = true;
std::function<void()> on_toggle = nullptr;
}; // toggle_button
struct progress_bar
{
std::string alias;
liblec::cui::color color = { 0, 150, 0 };
liblec::cui::color color_unfilled = { 250, 250, 250 };
double initial_percentage = 0;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
}; // progress_bar
struct password_strength_bar
{
std::string alias;
liblec::cui::color color_unfilled = { 230, 230, 230 };
double initial_percentage = 0;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
}; // password_strength_bar
struct rectangle
{
liblec::cui::color color = { 250, 250, 250 };
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
}; // rectangle
struct hairline
{
liblec::cui::color color = { 200, 200, 200 };
liblec::cui::point point;
size_t length_horizontal = 0;
size_t length_vertical = 0;
liblec::cui::widgets::on_resize on_resize;
}; // hairline
struct groupbox
{
liblec::cui::color color = { 200, 200, 200 };
std::vector<liblec::cui::rect> rects;
liblec::cui::widgets::on_resize on_resize;
size_t clearance_ = 5;
};
struct selector_item
{
std::string alias;
std::string label;
bool default_item = false;
std::function<void()> on_select = nullptr;
};
struct selector
{
std::string alias;
std::string tooltip;
std::vector<liblec::cui::widgets::selector_item> items;
std::string font;
double font_size = 9;
liblec::cui::color color_text = { 0, 0, 0 };
liblec::cui::color color_bar = { 21, 79, 139 };
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
}; // selector
struct star_rating
{
std::string alias;
std::string tooltip;
liblec::cui::color color_on = { 21, 79, 139 };
liblec::cui::color color_off = { 200, 200, 200 };
liblec::cui::color color_hot = { 255, 180, 0 };
liblec::cui::color color_border = { 200, 200, 200 };
size_t highest_rating = 5;
size_t initial_rating = 0;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
std::function<void()> on_rating = nullptr;
}; // star_rating
struct date
{
std::string alias;
std::string font;
double font_size = 9;
bool allow_none = false;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
std::function<void()> on_date = nullptr;
}; // date
struct time
{
std::string alias;
std::string font;
double font_size = 9;
bool allow_none = false;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
std::function<void()> on_time = nullptr;
}; // time
struct richedit
{
std::string alias;
std::string cue_banner;
std::string font_ui_;
double font_size_ui = 9;
std::string font = "Georgia";
double font_size = 11;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
bool read_only = false;
bool border = true;
liblec::cui::color color_border = { 200, 200, 200 };
}; // richedit
struct chart_entry
{
std::string label;
double value = 0;
liblec::cui::color color = { 79, 129, 189 };
};
struct barchart_data
{
std::string caption;
std::string x_label;
std::string y_label;
int lower_limit = 0;
int upper_limit = 100;
bool autoscale = true;
bool autocolor = false;
std::vector<liblec::cui::widgets::chart_entry> bars;
}; // barchart_data
struct barchart
{
std::string alias;
liblec::cui::widgets::barchart_data data;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
}; // barchart
struct line_info
{
std::string series_name;
liblec::cui::color color = { 79, 129, 189 };
std::vector<liblec::cui::widgets::chart_entry> points;
};
struct linechart_data
{
std::string caption;
std::string x_label;
std::string y_label;
int lower_limit = 0;
int upper_limit = 100;
bool autoscale = true;
bool autocolor = false;
std::vector<liblec::cui::widgets::line_info> lines;
}; // linechart_data
struct linechart
{
std::string alias;
liblec::cui::widgets::linechart_data data;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
}; // linechart
enum class piechart_hover_effect
{
glow,
glow_and_arc,
glow_and_grow,
glow_and_shrink_others,
};
struct piechart_data
{
std::string caption;
bool doughnut = true;
bool autocolor = true;
liblec::cui::widgets::piechart_hover_effect on_hover =
liblec::cui::widgets::piechart_hover_effect::glow_and_arc;
std::vector<liblec::cui::widgets::chart_entry> slices;
}; // piechart_data
struct piechart
{
std::string alias;
liblec::cui::widgets::piechart_data data;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
}; // piechart
enum class listview_column_type
{
string_,
char_,
int_,
float_,
};
struct listview_column
{
std::string name;
size_t width = 50;
liblec::cui::widgets::listview_column_type type;
bool barchart = false;
size_t barchart_max = 100;
liblec::cui::color color_bar = { 190, 190, 255 };
liblec::cui::color color_text = { 0, 0, 0 };
}; // listview_column
struct listview_item
{
std::string column_name;
std::string item_data;
bool custom_text_color = false;
liblec::cui::color color_text = { 0, 0, 0 };
size_t row_number = 0;
}; // listview_item
struct listview_row
{
std::vector<liblec::cui::widgets::listview_item> items;
};
struct context_menu_item
{
std::string label;
bool is_default = false;
std::function<void()> on_click = nullptr;
int png_resource = 0;
};
struct listview
{
std::string alias;
std::vector<liblec::cui::widgets::listview_column> columns;
std::vector<liblec::cui::widgets::listview_row> data;
std::vector<liblec::cui::widgets::context_menu_item> context_menu;
std::string unique_column_name;
bool border = true;
bool gridlines = true;
bool sort_by_clicking_column = true;
std::string font;
double font_size = 9;
liblec::cui::rect rect;
liblec::cui::widgets::on_resize on_resize;
std::function<void()> on_selection = nullptr;
}; // listview
struct tab_control
{
std::string alias;
liblec::cui::rect rect;
std::string font;
double font_size = 9;
liblec::cui::color color_tab_line = { 200, 200, 200 };
};
struct tab
{
std::string tab_name;
std::string tooltip;
bool default_tab = false;
};
} // namespace widgets
/// Correct usage of the liblec::cui::gui class is as follows:
///
/// 1. Make a class that inherits from liblec::cui::gui, optionally overwriting the
/// virtual functions. It is highly recommended to make these private to prevent manual
/// calls to them outside the class.
///
/// class my_gui_class : public liblec::cui::gui
/// {
/// public:
/// my_gui_class(){};
/// my_gui_class(const std::string &app_guid) :
/// liblec::cui::gui(app_guid) {};
///
/// void text_1_handler() { // text_1 has been clicked }
///
/// private:
/// bool layout(liblec::cui::gui::page &persistent_page,
/// liblec::cui::gui::page &home_page,
/// std::string &error) { // layout code here }
/// void on_run() { // startup code here }
/// void on_caption() { // caption has been clicked }
/// void on_stop() { stop(); }
/// void on_shutdown() { // cleanup code here }
/// }
///
/// 2. Add layout code to the layout() member as follows:
///
/// bool layout(liblec::cui::gui::page &persistent_page,
/// liblec::cui::gui::page &home_page,
/// std::string &error)
/// {
/// home_page.set_name("Sample App");
///
/// liblec::cui::widgets::text text_1;
/// text_1.text_value = "Sample text";
/// text_1.on_click = [&]() {text_1_handler(); }; // add handler for text 1
///
/// home_page.add_text(text_1);
///
/// return true;
/// }
///
/// To add controls that persist across all pages use persistent_page. When adding other
/// pages make sure not to draw over these controls.
///
/// NOTE: do not call add_page() in layout()
///
/// 3. Setup the handlers for the various controls. There are two options
///
/// Option A (using lambda functions, as shown above, and highly recommended)
/// text_1.on_click = [&]() {text_1_handler(); };
///
/// Option B (using std::bind)
/// text_1.on_click = std::bind(&my_gui_class::text_1_handler, this};
///
/// 4. Run the app
///
/// my_gui_class gui();
///
/// std::string error;
/// gui.run(error);
///
/// 5. To add another page to the window is simple (we will do this in text_1_handler in
/// this example
///
/// void text_1_handler()
/// {
/// liblec::cui::gui::page sample_page("Sample Page");
///
/// // add text control
/// liblec::cui::widgets::text text_1;
/// text_1.text_value = "< Back";
/// text_2.on_click = [&]() {show_previous_page(); };
/// sample_page.add_text(text_1);
///
/// // add edit box
/// liblec::cui::widgets::editbox edit_1;
/// edit_1.cue_banner = "Enter text here";
/// sample_page.add_editbox(edit_1);
///
/// add_page(sample_page);
/// }
///
/// 6. In order to interact with a control use the .alias member as follows
///
/// sample_page.set_name("Sample Page");
/// text_1.alias = "sample_alias";
/// sample_page.add_text(text_1);
///
/// .... then elsewhere when you need to, say read the value of text_1's text ....
///
/// std::string text_value, error;
/// get_text("Sample Page/sample_alias", text_value, error);
///
/// NOTE: when declaring an alias use a simple string (has to be unique in that page).
/// When calling the alias combine it with the page the control is in using a forward
/// slash.
///
/// <summary>
/// gui class.
/// </summary>
///
/// <remarks>
/// Any app that uses this class should declare itself as DPI-aware through its application
/// manifest.
/// </remarks>
class cui_api gui
{
public:
gui();
/// <param name="app_guid">
/// Unique guid used to prevent multiple instances of the app,
/// e.g. "Global\\{7DBACCA2-B96E-4D0E-B0F7-933EA9A3C064}"
/// Leave empty to allow multiple instances, or just use the overload that doesn't
/// take this parameter.
/// </param>
gui(const std::string &app_guid);
~gui();
void modal(gui& parent);
void modal(liblec::cui::gui_raw::cui_raw& parent);
liblec::cui::gui_raw::cui_raw& get_raw();
class cui_api page
{
public:
page(const std::string &page_name);
~page();
void set_name(const std::string &page_name);
void add_text(const liblec::cui::widgets::text &t);
void add_button(const liblec::cui::widgets::button &b);
void add_combobox(const liblec::cui::widgets::combobox &c);
void add_editbox(const liblec::cui::widgets::editbox &e);
void add_icon(const liblec::cui::widgets::icon &i);
void add_image(const liblec::cui::widgets::image &i);
void add_toggle_button(const liblec::cui::widgets::toggle_button &t);
void add_progress_bar(const liblec::cui::widgets::progress_bar &p);
void add_password_strength_bar(
const liblec::cui::widgets::password_strength_bar &p);
void add_rectangle(const liblec::cui::widgets::rectangle &r);
void add_hairline(const liblec::cui::widgets::hairline &h);
void add_groupbox(const liblec::cui::widgets::groupbox &g);
void add_selector(const liblec::cui::widgets::selector &s);
void add_star_rating(const liblec::cui::widgets::star_rating &s);
void add_date(const liblec::cui::widgets::date &d);
void add_time(const liblec::cui::widgets::time &t);
void add_richedit(const liblec::cui::widgets::richedit &r);
void add_barchart(const liblec::cui::widgets::barchart &b);
void add_linechart(const liblec::cui::widgets::linechart &l);
void add_piechart(const liblec::cui::widgets::piechart &p);
void add_listview(const liblec::cui::widgets::listview &l);
void add_tabcontrol(const liblec::cui::widgets::tab_control &t);
void add_tab(const liblec::cui::widgets::tab &t);
private:
class page_impl;
page_impl* d_;
page();
friend gui;
page(const page&);
page& operator=(const page&);
}; // page
bool page_exists(const std::string &page_name);
void add_page(const page &page_to_add);
void show_page(const std::string &page_name);
std::string current_page();
std::string previous_page();
void show_previous_page();
/// <summary>
/// Run the gui app.
/// </summary>
///
/// <param name="error">
/// Error information.
/// </param>
///
/// <returns>
/// Returns true if successful, else false.
/// </returns>
///
/// <remarks>
/// This is a blocking function and will only return when the gui window is closed.
/// </remarks>
bool run(std::string &error);
/// <summary>
/// Run the gui app.
/// </summary>
///
/// <param name="window_guid">
/// Unique guid used to enable another instance to find this instance's window and
/// open it. Leave empty to prevent another instance from finding and opening this
/// instance's window, or just use the overload that doesn't have this parameter.
/// </param>
///
/// <param name="error">
/// Error information.
/// </param>
///
/// <returns>
/// Returns true if successful, else false.
/// </returns>
///
/// <remarks>
/// This is a blocking function and will only return when <see cref="stop()"/> is
/// called. A good place to do that is in the <see cref="on_stop()"/> handler.
/// </remarks>
bool run(const std::string &window_guid,
std::string &error);
/// <summary>
/// Stop the gui app.
/// </summary>
void stop();
// app
/// <summary>
/// Get the name of the home page (this is also the name of the app).
/// </summary>
///
/// <returns>
/// Returns the name of the home page.
/// </returns>
std::string home_page();
// window controls used before run() is called
// Only width(), height(), and title_bar_height() also work after run() is called
void set_width(const size_t &width);
void set_min_width(const size_t &width);
void set_height(const size_t &height);
void set_min_height(const size_t &height);
void set_min_width_and_height(const size_t &width,
const size_t &height);
size_t width();
size_t min_width();
size_t height();
size_t min_height();
size_t title_bar_height();
void set_position(const size_t &x,
const size_t &y,
const size_t &width,
const size_t &height);
void set_position(const window_position &pos,
const size_t &width,
const size_t &height);
void set_resource_dll(const std::string& file_name);
struct caption_icon_png
{
size_t png_resource_16 = 0;
size_t png_resource_20 = 0;
size_t png_resource_24 = 0;
size_t png_resource_28 = 0;
size_t png_resource_32 = 0;
};
void set_icons(const size_t &ico_resource,
const caption_icon_png &png_resource);
struct font_file
{
std::string fullpath;
std::string font_name;
};
struct font_resource
{
int font_resource_id = 0;
std::string font_name;
};
bool load_fonts(const std::vector<font_file> &font_files,
std::string &error);
bool load_fonts(const std::vector<font_resource> &font_resources,
std::string &error);
void set_ui_font(const std::string &font);
void set_ui_color(color ui_color);
// window functions used after run() is called (the resizing functions also work
// before run() is called)
void disable();
void enable();
bool is_enabled();
void hide();
void show();
void show(const bool &foreground);
bool is_visible();
void maximize();
bool is_maximized();
bool is_prompt_displayed();
void exclude_from_title_bar(const std::string &alias);