FabGL
ESP32 VGA 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 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6  This file is part of FabGL Library.
7 
8  FabGL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  FabGL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #pragma once
24 
25 
34 #include <stdint.h>
35 #include <stddef.h>
36 
37 #include "freertos/FreeRTOS.h"
38 #include "freertos/queue.h"
39 
40 #include "fabglconf.h"
41 #include "fabutils.h"
42 #include "vgacontroller.h"
43 #include "canvas.h"
44 
45 
46 
47 /*
48 
49  *uiObject
50  *uiEvtHandler
51  *uiApp
52  *uiWindow
53  *uiFrame
54  *uiControl
55  *uiButton
56  *uiLabel
57  *uiImage
58  *uiPanel
59  *uiTextEdit
60  *uiScrollableControl
61  *uiPaintBox
62  *uiListBox
63  uiMemoEdit
64  *uiCheckBox
65  *uiComboBox
66  uiMenu
67  uiGauge
68  uiSlider
69  uiSpinButton
70 
71 */
72 
73 
74 namespace fabgl {
75 
76 
77 
78 // increase in case of garbage between windows!
79 #define FABGLIB_UI_EVENTS_QUEUE_SIZE 64
80 
81 
82 
84 // uiEvent
85 
86 enum uiEventID {
87  UIEVT_NULL,
88  UIEVT_DEBUGMSG,
89  UIEVT_APPINIT,
90  UIEVT_GENPAINTEVENTS,
91  UIEVT_PAINT,
92  UIEVT_ACTIVATE,
93  UIEVT_DEACTIVATE,
94  UIEVT_MOUSEMOVE,
95  UIEVT_MOUSEWHEEL,
96  UIEVT_MOUSEBUTTONDOWN,
97  UIEVT_MOUSEBUTTONUP,
98  UIEVT_SETPOS,
99  UIEVT_SETSIZE,
100  UIEVT_RESHAPEWINDOW,
101  UIEVT_MOUSEENTER,
102  UIEVT_MOUSELEAVE,
103  UIEVT_MAXIMIZE, // Request for maximize
104  UIEVT_MINIMIZE, // Request for minimize
105  UIEVT_RESTORE, // restore from UIEVT_MAXIMIZE or UIEVT_MINIMIZE
106  UIEVT_SHOW,
107  UIEVT_HIDE,
108  UIEVT_SETFOCUS,
109  UIEVT_KILLFOCUS,
110  UIEVT_KEYDOWN,
111  UIEVT_KEYUP,
112  UIEVT_TIMER,
113  UIEVT_CLICK,
114  UIEVT_DBLCLICK,
115  UIEVT_EXITMODAL,
116  UIEVT_DESTROY,
117  UIEVT_CLOSE, // Request to close (frame Close button)
118 };
119 
120 
121 class uiEvtHandler;
122 class uiApp;
123 class uiWindow;
124 
125 
126 typedef void * uiTimerHandle;
127 
128 
132  uint8_t LALT : 1;
133  uint8_t RALT : 1;
134  uint8_t CTRL : 1;
135  uint8_t SHIFT : 1;
136  uint8_t GUI : 1;
137 };
138 
139 
143  uint8_t changedButton;
144 };
145 
146 
147 struct uiEvent {
148  uiEvtHandler * dest;
149  uiEventID id;
150 
151  union uiEventParams {
152  // event: UIEVT_MOUSEMOVE, UIEVT_MOUSEWHEEL, UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP, UIEVT_CLICK, UIEVT_DBLCLICK
153  uiMouseEventInfo mouse;
154  // event: UIEVT_PAINT, UIEVT_GENPAINTEVENTS, UIEVT_RESHAPEWINDOW
155  Rect rect;
156  // event: UIEVT_SETPOS
157  Point pos;
158  // event: UIEVT_SETSIZE
159  Size size;
160  // event: UIEVT_DEBUGMSG
161  char const * debugMsg;
162  // event: UIEVT_KEYDOWN, UIEVT_KEYUP
163  uiKeyEventInfo key;
164  // event: UIEVT_TIMER
165  uiTimerHandle timerHandle;
166  // event: UIEVT_EXITMODAL
167  int modalResult;
168  // event: UIEVT_SETFOCUS
169  uiWindow * oldFocused;
170  // event: UIEVT_KILLFOCUS
171  uiWindow * newFocused;
172 
173  uiEventParams() { }
174  } params;
175 
176  uiEvent() : dest(nullptr), id(UIEVT_NULL) { }
177  uiEvent(uiEvent const & e) { dest = e.dest; id = e.id; params = e.params; }
178  uiEvent(uiEvtHandler * dest_, uiEventID id_) : dest(dest_), id(id_) { }
179 };
180 
181 
182 
184 // uiObject
185 
186 
188 struct uiObjectType {
189  uint32_t uiApp : 1;
190  uint32_t uiEvtHandler : 1;
191  uint32_t uiWindow : 1;
192  uint32_t uiFrame : 1;
193  uint32_t uiControl : 1;
194  uint32_t uiScrollableControl : 1;
195  uint32_t uiButton : 1;
196  uint32_t uiTextEdit : 1;
197  uint32_t uiLabel : 1;
198  uint32_t uiImage : 1;
199  uint32_t uiPanel : 1;
200  uint32_t uiPaintBox : 1;
201  uint32_t uiListBox : 1;
202  uint32_t uiComboBox : 1;
203  uint32_t uiCheckBox : 1;
204 
206  uiLabel(0), uiImage(0), uiPanel(0), uiPaintBox(0), uiListBox(0), uiComboBox(0), uiCheckBox(0)
207  { }
208 };
209 
210 
212 class uiObject {
213 
214 public:
215 
216  uiObject();
217 
218  virtual ~uiObject();
219 
225  uiObjectType & objectType() { return m_objectType; }
226 
227 private:
228  uiObjectType m_objectType;
229 };
230 
231 
232 
234 // uiEvtHandler
235 
236 
238 class uiEvtHandler : public uiObject {
239 
240 public:
241 
243 
244  virtual ~uiEvtHandler();
245 
246  virtual void processEvent(uiEvent * event);
247 
253  uiApp * app() { return m_app; }
254 
255 
256 protected:
257 
258  void setApp(uiApp * value) { m_app = value; }
259 
260 
261 private:
262 
263  uiApp * m_app;
264 };
265 
266 
267 
269 // uiWindow
270 
274 enum class uiOrigin {
275  Screen,
276  Parent,
277  Window,
278 };
279 
280 
283  uint8_t visible : 1;
284  uint8_t maximized : 1;
285  uint8_t minimized : 1;
286  uint8_t active : 1;
287 };
288 
289 
292  uint8_t activable : 1;
293  uint8_t focusable : 1;
295  uiWindowProps() :
296  activable(true),
297  focusable(false)
298  { }
299 };
300 
301 
305  RGB borderColor = RGB(2, 2, 2);
306  RGB activeBorderColor = RGB(2, 2, 3);
308  uint8_t borderSize = 3;
309  uint8_t focusedBorderSize = 1;
310 };
311 
312 
314 struct uiAnchors {
315  uint8_t left : 1;
316  uint8_t top : 1;
317  uint8_t right : 1;
318  uint8_t bottom : 1;
320  uiAnchors() : left(true), top(true), right(false), bottom(false) { }
321 };
322 
323 
325 class uiWindow : public uiEvtHandler {
326 
327 friend class uiApp;
328 
329 public:
330 
339  uiWindow(uiWindow * parent, const Point & pos, const Size & size, bool visible);
340 
341  virtual ~uiWindow();
342 
343  virtual void processEvent(uiEvent * event);
344 
352  uiWindow * next() { return m_next; }
353 
361  uiWindow * prev() { return m_prev; }
362 
368  uiWindow * firstChild() { return m_firstChild; }
369 
375  uiWindow * lastChild() { return m_lastChild; }
376 
382  bool hasChildren() { return m_firstChild != nullptr; }
383 
387  void bringOnTop();
388 
394  void bringAfter(uiWindow * insertionPoint);
395 
403  Point pos() { return m_pos; }
404 
410  Point clientPos();
411 
419  Size size() { return m_size; }
420 
426  Size clientSize();
427 
437  Rect rect(uiOrigin origin);
438 
446  virtual Rect clientRect(uiOrigin origin);
447 
455  uiWindowState state() { return m_state; }
456 
462  uiWindowProps & windowProps() { return m_windowProps; }
463 
469  uiWindowStyle & windowStyle() { return m_windowStyle; }
470 
476  uiWindow * parent() { return m_parent; }
477 
483  Point mouseDownPos() { return m_mouseDownPos; }
484 
493  Rect transformRect(Rect const & rect, uiWindow * baseWindow);
494 
500  void repaint(Rect const & rect);
501 
505  void repaint();
506 
514  bool isMouseOver() { return m_isMouseOver; }
515 
523  void exitModal(int modalResult);
524 
532  bool hasFocus();
533 
539  uiAnchors & anchors() { return m_anchors; }
540 
546  void setFocusIndex(int value) { m_focusIndex = value; }
547 
555  int focusIndex() { return m_focusIndex; }
556 
557 
558  // Delegates
559 
565  Delegate<> onClick;
566 
573  Delegate<> onDblClick;
574 
575 
576 protected:
577 
578  void addChild(uiWindow * child);
579  void insertAfter(uiWindow * child, uiWindow * underlyingChild);
580  void freeChildren();
581  void removeChild(uiWindow * child, bool freeChild = true);
582  void moveChildOnTop(uiWindow * child);
583  void moveAfter(uiWindow * child, uiWindow * underlyingChild);
584  bool isChild(uiWindow * window);
585 
586  Size sizeAtMouseDown() { return m_sizeAtMouseDown; }
587  Point posAtMouseDown() { return m_posAtMouseDown; }
588 
589  virtual Size minWindowSize() { return Size(0, 0); }
590 
591  void beginPaint(uiEvent * paintEvent, Rect const & clippingRect);
592 
593  void generatePaintEvents(Rect const & paintRect);
594  void reshape(Rect const & r);
595 
596  bool isFocusable();
597 
598 private:
599 
600  void paintWindow();
601  uiWindow * getChildWithFocusIndex(int focusIndex, int * maxIndex);
602 
603 
604  uiWindow * m_parent;
605 
606  Point m_pos;
607  Size m_size;
608 
609  // saved screen rect before Maximize or Minimize
610  Rect m_savedScreenRect;
611 
612  uiWindowState m_state;
613 
614  uiWindowProps m_windowProps;
615 
616  uiWindowStyle m_windowStyle;
617 
618  Point m_mouseDownPos; // mouse position when mouse down event has been received
619 
620  Point m_posAtMouseDown; // used to resize
621  Size m_sizeAtMouseDown; // used to resize
622 
623  bool m_isMouseOver; // true after mouse entered, false after mouse left
624 
625  uiAnchors m_anchors;
626 
627  int16_t m_focusIndex; // -1 = doesn't partecipate to focus trip
628 
629  // double linked list, order is: bottom (first items) -> up (last items)
630  uiWindow * m_next;
631  uiWindow * m_prev;
632  uiWindow * m_firstChild;
633  uiWindow * m_lastChild;
634 };
635 
636 
637 
639 // uiFrame
640 
641 
645 struct uiFrameStyle {
646  RGB backgroundColor = RGB(3, 3, 3);
649  RGB titleColor = RGB(0, 0, 0);
650  RGB activeTitleColor = RGB(0, 0, 0);
651  FontInfo const * titleFont = Canvas.getPresetFontInfoFromHeight(14, false);
652  RGB buttonColor = RGB(1, 1, 1);
653  RGB activeButtonColor = RGB(0, 0, 0);
656 };
657 
658 
662 struct uiFrameProps {
663  uint8_t resizeable : 1;
664  uint8_t moveable : 1;
665  uint8_t hasCloseButton : 1;
666  uint8_t hasMaximizeButton : 1;
667  uint8_t hasMinimizeButton : 1;
669  uiFrameProps() :
670  resizeable(true),
671  moveable(true),
672  hasCloseButton(true),
673  hasMaximizeButton(true),
674  hasMinimizeButton(true)
675  { }
676 };
677 
678 
679 enum class uiFrameItem : uint8_t {
680  None,
681  MoveArea,
682  TopLeftResize,
683  TopCenterResize,
684  TopRightResize,
685  CenterLeftResize,
686  CenterRightResize,
687  BottomLeftResize,
688  BottomCenterResize,
689  BottomRightResize,
690  CloseButton,
691  MaximizeButton,
692  MinimizeButton,
693 };
694 
695 
699 class uiFrame : public uiWindow {
700 
701 public:
702 
712  uiFrame(uiWindow * parent, char const * title, const Point & pos, const Size & size, bool visible = true);
713 
714  virtual ~uiFrame();
715 
716  virtual void processEvent(uiEvent * event);
717 
723  char const * title() { return m_title; }
724 
732  void setTitle(char const * value);
733 
739  uiFrameStyle & frameStyle() { return m_frameStyle; }
740 
746  uiFrameProps & frameProps() { return m_frameProps; }
747 
748  Rect clientRect(uiOrigin origin);
749 
750 
751  // Delegates
752 
758  Delegate<> onShow;
759 
765  Delegate<> onHide;
766 
772  Delegate<> onResize;
773 
780  Delegate<uiTimerHandle> onTimer;
781 
782 
783 protected:
784 
785  Size minWindowSize();
786  int titleBarHeight();
787  Rect titleBarRect();
788 
789 private:
790 
791  void paintFrame();
792  int paintButtons(Rect const & bkgRect);
793  void movingCapturedMouse(int mouseX, int mouseY, bool mouseIsDown);
794  void movingFreeMouse(int mouseX, int mouseY);
795  uiFrameItem getFrameItemAt(int x, int y);
796  Rect getBtnRect(int buttonIndex);
797  void handleButtonsClick(int x, int y, bool doubleClick);
798  void drawTextWithEllipsis(FontInfo const * fontInfo, int X, int Y, char const * text, int maxX);
799  void drawReshapingBox(Rect boxRect);
800 
801 
802  static constexpr int CORNERSENSE = 10;
803 
804 
805  uiFrameStyle m_frameStyle;
806 
807  uiFrameProps m_frameProps;
808 
809  char * m_title;
810  int m_titleLength;
811 
812  uiFrameItem m_mouseDownFrameItem; // frame item on mouse down
813  uiFrameItem m_mouseMoveFrameItem; // frame item on mouse move
814 
815  Rect m_lastReshapingBox; // last reshaping box painted by drawReshapingBox(), (0,0,0,0) if there isn't any
816 
817 };
818 
819 
820 
822 // uiControl
823 
824 
828 class uiControl : public uiWindow {
829 
830 public:
831 
840  uiControl(uiWindow * parent, const Point & pos, const Size & size, bool visible);
841 
842  virtual ~uiControl();
843 
844  virtual void processEvent(uiEvent * event);
845 };
846 
847 
848 
850 // uiScrollableControl
851 
852 
858  uint8_t scrollBarSize = 11;
859 };
860 
861 
865 enum class uiScrollBar {
866  Vertical,
867  Horizontal,
868 };
869 
870 
871 enum class uiScrollBarItem {
872  None,
873  LeftButton,
874  RightButton,
875  TopButton,
876  BottomButton,
877  HBar,
878  VBar,
879  PageUp,
880  PageDown,
881  PageLeft,
882  PageRight,
883 };
884 
885 
890 
891 public:
892 
901  uiScrollableControl(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
902 
903  virtual ~uiScrollableControl();
904 
905  virtual void processEvent(uiEvent * event);
906 
907  Rect clientRect(uiOrigin origin);
908 
914  uiScrollableControlStyle & scrollableControlStyle() { return m_scrollableControlStyle; }
915 
924  int HScrollBarPos() { return m_HScrollBarPosition; }
925 
933  int HScrollBarVisible() { return m_HScrollBarVisible; }
934 
943  int HScrollBarRange() { return m_HScrollBarRange; }
944 
953  int VScrollBarPos() { return m_VScrollBarPosition; }
954 
962  int VScrollBarVisible() { return m_VScrollBarVisible; }
963 
972  int VScrollBarRange() { return m_VScrollBarRange; }
973 
974 
975  // Delegates
976 
980  Delegate<> onChangeHScrollBar;
981 
985  Delegate<> onChangeVScrollBar;
986 
987 
988 protected:
989 
999  virtual void setScrollBar(uiScrollBar orientation, int position, int visible, int range, bool repaintScrollbar = true);
1000 
1001 
1002 private:
1003 
1004  void paintScrollableControl();
1005  void paintScrollBars();
1006  Rect getVScrollBarRects(Rect * topButton = nullptr, Rect * bottonButton = nullptr, Rect * bar = nullptr);
1007  Rect getHScrollBarRects(Rect * leftButton = nullptr, Rect * rightButton = nullptr, Rect * bar = nullptr);
1008  uiScrollBarItem getItemAt(int x, int y);
1009  void repaintScrollBar(uiScrollBar orientation);
1010  void handleFreeMouseMove(int mouseX, int mouseY);
1011  void handleCapturedMouseMove(int mouseX, int mouseY);
1012  void handleButtonsScroll();
1013  void handlePageScroll();
1014 
1015  uiScrollableControlStyle m_scrollableControlStyle;
1016 
1017  int16_t m_HScrollBarPosition;
1018  int16_t m_HScrollBarVisible; // it means the "visible" area (how big is the bar)
1019  int16_t m_HScrollBarRange;
1020  int16_t m_VScrollBarPosition;
1021  int16_t m_VScrollBarVisible; // it means the "visible" area (how big is the bar)
1022  int16_t m_VScrollBarRange;
1023 
1024  // values updated by getVScrollBarRects() and getHScrollBarRects()
1025  int16_t m_HBarArea;
1026  int16_t m_VBarArea;
1027 
1028  int16_t m_mouseDownHScrollBarPosition;
1029  int16_t m_mouseDownVScrollBarPosition;
1030 
1031  uiScrollBarItem m_mouseOverItem;
1032 
1033  // a timer is active while mouse is down and the mouse is over a button
1034  uiTimerHandle m_scrollTimer;
1035 };
1036 
1037 
1038 
1040 // uiButton
1041 
1042 
1045  RGB backgroundColor = RGB(2, 2, 2);
1049  RGB textColor = RGB(0, 0, 0);
1050  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1051  uint8_t bitmapTextSpace = 4;
1052  Bitmap const * bitmap = nullptr;
1053  Bitmap const * downBitmap = nullptr;
1054 };
1055 
1056 
1060 enum class uiButtonKind {
1061  Button,
1062  Switch,
1063 };
1064 
1065 
1067 class uiButton : public uiControl {
1068 
1069 public:
1070 
1081  uiButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, uiButtonKind kind = uiButtonKind::Button, bool visible = true);
1082 
1083  virtual ~uiButton();
1084 
1085  virtual void processEvent(uiEvent * event);
1086 
1094  void setText(char const * value);
1095 
1101  char const * text() { return m_text; }
1102 
1108  uiButtonStyle & buttonStyle() { return m_buttonStyle; }
1109 
1117  bool down() { return m_down; }
1118 
1126  void setDown(bool value);
1127 
1128 
1129  // Delegates
1130 
1136  Delegate<> onChange;
1137 
1138 
1139 private:
1140 
1141  void paintButton();
1142  void paintContent(Rect const & rect);
1143 
1144  void trigger();
1145 
1146 
1147  uiButtonStyle m_buttonStyle;
1148 
1149  char * m_text;
1150  int m_textExtent; // calculated by setText(). TODO: changing font doesn't update m_textExtent!
1151 
1152  bool m_down;
1153 
1154  uiButtonKind m_kind;
1155 
1156 };
1157 
1158 
1159 
1161 // uiTextEdit
1162 // single line text edit
1163 
1164 
1171  RGB backgroundColor = RGB(2, 2, 2);
1174  RGB textColor = RGB(0, 0, 0);
1175  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1176 };
1177 
1178 
1183  uint8_t hasCaret : 1;
1184  uint8_t allowEdit : 1;
1186  uiTextEditProps()
1187  : hasCaret(true),
1188  allowEdit(true)
1189  {
1190  }
1191 };
1192 
1193 
1199 class uiTextEdit : public uiControl {
1200 
1201 public:
1202 
1212  uiTextEdit(uiWindow * parent, char const * text, const Point & pos, const Size & size, bool visible = true);
1213 
1214  virtual ~uiTextEdit();
1215 
1216  virtual void processEvent(uiEvent * event);
1217 
1223  uiTextEditStyle & textEditStyle() { return m_textEditStyle; }
1224 
1230  uiTextEditProps & textEditProps() { return m_textEditProps; }
1231 
1239  void setText(char const * value);
1240 
1246  char const * text() { return m_text; }
1247 
1248 
1249  // Delegates
1250 
1254  Delegate<> onChange;
1255 
1256 
1257 protected:
1258 
1259  virtual Rect getEditRect();
1260 
1261 private:
1262 
1263  void paintTextEdit();
1264  void paintContent();
1265 
1266  uint8_t const * getCharInfo(char ch, int * width);
1267  int charColumnToWindowX(int col);
1268  void updateCaret();
1269  void moveCursor(int col, int selCol);
1270  int getColFromMouseX(int mouseX);
1271  void handleKeyDown(uiKeyEventInfo key);
1272  void checkAllocatedSpace(int requiredLength);
1273  void insert(char c);
1274  void removeSel();
1275  int getWordPosAtLeft();
1276  int getWordPosAtRight();
1277  void selectWordAt(int mouseX);
1278 
1279 
1280  uiTextEditStyle m_textEditStyle;
1281  uiTextEditProps m_textEditProps;
1282 
1283  char * m_text;
1284  int m_textLength; // text length NOT including ending zero
1285  int m_textSpace; // actual space allocated including ending zero
1286 
1287  // rectangle where text will be painted (this is also the text clipping rect)
1288  Rect m_contentRect; // updated on painting
1289 
1290  // where text starts to be painted. Values less than m_contentRect.X1 are used to show characters which do not fit in m_contentRect
1291  int m_viewX;
1292 
1293  // character index of cursor position (0 = at first char)
1294  int m_cursorCol;
1295 
1296  // character index at start of selection (not included if < m_cursorCol, included if > m_cursorCol)
1297  int m_selCursorCol;
1298 
1299 };
1300 
1301 
1302 
1304 // uiLabel
1305 
1306 
1309  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1310  RGB backgroundColor = RGB(3, 3, 3);
1311  RGB textColor = RGB(0, 0, 0);
1312 };
1313 
1314 
1316 class uiLabel : public uiControl {
1317 
1318 public:
1319 
1329  uiLabel(uiWindow * parent, char const * text, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1330 
1331  virtual ~uiLabel();
1332 
1333  virtual void processEvent(uiEvent * event);
1334 
1342  void setText(char const * value);
1343 
1349  char const * text() { return m_text; }
1350 
1356  uiLabelStyle & labelStyle() { return m_labelStyle; }
1357 
1363  void update();
1364 
1365 
1366 private:
1367 
1368  void paintLabel();
1369 
1370 
1371  char * m_text;
1372 
1373  uiLabelStyle m_labelStyle;
1374 
1375  uint16_t m_textExtent; // calculated by setText()
1376 
1377  uint8_t m_autoSize;
1378 
1379 };
1380 
1381 
1382 
1384 // uiImage
1385 
1386 
1389  RGB backgroundColor = RGB(3, 3, 3);
1390 };
1391 
1392 
1394 class uiImage : public uiControl {
1395 
1396 public:
1397 
1407  uiImage(uiWindow * parent, Bitmap const * bitmap, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1408 
1409  virtual ~uiImage();
1410 
1411  virtual void processEvent(uiEvent * event);
1412 
1420  void setBitmap(Bitmap const * bitmap);
1421 
1427  Bitmap const * bitmap() { return m_bitmap; }
1428 
1434  uiImageStyle & imageStyle() { return m_imageStyle; }
1435 
1436 
1437 private:
1438 
1439  void paintImage();
1440 
1441 
1442  Bitmap const * m_bitmap;
1443 
1444  uiImageStyle m_imageStyle;
1445 
1446  bool m_autoSize;
1447 
1448 };
1449 
1450 
1451 
1453 // uiPanel
1454 
1455 
1458  RGB backgroundColor = RGB(2, 2, 2);
1459 };
1460 
1461 
1463 class uiPanel : public uiControl {
1464 
1465 public:
1466 
1475  uiPanel(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1476 
1477  virtual ~uiPanel();
1478 
1479  virtual void processEvent(uiEvent * event);
1480 
1486  uiPanelStyle & panelStyle() { return m_panelStyle; }
1487 
1488 
1489 private:
1490 
1491  void paintPanel();
1492 
1493 
1494  uiPanelStyle m_panelStyle;
1495 };
1496 
1497 
1498 
1500 // uiPaintBox
1501 
1502 
1505  RGB backgroundColor = RGB(2, 2, 2);
1506 };
1507 
1508 
1511 
1512 public:
1513 
1522  uiPaintBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1523 
1524  virtual ~uiPaintBox();
1525 
1526  virtual void processEvent(uiEvent * event);
1527 
1533  uiPaintBoxStyle & paintBoxStyle() { return m_paintBoxStyle; }
1534 
1536 
1537  // Delegates
1538 
1544  Delegate<Rect> onPaint;
1545 
1546 
1547 private:
1548 
1549  void paintPaintBox();
1550 
1551 
1552  uiPaintBoxStyle m_paintBoxStyle;
1553 };
1554 
1555 
1556 
1558 // uiListBox
1559 
1560 
1563  RGB backgroundColor = RGB(2, 2, 2);
1567  int itemHeight = 16;
1568  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1569  RGB textColor = RGB(0, 0, 0);
1571 };
1572 
1573 
1576 
1577 public:
1578 
1587  uiListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1588 
1589  virtual ~uiListBox();
1590 
1591  virtual void processEvent(uiEvent * event);
1592 
1598  uiListBoxStyle & listBoxStyle() { return m_listBoxStyle; }
1599 
1608  StringList & items() { return m_items; }
1609 
1615  int firstSelectedItem();
1616 
1622  int lastSelectedItem();
1623 
1631  void selectItem(int index, bool add = false, bool range = false);
1632 
1636  void deselectAll();
1637 
1638 
1639  // Delegates
1640 
1646  Delegate<> onChange;
1647 
1651  Delegate<> onKillFocus;
1652 
1656  Delegate<uiKeyEventInfo> onKeyUp;
1657 
1658 
1659 protected:
1660 
1661  void setScrollBar(uiScrollBar orientation, int position, int visible, int range, bool repaintScrollbar);
1662 
1663 private:
1664 
1665  void paintListBox();
1666  int getItemAtMousePos(int mouseX, int mouseY);
1667  void handleMouseDown(int mouseX, int mouseY);
1668  void handleKeyDown(uiKeyEventInfo key);
1669 
1670 
1671  uiListBoxStyle m_listBoxStyle;
1672  StringList m_items;
1673  int m_firstVisibleItem; // the item on the top
1674 };
1675 
1676 
1678 // uiComboBox
1679 
1680 
1684  RGB buttonColor = RGB(2, 2, 2);
1685 };
1686 
1687 
1690  uint8_t openOnFocus : 1;
1692  uiComboBoxProps()
1693  : openOnFocus(true)
1694  {
1695  }
1696 };
1697 
1698 
1700 class uiComboBox : public uiTextEdit
1701 {
1702 
1703 public:
1704 
1714  uiComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true);
1715 
1716  ~uiComboBox();
1717 
1718  virtual void processEvent(uiEvent * event);
1719 
1727  StringList & items() { return m_listBox.items(); }
1728 
1734  uiComboBoxStyle & comboBoxStyle() { return m_comboBoxStyle; }
1735 
1741  uiComboBoxProps & comboBoxProps() { return m_comboBoxProps; }
1742 
1748  int selectedItem() { return m_listBox.firstSelectedItem(); }
1749 
1755  void selectItem(int index);
1756 
1757 
1758  // Delegates
1759 
1765  Delegate<> onChange;
1766 
1767 
1768 protected:
1769 
1770  virtual Rect getEditRect();
1771 
1772 
1773 private:
1774 
1775  void paintComboBox();
1776  Rect getButtonRect();
1777  int buttonWidth();
1778  void openListBox();
1779  void closeListBox();
1780  void switchListBox();
1781  void updateTextEdit();
1782 
1783 
1784  uiListBox m_listBox;
1785  int m_listHeight;
1786  uiComboBoxStyle m_comboBoxStyle;
1787  uiComboBoxProps m_comboBoxProps;
1788 
1789 
1790 };
1791 
1792 
1793 
1795 // uiCheckBox
1796 
1797 
1800  RGB backgroundColor = RGB(2, 2, 2);
1803  RGB foregroundColor = RGB(0, 0, 0);
1804 };
1805 
1806 
1810 enum class uiCheckBoxKind : int8_t {
1811  CheckBox,
1812  RadioButton,
1813 };
1814 
1815 
1822 class uiCheckBox : public uiControl {
1823 
1824 public:
1825 
1835  uiCheckBox(uiWindow * parent, const Point & pos, const Size & size, uiCheckBoxKind kind = uiCheckBoxKind::CheckBox, bool visible = true);
1836 
1837  virtual ~uiCheckBox();
1838 
1839  virtual void processEvent(uiEvent * event);
1840 
1846  uiCheckBoxStyle & checkBoxStyle() { return m_checkBoxStyle; }
1847 
1853  bool checked() { return m_checked; }
1854 
1862  void setChecked(bool value);
1863 
1869  int groupIndex() { return m_groupIndex; }
1870 
1876  void setGroupIndex(int value) { m_groupIndex = value; }
1877 
1878 
1879  // Delegates
1880 
1886  Delegate<> onChange;
1887 
1888 
1889 private:
1890 
1891  void paintCheckBox();
1892  void trigger();
1893  void unCheckGroup();
1894 
1895 
1896  uiCheckBoxStyle m_checkBoxStyle;
1897  bool m_checked;
1898  uiCheckBoxKind m_kind;
1899  int16_t m_groupIndex; // -1 = no group
1900 
1901 };
1902 
1903 
1904 
1905 
1906 
1908 // uiApp
1909 
1910 
1912 struct uiAppProps {
1913  uint16_t caretBlinkingTime = 500;
1914  uint16_t doubleClickTime = 250;
1915  bool realtimeReshaping = false;
1916 };
1917 
1918 
1923  Cancel,
1924  Button1,
1925  Button2,
1926  Button3,
1927 };
1928 
1929 
1933 enum class uiMessageBoxIcon {
1934  None,
1935  Question,
1936  Info,
1937  Warning,
1938  Error,
1939 };
1940 
1941 
1948 class uiApp : public uiEvtHandler {
1949 
1950 public:
1951 
1952  uiApp();
1953 
1954  virtual ~uiApp();
1955 
1961  void run();
1962 
1970  bool postEvent(uiEvent const * event);
1971 
1979  bool insertEvent(uiEvent const * event);
1980 
1981  void postDebugMsg(char const * msg);
1982 
1983  virtual void processEvent(uiEvent * event);
1984 
1993  uiFrame * rootWindow() { return m_rootWindow; }
1994 
2003  uiWindow * activeWindow() { return m_activeWindow; }
2004 
2014  uiWindow * setActiveWindow(uiWindow * value);
2015 
2028  uiWindow * focusedWindow() { return m_focusedWindow; }
2029 
2040  uiWindow * setFocusedWindow(uiWindow * value);
2041 
2052  uiWindow * moveFocus(int delta);
2053 
2054  void captureMouse(uiWindow * window);
2055 
2063  uiWindow * capturedMouseWindow() { return m_capturedMouseWindow; }
2064 
2070  void repaintWindow(uiWindow * window);
2071 
2077  void repaintRect(Rect const & rect);
2078 
2086  void moveWindow(uiWindow * window, int x, int y);
2087 
2095  void resizeWindow(uiWindow * window, int width, int height);
2096 
2103  void resizeWindow(uiWindow * window, Size size);
2104 
2111  void reshapeWindow(uiWindow * window, Rect const & rect);
2112 
2120  uiWindow * screenToWindow(Point & point);
2121 
2128  void showWindow(uiWindow * window, bool value);
2129 
2140  int showModalWindow(uiWindow * window);
2141 
2148  void maximizeWindow(uiWindow * window, bool value);
2149 
2156  void minimizeWindow(uiWindow * window, bool value);
2157 
2158  void combineMouseMoveEvents(bool value) { m_combineMouseMoveEvents = value; }
2159 
2160  void showCaret(uiWindow * window);
2161 
2162  void setCaret(bool value);
2163 
2164  void setCaret(Point const & pos);
2165 
2166  void setCaret(Rect const & rect);
2167 
2179  uiTimerHandle setTimer(uiEvtHandler * dest, int periodMS);
2180 
2188  void killTimer(uiTimerHandle handle);
2189 
2195  uiAppProps & appProps() { return m_appProps; }
2196 
2202  void destroyWindow(uiWindow * window);
2203 
2204  void cleanWindowReferences(uiWindow * window);
2205 
2218  uiMessageBoxResult messageBox(char const * title, char const * text, char const * button1Text, char const * button2Text = nullptr, char const * button3Text = nullptr, uiMessageBoxIcon icon = uiMessageBoxIcon::Question);
2219 
2220 
2224  virtual void init();
2225 
2226  // delegates
2227 
2234  Delegate<uiTimerHandle> onTimer;
2235 
2236 protected:
2237 
2238  bool getEvent(uiEvent * event, int timeOutMS);
2239  bool peekEvent(uiEvent * event, int timeOutMS);
2240 
2241 
2242 private:
2243 
2244  void preprocessEvent(uiEvent * event);
2245  void preprocessMouseEvent(uiEvent * event);
2246  void preprocessKeyboardEvent(uiEvent * event);
2247  void filterModalEvent(uiEvent * event);
2248 
2249  static void timerFunc(TimerHandle_t xTimer);
2250 
2251  void blinkCaret(bool forceOFF = false);
2252  void suspendCaret(bool value);
2253 
2254 
2255  uiAppProps m_appProps;
2256 
2257  QueueHandle_t m_eventsQueue;
2258 
2259  uiFrame * m_rootWindow;
2260 
2261  uiWindow * m_activeWindow; // foreground window. Also gets keyboard events (other than focused window)
2262 
2263  uiWindow * m_focusedWindow; // window that captures keyboard events (other than active window)
2264 
2265  uiWindow * m_capturedMouseWindow; // window that has captured mouse
2266 
2267  uiWindow * m_freeMouseWindow; // window where mouse is over
2268 
2269  uiWindow * m_modalWindow; // current modal window
2270 
2271  bool m_combineMouseMoveEvents;
2272 
2273  uiWindow * m_caretWindow; // nullptr = caret is not visible
2274  Rect m_caretRect; // caret rect relative to m_caretWindow
2275  uiTimerHandle m_caretTimer;
2276  int m_caretInvertState; // -1 = suspended, 1 = rect reversed (cat visible), 0 = rect not reversed (caret invisible)
2277 
2278  int m_lastMouseUpTimeMS; // time (MS) at mouse up. Used to measure double clicks
2279  Point m_lastMouseUpPos; // screen position of last mouse up
2280 };
2281 
2282 
2283 
2284 
2285 } // end of namespace
2286 
2287 
2288 
Bitmap const * bitmap
Definition: fabui.h:1052
uiWindowStyle & windowStyle()
Sets or gets window style.
Definition: fabui.h:469
void selectItem(int index, bool add=false, bool range=false)
Selects a listbox item.
Definition: fabui.cpp:3278
uiCheckBoxKind
Specifies the combobox behaviour.
Definition: fabui.h:1810
VirtualKey VK
Definition: fabui.h:131
FontInfo const * textFont
Definition: fabui.h:1050
uint8_t SHIFT
Definition: fabui.h:135
bool hasFocus()
Determines whether this window or control has focus.
Definition: fabui.cpp:1430
uiApp * app()
Determines the app that owns this object.
Definition: fabui.h:253
char const * text()
Determines button text.
Definition: fabui.h:1101
Definition: vgacontroller.h:394
uiImageStyle & imageStyle()
Sets or gets image style.
Definition: fabui.h:1434
RGB backgroundColor
Definition: fabui.h:1505
RGB downBackgroundColor
Definition: fabui.h:1046
uint8_t hasMinimizeButton
Definition: fabui.h:667
uiPanelStyle & panelStyle()
Sets or gets panel style.
Definition: fabui.h:1486
void moveWindow(uiWindow *window, int x, int y)
Moves a window.
Definition: fabui.cpp:587
uiWindow * capturedMouseWindow()
Determines which window is capturing mouse.
Definition: fabui.h:2063
Represents an RGB color.
Definition: vgacontroller.h:239
uiComboBoxStyle & comboBoxStyle()
Sets or gets combobox style.
Definition: fabui.h:1734
int VScrollBarRange()
Determines vertical scrollbar range.
Definition: fabui.h:972
uiWindow * screenToWindow(Point &point)
Determines which window a point belongs to.
Definition: fabui.cpp:391
A frame is a window with a title bar, maximize/minimize/close buttons and that is resizeable or movea...
Definition: fabui.h:699
Contains details about the key event.
Definition: fabui.h:130
void setText(char const *value)
Sets button text.
Definition: fabui.cpp:2037
int HScrollBarVisible()
Determines horizontal scrollbar visible portion (aka thumb size) of the scrollable content...
Definition: fabui.h:933
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:2234
void minimizeWindow(uiWindow *window, bool value)
Minimizes or restores a window.
Definition: fabui.cpp:673
RGB backgroundColor
Definition: fabui.h:1389
uiTimerHandle setTimer(uiEvtHandler *dest, int periodMS)
Setups a timer.
Definition: fabui.cpp:690
RGB mouseOverBackgroundColor
Definition: fabui.h:1047
void repaintRect(Rect const &rect)
Repaints a screen area.
Definition: fabui.cpp:578
uint8_t right
Definition: fabui.h:317
Represents the whole application base class.
Definition: fabui.h:1948
void resizeWindow(uiWindow *window, int width, int height)
Resizes a window.
Definition: fabui.cpp:593
void selectItem(int index)
Selects an item.
Definition: fabui.cpp:3469
uint8_t minimized
Definition: fabui.h:285
uiPaintBoxStyle & paintBoxStyle()
Sets or gets paintbox style.
Definition: fabui.h:1533
Bitmap const * downBitmap
Definition: fabui.h:1053
uint8_t left
Definition: fabui.h:315
virtual void init()
Method to inherit to implement an application.
Definition: fabui.cpp:410
A scrollable control is a control with optionally vertical and/or horizontal scrollbars.
Definition: fabui.h:889
RGB borderColor
Definition: fabui.h:305
uiWindow * setFocusedWindow(uiWindow *value)
Sets the focused window (control)
Definition: fabui.cpp:512
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:415
Base class for all visible UI elements (Frames and Controls)
Definition: fabui.h:325
char const * text()
Determines label text.
Definition: fabui.h:1349
uiLabelStyle & labelStyle()
Sets or gets label style.
Definition: fabui.h:1356
bool isMouseOver()
Determines whether the mouse is over this window.
Definition: fabui.h:514
RGB activeTitleBackgroundColor
Definition: fabui.h:648
RGB mouseOverScrollBarForegroundColor
Definition: fabui.h:857
Rect transformRect(Rect const &rect, uiWindow *baseWindow)
Transforms rectangle origins from current window to another one.
Definition: fabui.cpp:1077
void maximizeWindow(uiWindow *window, bool value)
Maximizes or restores a window.
Definition: fabui.cpp:666
uiWindow * lastChild()
Gets last child.
Definition: fabui.h:375
Delegate onChange
Change event delegate.
Definition: fabui.h:1886
uiWindow * activeWindow()
Gets a pointer to the currently active window.
Definition: fabui.h:2003
FontInfo const * titleFont
Definition: fabui.h:651
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:1230
uint8_t bottom
Definition: fabui.h:318
Contains a list of selectable items.
Definition: fabui.h:1575
uint8_t top
Definition: fabui.h:316
uiImage(uiWindow *parent, Bitmap const *bitmap, const Point &pos, const Size &size=Size(0, 0), bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2672
uint8_t focusable
Definition: fabui.h:293
RGB checkedBackgroundColor
Definition: fabui.h:1801
Delegate onChange
Text edit event delegate.
Definition: fabui.h:1254
Contains the listbox style.
Definition: fabui.h:1562
RGB selectedBackgroundColor
Definition: fabui.h:1565
Point pos()
Determines the window position relative to parent window.
Definition: fabui.h:403
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:780
RGB titleColor
Definition: fabui.h:649
uiControl(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:1982
RGB scrollBarForegroundColor
Definition: fabui.h:856
uiWindow * parent()
Determines the parent window.
Definition: fabui.h:476
RGB activeTitleColor
Definition: fabui.h:650
uint8_t borderSize
Definition: fabui.h:308
Base class of all UI elements that can receive events.
Definition: fabui.h:238
RGB focusedBackgroundColor
Definition: fabui.h:1173
Sets or gets text edit style.
Definition: fabui.h:1170
uint8_t GUI
Definition: fabui.h:136
void deselectAll()
Deselects all selected items.
Definition: fabui.cpp:3311
Contains the paintbox style.
Definition: fabui.h:1504
int lastSelectedItem()
Gets the last selected item.
Definition: fabui.cpp:3381
int HScrollBarRange()
Determines horizontal scrollbar range.
Definition: fabui.h:943
Properties of the combobox.
Definition: fabui.h:1689
uiWindow * moveFocus(int delta)
Move focus to a control with current focus index plus a delta.
Definition: fabui.cpp:546
uiMessageBoxIcon
Icon displayed by the uiApp.messageBox() method.
Definition: fabui.h:1933
FontInfo const * textFont
Definition: fabui.h:1568
This file contains fabgl::CanvasClass definition and the related Canvas instance. ...
This file contains fabgl::VGAControllerClass definition and the VGAController instance.
A panel is used to contain and to group some controls.
Definition: fabui.h:1463
Represents a checkbox or a radiobutton.
Definition: fabui.h:1822
uint8_t resizeable
Definition: fabui.h:663
RGB mouseOverBackgroundButtonColor
Definition: fabui.h:654
void showWindow(uiWindow *window, bool value)
Makes a window visible or invisible.
Definition: fabui.cpp:614
uint8_t hasCaret
Definition: fabui.h:1183
virtual Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1115
int VScrollBarPos()
Determines position of the vertical scrollbar thumb.
Definition: fabui.h:953
Point clientPos()
Determines position of the client area.
Definition: fabui.cpp:1128
void bringOnTop()
Brings this window on top.
Definition: fabui.cpp:1054
bool realtimeReshaping
Definition: fabui.h:1915
Delegate onKillFocus
Kill focus event delegate.
Definition: fabui.h:1651
void reshapeWindow(uiWindow *window, Rect const &rect)
Reshapes a window.
Definition: fabui.cpp:606
Delegate onChange
Button changed event delegate.
Definition: fabui.h:1136
void setText(char const *value)
Sets label text.
Definition: fabui.cpp:2614
RGB focusedSelectedBackgroundColor
Definition: fabui.h:1566
void destroyWindow(uiWindow *window)
Destroys a window.
Definition: fabui.cpp:781
uiTextEdit(uiWindow *parent, char const *text, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2157
uiWindow * prev()
Gets previous sibling.
Definition: fabui.h:361
uiFrameProps & frameProps()
Sets or gets frame properties.
Definition: fabui.h:746
Properties of the application.
Definition: fabui.h:1912
Contains the scrollable control style.
Definition: fabui.h:854
Represents a button control. A button can have text and optionally a bitmap.
Definition: fabui.h:1067
uiButtonKind
Specifies the button kind.
Definition: fabui.h:1060
uiAppProps & appProps()
Sets or gets application properties.
Definition: fabui.h:2195
void update()
Updates the label content.
Definition: fabui.cpp:2623
Contains the label style.
Definition: fabui.h:1308
void bringAfter(uiWindow *insertionPoint)
Brings this window after another one.
Definition: fabui.cpp:1060
Describes mouse absolute position, scroll wheel delta and buttons status.
Definition: fabutils.h:206
uint8_t moveable
Definition: fabui.h:664
Point mouseDownPos()
Determines mouse position when left button was down.
Definition: fabui.h:483
uint16_t caretBlinkingTime
Definition: fabui.h:1913
uiFrameStyle & frameStyle()
Sets or gets frame style.
Definition: fabui.h:739
RGB backgroundColor
Definition: fabui.h:1310
Rect rect(uiOrigin origin)
Determines the window bounding box.
Definition: fabui.cpp:1099
uiWindowState state()
Determines the window state.
Definition: fabui.h:455
int focusIndex()
Determines the focus index (aka tab-index)
Definition: fabui.h:555
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:366
RGB backgroundColor
Definition: fabui.h:1458
Represents the coordinate of a point.
Definition: fabutils.h:125
Represents an image with 64 colors image and transparency.
Definition: vgacontroller.h:367
Delegate< uiKeyEventInfo > onKeyUp
Key-up event delegate.
Definition: fabui.h:1656
Size size()
Determines the window size.
Definition: fabui.h:419
Contains the window style.
Definition: fabui.h:303
Properties of the frame.
Definition: fabui.h:662
void setFocusIndex(int value)
Sets the focus index (aka tab-index)
Definition: fabui.h:546
This file contains some utility classes and functions.
RGB activeBorderColor
Definition: fabui.h:306
RGB textColor
Definition: fabui.h:1311
uiLabel(uiWindow *parent, char const *text, const Point &pos, const Size &size=Size(0, 0), bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2594
Definition: canvas.cpp:47
RGB foregroundColor
Definition: fabui.h:1803
uint8_t activable
Definition: fabui.h:292
CursorName
This enum defines a set of predefined mouse cursors.
Definition: vgacontroller.h:392
uiWindow * firstChild()
Gets first child.
Definition: fabui.h:368
void run()
Initialize application and executes the main event loop.
Definition: fabui.cpp:186
void repaint()
Repaints this window.
Definition: fabui.cpp:1093
Specifies the object type.
Definition: fabui.h:188
Contains some window options.
Definition: fabui.h:291
Delegate onChangeVScrollBar
Vertical scrollbar change event delegate.
Definition: fabui.h:985
uiPanel(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2738
uint8_t visible
Definition: fabui.h:283
void exitModal(int modalResult)
Exits from a modal window.
Definition: fabui.cpp:1422
StringList & items()
A list of strings representing the listbox content.
Definition: fabui.h:1608
uint8_t active
Definition: fabui.h:286
MouseStatus status
Definition: fabui.h:142
Contains the button style.
Definition: fabui.h:1044
RGB backgroundColor
Definition: fabui.h:1800
Delegate onChange
Change event delegate.
Definition: fabui.h:1646
RGB mouseDownBackgroundColor
Definition: fabui.h:1048
RGB scrollBarBackgroundColor
Definition: fabui.h:855
void repaintWindow(uiWindow *window)
Repaints a window.
Definition: fabui.cpp:572
uint8_t hasCloseButton
Definition: fabui.h:665
Represents a rectangle.
Definition: fabutils.h:158
void setText(char const *value)
Replaces current text.
Definition: fabui.cpp:2184
uint8_t changedButton
Definition: fabui.h:143
uiWindowProps & windowProps()
Sets or gets window properties.
Definition: fabui.h:462
uiScrollableControl(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2843
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:1223
uiComboBoxProps & comboBoxProps()
Sets or gets combobox properties.
Definition: fabui.h:1741
uiScrollableControlStyle & scrollableControlStyle()
Sets or gets control style.
Definition: fabui.h:914
static FontInfo const * getPresetFontInfoFromHeight(int height, bool fixedWidth)
Gets the font info that best fits the specified height.
Definition: canvas.cpp:493
Represents a text edit control.
Definition: fabui.h:1199
uint8_t scrollBarSize
Definition: fabui.h:858
uiComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3435
uint8_t RALT
Definition: fabui.h:133
Delegate onShow
Show window event delegate.
Definition: fabui.h:758
Contains details about the mouse event.
Definition: fabui.h:141
RGB buttonColor
Definition: fabui.h:652
RGB backgroundColor
Definition: fabui.h:1045
int VScrollBarVisible()
Determines vertical scrollbar visible portion (aka thumb size) of the scrollable content.
Definition: fabui.h:962
Delegate onDblClick
Mouse double click event delegate4.
Definition: fabui.h:573
StringList & items()
A list of strings representing items of the combobox.
Definition: fabui.h:1727
uiWindow * focusedWindow()
Gets the focused window (control)
Definition: fabui.h:2028
int showModalWindow(uiWindow *window)
Makes a window visible and handles it has a modal window.
Definition: fabui.cpp:622
uiPaintBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2789
RGB textColor
Definition: fabui.h:1569
uiCheckBoxStyle & checkBoxStyle()
Sets or gets checkbox style.
Definition: fabui.h:1846
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:820
void killTimer(uiTimerHandle handle)
Kills a timer.
Definition: fabui.cpp:698
uiButtonStyle & buttonStyle()
Sets or gets button style.
Definition: fabui.h:1108
void setChecked(bool value)
Sets current checkbox or radiobutton checked status.
Definition: fabui.cpp:3717
uint8_t CTRL
Definition: fabui.h:134
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1506
bool hasChildren()
Determines whether this window has children.
Definition: fabui.h:382
This file contains FabGL library configuration settings, like number of supported colors...
Base class of all UI elements like windows and controls.
Definition: fabui.h:212
uiObjectType & objectType()
Determines the object type.
Definition: fabui.h:225
A paintbox control allows applications to perform custom drawings providing uiPaintBox.onPaint delegate. A paintbox can have horizontal and vertical scrollbars.
Definition: fabui.h:1510
int firstSelectedItem()
Gets the first selected item.
Definition: fabui.cpp:3371
RGB activeButtonColor
Definition: fabui.h:653
virtual void setScrollBar(uiScrollBar orientation, int position, int visible, int range, bool repaintScrollbar=true)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:2868
uint8_t bitmapTextSpace
Definition: fabui.h:1051
RGB titleBackgroundColor
Definition: fabui.h:647
Represents a bidimensional size.
Definition: fabutils.h:143
uiWindow * next()
Gets next sibling.
Definition: fabui.h:352
FontInfo const * textFont
Definition: fabui.h:1175
CursorName defaultCursor
Definition: fabui.h:304
RGB textColor
Definition: fabui.h:1174
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:565
uiListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3186
RGB backgroundColor
Definition: fabui.h:646
Definition: fabui.h:645
uint8_t maximized
Definition: fabui.h:284
Contains the listbox style.
Definition: fabui.h:1682
uint8_t openOnFocus
Definition: fabui.h:1690
uint8_t focusedBorderSize
Definition: fabui.h:309
RGB buttonBackgroundColor
Definition: fabui.h:1683
RGB mouseOverButtonColor
Definition: fabui.h:655
RGB focusedBackgroundColor
Definition: fabui.h:1564
Delegate onResize
Resize window event delegate.
Definition: fabui.h:772
uiCheckBox(uiWindow *parent, const Point &pos, const Size &size, uiCheckBoxKind kind=uiCheckBoxKind::CheckBox, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3610
A label is a static text UI element.
Definition: fabui.h:1316
uiButton(uiWindow *parent, char const *text, const Point &pos, const Size &size, uiButtonKind kind=uiButtonKind::Button, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2011
int itemHeight
Definition: fabui.h:1567
Properties of the text edit.
Definition: fabui.h:1182
Contains the image style.
Definition: fabui.h:1388
RGB backgroundColor
Definition: fabui.h:1171
RGB textColor
Definition: fabui.h:1049
This is the base class for all controls. A control can have focus and is not activable.
Definition: fabui.h:828
void setScrollBar(uiScrollBar orientation, int position, int visible, int range, bool repaintScrollbar)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3390
RGB selectedTextColor
Definition: fabui.h:1570
Contains anchors enable/disable switches.
Definition: fabui.h:314
bool down()
Determines whether the switch button is down or up.
Definition: fabui.h:1117
RGB buttonColor
Definition: fabui.h:1684
uiFrame * rootWindow()
Gets a pointer to the root window.
Definition: fabui.h:1993
uiOrigin
Specifies window rectangle origin.
Definition: fabui.h:274
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1598
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:421
uiScrollBar
Scrollbar direction.
Definition: fabui.h:865
void setBitmap(Bitmap const *bitmap)
Sets image bitmap.
Definition: fabui.cpp:2690
Delegate onHide
Hide window event delegate.
Definition: fabui.h:765
RGB backgroundColor
Definition: fabui.h:1563
int groupIndex()
Determines radiobutton group index.
Definition: fabui.h:1869
uint16_t doubleClickTime
Definition: fabui.h:1914
Specifies current window state.
Definition: fabui.h:282
int selectedItem()
Represents currently selected item.
Definition: fabui.h:1748
char const * title()
Determines the window title.
Definition: fabui.h:723
uint8_t hasMaximizeButton
Definition: fabui.h:666
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:3167
This is a combination of a listbox and a single-line editable textbox.
Definition: fabui.h:1700
int HScrollBarPos()
Determines position of the horizontal scrollbar thumb.
Definition: fabui.h:924
uiWindow * setActiveWindow(uiWindow *value)
Sets the active window.
Definition: fabui.cpp:468
Delegate< Rect > onPaint
Paint event delegate.
Definition: fabui.h:1544
uint8_t LALT
Definition: fabui.h:132
RGB mouseOverBackgroundColor
Definition: fabui.h:1172
FontInfo const * textFont
Definition: fabui.h:1309
void setTitle(char const *value)
Sets window title.
Definition: fabui.cpp:1484
Contains the checkbox style.
Definition: fabui.h:1799
bool checked()
Determines whether the checkbox or radiobutton is checked.
Definition: fabui.h:1853
uint8_t allowEdit
Definition: fabui.h:1184
uiAnchors & anchors()
Allows to switch on or off anchors.
Definition: fabui.h:539
Contains the panel style.
Definition: fabui.h:1457
char const * text()
Gets current content of the text edit.
Definition: fabui.h:1246
uiMessageBoxResult
Return values from uiApp.messageBox() method.
Definition: fabui.h:1922
uiWindow(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:928
void setDown(bool value)
Sets button state of a switch button.
Definition: fabui.cpp:2137
Size clientSize()
Determines the client area size.
Definition: fabui.cpp:1122
Delegate onChange
Change event delegate.
Definition: fabui.h:1765
RGB mouseOverBackgroundColor
Definition: fabui.h:1802
RGB focusedBorderColor
Definition: fabui.h:307
Bitmap const * bitmap()
Gets image bitmap.
Definition: fabui.h:1427
void setGroupIndex(int value)
Sets radiobutton group index.
Definition: fabui.h:1876
Image control to display a static bitmap.
Definition: fabui.h:1394
uiFrame(uiWindow *parent, char const *title, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:1465
Delegate onChangeHScrollBar
Horizontal scrollbar change event delegate.
Definition: fabui.h:980