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 #include "freertos/timers.h"
40 
41 #include "fabglconf.h"
42 #include "fabutils.h"
43 #include "vgacontroller.h"
44 #include "canvas.h"
45 
46 
47 
48 /*
49 
50  *uiObject
51  *uiEvtHandler
52  *uiApp
53  *uiWindow
54  *uiFrame
55  *uiControl
56  *uiButton
57  *uiLabel
58  *uiImage
59  *uiPanel
60  *uiTextEdit
61  *uiScrollableControl
62  *uiPaintBox
63  *uiListBox
64  uiMemoEdit
65  *uiCheckBox
66  *uiComboBox
67  uiMenu
68  uiGauge
69  *uiSlider
70  uiSpinButton
71 
72 */
73 
74 
75 namespace fabgl {
76 
77 
78 
79 // increase in case of garbage between windows!
80 #define FABGLIB_UI_EVENTS_QUEUE_SIZE 128
81 
82 
83 
85 // uiEvent
86 
87 enum uiEventID {
88  UIEVT_NULL,
89  UIEVT_DEBUGMSG,
90  UIEVT_APPINIT,
91  UIEVT_GENPAINTEVENTS,
92  UIEVT_PAINT,
93  UIEVT_ACTIVATE,
94  UIEVT_DEACTIVATE,
95  UIEVT_MOUSEMOVE,
96  UIEVT_MOUSEWHEEL,
97  UIEVT_MOUSEBUTTONDOWN,
98  UIEVT_MOUSEBUTTONUP,
99  UIEVT_SETPOS,
100  UIEVT_SETSIZE,
101  UIEVT_RESHAPEWINDOW,
102  UIEVT_MOUSEENTER,
103  UIEVT_MOUSELEAVE,
104  UIEVT_MAXIMIZE, // Request for maximize
105  UIEVT_MINIMIZE, // Request for minimize
106  UIEVT_RESTORE, // restore from UIEVT_MAXIMIZE or UIEVT_MINIMIZE
107  UIEVT_SHOW,
108  UIEVT_HIDE,
109  UIEVT_SETFOCUS,
110  UIEVT_KILLFOCUS,
111  UIEVT_KEYDOWN,
112  UIEVT_KEYUP,
113  UIEVT_TIMER,
114  UIEVT_CLICK,
115  UIEVT_DBLCLICK,
116  UIEVT_EXITMODAL,
117  UIEVT_DESTROY,
118  UIEVT_CLOSE, // Request to close (frame Close button)
119 };
120 
121 
122 class uiEvtHandler;
123 class uiApp;
124 class uiWindow;
125 
126 
127 typedef void * uiTimerHandle;
128 
129 
133  uint8_t LALT : 1;
134  uint8_t RALT : 1;
135  uint8_t CTRL : 1;
136  uint8_t SHIFT : 1;
137  uint8_t GUI : 1;
138 };
139 
140 
144  uint8_t changedButton;
145 };
146 
147 
148 struct uiEvent {
149  uiEvtHandler * dest;
150  uiEventID id;
151 
152  union uiEventParams {
153  // event: UIEVT_MOUSEMOVE, UIEVT_MOUSEWHEEL, UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP, UIEVT_CLICK, UIEVT_DBLCLICK
154  uiMouseEventInfo mouse;
155  // event: UIEVT_PAINT, UIEVT_GENPAINTEVENTS, UIEVT_RESHAPEWINDOW
156  Rect rect;
157  // event: UIEVT_SETPOS
158  Point pos;
159  // event: UIEVT_SETSIZE
160  Size size;
161  // event: UIEVT_DEBUGMSG
162  char const * debugMsg;
163  // event: UIEVT_KEYDOWN, UIEVT_KEYUP
164  uiKeyEventInfo key;
165  // event: UIEVT_TIMER
166  uiTimerHandle timerHandle;
167  // event: UIEVT_EXITMODAL
168  int modalResult;
169  // event: UIEVT_SETFOCUS
170  uiWindow * oldFocused;
171  // event: UIEVT_KILLFOCUS
172  uiWindow * newFocused;
173 
174  uiEventParams() { }
175  } params;
176 
177  uiEvent() : dest(nullptr), id(UIEVT_NULL) { }
178  uiEvent(uiEvent const & e) { dest = e.dest; id = e.id; params = e.params; }
179  uiEvent(uiEvtHandler * dest_, uiEventID id_) : dest(dest_), id(id_) { }
180 };
181 
182 
183 
187 enum class uiOrientation {
188  Vertical,
189  Horizontal,
190 };
191 
192 
193 
195 // uiObject
196 
197 
199 struct uiObjectType {
200  uint32_t uiApp : 1;
201  uint32_t uiEvtHandler : 1;
202  uint32_t uiWindow : 1;
203  uint32_t uiFrame : 1;
204  uint32_t uiControl : 1;
205  uint32_t uiScrollableControl : 1;
206  uint32_t uiButton : 1;
207  uint32_t uiTextEdit : 1;
208  uint32_t uiLabel : 1;
209  uint32_t uiImage : 1;
210  uint32_t uiPanel : 1;
211  uint32_t uiPaintBox : 1;
212  uint32_t uiListBox : 1;
213  uint32_t uiComboBox : 1;
214  uint32_t uiCheckBox : 1;
215  uint32_t uiSlider : 1;
216 
219  { }
220 };
221 
222 
224 class uiObject {
225 
226 public:
227 
228  uiObject();
229 
230  virtual ~uiObject();
231 
237  uiObjectType & objectType() { return m_objectType; }
238 
239 private:
240  uiObjectType m_objectType;
241 };
242 
243 
244 
246 // uiEvtHandler
247 
248 
250 class uiEvtHandler : public uiObject {
251 
252 public:
253 
255 
256  virtual ~uiEvtHandler();
257 
258  virtual void processEvent(uiEvent * event);
259 
265  uiApp * app() { return m_app; }
266 
267 
268 protected:
269 
270  void setApp(uiApp * value) { m_app = value; }
271 
272 
273 private:
274 
275  uiApp * m_app;
276 };
277 
278 
279 
281 // uiWindow
282 
286 enum class uiOrigin {
287  Screen,
288  Parent,
289  Window,
290 };
291 
292 
295  uint8_t visible : 1;
296  uint8_t maximized : 1;
297  uint8_t minimized : 1;
298  uint8_t active : 1;
299 };
300 
301 
304  uint8_t activable : 1;
305  uint8_t focusable : 1;
307  uiWindowProps() :
308  activable(true),
309  focusable(false)
310  { }
311 };
312 
313 
317  RGB borderColor = RGB(2, 2, 2);
318  RGB activeBorderColor = RGB(2, 2, 3);
320  uint8_t borderSize = 3;
321  uint8_t focusedBorderSize = 1;
322 };
323 
324 
326 struct uiAnchors {
327  uint8_t left : 1;
328  uint8_t top : 1;
329  uint8_t right : 1;
330  uint8_t bottom : 1;
332  uiAnchors() : left(true), top(true), right(false), bottom(false) { }
333 };
334 
335 
337 class uiWindow : public uiEvtHandler {
338 
339 friend class uiApp;
340 
341 public:
342 
351  uiWindow(uiWindow * parent, const Point & pos, const Size & size, bool visible);
352 
353  virtual ~uiWindow();
354 
355  virtual void processEvent(uiEvent * event);
356 
364  uiWindow * next() { return m_next; }
365 
373  uiWindow * prev() { return m_prev; }
374 
380  uiWindow * firstChild() { return m_firstChild; }
381 
387  uiWindow * lastChild() { return m_lastChild; }
388 
394  bool hasChildren() { return m_firstChild != nullptr; }
395 
399  void bringOnTop();
400 
406  void bringAfter(uiWindow * insertionPoint);
407 
415  Point pos() { return m_pos; }
416 
422  Point clientPos();
423 
431  Size size() { return m_size; }
432 
438  Size clientSize();
439 
449  Rect rect(uiOrigin origin);
450 
458  virtual Rect clientRect(uiOrigin origin);
459 
467  uiWindowState state() { return m_state; }
468 
474  uiWindowProps & windowProps() { return m_windowProps; }
475 
481  uiWindowStyle & windowStyle() { return m_windowStyle; }
482 
488  uiWindow * parent() { return m_parent; }
489 
495  Point mouseDownPos() { return m_mouseDownPos; }
496 
505  Rect transformRect(Rect const & rect, uiWindow * baseWindow);
506 
512  void repaint(Rect const & rect);
513 
517  void repaint();
518 
526  bool isMouseOver() { return m_isMouseOver; }
527 
535  void exitModal(int modalResult);
536 
544  bool hasFocus();
545 
551  uiAnchors & anchors() { return m_anchors; }
552 
558  void setFocusIndex(int value) { m_focusIndex = value; }
559 
567  int focusIndex() { return m_focusIndex; }
568 
569 
570  // Delegates
571 
577  Delegate<> onClick;
578 
585  Delegate<> onDblClick;
586 
587 
588 protected:
589 
590  void addChild(uiWindow * child);
591  void insertAfter(uiWindow * child, uiWindow * underlyingChild);
592  void freeChildren();
593  void removeChild(uiWindow * child, bool freeChild = true);
594  void moveChildOnTop(uiWindow * child);
595  void moveAfter(uiWindow * child, uiWindow * underlyingChild);
596  bool isChild(uiWindow * window);
597 
598  Size sizeAtMouseDown() { return m_sizeAtMouseDown; }
599  Point posAtMouseDown() { return m_posAtMouseDown; }
600 
601  virtual Size minWindowSize() { return Size(0, 0); }
602 
603  void beginPaint(uiEvent * paintEvent, Rect const & clippingRect);
604 
605  void generatePaintEvents(Rect const & paintRect);
606  void reshape(Rect const & r);
607 
608  bool isFocusable();
609 
610 private:
611 
612  void paintWindow();
613  uiWindow * getChildWithFocusIndex(int focusIndex, int * maxIndex);
614 
615 
616  uiWindow * m_parent;
617 
618  Point m_pos;
619  Size m_size;
620 
621  // saved screen rect before Maximize or Minimize
622  Rect m_savedScreenRect;
623 
624  uiWindowState m_state;
625 
626  uiWindowProps m_windowProps;
627 
628  uiWindowStyle m_windowStyle;
629 
630  Point m_mouseDownPos; // mouse position when mouse down event has been received
631 
632  Point m_posAtMouseDown; // used to resize
633  Size m_sizeAtMouseDown; // used to resize
634 
635  bool m_isMouseOver; // true after mouse entered, false after mouse left
636 
637  uiAnchors m_anchors;
638 
639  int16_t m_focusIndex; // -1 = doesn't partecipate to focus trip
640 
641  // double linked list, order is: bottom (first items) -> up (last items)
642  uiWindow * m_next;
643  uiWindow * m_prev;
644  uiWindow * m_firstChild;
645  uiWindow * m_lastChild;
646 };
647 
648 
649 
651 // uiFrame
652 
653 
657 struct uiFrameStyle {
658  RGB backgroundColor = RGB(3, 3, 3);
661  RGB titleColor = RGB(0, 0, 0);
662  RGB activeTitleColor = RGB(0, 0, 0);
663  FontInfo const * titleFont = Canvas.getPresetFontInfoFromHeight(12, false);
664  RGB buttonColor = RGB(1, 1, 1);
665  RGB activeButtonColor = RGB(0, 0, 0);
668 };
669 
670 
674 struct uiFrameProps {
675  uint8_t resizeable : 1;
676  uint8_t moveable : 1;
677  uint8_t hasCloseButton : 1;
678  uint8_t hasMaximizeButton : 1;
679  uint8_t hasMinimizeButton : 1;
681  uiFrameProps() :
682  resizeable(true),
683  moveable(true),
684  hasCloseButton(true),
685  hasMaximizeButton(true),
686  hasMinimizeButton(true)
687  { }
688 };
689 
690 
691 enum class uiFrameItem : uint8_t {
692  None,
693  MoveArea,
694  TopLeftResize,
695  TopCenterResize,
696  TopRightResize,
697  CenterLeftResize,
698  CenterRightResize,
699  BottomLeftResize,
700  BottomCenterResize,
701  BottomRightResize,
702  CloseButton,
703  MaximizeButton,
704  MinimizeButton,
705 };
706 
707 
711 class uiFrame : public uiWindow {
712 
713 public:
714 
724  uiFrame(uiWindow * parent, char const * title, const Point & pos, const Size & size, bool visible = true);
725 
726  virtual ~uiFrame();
727 
728  virtual void processEvent(uiEvent * event);
729 
735  char const * title() { return m_title; }
736 
744  void setTitle(char const * value);
745 
753  void setTitleFmt(const char *format, ...);
754 
760  uiFrameStyle & frameStyle() { return m_frameStyle; }
761 
767  uiFrameProps & frameProps() { return m_frameProps; }
768 
769  Rect clientRect(uiOrigin origin);
770 
771 
772  // Delegates
773 
779  Delegate<> onShow;
780 
786  Delegate<> onHide;
787 
793  Delegate<> onResize;
794 
801  Delegate<uiTimerHandle> onTimer;
802 
803 
804 protected:
805 
806  Size minWindowSize();
807  int titleBarHeight();
808  Rect titleBarRect();
809 
810 private:
811 
812  void paintFrame();
813  int paintButtons(Rect const & bkgRect);
814  void movingCapturedMouse(int mouseX, int mouseY, bool mouseIsDown);
815  void movingFreeMouse(int mouseX, int mouseY);
816  uiFrameItem getFrameItemAt(int x, int y);
817  Rect getBtnRect(int buttonIndex);
818  void handleButtonsClick(int x, int y, bool doubleClick);
819  void drawTextWithEllipsis(FontInfo const * fontInfo, int X, int Y, char const * text, int maxX);
820  void drawReshapingBox(Rect boxRect);
821 
822 
823  static constexpr int CORNERSENSE = 10;
824 
825 
826  uiFrameStyle m_frameStyle;
827 
828  uiFrameProps m_frameProps;
829 
830  char * m_title;
831  int m_titleLength;
832 
833  uiFrameItem m_mouseDownFrameItem; // frame item on mouse down
834  uiFrameItem m_mouseMoveFrameItem; // frame item on mouse move
835 
836  Rect m_lastReshapingBox; // last reshaping box painted by drawReshapingBox(), (0,0,0,0) if there isn't any
837 
838 };
839 
840 
841 
843 // uiControl
844 
845 
849 class uiControl : public uiWindow {
850 
851 public:
852 
861  uiControl(uiWindow * parent, const Point & pos, const Size & size, bool visible);
862 
863  virtual ~uiControl();
864 
865  virtual void processEvent(uiEvent * event);
866 };
867 
868 
869 
871 // uiScrollableControl
872 
873 
879  uint8_t scrollBarSize = 11;
880 };
881 
882 
883 enum class uiScrollBarItem {
884  None,
885  LeftButton,
886  RightButton,
887  TopButton,
888  BottomButton,
889  HBar,
890  VBar,
891  PageUp,
892  PageDown,
893  PageLeft,
894  PageRight,
895 };
896 
897 
902 
903 public:
904 
913  uiScrollableControl(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
914 
915  virtual ~uiScrollableControl();
916 
917  virtual void processEvent(uiEvent * event);
918 
919  Rect clientRect(uiOrigin origin);
920 
926  uiScrollableControlStyle & scrollableControlStyle() { return m_scrollableControlStyle; }
927 
936  int HScrollBarPos() { return m_HScrollBarPosition; }
937 
945  int HScrollBarVisible() { return m_HScrollBarVisible; }
946 
955  int HScrollBarRange() { return m_HScrollBarRange; }
956 
965  int VScrollBarPos() { return m_VScrollBarPosition; }
966 
974  int VScrollBarVisible() { return m_VScrollBarVisible; }
975 
984  int VScrollBarRange() { return m_VScrollBarRange; }
985 
986 
987  // Delegates
988 
992  Delegate<> onChangeHScrollBar;
993 
997  Delegate<> onChangeVScrollBar;
998 
999 
1000 protected:
1001 
1011  virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar = true);
1012 
1013 
1014 private:
1015 
1016  void paintScrollableControl();
1017  void paintScrollBars();
1018  Rect getVScrollBarRects(Rect * topButton = nullptr, Rect * bottonButton = nullptr, Rect * bar = nullptr);
1019  Rect getHScrollBarRects(Rect * leftButton = nullptr, Rect * rightButton = nullptr, Rect * bar = nullptr);
1020  uiScrollBarItem getItemAt(int x, int y);
1021  void repaintScrollBar(uiOrientation orientation);
1022  void handleFreeMouseMove(int mouseX, int mouseY);
1023  void handleCapturedMouseMove(int mouseX, int mouseY);
1024  void handleButtonsScroll();
1025  void handlePageScroll();
1026 
1027  uiScrollableControlStyle m_scrollableControlStyle;
1028 
1029  int16_t m_HScrollBarPosition;
1030  int16_t m_HScrollBarVisible; // it means the "visible" area (how big is the bar)
1031  int16_t m_HScrollBarRange;
1032  int16_t m_VScrollBarPosition;
1033  int16_t m_VScrollBarVisible; // it means the "visible" area (how big is the bar)
1034  int16_t m_VScrollBarRange;
1035 
1036  // values updated by getVScrollBarRects() and getHScrollBarRects()
1037  int16_t m_HBarArea;
1038  int16_t m_VBarArea;
1039 
1040  int16_t m_mouseDownHScrollBarPosition;
1041  int16_t m_mouseDownVScrollBarPosition;
1042 
1043  uiScrollBarItem m_mouseOverItem;
1044 
1045  // a timer is active while mouse is down and the mouse is over a button
1046  uiTimerHandle m_scrollTimer;
1047 };
1048 
1049 
1050 
1052 // uiButton
1053 
1054 
1057  RGB backgroundColor = RGB(2, 2, 2);
1061  RGB textColor = RGB(0, 0, 0);
1062  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1063  uint8_t bitmapTextSpace = 4;
1064  Bitmap const * bitmap = nullptr;
1065  Bitmap const * downBitmap = nullptr;
1066 };
1067 
1068 
1072 enum class uiButtonKind {
1073  Button,
1074  Switch,
1075 };
1076 
1077 
1079 class uiButton : public uiControl {
1080 
1081 public:
1082 
1093  uiButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, uiButtonKind kind = uiButtonKind::Button, bool visible = true);
1094 
1095  virtual ~uiButton();
1096 
1097  virtual void processEvent(uiEvent * event);
1098 
1106  void setText(char const * value);
1107 
1113  char const * text() { return m_text; }
1114 
1120  uiButtonStyle & buttonStyle() { return m_buttonStyle; }
1121 
1129  bool down() { return m_down; }
1130 
1138  void setDown(bool value);
1139 
1140 
1141  // Delegates
1142 
1148  Delegate<> onChange;
1149 
1150 
1151 private:
1152 
1153  void paintButton();
1154  void paintContent(Rect const & rect);
1155 
1156  void trigger();
1157 
1158 
1159  uiButtonStyle m_buttonStyle;
1160 
1161  char * m_text;
1162  int m_textExtent; // calculated by setText(). TODO: changing font doesn't update m_textExtent!
1163 
1164  bool m_down;
1165 
1166  uiButtonKind m_kind;
1167 
1168 };
1169 
1170 
1171 
1173 // uiTextEdit
1174 // single line text edit
1175 
1176 
1183  RGB backgroundColor = RGB(2, 2, 2);
1186  RGB textColor = RGB(0, 0, 0);
1187  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1188 };
1189 
1190 
1195  uint8_t hasCaret : 1;
1196  uint8_t allowEdit : 1;
1198  uiTextEditProps()
1199  : hasCaret(true),
1200  allowEdit(true)
1201  {
1202  }
1203 };
1204 
1205 
1211 class uiTextEdit : public uiControl {
1212 
1213 public:
1214 
1224  uiTextEdit(uiWindow * parent, char const * text, const Point & pos, const Size & size, bool visible = true);
1225 
1226  virtual ~uiTextEdit();
1227 
1228  virtual void processEvent(uiEvent * event);
1229 
1235  uiTextEditStyle & textEditStyle() { return m_textEditStyle; }
1236 
1242  uiTextEditProps & textEditProps() { return m_textEditProps; }
1243 
1251  void setText(char const * value);
1252 
1258  char const * text() { return m_text; }
1259 
1260 
1261  // Delegates
1262 
1266  Delegate<> onChange;
1267 
1268 
1269 protected:
1270 
1271  virtual Rect getEditRect();
1272 
1273 private:
1274 
1275  void paintTextEdit();
1276  void paintContent();
1277 
1278  uint8_t const * getCharInfo(char ch, int * width);
1279  int charColumnToWindowX(int col);
1280  void updateCaret();
1281  void moveCursor(int col, int selCol);
1282  int getColFromMouseX(int mouseX);
1283  void handleKeyDown(uiKeyEventInfo key);
1284  void checkAllocatedSpace(int requiredLength);
1285  void insert(char c);
1286  void removeSel();
1287  int getWordPosAtLeft();
1288  int getWordPosAtRight();
1289  void selectWordAt(int mouseX);
1290 
1291 
1292  uiTextEditStyle m_textEditStyle;
1293  uiTextEditProps m_textEditProps;
1294 
1295  char * m_text;
1296  int m_textLength; // text length NOT including ending zero
1297  int m_textSpace; // actual space allocated including ending zero
1298 
1299  // rectangle where text will be painted (this is also the text clipping rect)
1300  Rect m_contentRect; // updated on painting
1301 
1302  // where text starts to be painted. Values less than m_contentRect.X1 are used to show characters which do not fit in m_contentRect
1303  int m_viewX;
1304 
1305  // character index of cursor position (0 = at first char)
1306  int m_cursorCol;
1307 
1308  // character index at start of selection (not included if < m_cursorCol, included if > m_cursorCol)
1309  int m_selCursorCol;
1310 
1311 };
1312 
1313 
1314 
1316 // uiLabel
1317 
1318 
1321  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1322  RGB backgroundColor = RGB(3, 3, 3);
1323  RGB textColor = RGB(0, 0, 0);
1324 };
1325 
1326 
1328 class uiLabel : public uiControl {
1329 
1330 public:
1331 
1341  uiLabel(uiWindow * parent, char const * text, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1342 
1343  virtual ~uiLabel();
1344 
1345  virtual void processEvent(uiEvent * event);
1346 
1354  void setText(char const * value);
1355 
1363  void setTextFmt(const char *format, ...);
1364 
1370  char const * text() { return m_text; }
1371 
1377  uiLabelStyle & labelStyle() { return m_labelStyle; }
1378 
1384  void update();
1385 
1386 
1387 private:
1388 
1389  void paintLabel();
1390 
1391 
1392  char * m_text;
1393 
1394  uiLabelStyle m_labelStyle;
1395 
1396  uint16_t m_textExtent; // calculated by setText()
1397 
1398  uint8_t m_autoSize;
1399 
1400 };
1401 
1402 
1403 
1405 // uiImage
1406 
1407 
1410  RGB backgroundColor = RGB(3, 3, 3);
1411 };
1412 
1413 
1415 class uiImage : public uiControl {
1416 
1417 public:
1418 
1428  uiImage(uiWindow * parent, Bitmap const * bitmap, const Point & pos, const Size & size = Size(0, 0), bool visible = true);
1429 
1430  virtual ~uiImage();
1431 
1432  virtual void processEvent(uiEvent * event);
1433 
1441  void setBitmap(Bitmap const * bitmap);
1442 
1448  Bitmap const * bitmap() { return m_bitmap; }
1449 
1455  uiImageStyle & imageStyle() { return m_imageStyle; }
1456 
1457 
1458 private:
1459 
1460  void paintImage();
1461 
1462 
1463  Bitmap const * m_bitmap;
1464 
1465  uiImageStyle m_imageStyle;
1466 
1467  bool m_autoSize;
1468 
1469 };
1470 
1471 
1472 
1474 // uiPanel
1475 
1476 
1479  RGB backgroundColor = RGB(2, 2, 2);
1480 };
1481 
1482 
1484 class uiPanel : public uiControl {
1485 
1486 public:
1487 
1496  uiPanel(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1497 
1498  virtual ~uiPanel();
1499 
1500  virtual void processEvent(uiEvent * event);
1501 
1507  uiPanelStyle & panelStyle() { return m_panelStyle; }
1508 
1509 
1510 private:
1511 
1512  void paintPanel();
1513 
1514 
1515  uiPanelStyle m_panelStyle;
1516 };
1517 
1518 
1519 
1521 // uiPaintBox
1522 
1523 
1526  RGB backgroundColor = RGB(2, 2, 2);
1527 };
1528 
1529 
1532 
1533 public:
1534 
1543  uiPaintBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1544 
1545  virtual ~uiPaintBox();
1546 
1547  virtual void processEvent(uiEvent * event);
1548 
1554  uiPaintBoxStyle & paintBoxStyle() { return m_paintBoxStyle; }
1555 
1557 
1558  // Delegates
1559 
1565  Delegate<Rect> onPaint;
1566 
1567 
1568 private:
1569 
1570  void paintPaintBox();
1571 
1572 
1573  uiPaintBoxStyle m_paintBoxStyle;
1574 };
1575 
1576 
1577 
1579 // uiListBox
1580 
1581 
1584  RGB backgroundColor = RGB(2, 2, 2);
1588  int itemHeight = 16;
1589  FontInfo const * textFont = Canvas.getPresetFontInfoFromHeight(14, false);
1590  RGB textColor = RGB(0, 0, 0);
1592 };
1593 
1594 
1597 
1598 public:
1599 
1608  uiListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true);
1609 
1610  virtual ~uiListBox();
1611 
1612  virtual void processEvent(uiEvent * event);
1613 
1619  uiListBoxStyle & listBoxStyle() { return m_listBoxStyle; }
1620 
1629  StringList & items() { return m_items; }
1630 
1636  int firstSelectedItem();
1637 
1643  int lastSelectedItem();
1644 
1652  void selectItem(int index, bool add = false, bool range = false);
1653 
1657  void deselectAll();
1658 
1659 
1660  // Delegates
1661 
1667  Delegate<> onChange;
1668 
1672  Delegate<> onKillFocus;
1673 
1677  Delegate<uiKeyEventInfo> onKeyUp;
1678 
1679 
1680 protected:
1681 
1682  void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar);
1683 
1684 private:
1685 
1686  void paintListBox();
1687  int getItemAtMousePos(int mouseX, int mouseY);
1688  void handleMouseDown(int mouseX, int mouseY);
1689  void handleKeyDown(uiKeyEventInfo key);
1690 
1691 
1692  uiListBoxStyle m_listBoxStyle;
1693  StringList m_items;
1694  int m_firstVisibleItem; // the item on the top
1695 };
1696 
1697 
1699 // uiComboBox
1700 
1701 
1705  RGB buttonColor = RGB(2, 2, 2);
1706 };
1707 
1708 
1711  uint8_t openOnFocus : 1;
1713  uiComboBoxProps()
1714  : openOnFocus(true)
1715  {
1716  }
1717 };
1718 
1719 
1721 class uiComboBox : public uiTextEdit
1722 {
1723 
1724 public:
1725 
1735  uiComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true);
1736 
1737  ~uiComboBox();
1738 
1739  virtual void processEvent(uiEvent * event);
1740 
1748  StringList & items() { return m_listBox.items(); }
1749 
1755  uiComboBoxStyle & comboBoxStyle() { return m_comboBoxStyle; }
1756 
1762  uiListBoxStyle & listBoxStyle() { return m_listBox.listBoxStyle(); }
1763 
1769  uiComboBoxProps & comboBoxProps() { return m_comboBoxProps; }
1770 
1776  int selectedItem() { return m_listBox.firstSelectedItem(); }
1777 
1783  void selectItem(int index);
1784 
1785 
1786  // Delegates
1787 
1793  Delegate<> onChange;
1794 
1795 
1796 protected:
1797 
1798  virtual Rect getEditRect();
1799 
1800 
1801 private:
1802 
1803  void paintComboBox();
1804  Rect getButtonRect();
1805  int buttonWidth();
1806  void openListBox();
1807  void closeListBox();
1808  void switchListBox();
1809  void updateTextEdit();
1810 
1811 
1812  uiListBox m_listBox;
1813  int m_listHeight;
1814  uiComboBoxStyle m_comboBoxStyle;
1815  uiComboBoxProps m_comboBoxProps;
1816 
1817 
1818 };
1819 
1820 
1821 
1823 // uiCheckBox
1824 
1825 
1828  RGB backgroundColor = RGB(2, 2, 2);
1831  RGB foregroundColor = RGB(0, 0, 0);
1832 };
1833 
1834 
1838 enum class uiCheckBoxKind : int8_t {
1839  CheckBox,
1840  RadioButton,
1841 };
1842 
1843 
1850 class uiCheckBox : public uiControl {
1851 
1852 public:
1853 
1863  uiCheckBox(uiWindow * parent, const Point & pos, const Size & size, uiCheckBoxKind kind = uiCheckBoxKind::CheckBox, bool visible = true);
1864 
1865  virtual ~uiCheckBox();
1866 
1867  virtual void processEvent(uiEvent * event);
1868 
1874  uiCheckBoxStyle & checkBoxStyle() { return m_checkBoxStyle; }
1875 
1881  bool checked() { return m_checked; }
1882 
1890  void setChecked(bool value);
1891 
1897  int groupIndex() { return m_groupIndex; }
1898 
1904  void setGroupIndex(int value) { m_groupIndex = value; }
1905 
1906 
1907  // Delegates
1908 
1914  Delegate<> onChange;
1915 
1916 
1917 private:
1918 
1919  void paintCheckBox();
1920  void trigger();
1921  void unCheckGroup();
1922 
1923 
1924  uiCheckBoxStyle m_checkBoxStyle;
1925  bool m_checked;
1926  uiCheckBoxKind m_kind;
1927  int16_t m_groupIndex; // -1 = no group
1928 
1929 };
1930 
1931 
1932 
1934 // uiSlider
1935 
1936 
1939  RGB backgroundColor = RGB(3, 3, 3);
1940  RGB slideColor = RGB(0, 2, 2);
1941  RGB rangeColor = RGB(0, 2, 3);
1942  RGB gripColor = RGB(0, 0, 3);
1943  RGB ticksColor = RGB(3, 3, 3);
1944 };
1945 
1946 
1948 class uiSlider : public uiControl {
1949 
1950 public:
1951 
1961  uiSlider(uiWindow * parent, const Point & pos, const Size & size, uiOrientation orientation, bool visible = true);
1962 
1963  virtual ~uiSlider();
1964 
1965  virtual void processEvent(uiEvent * event);
1966 
1972  uiSliderStyle & sliderStyle() { return m_sliderStyle; }
1973 
1979  int position() { return m_position; }
1980 
1986  void setPosition(int value);
1987 
1993  int min() { return m_min; }
1994 
2000  int max() { return m_max; }
2001 
2009  void setup(int min, int max, int ticksFrequency);
2010 
2011 
2017  Delegate<> onChange;
2018 
2019 
2020 private:
2021 
2022  void paintSlider();
2023  Rect getGripRect();
2024  void moveGripTo(int x, int y);
2025  void handleKeyDown(uiKeyEventInfo key);
2026 
2027 
2028  uiSliderStyle m_sliderStyle;
2029  uiOrientation m_orientation;
2030 
2031  int16_t m_position;
2032  int16_t m_min;
2033  int16_t m_max;
2034  int16_t m_ticksFrequency;
2035 };
2036 
2037 
2038 
2039 
2040 
2042 // uiApp
2043 
2044 
2046 struct uiAppProps {
2047  uint16_t caretBlinkingTime = 500;
2048  uint16_t doubleClickTime = 250;
2049  bool realtimeReshaping = false;
2050 };
2051 
2052 
2057  Cancel,
2058  Button1,
2059  Button2,
2060  Button3,
2061 };
2062 
2063 
2067 enum class uiMessageBoxIcon {
2068  None,
2069  Question,
2070  Info,
2071  Warning,
2072  Error,
2073 };
2074 
2075 
2082 class uiApp : public uiEvtHandler {
2083 
2084 public:
2085 
2086  uiApp();
2087 
2088  virtual ~uiApp();
2089 
2095  void run();
2096 
2104  bool postEvent(uiEvent const * event);
2105 
2113  bool insertEvent(uiEvent const * event);
2114 
2115  void postDebugMsg(char const * msg);
2116 
2117  virtual void processEvent(uiEvent * event);
2118 
2127  uiFrame * rootWindow() { return m_rootWindow; }
2128 
2137  uiWindow * activeWindow() { return m_activeWindow; }
2138 
2148  uiWindow * setActiveWindow(uiWindow * value);
2149 
2162  uiWindow * focusedWindow() { return m_focusedWindow; }
2163 
2174  uiWindow * setFocusedWindow(uiWindow * value);
2175 
2186  uiWindow * moveFocus(int delta);
2187 
2188  void captureMouse(uiWindow * window);
2189 
2197  uiWindow * capturedMouseWindow() { return m_capturedMouseWindow; }
2198 
2204  void repaintWindow(uiWindow * window);
2205 
2211  void repaintRect(Rect const & rect);
2212 
2220  void moveWindow(uiWindow * window, int x, int y);
2221 
2229  void resizeWindow(uiWindow * window, int width, int height);
2230 
2237  void resizeWindow(uiWindow * window, Size size);
2238 
2245  void reshapeWindow(uiWindow * window, Rect const & rect);
2246 
2254  uiWindow * screenToWindow(Point & point);
2255 
2262  void showWindow(uiWindow * window, bool value);
2263 
2274  int showModalWindow(uiWindow * window);
2275 
2282  void maximizeWindow(uiWindow * window, bool value);
2283 
2290  void minimizeWindow(uiWindow * window, bool value);
2291 
2292  void combineMouseMoveEvents(bool value) { m_combineMouseMoveEvents = value; }
2293 
2294  void showCaret(uiWindow * window);
2295 
2296  void setCaret(bool value);
2297 
2298  void setCaret(Point const & pos);
2299 
2300  void setCaret(Rect const & rect);
2301 
2313  uiTimerHandle setTimer(uiEvtHandler * dest, int periodMS);
2314 
2322  void killTimer(uiTimerHandle handle);
2323 
2329  uiAppProps & appProps() { return m_appProps; }
2330 
2336  void destroyWindow(uiWindow * window);
2337 
2338  void cleanWindowReferences(uiWindow * window);
2339 
2352  uiMessageBoxResult messageBox(char const * title, char const * text, char const * button1Text, char const * button2Text = nullptr, char const * button3Text = nullptr, uiMessageBoxIcon icon = uiMessageBoxIcon::Question);
2353 
2354 
2358  virtual void init();
2359 
2360  // delegates
2361 
2368  Delegate<uiTimerHandle> onTimer;
2369 
2370 protected:
2371 
2372  bool getEvent(uiEvent * event, int timeOutMS);
2373  bool peekEvent(uiEvent * event, int timeOutMS);
2374 
2375 
2376 private:
2377 
2378  void preprocessEvent(uiEvent * event);
2379  void preprocessMouseEvent(uiEvent * event);
2380  void preprocessKeyboardEvent(uiEvent * event);
2381  void filterModalEvent(uiEvent * event);
2382 
2383  static void timerFunc(TimerHandle_t xTimer);
2384 
2385  void blinkCaret(bool forceOFF = false);
2386  void suspendCaret(bool value);
2387 
2388 
2389  uiAppProps m_appProps;
2390 
2391  QueueHandle_t m_eventsQueue;
2392 
2393  uiFrame * m_rootWindow;
2394 
2395  uiWindow * m_activeWindow; // foreground window. Also gets keyboard events (other than focused window)
2396 
2397  uiWindow * m_focusedWindow; // window that captures keyboard events (other than active window)
2398 
2399  uiWindow * m_capturedMouseWindow; // window that has captured mouse
2400 
2401  uiWindow * m_freeMouseWindow; // window where mouse is over
2402 
2403  uiWindow * m_modalWindow; // current modal window
2404 
2405  bool m_combineMouseMoveEvents;
2406 
2407  uiWindow * m_caretWindow; // nullptr = caret is not visible
2408  Rect m_caretRect; // caret rect relative to m_caretWindow
2409  uiTimerHandle m_caretTimer;
2410  int m_caretInvertState; // -1 = suspended, 1 = rect reversed (cat visible), 0 = rect not reversed (caret invisible)
2411 
2412  int m_lastMouseUpTimeMS; // time (MS) at mouse up. Used to measure double clicks
2413  Point m_lastMouseUpPos; // screen position of last mouse up
2414 };
2415 
2416 
2417 
2418 
2419 } // end of namespace
2420 
2421 
2422 
Bitmap const * bitmap
Definition: fabui.h:1064
uiWindowStyle & windowStyle()
Sets or gets window style.
Definition: fabui.h:481
void selectItem(int index, bool add=false, bool range=false)
Selects a listbox item.
Definition: fabui.cpp:3312
uiCheckBoxKind
Specifies the combobox behaviour.
Definition: fabui.h:1838
VirtualKey VK
Definition: fabui.h:132
FontInfo const * textFont
Definition: fabui.h:1062
uint8_t SHIFT
Definition: fabui.h:136
bool hasFocus()
Determines whether this window or control has focus.
Definition: fabui.cpp:1435
uiApp * app()
Determines the app that owns this object.
Definition: fabui.h:265
char const * text()
Determines button text.
Definition: fabui.h:1113
Definition: vgacontroller.h:394
uiImageStyle & imageStyle()
Sets or gets image style.
Definition: fabui.h:1455
RGB backgroundColor
Definition: fabui.h:1526
RGB downBackgroundColor
Definition: fabui.h:1058
uint8_t hasMinimizeButton
Definition: fabui.h:679
virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar=true)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:2902
uiPanelStyle & panelStyle()
Sets or gets panel style.
Definition: fabui.h:1507
void moveWindow(uiWindow *window, int x, int y)
Moves a window.
Definition: fabui.cpp:592
Delegate onChange
Slider changed event delegate.
Definition: fabui.h:2017
uiWindow * capturedMouseWindow()
Determines which window is capturing mouse.
Definition: fabui.h:2197
Represents an RGB color.
Definition: vgacontroller.h:239
uiComboBoxStyle & comboBoxStyle()
Sets or gets combobox style.
Definition: fabui.h:1755
int VScrollBarRange()
Determines vertical scrollbar range.
Definition: fabui.h:984
uiWindow * screenToWindow(Point &point)
Determines which window a point belongs to.
Definition: fabui.cpp:396
A frame is a window with a title bar, maximize/minimize/close buttons and that is resizeable or movea...
Definition: fabui.h:711
Contains details about the key event.
Definition: fabui.h:131
void setText(char const *value)
Sets button text.
Definition: fabui.cpp:2056
void setup(int min, int max, int ticksFrequency)
Sets minimum, maximum position and ticks frequency.
Definition: fabui.cpp:3820
int HScrollBarVisible()
Determines horizontal scrollbar visible portion (aka thumb size) of the scrollable content...
Definition: fabui.h:945
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:2368
void setPosition(int value)
Sets the slider position.
Definition: fabui.cpp:3810
void minimizeWindow(uiWindow *window, bool value)
Minimizes or restores a window.
Definition: fabui.cpp:678
RGB backgroundColor
Definition: fabui.h:1410
uiTimerHandle setTimer(uiEvtHandler *dest, int periodMS)
Setups a timer.
Definition: fabui.cpp:695
RGB mouseOverBackgroundColor
Definition: fabui.h:1059
void repaintRect(Rect const &rect)
Repaints a screen area.
Definition: fabui.cpp:583
uint8_t right
Definition: fabui.h:329
Represents the whole application base class.
Definition: fabui.h:2082
void resizeWindow(uiWindow *window, int width, int height)
Resizes a window.
Definition: fabui.cpp:598
void selectItem(int index)
Selects an item.
Definition: fabui.cpp:3503
uint8_t minimized
Definition: fabui.h:297
uiPaintBoxStyle & paintBoxStyle()
Sets or gets paintbox style.
Definition: fabui.h:1554
Bitmap const * downBitmap
Definition: fabui.h:1065
uint8_t left
Definition: fabui.h:327
virtual void init()
Method to inherit to implement an application.
Definition: fabui.cpp:415
A scrollable control is a control with optionally vertical and/or horizontal scrollbars.
Definition: fabui.h:901
RGB borderColor
Definition: fabui.h:317
uiWindow * setFocusedWindow(uiWindow *value)
Sets the focused window (control)
Definition: fabui.cpp:517
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:420
Base class for all visible UI elements (Frames and Controls)
Definition: fabui.h:337
char const * text()
Determines label text.
Definition: fabui.h:1370
uiLabelStyle & labelStyle()
Sets or gets label style.
Definition: fabui.h:1377
bool isMouseOver()
Determines whether the mouse is over this window.
Definition: fabui.h:526
RGB activeTitleBackgroundColor
Definition: fabui.h:660
RGB mouseOverScrollBarForegroundColor
Definition: fabui.h:878
Rect transformRect(Rect const &rect, uiWindow *baseWindow)
Transforms rectangle origins from current window to another one.
Definition: fabui.cpp:1082
void maximizeWindow(uiWindow *window, bool value)
Maximizes or restores a window.
Definition: fabui.cpp:671
uiWindow * lastChild()
Gets last child.
Definition: fabui.h:387
Delegate onChange
Change event delegate.
Definition: fabui.h:1914
uiWindow * activeWindow()
Gets a pointer to the currently active window.
Definition: fabui.h:2137
FontInfo const * titleFont
Definition: fabui.h:663
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:1242
uint8_t bottom
Definition: fabui.h:330
Contains a list of selectable items.
Definition: fabui.h:1596
uint8_t top
Definition: fabui.h:328
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:2706
uint8_t focusable
Definition: fabui.h:305
RGB checkedBackgroundColor
Definition: fabui.h:1829
Delegate onChange
Text edit event delegate.
Definition: fabui.h:1266
Contains the listbox style.
Definition: fabui.h:1583
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1762
Contains the slider style.
Definition: fabui.h:1938
RGB selectedBackgroundColor
Definition: fabui.h:1586
Point pos()
Determines the window position relative to parent window.
Definition: fabui.h:415
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:801
RGB titleColor
Definition: fabui.h:661
uiControl(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:2001
RGB scrollBarForegroundColor
Definition: fabui.h:877
uiWindow * parent()
Determines the parent window.
Definition: fabui.h:488
RGB activeTitleColor
Definition: fabui.h:662
uint8_t borderSize
Definition: fabui.h:320
Base class of all UI elements that can receive events.
Definition: fabui.h:250
RGB focusedBackgroundColor
Definition: fabui.h:1185
Sets or gets text edit style.
Definition: fabui.h:1182
uint8_t GUI
Definition: fabui.h:137
void deselectAll()
Deselects all selected items.
Definition: fabui.cpp:3345
Contains the paintbox style.
Definition: fabui.h:1525
int lastSelectedItem()
Gets the last selected item.
Definition: fabui.cpp:3415
int HScrollBarRange()
Determines horizontal scrollbar range.
Definition: fabui.h:955
Properties of the combobox.
Definition: fabui.h:1710
uiWindow * moveFocus(int delta)
Move focus to a control with current focus index plus a delta.
Definition: fabui.cpp:551
uiMessageBoxIcon
Icon displayed by the uiApp.messageBox() method.
Definition: fabui.h:2067
FontInfo const * textFont
Definition: fabui.h:1589
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:1484
Represents a checkbox or a radiobutton.
Definition: fabui.h:1850
uint8_t resizeable
Definition: fabui.h:675
RGB mouseOverBackgroundButtonColor
Definition: fabui.h:666
void showWindow(uiWindow *window, bool value)
Makes a window visible or invisible.
Definition: fabui.cpp:619
uint8_t hasCaret
Definition: fabui.h:1195
virtual Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1120
int VScrollBarPos()
Determines position of the vertical scrollbar thumb.
Definition: fabui.h:965
Point clientPos()
Determines position of the client area.
Definition: fabui.cpp:1133
void bringOnTop()
Brings this window on top.
Definition: fabui.cpp:1059
bool realtimeReshaping
Definition: fabui.h:2049
Delegate onKillFocus
Kill focus event delegate.
Definition: fabui.h:1672
void reshapeWindow(uiWindow *window, Rect const &rect)
Reshapes a window.
Definition: fabui.cpp:611
Delegate onChange
Button changed event delegate.
Definition: fabui.h:1148
void setText(char const *value)
Sets label text.
Definition: fabui.cpp:2633
RGB focusedSelectedBackgroundColor
Definition: fabui.h:1587
void destroyWindow(uiWindow *window)
Destroys a window.
Definition: fabui.cpp:786
uiTextEdit(uiWindow *parent, char const *text, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2176
uiWindow * prev()
Gets previous sibling.
Definition: fabui.h:373
uiFrameProps & frameProps()
Sets or gets frame properties.
Definition: fabui.h:767
Properties of the application.
Definition: fabui.h:2046
Contains the scrollable control style.
Definition: fabui.h:875
Represents a button control. A button can have text and optionally a bitmap.
Definition: fabui.h:1079
uiButtonKind
Specifies the button kind.
Definition: fabui.h:1072
uiAppProps & appProps()
Sets or gets application properties.
Definition: fabui.h:2329
void update()
Updates the label content.
Definition: fabui.cpp:2656
Contains the label style.
Definition: fabui.h:1320
void bringAfter(uiWindow *insertionPoint)
Brings this window after another one.
Definition: fabui.cpp:1065
RGB rangeColor
Definition: fabui.h:1941
Describes mouse absolute position, scroll wheel delta and buttons status.
Definition: fabutils.h:206
uint8_t moveable
Definition: fabui.h:676
Point mouseDownPos()
Determines mouse position when left button was down.
Definition: fabui.h:495
uint16_t caretBlinkingTime
Definition: fabui.h:2047
int position()
Determines slider position.
Definition: fabui.h:1979
uiFrameStyle & frameStyle()
Sets or gets frame style.
Definition: fabui.h:760
RGB backgroundColor
Definition: fabui.h:1322
Rect rect(uiOrigin origin)
Determines the window bounding box.
Definition: fabui.cpp:1104
uiWindowState state()
Determines the window state.
Definition: fabui.h:467
int focusIndex()
Determines the focus index (aka tab-index)
Definition: fabui.h:567
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:366
RGB backgroundColor
Definition: fabui.h:1479
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:1677
Size size()
Determines the window size.
Definition: fabui.h:431
Contains the window style.
Definition: fabui.h:315
Properties of the frame.
Definition: fabui.h:674
void setFocusIndex(int value)
Sets the focus index (aka tab-index)
Definition: fabui.h:558
This file contains some utility classes and functions.
RGB activeBorderColor
Definition: fabui.h:318
RGB textColor
Definition: fabui.h:1323
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:2613
Definition: canvas.cpp:47
RGB foregroundColor
Definition: fabui.h:1831
uint8_t activable
Definition: fabui.h:304
CursorName
This enum defines a set of predefined mouse cursors.
Definition: vgacontroller.h:392
uiWindow * firstChild()
Gets first child.
Definition: fabui.h:380
void run()
Initialize application and executes the main event loop.
Definition: fabui.cpp:191
void repaint()
Repaints this window.
Definition: fabui.cpp:1098
Specifies the object type.
Definition: fabui.h:199
Contains some window options.
Definition: fabui.h:303
Delegate onChangeVScrollBar
Vertical scrollbar change event delegate.
Definition: fabui.h:997
uiPanel(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2772
uint8_t visible
Definition: fabui.h:295
void exitModal(int modalResult)
Exits from a modal window.
Definition: fabui.cpp:1427
StringList & items()
A list of strings representing the listbox content.
Definition: fabui.h:1629
uint8_t active
Definition: fabui.h:298
MouseStatus status
Definition: fabui.h:143
Contains the button style.
Definition: fabui.h:1056
RGB backgroundColor
Definition: fabui.h:1828
Delegate onChange
Change event delegate.
Definition: fabui.h:1667
RGB mouseDownBackgroundColor
Definition: fabui.h:1060
RGB scrollBarBackgroundColor
Definition: fabui.h:876
void repaintWindow(uiWindow *window)
Repaints a window.
Definition: fabui.cpp:577
uint8_t hasCloseButton
Definition: fabui.h:677
Represents a rectangle.
Definition: fabutils.h:158
void setText(char const *value)
Replaces current text.
Definition: fabui.cpp:2203
uint8_t changedButton
Definition: fabui.h:144
uiWindowProps & windowProps()
Sets or gets window properties.
Definition: fabui.h:474
uiScrollableControl(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2877
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:1235
uiComboBoxProps & comboBoxProps()
Sets or gets combobox properties.
Definition: fabui.h:1769
void setTitleFmt(const char *format,...)
Sets window title as formatted text.
Definition: fabui.cpp:1497
uiScrollableControlStyle & scrollableControlStyle()
Sets or gets control style.
Definition: fabui.h:926
static FontInfo const * getPresetFontInfoFromHeight(int height, bool fixedWidth)
Gets the font info that best fits the specified height.
Definition: canvas.cpp:493
uiSliderStyle & sliderStyle()
Sets or gets slider style.
Definition: fabui.h:1972
Represents a text edit control.
Definition: fabui.h:1211
uint8_t scrollBarSize
Definition: fabui.h:879
uiComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3469
uint8_t RALT
Definition: fabui.h:134
Delegate onShow
Show window event delegate.
Definition: fabui.h:779
void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3424
Contains details about the mouse event.
Definition: fabui.h:142
int max()
Gets maximum position.
Definition: fabui.h:2000
RGB buttonColor
Definition: fabui.h:664
RGB backgroundColor
Definition: fabui.h:1057
int VScrollBarVisible()
Determines vertical scrollbar visible portion (aka thumb size) of the scrollable content.
Definition: fabui.h:974
Delegate onDblClick
Mouse double click event delegate4.
Definition: fabui.h:585
StringList & items()
A list of strings representing items of the combobox.
Definition: fabui.h:1748
uiWindow * focusedWindow()
Gets the focused window (control)
Definition: fabui.h:2162
int showModalWindow(uiWindow *window)
Makes a window visible and handles it has a modal window.
Definition: fabui.cpp:627
uiPaintBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:2823
RGB textColor
Definition: fabui.h:1590
uiCheckBoxStyle & checkBoxStyle()
Sets or gets checkbox style.
Definition: fabui.h:1874
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:825
void killTimer(uiTimerHandle handle)
Kills a timer.
Definition: fabui.cpp:703
uiButtonStyle & buttonStyle()
Sets or gets button style.
Definition: fabui.h:1120
void setChecked(bool value)
Sets current checkbox or radiobutton checked status.
Definition: fabui.cpp:3751
uint8_t CTRL
Definition: fabui.h:135
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1525
bool hasChildren()
Determines whether this window has children.
Definition: fabui.h:394
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:224
uiObjectType & objectType()
Determines the object type.
Definition: fabui.h:237
A paintbox control allows applications to perform custom drawings providing uiPaintBox.onPaint delegate. A paintbox can have horizontal and vertical scrollbars.
Definition: fabui.h:1531
int firstSelectedItem()
Gets the first selected item.
Definition: fabui.cpp:3405
RGB activeButtonColor
Definition: fabui.h:665
uint8_t bitmapTextSpace
Definition: fabui.h:1063
RGB titleBackgroundColor
Definition: fabui.h:659
Represents a bidimensional size.
Definition: fabutils.h:143
uiWindow * next()
Gets next sibling.
Definition: fabui.h:364
FontInfo const * textFont
Definition: fabui.h:1187
CursorName defaultCursor
Definition: fabui.h:316
RGB textColor
Definition: fabui.h:1186
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:577
int min()
Gets minimum position.
Definition: fabui.h:1993
uiListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3220
RGB backgroundColor
Definition: fabui.h:658
Definition: fabui.h:657
uint8_t maximized
Definition: fabui.h:296
uiSlider(uiWindow *parent, const Point &pos, const Size &size, uiOrientation orientation, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:3787
Contains the listbox style.
Definition: fabui.h:1703
uint8_t openOnFocus
Definition: fabui.h:1711
uint8_t focusedBorderSize
Definition: fabui.h:321
RGB buttonBackgroundColor
Definition: fabui.h:1704
RGB mouseOverButtonColor
Definition: fabui.h:667
RGB focusedBackgroundColor
Definition: fabui.h:1585
Delegate onResize
Resize window event delegate.
Definition: fabui.h:793
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:3644
A label is a static text UI element.
Definition: fabui.h:1328
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:2030
int itemHeight
Definition: fabui.h:1588
RGB gripColor
Definition: fabui.h:1942
Properties of the text edit.
Definition: fabui.h:1194
Contains the image style.
Definition: fabui.h:1409
RGB backgroundColor
Definition: fabui.h:1183
RGB textColor
Definition: fabui.h:1061
This is the base class for all controls. A control can have focus and is not activable.
Definition: fabui.h:849
RGB selectedTextColor
Definition: fabui.h:1591
Contains anchors enable/disable switches.
Definition: fabui.h:326
bool down()
Determines whether the switch button is down or up.
Definition: fabui.h:1129
void setTextFmt(const char *format,...)
Sets label formatted text.
Definition: fabui.cpp:2642
RGB buttonColor
Definition: fabui.h:1705
uiFrame * rootWindow()
Gets a pointer to the root window.
Definition: fabui.h:2127
uiOrigin
Specifies window rectangle origin.
Definition: fabui.h:286
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1619
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:426
void setBitmap(Bitmap const *bitmap)
Sets image bitmap.
Definition: fabui.cpp:2724
Delegate onHide
Hide window event delegate.
Definition: fabui.h:786
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:1948
RGB backgroundColor
Definition: fabui.h:1584
int groupIndex()
Determines radiobutton group index.
Definition: fabui.h:1897
uint16_t doubleClickTime
Definition: fabui.h:2048
Specifies current window state.
Definition: fabui.h:294
int selectedItem()
Represents currently selected item.
Definition: fabui.h:1776
char const * title()
Determines the window title.
Definition: fabui.h:735
uint8_t hasMaximizeButton
Definition: fabui.h:678
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:3201
RGB backgroundColor
Definition: fabui.h:1939
This is a combination of a listbox and a single-line editable textbox.
Definition: fabui.h:1721
int HScrollBarPos()
Determines position of the horizontal scrollbar thumb.
Definition: fabui.h:936
uiWindow * setActiveWindow(uiWindow *value)
Sets the active window.
Definition: fabui.cpp:473
Delegate< Rect > onPaint
Paint event delegate.
Definition: fabui.h:1565
uint8_t LALT
Definition: fabui.h:133
RGB mouseOverBackgroundColor
Definition: fabui.h:1184
FontInfo const * textFont
Definition: fabui.h:1321
void setTitle(char const *value)
Sets window title.
Definition: fabui.cpp:1489
Contains the checkbox style.
Definition: fabui.h:1827
bool checked()
Determines whether the checkbox or radiobutton is checked.
Definition: fabui.h:1881
uint8_t allowEdit
Definition: fabui.h:1196
uiAnchors & anchors()
Allows to switch on or off anchors.
Definition: fabui.h:551
Contains the panel style.
Definition: fabui.h:1478
char const * text()
Gets current content of the text edit.
Definition: fabui.h:1258
uiMessageBoxResult
Return values from uiApp.messageBox() method.
Definition: fabui.h:2056
uiWindow(uiWindow *parent, const Point &pos, const Size &size, bool visible)
Creates an instance of the object.
Definition: fabui.cpp:933
void setDown(bool value)
Sets button state of a switch button.
Definition: fabui.cpp:2156
uiOrientation
Item direction/orientation.
Definition: fabui.h:187
Size clientSize()
Determines the client area size.
Definition: fabui.cpp:1127
Delegate onChange
Change event delegate.
Definition: fabui.h:1793
RGB mouseOverBackgroundColor
Definition: fabui.h:1830
RGB focusedBorderColor
Definition: fabui.h:319
RGB slideColor
Definition: fabui.h:1940
Bitmap const * bitmap()
Gets image bitmap.
Definition: fabui.h:1448
void setGroupIndex(int value)
Sets radiobutton group index.
Definition: fabui.h:1904
Image control to display a static bitmap.
Definition: fabui.h:1415
uiFrame(uiWindow *parent, char const *title, const Point &pos, const Size &size, bool visible=true)
Creates an instance of the object.
Definition: fabui.cpp:1470
Delegate onChangeHScrollBar
Horizontal scrollbar change event delegate.
Definition: fabui.h:992