FabGL
ESP32 Display Controller and Graphics Library
fabui.h
Go to the documentation of this file.
1/*
2 Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3 Copyright (c) 2019-2022 Fabrizio Di Vittorio.
4 All rights reserved.
5
6
7* Please contact fdivitto2013@gmail.com if you need a commercial license.
8
9
10* This library and related software is available under GPL v3.
11
12 FabGL is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 FabGL is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26
27#pragma once
28
29
38#include <stdint.h>
39#include <stddef.h>
40
41#include <list>
42
43#include "freertos/FreeRTOS.h"
44#include "freertos/queue.h"
45#include "freertos/timers.h"
46
47#include "fabglconf.h"
48#include "fabutils.h"
49#include "displaycontroller.h"
50#include "canvas.h"
51#include "fabfonts.h"
52#include "codepages.h"
53
54
55
56/*
57
58 *uiObject
59 *uiEvtHandler
60 *uiApp
61 *uiWindow
62 *uiFrame
63 *uiControl
64 *uiButton
65 *uiLabel
66 *uiStaticLabel
67 *uiImage
68 *uiPanel
69 *uiTextEdit
70 *uiScrollableControl
71 *uiPaintBox
72 *uiCustomListBox
73 *uiListBox
74 *uiColorListBox
75 *uiFileBrowser
76 *uiSimpleMenu
77 uiMemoEdit
78 *uiCheckBox
79 *uiCustomComboBox
80 *uiComboBox
81 *uiColorComboBox
82 *uiSplitButton
83 uiMenu
84 uiGauge
85 *uiSlider
86 uiSpinButton
87 *uiColorBox
88 *uiProgressBar
89
90*/
91
92
93namespace fabgl {
94
95
96
97// increase in case of garbage between windows!
98#define FABGLIB_UI_EVENTS_QUEUE_SIZE 300
99
100
101using std::list;
102using std::pair;
103
104
106// uiEvent
107
108enum uiEventID {
109 UIEVT_NULL,
110 UIEVT_DEBUGMSG,
111 UIEVT_APPINIT,
112 UIEVT_GENPAINTEVENTS,
113 UIEVT_PAINT,
114 UIEVT_ACTIVATE,
115 UIEVT_DEACTIVATE,
116 UIEVT_MOUSEMOVE,
117 UIEVT_MOUSEWHEEL,
118 UIEVT_MOUSEBUTTONDOWN,
119 UIEVT_MOUSEBUTTONUP,
120 UIEVT_SETPOS,
121 UIEVT_SETSIZE,
122 UIEVT_RESHAPEWINDOW,
123 UIEVT_MOUSEENTER,
124 UIEVT_MOUSELEAVE,
125 UIEVT_MAXIMIZE, // Request for maximize
126 UIEVT_MINIMIZE, // Request for minimize
127 UIEVT_RESTORE, // Restore from UIEVT_MAXIMIZE or UIEVT_MINIMIZE
128 UIEVT_SHOW,
129 UIEVT_HIDE,
130 UIEVT_SETFOCUS,
131 UIEVT_KILLFOCUS,
132 UIEVT_KEYDOWN,
133 UIEVT_KEYUP,
134 UIEVT_KEYTYPE,
135 UIEVT_TIMER,
136 UIEVT_CLICK,
137 UIEVT_DBLCLICK,
138 UIEVT_EXITMODAL,
139 UIEVT_DESTROY,
140 UIEVT_CLOSE, // Request to close (frame Close button)
141 UIEVT_QUIT, // Quit the application
142 UIEVT_CREATE,
143 UIEVT_CHILDSETFOCUS, // a UIEVT_SETFOCUS has been sent to a child
144 UIEVT_CHILDKILLFOCUS, // a UIEVT_KILLFOCUS has been sent to a child
145};
146
147
148class uiEvtHandler;
149class uiApp;
150class uiWindow;
151
152
153typedef void * uiTimerHandle;
154
155
159 uint8_t ASCII;
160 uint8_t LALT : 1;
161 uint8_t RALT : 1;
162 uint8_t CTRL : 1;
163 uint8_t SHIFT : 1;
164 uint8_t GUI : 1;
165};
166
167
172};
173
174
175struct uiFocusInfo {
176 uiWindow * oldFocused;
177 uiWindow * newFocused;
178};
179
180
181struct uiEvent {
182 uiEvtHandler * dest;
183 uiEventID id;
184
185 union uiEventParams {
186 // event: UIEVT_MOUSEMOVE, UIEVT_MOUSEWHEEL, UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP, UIEVT_CLICK, UIEVT_DBLCLICK
187 uiMouseEventInfo mouse;
188 // event: UIEVT_PAINT, UIEVT_GENPAINTEVENTS, UIEVT_RESHAPEWINDOW
189 Rect rect;
190 // event: UIEVT_SETPOS
191 Point pos;
192 // event: UIEVT_SETSIZE
193 Size size;
194 // event: UIEVT_DEBUGMSG
195 char const * debugMsg;
196 // event: UIEVT_KEYDOWN, UIEVT_KEYUP
197 uiKeyEventInfo key;
198 // event: UIEVT_TIMER
199 uiTimerHandle timerHandle;
200 // event: UIEVT_EXITMODAL
201 int modalResult;
202 // event: UIEVT_QUIT
203 int exitCode;
204 // event: UIEVT_SETFOCUS, UIEVT_KILLFOCUS, UIEVT_CHILDKILLFOCUS, UIEVT_CHILDSETFOCUS
205 uiFocusInfo focusInfo;
206
207 uiEventParams() { }
208 } params;
209
210 uiEvent() : dest(nullptr), id(UIEVT_NULL) { }
211 uiEvent(uiEvent const & e) { dest = e.dest; id = e.id; params = e.params; }
212 uiEvent(uiEvtHandler * dest_, uiEventID id_) : dest(dest_), id(id_) { }
213};
214
215
216
220enum class uiOrientation {
221 Vertical,
222 Horizontal,
223};
224
225
229enum class uiHAlign {
230 Left,
231 Right,
232 Center,
233};
234
235
236
238// uiObject
239
240
243 uint32_t uiApp : 1;
244 uint32_t uiEvtHandler : 1;
245 uint32_t uiWindow : 1;
246 uint32_t uiFrame : 1;
247 uint32_t uiControl : 1;
248 uint32_t uiScrollableControl : 1;
249 uint32_t uiButton : 1;
250 uint32_t uiTextEdit : 1;
251 uint32_t uiLabel : 1;
252 uint32_t uiStaticLabel : 1;
253 uint32_t uiImage : 1;
254 uint32_t uiPanel : 1;
255 uint32_t uiPaintBox : 1;
256 uint32_t uiCustomListBox : 1;
257 uint32_t uiListBox : 1;
258 uint32_t uiFileBrowser : 1;
259 uint32_t uiComboBox : 1;
260 uint32_t uiCheckBox : 1;
261 uint32_t uiSlider : 1;
262 uint32_t uiColorListBox : 1;
263 uint32_t uiCustomComboBox : 1;
264 uint32_t uiColorBox : 1;
265 uint32_t uiColorComboBox : 1;
266 uint32_t uiProgressBar : 1;
267 uint32_t uiSplitButton : 1;
268 uint32_t uiSimpleMenu : 1;
269
274 { }
275};
276
277
279class uiObject {
280
281public:
282
283 uiObject();
284
285 virtual ~uiObject();
286
292 uiObjectType & objectType() { return m_objectType; }
293
294private:
295 uiObjectType m_objectType;
296};
297
298
299
301// uiEvtHandler
302
303
305class uiEvtHandler : public uiObject {
306
307public:
308
310
311 virtual ~uiEvtHandler();
312
313 virtual void processEvent(uiEvent * event);
314
320 uiApp * app() { return m_app; }
321
322
323protected:
324
325 void setApp(uiApp * value) { m_app = value; }
326
327
328private:
329
330 uiApp * m_app;
331};
332
333
334
336// uiWindow
337
341enum class uiOrigin {
342 Screen,
343 Parent,
344 Window,
345};
346
347
350 uint8_t visible : 1;
351 uint8_t active : 1;
352};
353
354
357 uint8_t activable : 1;
358 uint8_t focusable : 1;
359 uint8_t activeLook : 1;
361 uiWindowProps() :
362 activable(true),
363 focusable(false),
364 activeLook(false)
365 { }
366};
367
368
372 RGB888 borderColor = RGB888(128, 128, 128);
373 RGB888 activeBorderColor = RGB888(128, 128, 255);
375 uint8_t borderSize = 3;
376 uint8_t focusedBorderSize = 1;
378 void adaptToDisplayColors(int displayColors) {
379 if (displayColors < 4) {
380 borderColor = RGB888(0, 0, 0);
381 activeBorderColor = RGB888(0, 0, 0);
382 focusedBorderColor = RGB888(0, 0, 0);
383 } else if (displayColors < 16) {
384 borderColor = RGB888(0, 0, 0);
385 }
386 }
387};
388
389
391struct uiAnchors {
392 uint8_t left : 1;
393 uint8_t top : 1;
394 uint8_t right : 1;
395 uint8_t bottom : 1;
397 uiAnchors() : left(true), top(true), right(false), bottom(false) { }
398};
399
400
401#define UIWINDOW_PARENTCENTER Point(-1000, -1000)
402
403
405class uiWindow : public uiEvtHandler {
406
407friend class uiApp;
408
409public:
410
420 uiWindow(uiWindow * parent, const Point & pos, const Size & size, bool visible, uint32_t styleClassID = 0);
421
422 virtual ~uiWindow();
423
424 virtual void processEvent(uiEvent * event);
425
433 uiWindow * next() { return m_next; }
434
442 uiWindow * prev() { return m_prev; }
443
449 uiWindow * firstChild() { return m_firstChild; }
450
456 uiWindow * lastChild() { return m_lastChild; }
457
463 bool hasChildren() { return m_firstChild != nullptr; }
464
468 void bringOnTop();
469
475 void bringAfter(uiWindow * insertionPoint);
476
484 Point pos() { return m_pos; }
485
492
500 Size size() { return m_size; }
501
508
518 Rect rect(uiOrigin origin);
519
527 virtual Rect clientRect(uiOrigin origin);
528
536 uiWindowState state() { return m_state; }
537
543 uiWindowProps & windowProps() { return m_windowProps; }
544
550 uiWindowStyle & windowStyle() { return m_windowStyle; }
551
557 uiWindow * parent() { return m_parent; }
558
565
574 Rect transformRect(Rect const & rect, uiWindow * baseWindow);
575
581 void repaint(Rect const & rect);
582
586 void repaint();
587
595 bool isMouseOver() { return m_isMouseOver; }
596
604 void exitModal(int modalResult);
605
613 bool hasFocus();
614
620 bool isActiveWindow();
621
627 uiAnchors & anchors() { return m_anchors; }
628
634 void setFocusIndex(int value) { m_focusIndex = value; }
635
643 int focusIndex() { return m_focusIndex; }
644
645 Canvas * canvas();
646
652 void setStyleClassID(uint16_t value) { m_styleClassID = value; }
653
659 uint16_t styleClassID() { return m_styleClassID; }
660
668 void setParentProcessKbdEvents(bool value) { m_parentProcessKbdEvents = value; }
669
670
671protected:
672
673 void addChild(uiWindow * child);
674 void insertAfter(uiWindow * child, uiWindow * underlyingChild);
675 void freeChildren();
676 void removeChild(uiWindow * child, bool freeChild = true);
677 void moveChildOnTop(uiWindow * child);
678 void moveAfter(uiWindow * child, uiWindow * underlyingChild);
679 bool isChild(uiWindow * window);
680
681 virtual Size minWindowSize() { return Size(0, 0); }
682
683 void beginPaint(uiEvent * paintEvent, Rect const & clippingRect);
684
685 void generatePaintEvents(Rect const & paintRect);
686 void reshape(Rect const & r);
687
688 bool isFocusable();
689
690private:
691
692 void paintWindow();
693
694 uiWindow * findChildWithFocusIndex(int focusIndex, int * maxIndex);
695
696
697 uiWindow * m_parent;
698
699 Point m_pos;
700 Size m_size;
701
702 // double linked list, order is: bottom (first items) -> up (last items)
703 uiWindow * m_next;
704 uiWindow * m_prev;
705 uiWindow * m_firstChild;
706 uiWindow * m_lastChild;
707
708 uiWindowStyle m_windowStyle;
709
710 uiWindowProps m_windowProps;
711
712 uiWindowState m_state;
713
714 uiAnchors m_anchors;
715
716 int8_t m_focusIndex; // -1 = doesn't partecipate to focus trip
717
718 uint8_t m_styleClassID;
719
720 uint8_t m_isMouseOver; // 1 after mouse entered, 0 after mouse left
721
722 uint8_t m_parentProcessKbdEvents; // if 1 parent processes keyboard events
723};
724
725
726
728// uiFrame
729
730
735 RGB888 backgroundColor = RGB888(255, 255, 255);
739 RGB888 activeTitleColor = RGB888(255, 255, 255);
740 FontInfo const * titleFont = &FONT_std_12;
741 RGB888 buttonColor = RGB888(64, 64, 64);
742 RGB888 activeButtonColor = RGB888(255, 255, 255);
746 void adaptToDisplayColors(int displayColors) {
747 if (displayColors < 4) {
748 titleBackgroundColor = RGB888(255, 255, 255);
749 titleColor = RGB888(0, 0, 0);
750 buttonColor = RGB888(0, 0, 0);
752 activeTitleColor = RGB888(255, 255, 255);
753 activeButtonColor = RGB888(255, 255, 255);
754 mouseOverButtonColor = RGB888(0, 0, 0);
755 mouseOverBackgroundButtonColor = RGB888(255, 255, 255);
756 } else if (displayColors < 16) {
757 titleBackgroundColor = RGB888(0, 0, 0);
758 titleColor = RGB888(255, 255, 255);
759 buttonColor = RGB888(255, 255, 255);
760 activeButtonColor = RGB888(0, 0, 0);
761 }
762 }
763};
764
765
770 uint8_t resizeable : 1;
771 uint8_t moveable : 1;
772 uint8_t hasCloseButton : 1;
773 uint8_t hasMaximizeButton : 1;
774 uint8_t hasMinimizeButton : 1;
775 uint8_t fillBackground : 1;
777 uiFrameProps() :
778 resizeable(true),
779 moveable(true),
780 hasCloseButton(true),
781 hasMaximizeButton(true),
782 hasMinimizeButton(true),
783 fillBackground(true)
784 { }
785};
786
787
790 uint8_t maximized : 1;
791 uint8_t minimized : 1;
792};
793
794
798enum class uiFrameItem : uint8_t {
799 None,
800 MoveArea,
801 TopLeftResize,
802 TopCenterResize,
803 TopRightResize,
804 CenterLeftResize,
805 CenterRightResize,
806 BottomLeftResize,
807 BottomCenterResize,
808 BottomRightResize,
809 CloseButton,
810 MaximizeButton,
811 MinimizeButton,
812};
813
814
820class uiFrame : public uiWindow {
821
822public:
823
834 uiFrame(uiWindow * parent, char const * title, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
835
836 virtual ~uiFrame();
837
838 virtual void processEvent(uiEvent * event);
839
845 char const * title() { return m_title; }
846
854 void setTitle(char const * value);
855
863 void setTitleFmt(const char *format, ...);
864
870 uiFrameStyle & frameStyle() { return m_frameStyle; }
871
877 uiFrameProps & frameProps() { return m_frameProps; }
878
879 Rect clientRect(uiOrigin origin);
880
881 int getNextFreeFocusIndex() { return m_nextFreeFocusIndex++; }
882
890 uiFrameState frameState() { return m_frameState; }
891
892
893
894 // Delegates
895
901 Delegate<> onShow;
902
908 Delegate<> onHide;
909
915 Delegate<> onResize;
916
923 Delegate<uiTimerHandle> onTimer;
924
928 Delegate<uiKeyEventInfo const &> onKeyDown;
929
933 Delegate<uiKeyEventInfo const &> onKeyUp;
934
938 Delegate<> onPaint;
939
940
941protected:
942
943 Size minWindowSize();
944 int titleBarHeight();
945 Rect titleBarRect();
946
947private:
948
949 void paintFrame();
950 int paintButtons(Rect const & bkgRect);
951 void movingCapturedMouse(int mouseX, int mouseY, bool mouseIsDown);
952 void movingFreeMouse(int mouseX, int mouseY);
953 uiFrameItem getFrameItemAt(int x, int y);
954 Rect getBtnRect(int buttonIndex);
955 void handleButtonsClick(int x, int y, bool doubleClick);
956 void drawTextWithEllipsis(FontInfo const * fontInfo, int X, int Y, char const * text, int maxX);
957 void drawReshapingBox(Rect boxRect);
958
959
960 static constexpr int CORNERSENSE = 10;
961
962
963 uiFrameStyle m_frameStyle;
964
965 uiFrameProps m_frameProps;
966
967 char * m_title;
968 int m_titleLength;
969
970 uiFrameItem m_mouseDownFrameItem; // frame item on mouse down
971 uiFrameItem m_mouseMoveFrameItem; // frame item on mouse move
972
973 Rect m_lastReshapingBox; // last reshaping box painted by drawReshapingBox(), (0,0,0,0) if there isn't any
974
975 int m_nextFreeFocusIndex;
976
977 Point m_mouseDownPos; // mouse position when mouse down event has been received
978
979 Rect m_savedScreenRect; // saved screen rect before Maximize or Minimize
980
981 Size m_sizeAtMouseDown; // used to resize
982
983 uiFrameState m_frameState;
984};
985
986
987
989// uiControl
990
991
995class uiControl : public uiWindow {
996
997public:
998
1008 uiControl(uiWindow * parent, const Point & pos, const Size & size, bool visible, uint32_t styleClassID = 0);
1009
1010 virtual ~uiControl();
1011
1012 virtual void processEvent(uiEvent * event);
1013};
1014
1015
1016
1018// uiScrollableControl
1019
1020
1026 uint8_t scrollBarSize = 11;
1028 void adaptToDisplayColors(int displayColors) {
1029 if (displayColors < 16) {
1031 }
1032 }
1033};
1034
1035
1039enum class uiScrollBarItem {
1040 None,
1041 LeftButton,
1042 RightButton,
1043 TopButton,
1044 BottomButton,
1045 HBar,
1046 VBar,
1047 PageUp,
1048 PageDown,
1049 PageLeft,
1050 PageRight,
1051};
1052
1053
1058
1059public:
1060
1070 uiScrollableControl(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1071
1072 virtual ~uiScrollableControl();
1073
1074 virtual void processEvent(uiEvent * event);
1075
1076 Rect clientRect(uiOrigin origin);
1077
1083 uiScrollableControlStyle & scrollableControlStyle() { return m_scrollableControlStyle; }
1084
1093 int HScrollBarPos() { return m_HScrollBarPosition; }
1094
1102 int HScrollBarVisible() { return m_HScrollBarVisible; }
1103
1112 int HScrollBarRange() { return m_HScrollBarRange; }
1113
1122 int VScrollBarPos() { return m_VScrollBarPosition; }
1123
1131 int VScrollBarVisible() { return m_VScrollBarVisible; }
1132
1141 int VScrollBarRange() { return m_VScrollBarRange; }
1142
1143
1144 // Delegates
1145
1150
1155
1156
1157protected:
1158
1168 virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar = true);
1169
1170
1171private:
1172
1173 void paintScrollableControl();
1174 void paintScrollBars();
1175 Rect getVScrollBarRects(Rect * topButton = nullptr, Rect * bottonButton = nullptr, Rect * bar = nullptr);
1176 Rect getHScrollBarRects(Rect * leftButton = nullptr, Rect * rightButton = nullptr, Rect * bar = nullptr);
1177 uiScrollBarItem getItemAt(int x, int y);
1178 void repaintScrollBar(uiOrientation orientation);
1179 void handleFreeMouseMove(int mouseX, int mouseY);
1180 void handleCapturedMouseMove(int mouseX, int mouseY);
1181 void handleButtonsScroll();
1182 void handlePageScroll();
1183
1184 uiScrollableControlStyle m_scrollableControlStyle;
1185
1186 int16_t m_HScrollBarPosition;
1187 int16_t m_HScrollBarVisible; // it means the "visible" area (how big is the bar)
1188 int16_t m_HScrollBarRange;
1189 int16_t m_VScrollBarPosition;
1190 int16_t m_VScrollBarVisible; // it means the "visible" area (how big is the bar)
1191 int16_t m_VScrollBarRange;
1192
1193 // values updated by getVScrollBarRects() and getHScrollBarRects()
1194 int16_t m_HBarArea;
1195 int16_t m_VBarArea;
1196
1197 int16_t m_mouseDownHScrollBarPosition;
1198 int16_t m_mouseDownVScrollBarPosition;
1199
1200 uiScrollBarItem m_mouseOverItem;
1201
1202 // a timer is active while mouse is down and the mouse is over a button
1203 uiTimerHandle m_scrollTimer;
1204
1205 Point m_mouseDownPos; // mouse position when mouse down event has been received
1206};
1207
1208
1209
1211// uiButton
1212
1213
1216 RGB888 backgroundColor = RGB888(128, 128, 128);
1223 FontInfo const * textFont = &FONT_std_14;
1224 uint8_t bitmapTextSpace = 4;
1225 Bitmap const * bitmap = nullptr;
1226 Bitmap const * downBitmap = nullptr;
1228 void adaptToDisplayColors(int displayColors) {
1229 if (displayColors < 4) {
1231 mouseOverTextColor = RGB888(255, 255, 255);
1232 downTextColor = RGB888(255, 255, 255);
1233 downBackgroundColor = RGB888(0, 0, 0);
1234 } else if (displayColors < 16) {
1235 mouseOverBackgroundColor = RGB888(255, 255, 255);
1236 mouseDownBackgroundColor = RGB888(255, 255, 255);
1237 backgroundColor = RGB888(0, 0, 255);
1238 downBackgroundColor = RGB888(0, 128, 0);
1239 downTextColor = displayColors < 8 ? RGB888(0, 0, 0) : RGB888(255, 255, 255);
1240 textColor = RGB888(255, 255, 255);
1241 mouseOverTextColor = RGB888(0, 0, 0);
1242 }
1243 }
1244};
1245
1246
1250enum class uiButtonKind {
1251 Button,
1252 Switch,
1253};
1254
1255
1257class uiButton : public uiControl {
1258
1259public:
1260
1272 uiButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, uiButtonKind kind = uiButtonKind::Button, bool visible = true, uint32_t styleClassID = 0);
1273
1274 virtual ~uiButton();
1275
1276 virtual void processEvent(uiEvent * event);
1277
1285 void setText(char const * value);
1286
1292 char const * text() { return m_text; }
1293
1299 uiButtonStyle & buttonStyle() { return m_buttonStyle; }
1300
1308 bool down() { return m_down; }
1309
1317 void setDown(bool value);
1318
1319
1320 // Delegates
1321
1327 Delegate<> onChange;
1328
1334 Delegate<> onClick;
1335
1341 Delegate<uiMouseEventInfo const&> onMouseDown;
1342
1348 Delegate<uiMouseEventInfo const&> onMouseUp;
1349
1350
1351private:
1352
1353 void paintButton();
1354 void paintContent(Rect const & rect);
1355
1356 void trigger();
1357
1358
1359 uiButtonStyle m_buttonStyle;
1360
1361 char * m_text;
1362 int m_textExtent; // calculated by setText(). TODO: changing font doesn't update m_textExtent!
1363
1364 bool m_down;
1365
1366 uiButtonKind m_kind;
1367
1368};
1369
1370
1371
1373// uiTextEdit
1374// single line text edit
1375
1376
1383 RGB888 backgroundColor = RGB888(128, 128, 128);
1387 FontInfo const * textFont = &FONT_std_14;
1389 void adaptToDisplayColors(int displayColors) {
1390 if (displayColors < 16) {
1391 }
1392 }
1393};
1394
1395
1400 uint8_t hasCaret : 1;
1401 uint8_t allowEdit : 1;
1402 uint8_t passwordMode : 1;
1405 : hasCaret(true),
1406 allowEdit(true),
1407 passwordMode(false)
1408 {
1409 }
1410};
1411
1412
1418class uiTextEdit : public uiControl {
1419
1420public:
1421
1432 uiTextEdit(uiWindow * parent, char const * text, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1433
1434 virtual ~uiTextEdit();
1435
1436 virtual void processEvent(uiEvent * event);
1437
1443 uiTextEditStyle & textEditStyle() { return m_textEditStyle; }
1444
1450 uiTextEditProps & textEditProps() { return m_textEditProps; }
1451
1459 void setText(char const * value);
1460
1468 void setTextFmt(const char *format, ...);
1469
1475 char const * text() { return m_text; }
1476
1477
1478 // Delegates
1479
1483 Delegate<> onChange;
1484
1488 Delegate<uiKeyEventInfo const &> onKeyType;
1489
1490
1491
1492protected:
1493
1494 virtual Rect getEditRect();
1495
1496private:
1497
1498 void paintTextEdit();
1499 void paintContent();
1500
1501 uint8_t const * getCharInfo(char ch, int * width);
1502 int charColumnToWindowX(int col);
1503 void updateCaret();
1504 void moveCursor(int col, int selCol);
1505 int getColFromMouseX(int mouseX);
1506 void handleKeyDown(uiKeyEventInfo const & key);
1507 void checkAllocatedSpace(int requiredLength);
1508 void insert(char c);
1509 void removeSel();
1510 int getWordPosAtLeft();
1511 int getWordPosAtRight();
1512 void selectWordAt(int mouseX);
1513 int keyToASCII(uiKeyEventInfo const & key);
1514
1515
1516 uiTextEditStyle m_textEditStyle;
1517 uiTextEditProps m_textEditProps;
1518
1519 char * m_text;
1520 int m_textLength; // text length NOT including ending zero
1521 int m_textSpace; // actual space allocated including ending zero
1522
1523 // rectangle where text will be painted (this is also the text clipping rect)
1524 Rect m_contentRect; // updated on painting
1525
1526 // where text starts to be painted. Values less than m_contentRect.X1 are used to show characters which do not fit in m_contentRect
1527 int m_viewX;
1528
1529 // character index of cursor position (0 = at first char)
1530 int m_cursorCol;
1531
1532 // character index at start of selection (not included if < m_cursorCol, included if > m_cursorCol)
1533 int m_selCursorCol;
1534
1535 CodePage const * m_codepage;
1536
1537};
1538
1539
1540
1542// uiLabel
1543
1544
1547 FontInfo const * textFont = &FONT_std_14;
1548 RGB888 backgroundColor = RGB888(255, 255, 255);
1552 void adaptToDisplayColors(int displayColors) {
1553 if (displayColors < 16) {
1554 }
1555 }
1556};
1557
1558
1560class uiLabel : public uiControl {
1561
1562public:
1563
1574 uiLabel(uiWindow * parent, char const * text, const Point & pos, const Size & size = Size(0, 0), bool visible = true, uint32_t styleClassID = 0);
1575
1576 virtual ~uiLabel();
1577
1578 virtual void processEvent(uiEvent * event);
1579
1587 void setText(char const * value);
1588
1596 void setTextFmt(const char *format, ...);
1597
1603 char const * text() { return m_text; }
1604
1610 uiLabelStyle & labelStyle() { return m_labelStyle; }
1611
1617 void update();
1618
1624 Delegate<> onClick;
1625
1626
1627private:
1628
1629 void paintLabel();
1630
1631
1632 char * m_text;
1633
1634 uiLabelStyle m_labelStyle;
1635
1636 uint8_t m_autoSize;
1637
1638};
1639
1640
1641
1643// uiStaticLabel
1644
1645
1648 FontInfo const * textFont = &FONT_std_14;
1649 RGB888 backgroundColor = RGB888(255, 255, 255);
1652 void adaptToDisplayColors(int displayColors) {
1653 if (displayColors < 16) {
1654 }
1655 }
1656};
1657
1658
1660class uiStaticLabel : public uiControl {
1661
1662public:
1663
1673 uiStaticLabel(uiWindow * parent, char const * text, const Point & pos, bool visible = true, uint32_t styleClassID = 0);
1674
1675 virtual void processEvent(uiEvent * event);
1676
1685 void setText(char const * value);
1686
1692 char const * text() { return m_text; }
1693
1699 uiStaticLabelStyle & labelStyle() { return m_staticLabelStyle; }
1700
1706 void update();
1707
1708
1709private:
1710
1711 void paintLabel();
1712
1713
1714 char const * m_text;
1715
1716 uiStaticLabelStyle m_staticLabelStyle;
1717
1718};
1719
1720
1721
1723// uiImage
1724
1725
1728 RGB888 backgroundColor = RGB888(255, 255, 255);
1730 void adaptToDisplayColors(int displayColors) {
1731 if (displayColors < 16) {
1732 }
1733 }
1734};
1735
1736
1738class uiImage : public uiControl {
1739
1740public:
1741
1752 uiImage(uiWindow * parent, Bitmap const * bitmap, const Point & pos, const Size & size = Size(0, 0), bool visible = true, uint32_t styleClassID = 0);
1753
1754 virtual ~uiImage();
1755
1756 virtual void processEvent(uiEvent * event);
1757
1765 void setBitmap(Bitmap const * bitmap);
1766
1772 Bitmap const * bitmap() { return m_bitmap; }
1773
1779 uiImageStyle & imageStyle() { return m_imageStyle; }
1780
1781
1782private:
1783
1784 void paintImage();
1785
1786
1787 Bitmap const * m_bitmap;
1788
1789 uiImageStyle m_imageStyle;
1790
1791 bool m_autoSize;
1792
1793};
1794
1795
1796
1798// uiPanel
1799
1800
1803 RGB888 backgroundColor = RGB888(128, 128, 128);
1805 void adaptToDisplayColors(int displayColors) {
1806 if (displayColors < 16) {
1807 }
1808 }
1809};
1810
1811
1813class uiPanel : public uiControl {
1814
1815public:
1816
1826 uiPanel(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1827
1828 virtual ~uiPanel();
1829
1830 virtual void processEvent(uiEvent * event);
1831
1837 uiPanelStyle & panelStyle() { return m_panelStyle; }
1838
1839
1840private:
1841
1842 void paintPanel();
1843
1844
1845 uiPanelStyle m_panelStyle;
1846};
1847
1848
1849
1851// uiPaintBox
1852
1853
1856 RGB888 backgroundColor = RGB888(128, 128, 128);
1858 void adaptToDisplayColors(int displayColors) {
1859 if (displayColors < 16) {
1860 }
1861 }
1862};
1863
1864
1867
1868public:
1869
1879 uiPaintBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1880
1881 virtual ~uiPaintBox();
1882
1883 virtual void processEvent(uiEvent * event);
1884
1890 uiPaintBoxStyle & paintBoxStyle() { return m_paintBoxStyle; }
1891
1893
1894 // Delegates
1895
1901 Delegate<Rect const &> onPaint;
1902
1903
1904private:
1905
1906 void paintPaintBox();
1907
1908
1909 uiPaintBoxStyle m_paintBoxStyle;
1910};
1911
1912
1913
1915// uiColorBox
1916
1918class uiColorBox : public uiControl {
1919
1920public:
1921
1932 uiColorBox(uiWindow * parent, const Point & pos, const Size & size, Color color = Color::BrightWhite, bool visible = true, uint32_t styleClassID = 0);
1933
1934 virtual ~uiColorBox();
1935
1936 virtual void processEvent(uiEvent * event);
1937
1943 Color color() { return m_color; }
1944
1950 void setColor(Color value);
1951
1952private:
1953
1954 void paintColorBox();
1955
1956
1957 Color m_color;
1958};
1959
1960
1961
1963// uiCustomListBox
1964
1965
1968 RGB888 backgroundColor = RGB888(128, 128, 128);
1972 int itemHeight = 16;
1973 FontInfo const * textFont = &FONT_std_14;
1977 void adaptToDisplayColors(int displayColors) {
1978 if (displayColors < 4) {
1981 selectedTextColor = RGB888(255, 255, 255);
1982 }
1983 }
1984};
1985
1986
1991 uint8_t allowMultiSelect : 1;
1992 uint8_t selectOnMouseOver : 1;
1995 : allowMultiSelect(true),
1996 selectOnMouseOver(false)
1997 {
1998 }
1999};
2000
2001
2004
2005public:
2006
2016 uiCustomListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2017
2018 virtual ~uiCustomListBox();
2019
2020 virtual void processEvent(uiEvent * event);
2021
2027 uiListBoxStyle & listBoxStyle() { return m_listBoxStyle; }
2028
2034 uiListBoxProps & listBoxProps() { return m_listBoxProps; }
2035
2041 int firstSelectedItem();
2042
2048 int lastSelectedItem();
2049
2057 void selectItem(int index, bool add = false, bool range = false);
2058
2062 void deselectAll();
2063
2064
2065 // Delegates
2066
2072 Delegate<> onChange;
2073
2077 Delegate<> onKillFocus;
2078
2082 Delegate<uiKeyEventInfo const &> onKeyType;
2083
2087 Delegate<uiKeyEventInfo const &> onKeyUp;
2088
2094 Delegate<> onClick;
2095
2102 Delegate<> onDblClick;
2103
2104
2105
2106protected:
2107
2108 void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar);
2109 int getItemAtMousePos(int mouseX, int mouseY);
2110
2111 // must be implemented by inherited class
2112 virtual int items_getCount() = 0;
2113 virtual void items_deselectAll() = 0;
2114 virtual void items_select(int index, bool select) = 0;
2115 virtual bool items_selected(int index) = 0;
2116 virtual void items_draw(int index, const Rect & itemRect) = 0;
2117
2118private:
2119
2120 void paintListBox();
2121 void mouseDownSelect(int mouseX, int mouseY);
2122 void mouseMoveSelect(int mouseX, int mouseY);
2123 void handleKeyDown(uiKeyEventInfo key);
2124 void makeItemVisible(int index);
2125
2126
2127 uiListBoxStyle m_listBoxStyle;
2128 uiListBoxProps m_listBoxProps;
2129 int m_firstVisibleItem; // the item on the top
2130};
2131
2132
2133
2135// uiListBox
2136
2137
2140
2141public:
2142
2152 uiListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2153
2162 StringList & items() { return m_items; }
2163
2164protected:
2165
2166 virtual int items_getCount() { return m_items.count(); }
2167 virtual void items_deselectAll() { m_items.deselectAll(); }
2168 virtual void items_select(int index, bool select) { m_items.select(index, select); }
2169 virtual bool items_selected(int index) { return m_items.selected(index); }
2170 virtual void items_draw(int index, const Rect & itemRect);
2171
2172
2173private:
2174
2175 StringList m_items;
2176};
2177
2178
2180// uiFileBrowser
2181
2184
2185public:
2186
2196 uiFileBrowser(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2197
2205 void setDirectory(char const * path);
2206
2214 void changeDirectory(char const * path);
2215
2221 char const * directory() { return m_dir.directory(); }
2222
2228 int count() { return m_dir.count(); }
2229
2235 char const * filename();
2236
2242 bool isDirectory();
2243
2244 void processEvent(uiEvent * event);
2245
2249 void update();
2250
2256 FileBrowser & content() { return m_dir; }
2257
2258
2259protected:
2260
2261 virtual int items_getCount() { return m_dir.count(); }
2262 virtual void items_deselectAll() { m_selected = -1; }
2263 virtual void items_select(int index, bool select);
2264 virtual bool items_selected(int index) { return index == m_selected; }
2265 virtual void items_draw(int index, const Rect & itemRect);
2266
2267private:
2268
2269 void enterSubDir();
2270
2271 FileBrowser m_dir;
2272 int m_selected; // -1 = no sel
2273
2274};
2275
2276
2278// uiColorListBox
2279
2282
2283public:
2284
2294 uiColorListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2295
2302
2303
2304protected:
2305
2306 virtual int items_getCount() { return 16; }
2307 virtual void items_deselectAll() { }
2308 virtual void items_select(int index, bool select) { if (select) m_selectedColor = (Color)index; }
2309 virtual bool items_selected(int index) { return index == (int)m_selectedColor; }
2310 virtual void items_draw(int index, const Rect & itemRect);
2311
2312
2313private:
2314
2315 Color m_selectedColor;
2316};
2317
2318
2319
2321// uiCustomComboBox
2322
2323
2327 RGB888 buttonColor = RGB888(128, 128, 128);
2329 void adaptToDisplayColors(int displayColors) {
2330 if (displayColors < 16) {
2331 }
2332 }
2333};
2334
2335
2338 uint8_t openOnFocus : 1;
2341 : openOnFocus(true)
2342 {
2343 }
2344};
2345
2346
2349{
2350
2351public:
2352
2363 uiCustomComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible, uint32_t styleClassID);
2364
2366
2367 virtual void processEvent(uiEvent * event);
2368
2374 uiComboBoxStyle & comboBoxStyle() { return m_comboBoxStyle; }
2375
2381 uiListBoxStyle & listBoxStyle() { return listbox()->listBoxStyle(); }
2382
2388 uiComboBoxProps & comboBoxProps() { return m_comboBoxProps; }
2389
2395 int selectedItem() { return listbox()->firstSelectedItem(); }
2396
2402 void selectItem(int index);
2403
2404
2405 // Delegates
2406
2412 Delegate<> onChange;
2413
2414
2415protected:
2416
2417 virtual uiCustomListBox * listbox() = 0;
2418 virtual uiControl * editcontrol() = 0;
2419 virtual void updateEditControl() = 0;
2420
2421 Size getEditControlSize();
2422
2423 virtual void openListBox();
2424 virtual void closeListBox();
2425 void switchListBox();
2426
2427 virtual void paintButton();
2428 Rect getButtonRect();
2429
2430 uiWindow * getListBoxParent() { return m_listBoxParent; }
2431
2432 bool isListBoxOpen() { return m_listBoxParent->state().visible; }
2433
2434private:
2435
2436 int buttonWidth();
2437
2438
2439 int16_t m_listHeight;
2440 int16_t m_loseFocusBy;
2441 uiComboBoxStyle m_comboBoxStyle;
2442 uiComboBoxProps m_comboBoxProps;
2443 uiWindow * m_listBoxParent;
2444};
2445
2446
2447
2448
2450// uiComboBox
2451
2452
2455{
2456
2457public:
2458
2469 uiComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true, uint32_t styleClassID = 0);
2470
2471 ~uiComboBox();
2472
2480 StringList & items() { return m_listBox->items(); }
2481
2487 uiTextEditStyle & textEditStyle() { return m_textEdit->textEditStyle(); }
2488
2494 uiTextEditProps & textEditProps() { return m_textEdit->textEditProps(); }
2495
2503 void setText(char const * value) { m_textEdit->setText(value); }
2504
2510 char const * text() { return m_textEdit->text(); }
2511
2512
2513protected:
2514
2515 uiCustomListBox * listbox() { return m_listBox; }
2516 uiControl * editcontrol() { return m_textEdit; }
2517 void updateEditControl();
2518
2519private:
2520 uiTextEdit * m_textEdit;
2521 uiListBox * m_listBox;
2522
2523};
2524
2525
2526
2528// uiColorComboBox
2529
2530
2533{
2534
2535public:
2536
2547 uiColorComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true, uint32_t styleClassID = 0);
2548
2550
2556 void selectColor(Color value) { selectItem((int)value); }
2557
2564
2565
2566protected:
2567
2568 uiCustomListBox * listbox() { return m_colorListBox; }
2569 uiControl * editcontrol() { return m_colorBox; }
2570 void updateEditControl();
2571
2572private:
2573 uiColorBox * m_colorBox;
2574 uiColorListBox * m_colorListBox;
2575
2576};
2577
2578
2579
2581// uiCheckBox
2582
2583
2586 RGB888 backgroundColor = RGB888(128, 128, 128);
2592 void adaptToDisplayColors(int displayColors) {
2593 if (displayColors < 4) {
2594 } else if (displayColors < 16) {
2595 mouseOverForegroundColor = RGB888(255, 255, 255);
2596 }
2597 }
2598};
2599
2600
2604enum class uiCheckBoxKind : int8_t {
2605 CheckBox,
2606 RadioButton,
2607};
2608
2609
2616class uiCheckBox : public uiControl {
2617
2618public:
2619
2630 uiCheckBox(uiWindow * parent, const Point & pos, const Size & size, uiCheckBoxKind kind = uiCheckBoxKind::CheckBox, bool visible = true, uint32_t styleClassID = 0);
2631
2632 virtual ~uiCheckBox();
2633
2634 virtual void processEvent(uiEvent * event);
2635
2641 uiCheckBoxStyle & checkBoxStyle() { return m_checkBoxStyle; }
2642
2648 bool checked() { return m_checked; }
2649
2657 void setChecked(bool value);
2658
2664 int groupIndex() { return m_groupIndex; }
2665
2671 void setGroupIndex(int value) { m_groupIndex = value; }
2672
2673
2674 // Delegates
2675
2681 Delegate<> onChange;
2682
2688 Delegate<> onClick;
2689
2690
2691private:
2692
2693 void paintCheckBox();
2694 void trigger();
2695 void unCheckGroup();
2696
2697
2698 uiCheckBoxStyle m_checkBoxStyle;
2699 bool m_checked;
2700 uiCheckBoxKind m_kind;
2701 int16_t m_groupIndex; // -1 = no group
2702
2703};
2704
2705
2706
2708// uiSlider
2709
2710
2713 RGB888 backgroundColor = RGB888(255, 255, 255);
2714 RGB888 slideColor = RGB888(0, 128, 128);
2715 RGB888 rangeColor = RGB888(0, 128, 255);
2716 RGB888 gripColor = RGB888(0, 0, 255);
2717 RGB888 ticksColor = RGB888(255, 255, 255);
2720 void adaptToDisplayColors(int displayColors) {
2721 if (displayColors < 4) {
2722 slideColor = RGB888(0, 0, 0);
2723 rangeColor = RGB888(0, 0, 0);
2724 gripColor = RGB888(0, 0, 0);
2725 mouseOverGripColor = RGB888(255, 255, 255);
2726 } else if (displayColors < 16) {
2727 slideColor = RGB888(0, 0, 0);
2728 mouseOverGripColor = RGB888(255, 255, 255);
2729 }
2730 }
2731};
2732
2733
2735class uiSlider : public uiControl {
2736
2737public:
2738
2749 uiSlider(uiWindow * parent, const Point & pos, const Size & size, uiOrientation orientation, bool visible = true, uint32_t styleClassID = 0);
2750
2751 virtual ~uiSlider();
2752
2753 virtual void processEvent(uiEvent * event);
2754
2760 uiSliderStyle & sliderStyle() { return m_sliderStyle; }
2761
2767 int position() { return m_position; }
2768
2774 void setPosition(int value);
2775
2781 int min() { return m_min; }
2782
2788 int max() { return m_max; }
2789
2797 void setup(int min, int max, int ticksFrequency);
2798
2799
2805 Delegate<> onChange;
2806
2807
2808private:
2809
2810 void paintSlider();
2811 Rect getGripRect();
2812 void moveGripTo(int x, int y);
2813 void handleKeyDown(uiKeyEventInfo key);
2814
2815
2816 uiSliderStyle m_sliderStyle;
2817 uiOrientation m_orientation;
2818
2819 int16_t m_position;
2820 int16_t m_min;
2821 int16_t m_max;
2822 int16_t m_ticksFrequency;
2823};
2824
2825
2826
2828// uiProgressBar
2829
2830
2833 RGB888 backgroundColor = RGB888(128, 128, 128);
2835 FontInfo const * textFont = &FONT_std_14;
2836 RGB888 textColor = RGB888(255, 255, 255);
2838 void adaptToDisplayColors(int displayColors) {
2839 if (displayColors < 4) {
2840 foregroundColor = RGB888(0, 0, 0);
2841 } else if (displayColors < 8) {
2842 textColor = RGB888(0, 0, 0);
2843 }
2844 }
2845};
2846
2847
2850 uint8_t showPercentage : 1;
2853 : showPercentage(true)
2854 {
2855 }
2856};
2857
2858
2860class uiProgressBar : public uiControl {
2861
2862public:
2863
2873 uiProgressBar(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2874
2875 virtual ~uiProgressBar();
2876
2877 virtual void processEvent(uiEvent * event);
2878
2884 uiProgressBarStyle & progressBarStyle() { return m_progressBarStyle; }
2885
2891 uiProgressBarProps & progressBarProps() { return m_progressBarProps; }
2892
2898 void setPercentage(int value);
2899
2900
2901private:
2902
2903 void paintProgressBar();
2904
2905
2906 uiProgressBarStyle m_progressBarStyle;
2907 uiProgressBarProps m_progressBarProps;
2908
2909 int m_percentage;
2910};
2911
2912
2913
2915// uiSimpleMenu
2916
2917
2920
2921public:
2922
2932 uiSimpleMenu(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2933
2942 StringList & items() { return m_items; }
2943
2944 virtual void processEvent(uiEvent * event);
2945
2946
2947 // Delegates
2948
2954 Delegate<int> onSelect;
2955
2956protected:
2957
2958 virtual int items_getCount() { return m_items.count(); }
2959 virtual void items_deselectAll() { m_items.deselectAll(); }
2960 virtual void items_select(int index, bool select) { m_items.select(index, select); }
2961 virtual bool items_selected(int index) { return m_items.selected(index); }
2962 virtual void items_draw(int index, const Rect & itemRect);
2963
2964
2965private:
2966
2967 StringList m_items;
2968};
2969
2970
2971
2972
2974// uiSplitButton
2975
2976
2979{
2980
2981public:
2982
2996 uiSplitButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, int listHeight, char const * itemsText, char separator = ';', bool visible = true, uint32_t styleClassID = 0);
2997
2999
3005 StringList & items() { return m_menu->items(); }
3006
3007 void processEvent(uiEvent * event);
3008
3009
3010 // Delegates
3011
3017 Delegate<int> onSelect;
3018
3019
3020protected:
3021
3022 uiCustomListBox * listbox() { return m_menu; }
3023 uiControl * editcontrol() { return m_button; }
3024 void updateEditControl();
3025 virtual void openListBox();
3026 virtual void paintButton();
3027
3028private:
3029 uiButton * m_button;
3030 uiSimpleMenu * m_menu;
3031 int m_selectedItem;
3032
3033};
3034
3035
3036
3038// uiStyle
3039
3040struct uiStyle {
3041 virtual void setStyle(uiObject * object, uint32_t styleClassID) = 0;
3042};
3043
3044
3045
3047// uiApp
3048
3049
3052 uint16_t caretBlinkingTime = 500;
3053 uint16_t doubleClickTime = 250;
3054 bool realtimeReshaping = false;
3055 bool realtimeMoving = false;
3056};
3057
3058
3063 Cancel = 0,
3064 Button1 = 1,
3065 ButtonOK = 1,
3066 Button2 = 2,
3067 Button3 = 3,
3068};
3069
3070
3075 None,
3076 Question,
3077 Info,
3078 Warning,
3079 Error,
3080};
3081
3082
3083struct ModalWindowState {
3084 uiWindow * window;
3085 uiWindow * prevFocusedWindow;
3086 uiWindow * prevActiveWindow;
3087 uiWindow * prevModal;
3088 int modalResult;
3089};
3090
3091
3092typedef pair<uiEvtHandler *, TimerHandle_t> uiTimerAssoc;
3093
3094
3095class Keyboard;
3096class Mouse;
3097
3098
3105class uiApp : public uiEvtHandler {
3106
3107public:
3108
3109 uiApp();
3110
3111 virtual ~uiApp();
3112
3122 int run(BitmappedDisplayController * displayController, Keyboard * keyboard = nullptr, Mouse * mouse = nullptr);
3123
3134 uiApp & runAsync(BitmappedDisplayController * displayController, int taskStack = 3000, Keyboard * keyboard = nullptr, Mouse * mouse = nullptr);
3135
3139 void joinAsyncRun();
3140
3146 void quit(int exitCode);
3147
3155 bool postEvent(uiEvent const * event);
3156
3164 bool insertEvent(uiEvent const * event);
3165
3166 void postDebugMsg(char const * msg);
3167
3168 virtual void processEvent(uiEvent * event);
3169
3175 void processEvents();
3176
3185 uiFrame * rootWindow() { return m_rootWindow; }
3186
3195 uiWindow * activeWindow() { return m_activeWindow; }
3196
3207
3220 uiWindow * focusedWindow() { return m_focusedWindow; }
3221
3233
3244 uiWindow * moveFocus(int delta);
3245
3246 void captureMouse(uiWindow * window);
3247
3255 uiWindow * capturedMouseWindow() { return m_capturedMouseWindow; }
3256
3262 void repaintWindow(uiWindow * window);
3263
3269 void repaintRect(Rect const & rect);
3270
3278 void moveWindow(uiWindow * window, int x, int y);
3279
3287 void resizeWindow(uiWindow * window, int width, int height);
3288
3295 void resizeWindow(uiWindow * window, Size size);
3296
3303 void reshapeWindow(uiWindow * window, Rect const & rect);
3304
3312 uiWindow * screenToWindow(Point & point);
3313
3320 void showWindow(uiWindow * window, bool value);
3321
3333 int showModalWindow(uiWindow * window);
3334
3344 ModalWindowState * initModalWindow(uiWindow * window);
3345
3356 bool processModalWindowEvents(ModalWindowState * state, int timeout);
3357
3368 int endModalWindow(ModalWindowState * state);
3369
3376 void maximizeFrame(uiFrame * frame, bool value);
3377
3384 void minimizeFrame(uiFrame * frame, bool value);
3385
3386 void combineMouseMoveEvents(bool value) { m_combineMouseMoveEvents = value; }
3387
3388 void showCaret(uiWindow * window);
3389
3390 void setCaret(bool value);
3391
3392 void setCaret(Point const & pos);
3393
3394 void setCaret(Rect const & rect);
3395
3407 uiTimerHandle setTimer(uiEvtHandler * dest, int periodMS);
3408
3416 void killTimer(uiTimerHandle handle);
3417
3418 void killEvtHandlerTimers(uiEvtHandler * dest);
3419
3425 uiAppProps & appProps() { return m_appProps; }
3426
3432 void destroyWindow(uiWindow * window);
3433
3434 void cleanWindowReferences(uiWindow * window);
3435
3443 void enableKeyboardAndMouseEvents(bool value);
3444
3457 uiMessageBoxResult messageBox(char const * title, char const * text, char const * button1Text, char const * button2Text = nullptr, char const * button3Text = nullptr, uiMessageBoxIcon icon = uiMessageBoxIcon::Question);
3458
3474 uiMessageBoxResult inputBox(char const * title, char const * text, char * inOutString, int maxLength, char const * button1Text, char const * button2Text = nullptr);
3475
3491 uiMessageBoxResult fileDialog(char const * title, char * inOutDirectory, int maxDirNameSize, char * inOutFilename, int maxFileNameSize, char const * buttonOKText, char const * buttonCancelText, int frameWidth = 200, int frameHeight = 250);
3492
3496 virtual void init();
3497
3503 void setStyle(uiStyle * value) { m_style = value; }
3504
3510 uiStyle * style() { return m_style; }
3511
3512 Keyboard * keyboard() { return m_keyboard; }
3513
3514 Mouse * mouse() { return m_mouse; }
3515
3516 BitmappedDisplayController * displayController() { return m_displayController; }
3517
3518 int displayColors() { return m_displayColors; }
3519
3520 Canvas * canvas() { return m_canvas; }
3521
3527 int lastUserActionTime() { return m_lastUserActionTimeMS; }
3528
3529
3530 // delegates
3531
3538 Delegate<uiTimerHandle> onTimer;
3539
3540
3541protected:
3542
3543 bool getEvent(uiEvent * event, int timeOutMS);
3544 bool peekEvent(uiEvent * event, int timeOutMS);
3545
3546
3547private:
3548
3549 void preprocessEvent(uiEvent * event);
3550 void preprocessMouseEvent(uiEvent * event);
3551 void preprocessKeyboardEvent(uiEvent * event);
3552 void filterModalEvent(uiEvent * event);
3553
3554 static void timerFunc(TimerHandle_t xTimer);
3555
3556 static void asyncRunTask(void * arg);
3557
3558 void blinkCaret(bool forceOFF = false);
3559 void suspendCaret(bool value);
3560
3561
3562 BitmappedDisplayController * m_displayController;
3563
3564 int m_displayColors;
3565
3566 Canvas * m_canvas;
3567
3568 Keyboard * m_keyboard;
3569
3570 Mouse * m_mouse;
3571
3572 uiAppProps m_appProps;
3573
3574 QueueHandle_t m_eventsQueue;
3575
3576 uiFrame * m_rootWindow;
3577
3578 uiWindow * m_activeWindow; // foreground window. Also gets keyboard events (other than focused window)
3579
3580 uiWindow * m_focusedWindow; // window that captures keyboard events (other than active window)
3581
3582 uiWindow * m_lastFocusedWindow; // previous focused window
3583
3584 uiWindow * m_capturedMouseWindow; // window that has captured mouse
3585
3586 uiWindow * m_freeMouseWindow; // window where mouse is over
3587
3588 uiWindow * m_modalWindow; // current modal window
3589
3590 bool m_combineMouseMoveEvents;
3591
3592 uiEvtHandler * m_keyDownHandler; // used to produce UIEVT_KEYTYPE
3593
3594 uiWindow * m_caretWindow; // nullptr = caret is not visible
3595 Rect m_caretRect; // caret rect relative to m_caretWindow
3596 uiTimerHandle m_caretTimer;
3597 int m_caretInvertState; // -1 = suspended, 1 = rect reversed (cat visible), 0 = rect not reversed (caret invisible)
3598
3599 int m_lastMouseUpTimeMS; // time (MS) at mouse up. Used to measure double clicks
3600 Point m_lastMouseUpPos; // screen position of last mouse up
3601
3602 uiStyle * m_style;
3603
3604 int m_lastUserActionTimeMS; // time when last user action (mouse/keyboard) has been received, measured in milliseconds since boot
3605
3606 // associates event handler with FreeRTOS timer
3607 list<uiTimerAssoc> m_timers;
3608
3609 // used to wait for asyncRunTask to terminate
3610 SemaphoreHandle_t m_asyncRunWait;
3611};
3612
3613
3614
3615
3616} // end of namespace
3617
3618
3619// get out of namespace frequently used names
3620using fabgl::uiObject;
3622using fabgl::uiTimerHandle;
3623using fabgl::uiTextEdit;
3624using fabgl::uiApp;
3625using fabgl::uiFrame;
3626using fabgl::uiButton;
3627using fabgl::uiLabel;
3629using fabgl::uiImage;
3630using fabgl::uiPanel;
3632using fabgl::uiPaintBox;
3634using fabgl::uiListBox;
3635using fabgl::uiComboBox;
3636using fabgl::uiCheckBox;
3638using fabgl::uiSlider;
3639using fabgl::uiStyle;
3646using fabgl::uiHAlign;
3655using fabgl::uiColorBox;
3664
3665
3666
3667
This file contains fabgl::Canvas definition.
Represents the base abstract class for bitmapped display controllers.
A class with a set of drawing methods.
Definition: canvas.h:70
int count()
Determines number of files in current directory.
Definition: fabutils.h:598
char const * directory()
Determines absolute path of current directory.
Definition: fabutils.h:591
FileBrowser allows basic file system operations (dir, mkdir, remove and rename)
Definition: fabutils.h:554
The PS2 Keyboard controller class.
Definition: keyboard.h:77
The PS2 Mouse controller class.
Definition: mouse.h:111
void killTimer(uiTimerHandle handle)
Kills a timer.
Definition: fabui.cpp:945
virtual void init()
Method to inherit to implement an application.
Definition: fabui.cpp:604
int run(BitmappedDisplayController *displayController, Keyboard *keyboard=nullptr, Mouse *mouse=nullptr)
Initializes application and executes the main event loop.
Definition: fabui.cpp:238
void resizeWindow(uiWindow *window, int width, int height)
Resizes a window.
Definition: fabui.cpp:808
bool postEvent(uiEvent const *event)
Places an event in the event queue and returns without waiting for the receiver to process the event.
Definition: fabui.cpp:609
void destroyWindow(uiWindow *window)
Destroys a window.
Definition: fabui.cpp:1042
uiWindow * screenToWindow(Point &point)
Determines which window a point belongs to.
Definition: fabui.cpp:585
uiWindow * capturedMouseWindow()
Determines which window is capturing mouse.
Definition: fabui.h:3255
int showModalWindow(uiWindow *window)
Makes a window visible and handles it has a modal window.
Definition: fabui.cpp:903
uiWindow * moveFocus(int delta)
Move focus to a control with current focus index plus a delta.
Definition: fabui.cpp:760
void showWindow(uiWindow *window, bool value)
Makes a window visible or invisible.
Definition: fabui.cpp:829
uiMessageBoxResult messageBox(char const *title, char const *text, char const *button1Text, char const *button2Text=nullptr, char const *button3Text=nullptr, uiMessageBoxIcon icon=uiMessageBoxIcon::Question)
Displays a modal dialog box with an icon, text and some buttons.
Definition: fabui.cpp:1081
void repaintRect(Rect const &rect)
Repaints a screen area.
Definition: fabui.cpp:793
uiMessageBoxResult inputBox(char const *title, char const *text, char *inOutString, int maxLength, char const *button1Text, char const *button2Text=nullptr)
Displays a modal dialog box with a text, a text edit and up to two buttons.
Definition: fabui.cpp:1180
int endModalWindow(ModalWindowState *state)
Ends modal window processing.
Definition: fabui.cpp:891
uiWindow * setFocusedWindow(uiWindow *value)
Sets the focused window (control)
Definition: fabui.cpp:705
void enableKeyboardAndMouseEvents(bool value)
Enables or disables mouse and keyboard events.
Definition: fabui.cpp:1345
void quit(int exitCode)
Terminates application and free resources.
Definition: fabui.cpp:398
ModalWindowState * initModalWindow(uiWindow *window)
Begins modal window processing.
Definition: fabui.cpp:837
uiWindow * activeWindow()
Gets a pointer to the currently active window.
Definition: fabui.h:3195
uiTimerHandle setTimer(uiEvtHandler *dest, int periodMS)
Setups a timer.
Definition: fabui.cpp:936
int lastUserActionTime()
Returns time when last user action (mouse/keyboard) has been received, measured in milliseconds since...
Definition: fabui.h:3527
uiAppProps & appProps()
Sets or gets application properties.
Definition: fabui.h:3425
uiMessageBoxResult fileDialog(char const *title, char *inOutDirectory, int maxDirNameSize, char *inOutFilename, int maxFileNameSize, char const *buttonOKText, char const *buttonCancelText, int frameWidth=200, int frameHeight=250)
Displays a modal open/save dialog box.
Definition: fabui.cpp:1269
uiStyle * style()
Gets current application controls style.
Definition: fabui.h:3510
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:3538
void joinAsyncRun()
Waits for runAsync termination.
Definition: fabui.cpp:371
uiFrame * rootWindow()
Gets a pointer to the root window.
Definition: fabui.h:3185
void setStyle(uiStyle *value)
Sets application controls style.
Definition: fabui.h:3503
void repaintWindow(uiWindow *window)
Repaints a window.
Definition: fabui.cpp:787
uiWindow * setActiveWindow(uiWindow *value)
Sets the active window.
Definition: fabui.cpp:662
void processEvents()
Processes all events in queue.
Definition: fabui.cpp:380
void minimizeFrame(uiFrame *frame, bool value)
Minimizes or restores a frame.
Definition: fabui.cpp:919
uiWindow * focusedWindow()
Gets the focused window (control)
Definition: fabui.h:3220
void reshapeWindow(uiWindow *window, Rect const &rect)
Reshapes a window.
Definition: fabui.cpp:821
void moveWindow(uiWindow *window, int x, int y)
Moves a window.
Definition: fabui.cpp:802
uiApp & runAsync(BitmappedDisplayController *displayController, int taskStack=3000, Keyboard *keyboard=nullptr, Mouse *mouse=nullptr)
Initializes application and executes asynchronously the main event loop.
Definition: fabui.cpp:355
bool insertEvent(uiEvent const *event)
Inserts (first position) an event in the event queue and returns without waiting for the receiver to ...
Definition: fabui.cpp:615
void maximizeFrame(uiFrame *frame, bool value)
Maximizes or restores a frame.
Definition: fabui.cpp:912
bool processModalWindowEvents(ModalWindowState *state, int timeout)
Processes all messages from modal window.
Definition: fabui.cpp:855
Represents the whole application base class.
Definition: fabui.h:3105
char const * text()
Determines button text.
Definition: fabui.h:1292
uiButton(uiWindow *parent, char const *text, const Point &pos, const Size &size, uiButtonKind kind=uiButtonKind::Button, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:2533
Delegate onChange
Button changed event delegate.
Definition: fabui.h:1327
Delegate< uiMouseEventInfo const & > onMouseUp
Mouse up event delegate.
Definition: fabui.h:1348
Delegate< uiMouseEventInfo const & > onMouseDown
Mouse down event delegate.
Definition: fabui.h:1341
void setDown(bool value)
Sets button state of a switch button.
Definition: fabui.cpp:2675
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:1334
bool down()
Determines whether the switch button is down or up.
Definition: fabui.h:1308
void setText(char const *value)
Sets button text.
Definition: fabui.cpp:2564
uiButtonStyle & buttonStyle()
Sets or gets button style.
Definition: fabui.h:1299
Represents a button control. A button can have text and optionally a bitmap.
Definition: fabui.h:1257
void setChecked(bool value)
Sets current checkbox or radiobutton checked status.
Definition: fabui.cpp:4880
bool checked()
Determines whether the checkbox or radiobutton is checked.
Definition: fabui.h:2648
Delegate onChange
Change event delegate.
Definition: fabui.h:2681
void setGroupIndex(int value)
Sets radiobutton group index.
Definition: fabui.h:2671
uiCheckBox(uiWindow *parent, const Point &pos, const Size &size, uiCheckBoxKind kind=uiCheckBoxKind::CheckBox, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4767
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:2688
uiCheckBoxStyle & checkBoxStyle()
Sets or gets checkbox style.
Definition: fabui.h:2641
int groupIndex()
Determines radiobutton group index.
Definition: fabui.h:2664
Represents a checkbox or a radiobutton.
Definition: fabui.h:2616
Color color()
Gets current colorbox color.
Definition: fabui.h:1943
void setColor(Color value)
Sets current colorbox color.
Definition: fabui.cpp:3586
uiColorBox(uiWindow *parent, const Point &pos, const Size &size, Color color=Color::BrightWhite, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3566
A color box is a control that shows a single color.
Definition: fabui.h:1918
uiColorComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4731
void selectColor(Color value)
Sets current selected color.
Definition: fabui.h:2556
Color selectedColor()
Determines current selected color.
Definition: fabui.h:2563
This is a combination of a color listbox and a colorbox.
Definition: fabui.h:2533
Color color()
Currently selected color.
uiColorListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4315
Shows a list of 16 colors, one selectable.
Definition: fabui.h:2281
StringList & items()
A list of strings representing items of the combobox.
Definition: fabui.h:2480
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:2487
char const * text()
Gets current content of the text edit.
Definition: fabui.h:2510
uiComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4690
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:2494
void setText(char const *value)
Replaces current text.
Definition: fabui.h:2503
This is a combination of a listbox and a single-line editable textbox.
Definition: fabui.h:2455
uiControl(uiWindow *parent, const Point &pos, const Size &size, bool visible, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:2501
This is the base class for all controls. A control can have focus and is not activable.
Definition: fabui.h:995
uiComboBoxProps & comboBoxProps()
Sets or gets combobox properties.
Definition: fabui.h:2388
Delegate onChange
Change event delegate.
Definition: fabui.h:2412
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:2381
uiComboBoxStyle & comboBoxStyle()
Sets or gets combobox style.
Definition: fabui.h:2374
uiCustomComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible, uint32_t styleClassID)
Creates an instance of the object.
Definition: fabui.cpp:4467
int selectedItem()
Represents currently selected item.
Definition: fabui.h:2395
void selectItem(int index)
Selects an item.
Definition: fabui.cpp:4498
This is a combination of a listbox and another component, base of all combobox components.
Definition: fabui.h:2349
uiCustomListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3979
int firstSelectedItem()
Gets the first selected item.
Definition: fabui.cpp:4196
Delegate onKillFocus
Kill focus event delegate.
Definition: fabui.h:2077
void deselectAll()
Deselects all selected items.
Definition: fabui.cpp:4138
int lastSelectedItem()
Gets the last selected item.
Definition: fabui.cpp:4206
Delegate onChange
Change event delegate.
Definition: fabui.h:2072
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:2027
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:2094
Delegate< uiKeyEventInfo const & > onKeyUp
Key-up event delegate.
Definition: fabui.h:2087
uiListBoxProps & listBoxProps()
Sets or gets list box properties.
Definition: fabui.h:2034
void selectItem(int index, bool add=false, bool range=false)
Selects a listbox item.
Definition: fabui.cpp:4098
Delegate< uiKeyEventInfo const & > onKeyType
Key-type event delegate.
Definition: fabui.h:2082
Delegate onDblClick
Mouse double click event delegate.
Definition: fabui.h:2102
void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:4215
Shows generic a list of selectable items.
Definition: fabui.h:2003
uiApp * app()
Determines the app that owns this object.
Definition: fabui.h:320
Base class of all UI elements that can receive events.
Definition: fabui.h:305
FileBrowser & content()
Contains current directory representation.
Definition: fabui.h:2256
void changeDirectory(char const *path)
Changes current directory as relative path.
Definition: fabui.cpp:4386
void setDirectory(char const *path)
Sets current directory as absolute path.
Definition: fabui.cpp:4378
char const * filename()
Currently selected filename.
Definition: fabui.cpp:4394
int count()
Determines number of files in current directory.
Definition: fabui.h:2228
bool isDirectory()
Determines whether currently selected item is a directory.
Definition: fabui.cpp:4400
void update()
Reloads current directory content and repaints.
Definition: fabui.cpp:4420
char const * directory()
Determines current directory.
Definition: fabui.h:2221
uiFileBrowser(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4345
Shows and navigates Virtual Filesystem content.
Definition: fabui.h:2183
void setTitle(char const *value)
Sets window title.
Definition: fabui.cpp:1941
Delegate onHide
Hide window event delegate.
Definition: fabui.h:908
uiFrame(uiWindow *parent, char const *title, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:1911
Delegate onShow
Show window event delegate.
Definition: fabui.h:901
uiFrameProps & frameProps()
Sets or gets frame properties.
Definition: fabui.h:877
Delegate onPaint
Paint event delegate.
Definition: fabui.h:938
Delegate< uiKeyEventInfo const & > onKeyDown
Key-down event delegate.
Definition: fabui.h:928
void setTitleFmt(const char *format,...)
Sets window title as formatted text.
Definition: fabui.cpp:1955
Delegate< uiKeyEventInfo const & > onKeyUp
Key-up event delegate.
Definition: fabui.h:933
Delegate onResize
Resize window event delegate.
Definition: fabui.h:915
uiFrameStyle & frameStyle()
Sets or gets frame style.
Definition: fabui.h:870
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:923
uiFrameState frameState()
Determines the frame state.
Definition: fabui.h:890
char const * title()
Determines the window title.
Definition: fabui.h:845
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1985
A frame is a window with a title bar, maximize/minimize/close buttons and that is resizeable or movea...
Definition: fabui.h:820
Bitmap const * bitmap()
Gets image bitmap.
Definition: fabui.h:1772
uiImageStyle & imageStyle()
Sets or gets image style.
Definition: fabui.h:1779
void setBitmap(Bitmap const *bitmap)
Sets image bitmap.
Definition: fabui.cpp:3401
uiImage(uiWindow *parent, Bitmap const *bitmap, const Point &pos, const Size &size=Size(0, 0), bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3375
Image control to display a static bitmap.
Definition: fabui.h:1738
char const * text()
Determines label text.
Definition: fabui.h:1603
void setTextFmt(const char *format,...)
Sets label formatted text.
Definition: fabui.cpp:3220
uiLabel(uiWindow *parent, char const *text, const Point &pos, const Size &size=Size(0, 0), bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3184
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:1624
void update()
Updates the label content.
Definition: fabui.cpp:3236
void setText(char const *value)
Sets label text.
Definition: fabui.cpp:3211
uiLabelStyle & labelStyle()
Sets or gets label style.
Definition: fabui.h:1610
A label is a static text UI element.
Definition: fabui.h:1560
StringList & items()
A list of strings representing the listbox content.
Definition: fabui.h:2162
uiListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4288
Shows a list of selectable string items.
Definition: fabui.h:2139
uiObjectType & objectType()
Determines the object type.
Definition: fabui.h:292
Base class of all UI elements like windows and controls.
Definition: fabui.h:279
Delegate< Rect const & > onPaint
Paint event delegate.
Definition: fabui.h:1901
uiPaintBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3506
uiPaintBoxStyle & paintBoxStyle()
Sets or gets paintbox style.
Definition: fabui.h:1890
A paintbox control allows applications to perform custom drawings providing uiPaintBox....
Definition: fabui.h:1866
uiPanelStyle & panelStyle()
Sets or gets panel style.
Definition: fabui.h:1837
uiPanel(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3449
A panel is used to contain and to group some controls.
Definition: fabui.h:1813
void setPercentage(int value)
Sets percentage.
Definition: fabui.cpp:5211
uiProgressBarStyle & progressBarStyle()
Sets or gets progress bar style.
Definition: fabui.h:2884
uiProgressBarProps & progressBarProps()
Sets or gets progress bar properties.
Definition: fabui.h:2891
uiProgressBar(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:5144
A progress bar shows progress percentage using a colored bar.
Definition: fabui.h:2860
uiScrollableControlStyle & scrollableControlStyle()
Sets or gets control style.
Definition: fabui.h:1083
int VScrollBarRange()
Determines vertical scrollbar range.
Definition: fabui.h:1141
uiScrollableControl(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3628
virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar=true)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3660
Delegate onChangeHScrollBar
Horizontal scrollbar change event delegate.
Definition: fabui.h:1149
int HScrollBarRange()
Determines horizontal scrollbar range.
Definition: fabui.h:1112
int VScrollBarVisible()
Determines vertical scrollbar visible portion (aka thumb size) of the scrollable content.
Definition: fabui.h:1131
int HScrollBarPos()
Determines position of the horizontal scrollbar thumb.
Definition: fabui.h:1093
int HScrollBarVisible()
Determines horizontal scrollbar visible portion (aka thumb size) of the scrollable content.
Definition: fabui.h:1102
int VScrollBarPos()
Determines position of the vertical scrollbar thumb.
Definition: fabui.h:1122
Delegate onChangeVScrollBar
Vertical scrollbar change event delegate.
Definition: fabui.h:1154
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:3960
A scrollable control is a control with optionally vertical and/or horizontal scrollbars.
Definition: fabui.h:1057
StringList & items()
A list of strings representing the simplemenu content.
Definition: fabui.h:2942
Delegate< int > onSelect
Item select event.
Definition: fabui.h:2954
uiSimpleMenu(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:5230
Shows a list of selectable string items. Selection is done clicking or pressing ENTER or SPACE key.
Definition: fabui.h:2919
void setup(int min, int max, int ticksFrequency)
Sets minimum, maximum position and ticks frequency.
Definition: fabui.cpp:4954
void setPosition(int value)
Sets the slider position.
Definition: fabui.cpp:4944
uiSliderStyle & sliderStyle()
Sets or gets slider style.
Definition: fabui.h:2760
Delegate onChange
Slider changed event delegate.
Definition: fabui.h:2805
uiSlider(uiWindow *parent, const Point &pos, const Size &size, uiOrientation orientation, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4916
int max()
Gets maximum position.
Definition: fabui.h:2788
int position()
Determines slider position.
Definition: fabui.h:2767
int min()
Gets minimum position.
Definition: fabui.h:2781
A slider or track bar is a graphical control element with which a user may set a value by moving an i...
Definition: fabui.h:2735
StringList & items()
A list of strings representing the menu content.
Definition: fabui.h:3005
Delegate< int > onSelect
Item select event.
Definition: fabui.h:3017
uiSplitButton(uiWindow *parent, char const *text, const Point &pos, const Size &size, int listHeight, char const *itemsText, char separator=';', bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:5291
This is a combination of a button and a simple menu.
Definition: fabui.h:2979
char const * text()
Determines label text.
Definition: fabui.h:1692
uiStaticLabelStyle & labelStyle()
Sets or gets label style.
Definition: fabui.h:1699
uiStaticLabel(uiWindow *parent, char const *text, const Point &pos, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3300
void update()
Updates the label content.
Definition: fabui.cpp:3326
void setText(char const *value)
Sets label text.
Definition: fabui.cpp:3319
A staticlabel is a light version of uiLabel (text must be static). uiStaticLabel has lower memory foo...
Definition: fabui.h:1660
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:1443
char const * text()
Gets current content of the text edit.
Definition: fabui.h:1475
Delegate onChange
Text edit event delegate.
Definition: fabui.h:1483
void setTextFmt(const char *format,...)
Replaces current text.
Definition: fabui.cpp:2742
uiTextEdit(uiWindow *parent, char const *text, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:2695
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:1450
Delegate< uiKeyEventInfo const & > onKeyType
Key-type event delegate.
Definition: fabui.h:1488
void setText(char const *value)
Replaces current text.
Definition: fabui.cpp:2729
Represents a text edit control.
Definition: fabui.h:1418
uiWindow * prev()
Gets previous sibling.
Definition: fabui.h:442
uiAnchors & anchors()
Allows to switch on or off anchors.
Definition: fabui.h:627
bool hasChildren()
Determines whether this window has children.
Definition: fabui.h:463
uiWindow * firstChild()
Gets first child.
Definition: fabui.h:449
bool isMouseOver()
Determines whether the mouse is over this window.
Definition: fabui.h:595
void bringOnTop()
Brings this window on top.
Definition: fabui.cpp:1519
void exitModal(int modalResult)
Exits from a modal window.
Definition: fabui.cpp:1846
Rect transformRect(Rect const &rect, uiWindow *baseWindow)
Transforms rectangle origins from current window to another one.
Definition: fabui.cpp:1542
void setStyleClassID(uint16_t value)
Sets style class for this UI element.
Definition: fabui.h:652
uiWindow * parentFrame()
Determines the parent frame.
Definition: fabui.cpp:1893
Point pos()
Determines the window position relative to parent window.
Definition: fabui.h:484
Rect rect(uiOrigin origin)
Determines the window bounding box.
Definition: fabui.cpp:1564
uiWindow * next()
Gets next sibling.
Definition: fabui.h:433
void setFocusIndex(int value)
Sets the focus index (aka tab-index)
Definition: fabui.h:634
uiWindow * lastChild()
Gets last child.
Definition: fabui.h:456
uint16_t styleClassID()
Determines current style class for this UI element.
Definition: fabui.h:659
void setParentProcessKbdEvents(bool value)
Enables a child window to send keyboard events to its parent.
Definition: fabui.h:668
Size size()
Determines the window size.
Definition: fabui.h:500
uiWindowProps & windowProps()
Sets or gets window properties.
Definition: fabui.h:543
uiWindowStyle & windowStyle()
Sets or gets window style.
Definition: fabui.h:550
int focusIndex()
Determines the focus index (aka tab-index)
Definition: fabui.h:643
Size clientSize()
Determines the client area size.
Definition: fabui.cpp:1587
bool isActiveWindow()
Determines wheter this window is the active window.
Definition: fabui.cpp:1854
void repaint()
Repaints this window.
Definition: fabui.cpp:1558
void bringAfter(uiWindow *insertionPoint)
Brings this window after another one.
Definition: fabui.cpp:1525
bool hasFocus()
Determines whether this window or control has focus.
Definition: fabui.cpp:1860
uiWindow * parent()
Determines the parent window.
Definition: fabui.h:557
uiWindow(uiWindow *parent, const Point &pos, const Size &size, bool visible, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:1374
Point clientPos()
Determines position of the client area.
Definition: fabui.cpp:1593
uiWindowState state()
Determines the window state.
Definition: fabui.h:536
virtual Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1580
Base class for all visible UI elements (Frames and Controls)
Definition: fabui.h:405
This file contains codepages declarations.
uint8_t width
int16_t X
int16_t Y
uint8_t height
This file contains fabgl::BitmappedDisplayController definition.
This file contains FabGL library configuration settings, like number of supported colors,...
This file contains some utility classes and functions.
uiButtonKind
Specifies the button kind.
Definition: fabui.h:1250
uiMessageBoxResult
Return values from uiApp.messageBox() method.
Definition: fabui.h:3062
uiHAlign
Text horizontal alignment.
Definition: fabui.h:229
uiOrientation
Item direction/orientation.
Definition: fabui.h:220
uiMessageBoxIcon
Icon displayed by the uiApp.messageBox() method.
Definition: fabui.h:3074
Color
This enum defines named colors.
CursorName
This enum defines a set of predefined mouse cursors.
@ CursorPointerSimpleReduced
uiCheckBoxKind
Specifies the combobox behaviour.
Definition: fabui.h:2604
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:1097
uiOrigin
Specifies window rectangle origin.
Definition: fabui.h:341
Represents an image.
Describes mouse absolute position, scroll wheel delta and buttons status.
Definition: fabutils.h:299
Represents the coordinate of a point.
Definition: fabutils.h:213
Represents a 24 bit RGB color.
Represents a rectangle.
Definition: fabutils.h:248
Represents a bidimensional size.
Definition: fabutils.h:231
uint8_t top
Definition: fabui.h:393
uint8_t right
Definition: fabui.h:394
uint8_t left
Definition: fabui.h:392
uint8_t bottom
Definition: fabui.h:395
Contains anchors enable/disable switches.
Definition: fabui.h:391
bool realtimeMoving
Definition: fabui.h:3055
bool realtimeReshaping
Definition: fabui.h:3054
uint16_t doubleClickTime
Definition: fabui.h:3053
uint16_t caretBlinkingTime
Definition: fabui.h:3052
Properties of the application.
Definition: fabui.h:3051
RGB888 mouseDownBackgroundColor
Definition: fabui.h:1219
FontInfo const * textFont
Definition: fabui.h:1223
RGB888 downTextColor
Definition: fabui.h:1222
RGB888 mouseOverTextColor
Definition: fabui.h:1220
Bitmap const * downBitmap
Definition: fabui.h:1226
Bitmap const * bitmap
Definition: fabui.h:1225
uint8_t bitmapTextSpace
Definition: fabui.h:1224
RGB888 mouseOverBackgroundColor
Definition: fabui.h:1218
RGB888 downBackgroundColor
Definition: fabui.h:1217
RGB888 backgroundColor
Definition: fabui.h:1216
Contains the button style.
Definition: fabui.h:1215
RGB888 mouseOverForegroundColor
Definition: fabui.h:2589
RGB888 foregroundColor
Definition: fabui.h:2590
RGB888 checkedBackgroundColor
Definition: fabui.h:2587
RGB888 mouseOverBackgroundColor
Definition: fabui.h:2588
RGB888 backgroundColor
Definition: fabui.h:2586
Contains the checkbox style.
Definition: fabui.h:2585
Properties of the combobox.
Definition: fabui.h:2337
RGB888 buttonBackgroundColor
Definition: fabui.h:2326
Contains the listbox style.
Definition: fabui.h:2325
uint8_t fillBackground
Definition: fabui.h:775
uint8_t moveable
Definition: fabui.h:771
uint8_t hasMaximizeButton
Definition: fabui.h:773
uint8_t resizeable
Definition: fabui.h:770
uint8_t hasCloseButton
Definition: fabui.h:772
uint8_t hasMinimizeButton
Definition: fabui.h:774
Properties of the frame.
Definition: fabui.h:769
uint8_t minimized
Definition: fabui.h:791
uint8_t maximized
Definition: fabui.h:790
Specifies current frame state.
Definition: fabui.h:789
RGB888 buttonColor
Definition: fabui.h:741
RGB888 mouseOverButtonColor
Definition: fabui.h:744
RGB888 activeTitleBackgroundColor
Definition: fabui.h:737
RGB888 activeTitleColor
Definition: fabui.h:739
RGB888 mouseOverBackgroundButtonColor
Definition: fabui.h:743
FontInfo const * titleFont
Definition: fabui.h:740
RGB888 titleColor
Definition: fabui.h:738
RGB888 activeButtonColor
Definition: fabui.h:742
RGB888 backgroundColor
Definition: fabui.h:735
RGB888 titleBackgroundColor
Definition: fabui.h:736
RGB888 backgroundColor
Definition: fabui.h:1728
Contains the image style.
Definition: fabui.h:1727
VirtualKey VK
Definition: fabui.h:158
Contains details about the key event.
Definition: fabui.h:157
FontInfo const * textFont
Definition: fabui.h:1547
RGB888 textColor
Definition: fabui.h:1549
uiHAlign textAlign
Definition: fabui.h:1550
RGB888 backgroundColor
Definition: fabui.h:1548
Contains the label style.
Definition: fabui.h:1546
uint8_t selectOnMouseOver
Definition: fabui.h:1992
uint8_t allowMultiSelect
Definition: fabui.h:1991
Properties of the list box.
Definition: fabui.h:1990
FontInfo const * textFont
Definition: fabui.h:1973
RGB888 selectedTextColor
Definition: fabui.h:1975
RGB888 selectedBackgroundColor
Definition: fabui.h:1970
RGB888 focusedSelectedBackgroundColor
Definition: fabui.h:1971
RGB888 backgroundColor
Definition: fabui.h:1968
RGB888 focusedBackgroundColor
Definition: fabui.h:1969
Contains the listbox style.
Definition: fabui.h:1967
uint8_t changedButton
Definition: fabui.h:171
MouseStatus status
Definition: fabui.h:170
Contains details about the mouse event.
Definition: fabui.h:169
Specifies the object type.
Definition: fabui.h:242
RGB888 backgroundColor
Definition: fabui.h:1856
Contains the paintbox style.
Definition: fabui.h:1855
RGB888 backgroundColor
Definition: fabui.h:1803
Contains the panel style.
Definition: fabui.h:1802
Properties of the progress bar.
Definition: fabui.h:2849
FontInfo const * textFont
Definition: fabui.h:2835
Contains the progress bar style.
Definition: fabui.h:2832
RGB888 mouseOverScrollBarForegroundColor
Definition: fabui.h:1025
Contains the scrollable control style.
Definition: fabui.h:1022
RGB888 mouseOverGripColor
Definition: fabui.h:2718
RGB888 backgroundColor
Definition: fabui.h:2713
Contains the slider style.
Definition: fabui.h:2712
FontInfo const * textFont
Definition: fabui.h:1648
Contains the label style.
Definition: fabui.h:1647
uint8_t passwordMode
Definition: fabui.h:1402
Properties of the text edit.
Definition: fabui.h:1399
FontInfo const * textFont
Definition: fabui.h:1387
RGB888 mouseOverBackgroundColor
Definition: fabui.h:1384
RGB888 backgroundColor
Definition: fabui.h:1383
RGB888 focusedBackgroundColor
Definition: fabui.h:1385
Sets or gets text edit style.
Definition: fabui.h:1382
uint8_t activeLook
Definition: fabui.h:359
uint8_t activable
Definition: fabui.h:357
uint8_t focusable
Definition: fabui.h:358
Contains some window options.
Definition: fabui.h:356
uint8_t active
Definition: fabui.h:351
uint8_t visible
Definition: fabui.h:350
Specifies current window state.
Definition: fabui.h:349
CursorName defaultCursor
Definition: fabui.h:371
RGB888 borderColor
Definition: fabui.h:372
uint8_t borderSize
Definition: fabui.h:375
RGB888 activeBorderColor
Definition: fabui.h:373
RGB888 focusedBorderColor
Definition: fabui.h:374
uint8_t focusedBorderSize
Definition: fabui.h:376
Contains the window style.
Definition: fabui.h:370