FabGL
ESP32 Display Controller and Graphics Library
fabui.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019-2021 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6 
7 * Please contact fdivitto2013@gmail.com if you need a commercial license.
8 
9 
10 * This library and related software is available under GPL v3.
11 
12  FabGL is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  FabGL is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 #pragma once
28 
29 
38 #include <stdint.h>
39 #include <stddef.h>
40 
41 #include <list>
42 
43 #include "freertos/FreeRTOS.h"
44 #include "freertos/queue.h"
45 #include "freertos/timers.h"
46 
47 #include "fabglconf.h"
48 #include "fabutils.h"
49 #include "displaycontroller.h"
50 #include "canvas.h"
51 #include "fabfonts.h"
52 #include "codepages.h"
53 
54 
55 
56 /*
57 
58  *uiObject
59  *uiEvtHandler
60  *uiApp
61  *uiWindow
62  *uiFrame
63  *uiControl
64  *uiButton
65  *uiLabel
66  *uiImage
67  *uiPanel
68  *uiTextEdit
69  *uiScrollableControl
70  *uiPaintBox
71  *uiCustomListBox
72  *uiListBox
73  *uiColorListBox
74  *uiFileBrowser
75  *uiSimpleMenu
76  uiMemoEdit
77  *uiCheckBox
78  *uiCustomComboBox
79  *uiComboBox
80  *uiColorComboBox
81  *uiSplitButton
82  uiMenu
83  uiGauge
84  *uiSlider
85  uiSpinButton
86  *uiColorBox
87  *uiProgressBar
88 
89 */
90 
91 
92 namespace fabgl {
93 
94 
95 
96 // increase in case of garbage between windows!
97 #define FABGLIB_UI_EVENTS_QUEUE_SIZE 300
98 
99 
100 using std::list;
101 using std::pair;
102 
103 
105 // uiEvent
106 
107 enum uiEventID {
108  UIEVT_NULL,
109  UIEVT_DEBUGMSG,
110  UIEVT_APPINIT,
111  UIEVT_GENPAINTEVENTS,
112  UIEVT_PAINT,
113  UIEVT_ACTIVATE,
114  UIEVT_DEACTIVATE,
115  UIEVT_MOUSEMOVE,
116  UIEVT_MOUSEWHEEL,
117  UIEVT_MOUSEBUTTONDOWN,
118  UIEVT_MOUSEBUTTONUP,
119  UIEVT_SETPOS,
120  UIEVT_SETSIZE,
121  UIEVT_RESHAPEWINDOW,
122  UIEVT_MOUSEENTER,
123  UIEVT_MOUSELEAVE,
124  UIEVT_MAXIMIZE, // Request for maximize
125  UIEVT_MINIMIZE, // Request for minimize
126  UIEVT_RESTORE, // Restore from UIEVT_MAXIMIZE or UIEVT_MINIMIZE
127  UIEVT_SHOW,
128  UIEVT_HIDE,
129  UIEVT_SETFOCUS,
130  UIEVT_KILLFOCUS,
131  UIEVT_KEYDOWN,
132  UIEVT_KEYUP,
133  UIEVT_KEYTYPE,
134  UIEVT_TIMER,
135  UIEVT_CLICK,
136  UIEVT_DBLCLICK,
137  UIEVT_EXITMODAL,
138  UIEVT_DESTROY,
139  UIEVT_CLOSE, // Request to close (frame Close button)
140  UIEVT_QUIT, // Quit the application
141  UIEVT_CREATE,
142  UIEVT_CHILDSETFOCUS, // a UIEVT_SETFOCUS has been sent to a child
143  UIEVT_CHILDKILLFOCUS, // a UIEVT_KILLFOCUS has been sent to a child
144 };
145 
146 
147 class uiEvtHandler;
148 class uiApp;
149 class uiWindow;
150 
151 
152 typedef void * uiTimerHandle;
153 
154 
158  uint8_t ASCII;
159  uint8_t LALT : 1;
160  uint8_t RALT : 1;
161  uint8_t CTRL : 1;
162  uint8_t SHIFT : 1;
163  uint8_t GUI : 1;
164 };
165 
166 
170  uint8_t changedButton;
171 };
172 
173 
174 struct uiFocusInfo {
175  uiWindow * oldFocused;
176  uiWindow * newFocused;
177 };
178 
179 
180 struct uiEvent {
181  uiEvtHandler * dest;
182  uiEventID id;
183 
184  union uiEventParams {
185  // event: UIEVT_MOUSEMOVE, UIEVT_MOUSEWHEEL, UIEVT_MOUSEBUTTONDOWN, UIEVT_MOUSEBUTTONUP, UIEVT_CLICK, UIEVT_DBLCLICK
186  uiMouseEventInfo mouse;
187  // event: UIEVT_PAINT, UIEVT_GENPAINTEVENTS, UIEVT_RESHAPEWINDOW
188  Rect rect;
189  // event: UIEVT_SETPOS
190  Point pos;
191  // event: UIEVT_SETSIZE
192  Size size;
193  // event: UIEVT_DEBUGMSG
194  char const * debugMsg;
195  // event: UIEVT_KEYDOWN, UIEVT_KEYUP
196  uiKeyEventInfo key;
197  // event: UIEVT_TIMER
198  uiTimerHandle timerHandle;
199  // event: UIEVT_EXITMODAL
200  int modalResult;
201  // event: UIEVT_QUIT
202  int exitCode;
203  // event: UIEVT_SETFOCUS, UIEVT_KILLFOCUS, UIEVT_CHILDKILLFOCUS, UIEVT_CHILDSETFOCUS
204  uiFocusInfo focusInfo;
205 
206  uiEventParams() { }
207  } params;
208 
209  uiEvent() : dest(nullptr), id(UIEVT_NULL) { }
210  uiEvent(uiEvent const & e) { dest = e.dest; id = e.id; params = e.params; }
211  uiEvent(uiEvtHandler * dest_, uiEventID id_) : dest(dest_), id(id_) { }
212 };
213 
214 
215 
219 enum class uiOrientation {
220  Vertical,
221  Horizontal,
222 };
223 
224 
228 enum class uiHAlign {
229  Left,
230  Right,
231  Center,
232 };
233 
234 
235 
237 // uiObject
238 
239 
241 struct uiObjectType {
242  uint32_t uiApp : 1;
243  uint32_t uiEvtHandler : 1;
244  uint32_t uiWindow : 1;
245  uint32_t uiFrame : 1;
246  uint32_t uiControl : 1;
247  uint32_t uiScrollableControl : 1;
248  uint32_t uiButton : 1;
249  uint32_t uiTextEdit : 1;
250  uint32_t uiLabel : 1;
251  uint32_t uiImage : 1;
252  uint32_t uiPanel : 1;
253  uint32_t uiPaintBox : 1;
254  uint32_t uiCustomListBox : 1;
255  uint32_t uiListBox : 1;
256  uint32_t uiFileBrowser : 1;
257  uint32_t uiComboBox : 1;
258  uint32_t uiCheckBox : 1;
259  uint32_t uiSlider : 1;
260  uint32_t uiColorListBox : 1;
261  uint32_t uiCustomComboBox : 1;
262  uint32_t uiColorBox : 1;
263  uint32_t uiColorComboBox : 1;
264  uint32_t uiProgressBar : 1;
265  uint32_t uiSplitButton : 1;
266  uint32_t uiSimpleMenu : 1;
267 
272  { }
273 };
274 
275 
277 class uiObject {
278 
279 public:
280 
281  uiObject();
282 
283  virtual ~uiObject();
284 
290  uiObjectType & objectType() { return m_objectType; }
291 
292 private:
293  uiObjectType m_objectType;
294 };
295 
296 
297 
299 // uiEvtHandler
300 
301 
303 class uiEvtHandler : public uiObject {
304 
305 public:
306 
308 
309  virtual ~uiEvtHandler();
310 
311  virtual void processEvent(uiEvent * event);
312 
318  uiApp * app() { return m_app; }
319 
320 
321 protected:
322 
323  void setApp(uiApp * value) { m_app = value; }
324 
325 
326 private:
327 
328  uiApp * m_app;
329 };
330 
331 
332 
334 // uiWindow
335 
339 enum class uiOrigin {
340  Screen,
341  Parent,
342  Window,
343 };
344 
345 
348  uint8_t visible : 1;
349  uint8_t active : 1;
350 };
351 
352 
355  uint8_t activable : 1;
356  uint8_t focusable : 1;
357  uint8_t activeLook : 1;
359  uiWindowProps() :
360  activable(true),
361  focusable(false),
362  activeLook(false)
363  { }
364 };
365 
366 
370  RGB888 borderColor = RGB888(128, 128, 128);
371  RGB888 activeBorderColor = RGB888(128, 128, 255);
373  uint8_t borderSize = 3;
374  uint8_t focusedBorderSize = 1;
376  void adaptToDisplayColors(int displayColors) {
377  if (displayColors < 4) {
378  borderColor = RGB888(0, 0, 0);
379  activeBorderColor = RGB888(0, 0, 0);
380  focusedBorderColor = RGB888(0, 0, 0);
381  } else if (displayColors < 16) {
382  borderColor = RGB888(0, 0, 0);
383  }
384  }
385 };
386 
387 
389 struct uiAnchors {
390  uint8_t left : 1;
391  uint8_t top : 1;
392  uint8_t right : 1;
393  uint8_t bottom : 1;
395  uiAnchors() : left(true), top(true), right(false), bottom(false) { }
396 };
397 
398 
399 #define UIWINDOW_PARENTCENTER Point(-1000, -1000)
400 
401 
403 class uiWindow : public uiEvtHandler {
404 
405 friend class uiApp;
406 
407 public:
408 
418  uiWindow(uiWindow * parent, const Point & pos, const Size & size, bool visible, uint32_t styleClassID = 0);
419 
420  virtual ~uiWindow();
421 
422  virtual void processEvent(uiEvent * event);
423 
424  void setCanvas(Canvas * canvas) { m_canvas = canvas; }
425 
433  uiWindow * next() { return m_next; }
434 
442  uiWindow * prev() { return m_prev; }
443 
449  uiWindow * firstChild() { return m_firstChild; }
450 
456  uiWindow * lastChild() { return m_lastChild; }
457 
463  bool hasChildren() { return m_firstChild != nullptr; }
464 
468  void bringOnTop();
469 
475  void bringAfter(uiWindow * insertionPoint);
476 
484  Point pos() { return m_pos; }
485 
491  Point clientPos();
492 
500  Size size() { return m_size; }
501 
507  Size clientSize();
508 
518  Rect rect(uiOrigin origin);
519 
527  virtual Rect clientRect(uiOrigin origin);
528 
536  uiWindowState state() { return m_state; }
537 
543  uiWindowProps & windowProps() { return m_windowProps; }
544 
550  uiWindowStyle & windowStyle() { return m_windowStyle; }
551 
557  uiWindow * parent() { return m_parent; }
558 
564  uiWindow * parentFrame();
565 
574  Rect transformRect(Rect const & rect, uiWindow * baseWindow);
575 
581  void repaint(Rect const & rect);
582 
586  void repaint();
587 
595  bool isMouseOver() { return m_isMouseOver; }
596 
604  void exitModal(int modalResult);
605 
613  bool hasFocus();
614 
620  bool isActiveWindow();
621 
627  uiAnchors & anchors() { return m_anchors; }
628 
634  void setFocusIndex(int value) { m_focusIndex = value; }
635 
643  int focusIndex() { return m_focusIndex; }
644 
645  Canvas * canvas() { return m_canvas; }
646 
652  void setStyleClassID(uint16_t value) { m_styleClassID = value; }
653 
659  uint16_t styleClassID() { return m_styleClassID; }
660 
668  void setParentProcessKbdEvents(bool value) { m_parentProcessKbdEvents = value; }
669 
670 
671 protected:
672 
673  void addChild(uiWindow * child);
674  void insertAfter(uiWindow * child, uiWindow * underlyingChild);
675  void freeChildren();
676  void removeChild(uiWindow * child, bool freeChild = true);
677  void moveChildOnTop(uiWindow * child);
678  void moveAfter(uiWindow * child, uiWindow * underlyingChild);
679  bool isChild(uiWindow * window);
680 
681  virtual Size minWindowSize() { return Size(0, 0); }
682 
683  void beginPaint(uiEvent * paintEvent, Rect const & clippingRect);
684 
685  void generatePaintEvents(Rect const & paintRect);
686  void reshape(Rect const & r);
687 
688  bool isFocusable();
689 
690 private:
691 
692  void paintWindow();
693 
694  uiWindow * findChildWithFocusIndex(int focusIndex, int * maxIndex);
695 
696 
697  uiWindow * m_parent;
698 
699  Canvas * m_canvas;
700 
701  Point m_pos;
702  Size m_size;
703 
704  uiWindowState m_state;
705 
706  uiWindowProps m_windowProps;
707 
708  uiWindowStyle m_windowStyle;
709 
710  bool m_isMouseOver; // true after mouse entered, false after mouse left
711 
712  uiAnchors m_anchors;
713 
714  int16_t m_focusIndex; // -1 = doesn't partecipate to focus trip
715 
716  uint16_t m_styleClassID;
717 
718  // double linked list, order is: bottom (first items) -> up (last items)
719  uiWindow * m_next;
720  uiWindow * m_prev;
721  uiWindow * m_firstChild;
722  uiWindow * m_lastChild;
723 
724  // if true parent processes keyboard events
725  bool m_parentProcessKbdEvents;
726 };
727 
728 
729 
731 // uiFrame
732 
733 
737 struct uiFrameStyle {
738  RGB888 backgroundColor = RGB888(255, 255, 255);
739  RGB888 titleBackgroundColor = RGB888(128, 128, 128);
741  RGB888 titleColor = RGB888(0, 0, 0);
742  RGB888 activeTitleColor = RGB888(255, 255, 255);
743  FontInfo const * titleFont = &FONT_std_12;
744  RGB888 buttonColor = RGB888(64, 64, 64);
745  RGB888 activeButtonColor = RGB888(255, 255, 255);
747  RGB888 mouseOverButtonColor = RGB888(255, 255, 255);
749  void adaptToDisplayColors(int displayColors) {
750  if (displayColors < 4) {
751  titleBackgroundColor = RGB888(255, 255, 255);
752  titleColor = RGB888(0, 0, 0);
753  buttonColor = RGB888(0, 0, 0);
755  activeTitleColor = RGB888(255, 255, 255);
756  activeButtonColor = RGB888(255, 255, 255);
757  mouseOverButtonColor = RGB888(0, 0, 0);
758  mouseOverBackgroundButtonColor = RGB888(255, 255, 255);
759  } else if (displayColors < 16) {
760  titleBackgroundColor = RGB888(0, 0, 0);
761  titleColor = RGB888(255, 255, 255);
762  buttonColor = RGB888(255, 255, 255);
763  activeButtonColor = RGB888(0, 0, 0);
764  }
765  }
766 };
767 
768 
772 struct uiFrameProps {
773  uint8_t resizeable : 1;
774  uint8_t moveable : 1;
775  uint8_t hasCloseButton : 1;
776  uint8_t hasMaximizeButton : 1;
777  uint8_t hasMinimizeButton : 1;
778  uint8_t fillBackground : 1;
780  uiFrameProps() :
781  resizeable(true),
782  moveable(true),
783  hasCloseButton(true),
784  hasMaximizeButton(true),
785  hasMinimizeButton(true),
786  fillBackground(true)
787  { }
788 };
789 
790 
792 struct uiFrameState {
793  uint8_t maximized : 1;
794  uint8_t minimized : 1;
795 };
796 
797 
801 enum class uiFrameItem : uint8_t {
802  None,
803  MoveArea,
804  TopLeftResize,
805  TopCenterResize,
806  TopRightResize,
807  CenterLeftResize,
808  CenterRightResize,
809  BottomLeftResize,
810  BottomCenterResize,
811  BottomRightResize,
812  CloseButton,
813  MaximizeButton,
814  MinimizeButton,
815 };
816 
817 
823 class uiFrame : public uiWindow {
824 
825 public:
826 
837  uiFrame(uiWindow * parent, char const * title, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
838 
839  virtual ~uiFrame();
840 
841  virtual void processEvent(uiEvent * event);
842 
848  char const * title() { return m_title; }
849 
857  void setTitle(char const * value);
858 
866  void setTitleFmt(const char *format, ...);
867 
873  uiFrameStyle & frameStyle() { return m_frameStyle; }
874 
880  uiFrameProps & frameProps() { return m_frameProps; }
881 
882  Rect clientRect(uiOrigin origin);
883 
884  int getNextFreeFocusIndex() { return m_nextFreeFocusIndex++; }
885 
893  uiFrameState frameState() { return m_frameState; }
894 
895 
896 
897  // Delegates
898 
904  Delegate<> onShow;
905 
911  Delegate<> onHide;
912 
918  Delegate<> onResize;
919 
926  Delegate<uiTimerHandle> onTimer;
927 
931  Delegate<uiKeyEventInfo const &> onKeyDown;
932 
936  Delegate<uiKeyEventInfo const &> onKeyUp;
937 
941  Delegate<> onPaint;
942 
943 
944 protected:
945 
946  Size minWindowSize();
947  int titleBarHeight();
948  Rect titleBarRect();
949 
950 private:
951 
952  void paintFrame();
953  int paintButtons(Rect const & bkgRect);
954  void movingCapturedMouse(int mouseX, int mouseY, bool mouseIsDown);
955  void movingFreeMouse(int mouseX, int mouseY);
956  uiFrameItem getFrameItemAt(int x, int y);
957  Rect getBtnRect(int buttonIndex);
958  void handleButtonsClick(int x, int y, bool doubleClick);
959  void drawTextWithEllipsis(FontInfo const * fontInfo, int X, int Y, char const * text, int maxX);
960  void drawReshapingBox(Rect boxRect);
961 
962 
963  static constexpr int CORNERSENSE = 10;
964 
965 
966  uiFrameStyle m_frameStyle;
967 
968  uiFrameProps m_frameProps;
969 
970  char * m_title;
971  int m_titleLength;
972 
973  uiFrameItem m_mouseDownFrameItem; // frame item on mouse down
974  uiFrameItem m_mouseMoveFrameItem; // frame item on mouse move
975 
976  Rect m_lastReshapingBox; // last reshaping box painted by drawReshapingBox(), (0,0,0,0) if there isn't any
977 
978  int m_nextFreeFocusIndex;
979 
980  Point m_mouseDownPos; // mouse position when mouse down event has been received
981 
982  Rect m_savedScreenRect; // saved screen rect before Maximize or Minimize
983 
984  Size m_sizeAtMouseDown; // used to resize
985 
986  uiFrameState m_frameState;
987 };
988 
989 
990 
992 // uiControl
993 
994 
998 class uiControl : public uiWindow {
999 
1000 public:
1001 
1011  uiControl(uiWindow * parent, const Point & pos, const Size & size, bool visible, uint32_t styleClassID = 0);
1012 
1013  virtual ~uiControl();
1014 
1015  virtual void processEvent(uiEvent * event);
1016 };
1017 
1018 
1019 
1021 // uiScrollableControl
1022 
1023 
1029  uint8_t scrollBarSize = 11;
1031  void adaptToDisplayColors(int displayColors) {
1032  if (displayColors < 16) {
1034  }
1035  }
1036 };
1037 
1038 
1042 enum class uiScrollBarItem {
1043  None,
1044  LeftButton,
1045  RightButton,
1046  TopButton,
1047  BottomButton,
1048  HBar,
1049  VBar,
1050  PageUp,
1051  PageDown,
1052  PageLeft,
1053  PageRight,
1054 };
1055 
1056 
1061 
1062 public:
1063 
1073  uiScrollableControl(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1074 
1075  virtual ~uiScrollableControl();
1076 
1077  virtual void processEvent(uiEvent * event);
1078 
1079  Rect clientRect(uiOrigin origin);
1080 
1086  uiScrollableControlStyle & scrollableControlStyle() { return m_scrollableControlStyle; }
1087 
1096  int HScrollBarPos() { return m_HScrollBarPosition; }
1097 
1105  int HScrollBarVisible() { return m_HScrollBarVisible; }
1106 
1115  int HScrollBarRange() { return m_HScrollBarRange; }
1116 
1125  int VScrollBarPos() { return m_VScrollBarPosition; }
1126 
1134  int VScrollBarVisible() { return m_VScrollBarVisible; }
1135 
1144  int VScrollBarRange() { return m_VScrollBarRange; }
1145 
1146 
1147  // Delegates
1148 
1153 
1158 
1159 
1160 protected:
1161 
1171  virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar = true);
1172 
1173 
1174 private:
1175 
1176  void paintScrollableControl();
1177  void paintScrollBars();
1178  Rect getVScrollBarRects(Rect * topButton = nullptr, Rect * bottonButton = nullptr, Rect * bar = nullptr);
1179  Rect getHScrollBarRects(Rect * leftButton = nullptr, Rect * rightButton = nullptr, Rect * bar = nullptr);
1180  uiScrollBarItem getItemAt(int x, int y);
1181  void repaintScrollBar(uiOrientation orientation);
1182  void handleFreeMouseMove(int mouseX, int mouseY);
1183  void handleCapturedMouseMove(int mouseX, int mouseY);
1184  void handleButtonsScroll();
1185  void handlePageScroll();
1186 
1187  uiScrollableControlStyle m_scrollableControlStyle;
1188 
1189  int16_t m_HScrollBarPosition;
1190  int16_t m_HScrollBarVisible; // it means the "visible" area (how big is the bar)
1191  int16_t m_HScrollBarRange;
1192  int16_t m_VScrollBarPosition;
1193  int16_t m_VScrollBarVisible; // it means the "visible" area (how big is the bar)
1194  int16_t m_VScrollBarRange;
1195 
1196  // values updated by getVScrollBarRects() and getHScrollBarRects()
1197  int16_t m_HBarArea;
1198  int16_t m_VBarArea;
1199 
1200  int16_t m_mouseDownHScrollBarPosition;
1201  int16_t m_mouseDownVScrollBarPosition;
1202 
1203  uiScrollBarItem m_mouseOverItem;
1204 
1205  // a timer is active while mouse is down and the mouse is over a button
1206  uiTimerHandle m_scrollTimer;
1207 
1208  Point m_mouseDownPos; // mouse position when mouse down event has been received
1209 };
1210 
1211 
1212 
1214 // uiButton
1215 
1216 
1219  RGB888 backgroundColor = RGB888(128, 128, 128);
1224  RGB888 textColor = RGB888(0, 0, 0);
1226  FontInfo const * textFont = &FONT_std_14;
1227  uint8_t bitmapTextSpace = 4;
1228  Bitmap const * bitmap = nullptr;
1229  Bitmap const * downBitmap = nullptr;
1231  void adaptToDisplayColors(int displayColors) {
1232  if (displayColors < 4) {
1233  mouseOverBackgroundColor = RGB888(0, 0, 0);
1234  mouseOverTextColor = RGB888(255, 255, 255);
1235  downTextColor = RGB888(255, 255, 255);
1236  downBackgroundColor = RGB888(0, 0, 0);
1237  } else if (displayColors < 16) {
1238  mouseOverBackgroundColor = RGB888(255, 255, 255);
1239  mouseDownBackgroundColor = RGB888(255, 255, 255);
1240  backgroundColor = RGB888(0, 0, 255);
1241  downBackgroundColor = RGB888(0, 128, 0);
1242  downTextColor = displayColors < 8 ? RGB888(0, 0, 0) : RGB888(255, 255, 255);
1243  textColor = RGB888(255, 255, 255);
1244  mouseOverTextColor = RGB888(0, 0, 0);
1245  }
1246  }
1247 };
1248 
1249 
1253 enum class uiButtonKind {
1254  Button,
1255  Switch,
1256 };
1257 
1258 
1260 class uiButton : public uiControl {
1261 
1262 public:
1263 
1275  uiButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, uiButtonKind kind = uiButtonKind::Button, bool visible = true, uint32_t styleClassID = 0);
1276 
1277  virtual ~uiButton();
1278 
1279  virtual void processEvent(uiEvent * event);
1280 
1288  void setText(char const * value);
1289 
1295  char const * text() { return m_text; }
1296 
1302  uiButtonStyle & buttonStyle() { return m_buttonStyle; }
1303 
1311  bool down() { return m_down; }
1312 
1320  void setDown(bool value);
1321 
1322 
1323  // Delegates
1324 
1330  Delegate<> onChange;
1331 
1337  Delegate<> onClick;
1338 
1344  Delegate<uiMouseEventInfo const&> onMouseDown;
1345 
1351  Delegate<uiMouseEventInfo const&> onMouseUp;
1352 
1353 
1354 private:
1355 
1356  void paintButton();
1357  void paintContent(Rect const & rect);
1358 
1359  void trigger();
1360 
1361 
1362  uiButtonStyle m_buttonStyle;
1363 
1364  char * m_text;
1365  int m_textExtent; // calculated by setText(). TODO: changing font doesn't update m_textExtent!
1366 
1367  bool m_down;
1368 
1369  uiButtonKind m_kind;
1370 
1371 };
1372 
1373 
1374 
1376 // uiTextEdit
1377 // single line text edit
1378 
1379 
1386  RGB888 backgroundColor = RGB888(128, 128, 128);
1389  RGB888 textColor = RGB888(0, 0, 0);
1390  FontInfo const * textFont = &FONT_std_14;
1392  void adaptToDisplayColors(int displayColors) {
1393  if (displayColors < 16) {
1394  }
1395  }
1396 };
1397 
1398 
1403  uint8_t hasCaret : 1;
1404  uint8_t allowEdit : 1;
1405  uint8_t passwordMode : 1;
1407  uiTextEditProps()
1408  : hasCaret(true),
1409  allowEdit(true),
1410  passwordMode(false)
1411  {
1412  }
1413 };
1414 
1415 
1421 class uiTextEdit : public uiControl {
1422 
1423 public:
1424 
1435  uiTextEdit(uiWindow * parent, char const * text, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1436 
1437  virtual ~uiTextEdit();
1438 
1439  virtual void processEvent(uiEvent * event);
1440 
1446  uiTextEditStyle & textEditStyle() { return m_textEditStyle; }
1447 
1453  uiTextEditProps & textEditProps() { return m_textEditProps; }
1454 
1462  void setText(char const * value);
1463 
1471  void setTextFmt(const char *format, ...);
1472 
1478  char const * text() { return m_text; }
1479 
1480 
1481  // Delegates
1482 
1486  Delegate<> onChange;
1487 
1491  Delegate<uiKeyEventInfo const &> onKeyType;
1492 
1493 
1494 
1495 protected:
1496 
1497  virtual Rect getEditRect();
1498 
1499 private:
1500 
1501  void paintTextEdit();
1502  void paintContent();
1503 
1504  uint8_t const * getCharInfo(char ch, int * width);
1505  int charColumnToWindowX(int col);
1506  void updateCaret();
1507  void moveCursor(int col, int selCol);
1508  int getColFromMouseX(int mouseX);
1509  void handleKeyDown(uiKeyEventInfo const & key);
1510  void checkAllocatedSpace(int requiredLength);
1511  void insert(char c);
1512  void removeSel();
1513  int getWordPosAtLeft();
1514  int getWordPosAtRight();
1515  void selectWordAt(int mouseX);
1516  int keyToASCII(uiKeyEventInfo const & key);
1517 
1518 
1519  uiTextEditStyle m_textEditStyle;
1520  uiTextEditProps m_textEditProps;
1521 
1522  char * m_text;
1523  int m_textLength; // text length NOT including ending zero
1524  int m_textSpace; // actual space allocated including ending zero
1525 
1526  // rectangle where text will be painted (this is also the text clipping rect)
1527  Rect m_contentRect; // updated on painting
1528 
1529  // where text starts to be painted. Values less than m_contentRect.X1 are used to show characters which do not fit in m_contentRect
1530  int m_viewX;
1531 
1532  // character index of cursor position (0 = at first char)
1533  int m_cursorCol;
1534 
1535  // character index at start of selection (not included if < m_cursorCol, included if > m_cursorCol)
1536  int m_selCursorCol;
1537 
1538  CodePage const * m_codepage;
1539 
1540 };
1541 
1542 
1543 
1545 // uiLabel
1546 
1547 
1550  FontInfo const * textFont = &FONT_std_14;
1551  RGB888 backgroundColor = RGB888(255, 255, 255);
1552  RGB888 textColor = RGB888(0, 0, 0);
1555  void adaptToDisplayColors(int displayColors) {
1556  if (displayColors < 16) {
1557  }
1558  }
1559 };
1560 
1561 
1563 class uiLabel : public uiControl {
1564 
1565 public:
1566 
1577  uiLabel(uiWindow * parent, char const * text, const Point & pos, const Size & size = Size(0, 0), bool visible = true, uint32_t styleClassID = 0);
1578 
1579  virtual ~uiLabel();
1580 
1581  virtual void processEvent(uiEvent * event);
1582 
1590  void setText(char const * value);
1591 
1599  void setTextFmt(const char *format, ...);
1600 
1606  char const * text() { return m_text; }
1607 
1613  uiLabelStyle & labelStyle() { return m_labelStyle; }
1614 
1620  void update();
1621 
1627  Delegate<> onClick;
1628 
1629 
1630 private:
1631 
1632  void paintLabel();
1633 
1634 
1635  char * m_text;
1636 
1637  uiLabelStyle m_labelStyle;
1638 
1639  uint16_t m_textExtent; // calculated by setText()
1640 
1641  uint8_t m_autoSize;
1642 
1643 };
1644 
1645 
1646 
1648 // uiImage
1649 
1650 
1653  RGB888 backgroundColor = RGB888(255, 255, 255);
1655  void adaptToDisplayColors(int displayColors) {
1656  if (displayColors < 16) {
1657  }
1658  }
1659 };
1660 
1661 
1663 class uiImage : public uiControl {
1664 
1665 public:
1666 
1677  uiImage(uiWindow * parent, Bitmap const * bitmap, const Point & pos, const Size & size = Size(0, 0), bool visible = true, uint32_t styleClassID = 0);
1678 
1679  virtual ~uiImage();
1680 
1681  virtual void processEvent(uiEvent * event);
1682 
1690  void setBitmap(Bitmap const * bitmap);
1691 
1697  Bitmap const * bitmap() { return m_bitmap; }
1698 
1704  uiImageStyle & imageStyle() { return m_imageStyle; }
1705 
1706 
1707 private:
1708 
1709  void paintImage();
1710 
1711 
1712  Bitmap const * m_bitmap;
1713 
1714  uiImageStyle m_imageStyle;
1715 
1716  bool m_autoSize;
1717 
1718 };
1719 
1720 
1721 
1723 // uiPanel
1724 
1725 
1728  RGB888 backgroundColor = RGB888(128, 128, 128);
1730  void adaptToDisplayColors(int displayColors) {
1731  if (displayColors < 16) {
1732  }
1733  }
1734 };
1735 
1736 
1738 class uiPanel : public uiControl {
1739 
1740 public:
1741 
1751  uiPanel(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1752 
1753  virtual ~uiPanel();
1754 
1755  virtual void processEvent(uiEvent * event);
1756 
1762  uiPanelStyle & panelStyle() { return m_panelStyle; }
1763 
1764 
1765 private:
1766 
1767  void paintPanel();
1768 
1769 
1770  uiPanelStyle m_panelStyle;
1771 };
1772 
1773 
1774 
1776 // uiPaintBox
1777 
1778 
1781  RGB888 backgroundColor = RGB888(128, 128, 128);
1783  void adaptToDisplayColors(int displayColors) {
1784  if (displayColors < 16) {
1785  }
1786  }
1787 };
1788 
1789 
1792 
1793 public:
1794 
1804  uiPaintBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1805 
1806  virtual ~uiPaintBox();
1807 
1808  virtual void processEvent(uiEvent * event);
1809 
1815  uiPaintBoxStyle & paintBoxStyle() { return m_paintBoxStyle; }
1816 
1818 
1819  // Delegates
1820 
1826  Delegate<Rect const &> onPaint;
1827 
1828 
1829 private:
1830 
1831  void paintPaintBox();
1832 
1833 
1834  uiPaintBoxStyle m_paintBoxStyle;
1835 };
1836 
1837 
1838 
1840 // uiColorBox
1841 
1843 class uiColorBox : public uiControl {
1844 
1845 public:
1846 
1857  uiColorBox(uiWindow * parent, const Point & pos, const Size & size, Color color = Color::BrightWhite, bool visible = true, uint32_t styleClassID = 0);
1858 
1859  virtual ~uiColorBox();
1860 
1861  virtual void processEvent(uiEvent * event);
1862 
1868  Color color() { return m_color; }
1869 
1875  void setColor(Color value);
1876 
1877 private:
1878 
1879  void paintColorBox();
1880 
1881 
1882  Color m_color;
1883 };
1884 
1885 
1886 
1888 // uiCustomListBox
1889 
1890 
1893  RGB888 backgroundColor = RGB888(128, 128, 128);
1897  int itemHeight = 16;
1898  FontInfo const * textFont = &FONT_std_14;
1899  RGB888 textColor = RGB888(0, 0, 0);
1900  RGB888 selectedTextColor = RGB888(255, 255, 255);
1902  void adaptToDisplayColors(int displayColors) {
1903  if (displayColors < 4) {
1904  selectedBackgroundColor = RGB888(0, 0, 0);
1906  selectedTextColor = RGB888(255, 255, 255);
1907  }
1908  }
1909 };
1910 
1911 
1916  uint8_t allowMultiSelect : 1;
1917  uint8_t selectOnMouseOver : 1;
1919  uiListBoxProps()
1920  : allowMultiSelect(true),
1921  selectOnMouseOver(false)
1922  {
1923  }
1924 };
1925 
1926 
1929 
1930 public:
1931 
1941  uiCustomListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
1942 
1943  virtual ~uiCustomListBox();
1944 
1945  virtual void processEvent(uiEvent * event);
1946 
1952  uiListBoxStyle & listBoxStyle() { return m_listBoxStyle; }
1953 
1959  uiListBoxProps & listBoxProps() { return m_listBoxProps; }
1960 
1966  int firstSelectedItem();
1967 
1973  int lastSelectedItem();
1974 
1982  void selectItem(int index, bool add = false, bool range = false);
1983 
1987  void deselectAll();
1988 
1989 
1990  // Delegates
1991 
1997  Delegate<> onChange;
1998 
2002  Delegate<> onKillFocus;
2003 
2007  Delegate<uiKeyEventInfo const &> onKeyType;
2008 
2012  Delegate<uiKeyEventInfo const &> onKeyUp;
2013 
2019  Delegate<> onClick;
2020 
2027  Delegate<> onDblClick;
2028 
2029 
2030 
2031 protected:
2032 
2033  void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar);
2034  int getItemAtMousePos(int mouseX, int mouseY);
2035 
2036  // must be implemented by inherited class
2037  virtual int items_getCount() = 0;
2038  virtual void items_deselectAll() = 0;
2039  virtual void items_select(int index, bool select) = 0;
2040  virtual bool items_selected(int index) = 0;
2041  virtual void items_draw(int index, const Rect & itemRect) = 0;
2042 
2043 private:
2044 
2045  void paintListBox();
2046  void mouseDownSelect(int mouseX, int mouseY);
2047  void mouseMoveSelect(int mouseX, int mouseY);
2048  void handleKeyDown(uiKeyEventInfo key);
2049  void makeItemVisible(int index);
2050 
2051 
2052  uiListBoxStyle m_listBoxStyle;
2053  uiListBoxProps m_listBoxProps;
2054  int m_firstVisibleItem; // the item on the top
2055 };
2056 
2057 
2058 
2060 // uiListBox
2061 
2062 
2064 class uiListBox : public uiCustomListBox {
2065 
2066 public:
2067 
2077  uiListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2078 
2087  StringList & items() { return m_items; }
2088 
2089 protected:
2090 
2091  virtual int items_getCount() { return m_items.count(); }
2092  virtual void items_deselectAll() { m_items.deselectAll(); }
2093  virtual void items_select(int index, bool select) { m_items.select(index, select); }
2094  virtual bool items_selected(int index) { return m_items.selected(index); }
2095  virtual void items_draw(int index, const Rect & itemRect);
2096 
2097 
2098 private:
2099 
2100  StringList m_items;
2101 };
2102 
2103 
2105 // uiFileBrowser
2106 
2109 
2110 public:
2111 
2121  uiFileBrowser(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2122 
2130  void setDirectory(char const * path);
2131 
2139  void changeDirectory(char const * path);
2140 
2146  char const * directory() { return m_dir.directory(); }
2147 
2153  int count() { return m_dir.count(); }
2154 
2160  char const * filename();
2161 
2167  bool isDirectory();
2168 
2169  void processEvent(uiEvent * event);
2170 
2174  void update();
2175 
2181  FileBrowser & content() { return m_dir; }
2182 
2183 
2184 protected:
2185 
2186  virtual int items_getCount() { return m_dir.count(); }
2187  virtual void items_deselectAll() { m_selected = -1; }
2188  virtual void items_select(int index, bool select);
2189  virtual bool items_selected(int index) { return index == m_selected; }
2190  virtual void items_draw(int index, const Rect & itemRect);
2191 
2192 private:
2193 
2194  void enterSubDir();
2195 
2196  FileBrowser m_dir;
2197  int m_selected; // -1 = no sel
2198 
2199 };
2200 
2201 
2203 // uiColorListBox
2204 
2207 
2208 public:
2209 
2219  uiColorListBox(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2220 
2226  Color color();
2227 
2228 
2229 protected:
2230 
2231  virtual int items_getCount() { return 16; }
2232  virtual void items_deselectAll() { }
2233  virtual void items_select(int index, bool select) { if (select) m_selectedColor = (Color)index; }
2234  virtual bool items_selected(int index) { return index == (int)m_selectedColor; }
2235  virtual void items_draw(int index, const Rect & itemRect);
2236 
2237 
2238 private:
2239 
2240  Color m_selectedColor;
2241 };
2242 
2243 
2244 
2246 // uiCustomComboBox
2247 
2248 
2252  RGB888 buttonColor = RGB888(128, 128, 128);
2254  void adaptToDisplayColors(int displayColors) {
2255  if (displayColors < 16) {
2256  }
2257  }
2258 };
2259 
2260 
2263  uint8_t openOnFocus : 1;
2265  uiComboBoxProps()
2266  : openOnFocus(true)
2267  {
2268  }
2269 };
2270 
2271 
2274 {
2275 
2276 public:
2277 
2288  uiCustomComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible, uint32_t styleClassID);
2289 
2290  ~uiCustomComboBox();
2291 
2292  virtual void processEvent(uiEvent * event);
2293 
2299  uiComboBoxStyle & comboBoxStyle() { return m_comboBoxStyle; }
2300 
2306  uiListBoxStyle & listBoxStyle() { return listbox()->listBoxStyle(); }
2307 
2313  uiComboBoxProps & comboBoxProps() { return m_comboBoxProps; }
2314 
2320  int selectedItem() { return listbox()->firstSelectedItem(); }
2321 
2327  void selectItem(int index);
2328 
2329 
2330  // Delegates
2331 
2337  Delegate<> onChange;
2338 
2339 
2340 protected:
2341 
2342  virtual uiCustomListBox * listbox() = 0;
2343  virtual uiControl * editcontrol() = 0;
2344  virtual void updateEditControl() = 0;
2345 
2346  Size getEditControlSize();
2347 
2348  virtual void openListBox();
2349  virtual void closeListBox();
2350  void switchListBox();
2351 
2352  virtual void paintButton();
2353  Rect getButtonRect();
2354 
2355  uiWindow * getListBoxParent() { return m_listBoxParent; }
2356 
2357  bool isListBoxOpen() { return m_listBoxParent->state().visible; }
2358 
2359 private:
2360 
2361  int buttonWidth();
2362 
2363 
2364  int16_t m_listHeight;
2365  int16_t m_loseFocusBy;
2366  uiComboBoxStyle m_comboBoxStyle;
2367  uiComboBoxProps m_comboBoxProps;
2368  uiWindow * m_listBoxParent;
2369 };
2370 
2371 
2372 
2373 
2375 // uiComboBox
2376 
2377 
2380 {
2381 
2382 public:
2383 
2394  uiComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true, uint32_t styleClassID = 0);
2395 
2396  ~uiComboBox();
2397 
2405  StringList & items() { return m_listBox->items(); }
2406 
2412  uiTextEditStyle & textEditStyle() { return m_textEdit->textEditStyle(); }
2413 
2419  uiTextEditProps & textEditProps() { return m_textEdit->textEditProps(); }
2420 
2428  void setText(char const * value) { m_textEdit->setText(value); }
2429 
2435  char const * text() { return m_textEdit->text(); }
2436 
2437 
2438 protected:
2439 
2440  uiCustomListBox * listbox() { return m_listBox; }
2441  uiControl * editcontrol() { return m_textEdit; }
2442  void updateEditControl();
2443 
2444 private:
2445  uiTextEdit * m_textEdit;
2446  uiListBox * m_listBox;
2447 
2448 };
2449 
2450 
2451 
2453 // uiColorComboBox
2454 
2455 
2458 {
2459 
2460 public:
2461 
2472  uiColorComboBox(uiWindow * parent, const Point & pos, const Size & size, int listHeight, bool visible = true, uint32_t styleClassID = 0);
2473 
2474  ~uiColorComboBox();
2475 
2481  void selectColor(Color value) { selectItem((int)value); }
2482 
2489 
2490 
2491 protected:
2492 
2493  uiCustomListBox * listbox() { return m_colorListBox; }
2494  uiControl * editcontrol() { return m_colorBox; }
2495  void updateEditControl();
2496 
2497 private:
2498  uiColorBox * m_colorBox;
2499  uiColorListBox * m_colorListBox;
2500 
2501 };
2502 
2503 
2504 
2506 // uiCheckBox
2507 
2508 
2511  RGB888 backgroundColor = RGB888(128, 128, 128);
2517  void adaptToDisplayColors(int displayColors) {
2518  if (displayColors < 4) {
2519  } else if (displayColors < 16) {
2520  mouseOverForegroundColor = RGB888(255, 255, 255);
2521  }
2522  }
2523 };
2524 
2525 
2529 enum class uiCheckBoxKind : int8_t {
2530  CheckBox,
2531  RadioButton,
2532 };
2533 
2534 
2541 class uiCheckBox : public uiControl {
2542 
2543 public:
2544 
2555  uiCheckBox(uiWindow * parent, const Point & pos, const Size & size, uiCheckBoxKind kind = uiCheckBoxKind::CheckBox, bool visible = true, uint32_t styleClassID = 0);
2556 
2557  virtual ~uiCheckBox();
2558 
2559  virtual void processEvent(uiEvent * event);
2560 
2566  uiCheckBoxStyle & checkBoxStyle() { return m_checkBoxStyle; }
2567 
2573  bool checked() { return m_checked; }
2574 
2582  void setChecked(bool value);
2583 
2589  int groupIndex() { return m_groupIndex; }
2590 
2596  void setGroupIndex(int value) { m_groupIndex = value; }
2597 
2598 
2599  // Delegates
2600 
2606  Delegate<> onChange;
2607 
2613  Delegate<> onClick;
2614 
2615 
2616 private:
2617 
2618  void paintCheckBox();
2619  void trigger();
2620  void unCheckGroup();
2621 
2622 
2623  uiCheckBoxStyle m_checkBoxStyle;
2624  bool m_checked;
2625  uiCheckBoxKind m_kind;
2626  int16_t m_groupIndex; // -1 = no group
2627 
2628 };
2629 
2630 
2631 
2633 // uiSlider
2634 
2635 
2638  RGB888 backgroundColor = RGB888(255, 255, 255);
2639  RGB888 slideColor = RGB888(0, 128, 128);
2640  RGB888 rangeColor = RGB888(0, 128, 255);
2641  RGB888 gripColor = RGB888(0, 0, 255);
2642  RGB888 ticksColor = RGB888(255, 255, 255);
2643  RGB888 mouseOverGripColor = RGB888(255, 255, 255);
2645  void adaptToDisplayColors(int displayColors) {
2646  if (displayColors < 4) {
2647  slideColor = RGB888(0, 0, 0);
2648  rangeColor = RGB888(0, 0, 0);
2649  gripColor = RGB888(0, 0, 0);
2650  mouseOverGripColor = RGB888(255, 255, 255);
2651  } else if (displayColors < 16) {
2652  slideColor = RGB888(0, 0, 0);
2653  mouseOverGripColor = RGB888(255, 255, 255);
2654  }
2655  }
2656 };
2657 
2658 
2660 class uiSlider : public uiControl {
2661 
2662 public:
2663 
2674  uiSlider(uiWindow * parent, const Point & pos, const Size & size, uiOrientation orientation, bool visible = true, uint32_t styleClassID = 0);
2675 
2676  virtual ~uiSlider();
2677 
2678  virtual void processEvent(uiEvent * event);
2679 
2685  uiSliderStyle & sliderStyle() { return m_sliderStyle; }
2686 
2692  int position() { return m_position; }
2693 
2699  void setPosition(int value);
2700 
2706  int min() { return m_min; }
2707 
2713  int max() { return m_max; }
2714 
2722  void setup(int min, int max, int ticksFrequency);
2723 
2724 
2730  Delegate<> onChange;
2731 
2732 
2733 private:
2734 
2735  void paintSlider();
2736  Rect getGripRect();
2737  void moveGripTo(int x, int y);
2738  void handleKeyDown(uiKeyEventInfo key);
2739 
2740 
2741  uiSliderStyle m_sliderStyle;
2742  uiOrientation m_orientation;
2743 
2744  int16_t m_position;
2745  int16_t m_min;
2746  int16_t m_max;
2747  int16_t m_ticksFrequency;
2748 };
2749 
2750 
2751 
2753 // uiProgressBar
2754 
2755 
2758  RGB888 backgroundColor = RGB888(128, 128, 128);
2759  RGB888 foregroundColor = RGB888(64, 128, 64);
2760  FontInfo const * textFont = &FONT_std_14;
2761  RGB888 textColor = RGB888(255, 255, 255);
2763  void adaptToDisplayColors(int displayColors) {
2764  if (displayColors < 4) {
2765  foregroundColor = RGB888(0, 0, 0);
2766  } else if (displayColors < 8) {
2767  textColor = RGB888(0, 0, 0);
2768  }
2769  }
2770 };
2771 
2772 
2775  uint8_t showPercentage : 1;
2778  : showPercentage(true)
2779  {
2780  }
2781 };
2782 
2783 
2785 class uiProgressBar : public uiControl {
2786 
2787 public:
2788 
2798  uiProgressBar(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2799 
2800  virtual ~uiProgressBar();
2801 
2802  virtual void processEvent(uiEvent * event);
2803 
2809  uiProgressBarStyle & progressBarStyle() { return m_progressBarStyle; }
2810 
2816  uiProgressBarProps & progressBarProps() { return m_progressBarProps; }
2817 
2823  void setPercentage(int value);
2824 
2825 
2826 private:
2827 
2828  void paintProgressBar();
2829 
2830 
2831  uiProgressBarStyle m_progressBarStyle;
2832  uiProgressBarProps m_progressBarProps;
2833 
2834  int m_percentage;
2835 };
2836 
2837 
2838 
2840 // uiSimpleMenu
2841 
2842 
2845 
2846 public:
2847 
2857  uiSimpleMenu(uiWindow * parent, const Point & pos, const Size & size, bool visible = true, uint32_t styleClassID = 0);
2858 
2867  StringList & items() { return m_items; }
2868 
2869  virtual void processEvent(uiEvent * event);
2870 
2871 
2872  // Delegates
2873 
2879  Delegate<int> onSelect;
2880 
2881 protected:
2882 
2883  virtual int items_getCount() { return m_items.count(); }
2884  virtual void items_deselectAll() { m_items.deselectAll(); }
2885  virtual void items_select(int index, bool select) { m_items.select(index, select); }
2886  virtual bool items_selected(int index) { return m_items.selected(index); }
2887  virtual void items_draw(int index, const Rect & itemRect);
2888 
2889 
2890 private:
2891 
2892  StringList m_items;
2893 };
2894 
2895 
2896 
2897 
2899 // uiSplitButton
2900 
2901 
2904 {
2905 
2906 public:
2907 
2921  uiSplitButton(uiWindow * parent, char const * text, const Point & pos, const Size & size, int listHeight, char const * itemsText, char separator = ';', bool visible = true, uint32_t styleClassID = 0);
2922 
2923  ~uiSplitButton();
2924 
2930  StringList & items() { return m_menu->items(); }
2931 
2932  void processEvent(uiEvent * event);
2933 
2934 
2935  // Delegates
2936 
2942  Delegate<int> onSelect;
2943 
2944 
2945 protected:
2946 
2947  uiCustomListBox * listbox() { return m_menu; }
2948  uiControl * editcontrol() { return m_button; }
2949  void updateEditControl();
2950  virtual void openListBox();
2951  virtual void paintButton();
2952 
2953 private:
2954  uiButton * m_button;
2955  uiSimpleMenu * m_menu;
2956  int m_selectedItem;
2957 
2958 };
2959 
2960 
2961 
2963 // uiStyle
2964 
2965 struct uiStyle {
2966  virtual void setStyle(uiObject * object, uint32_t styleClassID) = 0;
2967 };
2968 
2969 
2970 
2972 // uiApp
2973 
2974 
2976 struct uiAppProps {
2977  uint16_t caretBlinkingTime = 500;
2978  uint16_t doubleClickTime = 250;
2979  bool realtimeReshaping = false;
2980  bool realtimeMoving = false;
2981 };
2982 
2983 
2988  Cancel = 0,
2989  Button1 = 1,
2990  ButtonOK = 1,
2991  Button2 = 2,
2992  Button3 = 3,
2993 };
2994 
2995 
2999 enum class uiMessageBoxIcon {
3000  None,
3001  Question,
3002  Info,
3003  Warning,
3004  Error,
3005 };
3006 
3007 
3008 struct ModalWindowState {
3009  uiWindow * window;
3010  uiWindow * prevFocusedWindow;
3011  uiWindow * prevActiveWindow;
3012  uiWindow * prevModal;
3013  int modalResult;
3014 };
3015 
3016 
3017 typedef pair<uiEvtHandler *, TimerHandle_t> uiTimerAssoc;
3018 
3019 
3020 class Keyboard;
3021 class Mouse;
3022 
3023 
3030 class uiApp : public uiEvtHandler {
3031 
3032 public:
3033 
3034  uiApp();
3035 
3036  virtual ~uiApp();
3037 
3047  int run(BitmappedDisplayController * displayController, Keyboard * keyboard = nullptr, Mouse * mouse = nullptr);
3048 
3059  uiApp & runAsync(BitmappedDisplayController * displayController, int taskStack = 3000, Keyboard * keyboard = nullptr, Mouse * mouse = nullptr);
3060 
3064  void joinAsyncRun();
3065 
3071  void quit(int exitCode);
3072 
3080  bool postEvent(uiEvent const * event);
3081 
3089  bool insertEvent(uiEvent const * event);
3090 
3091  void postDebugMsg(char const * msg);
3092 
3093  virtual void processEvent(uiEvent * event);
3094 
3100  void processEvents();
3101 
3110  uiFrame * rootWindow() { return m_rootWindow; }
3111 
3120  uiWindow * activeWindow() { return m_activeWindow; }
3121 
3131  uiWindow * setActiveWindow(uiWindow * value);
3132 
3145  uiWindow * focusedWindow() { return m_focusedWindow; }
3146 
3157  uiWindow * setFocusedWindow(uiWindow * value);
3158 
3169  uiWindow * moveFocus(int delta);
3170 
3171  void captureMouse(uiWindow * window);
3172 
3180  uiWindow * capturedMouseWindow() { return m_capturedMouseWindow; }
3181 
3187  void repaintWindow(uiWindow * window);
3188 
3194  void repaintRect(Rect const & rect);
3195 
3203  void moveWindow(uiWindow * window, int x, int y);
3204 
3212  void resizeWindow(uiWindow * window, int width, int height);
3213 
3220  void resizeWindow(uiWindow * window, Size size);
3221 
3228  void reshapeWindow(uiWindow * window, Rect const & rect);
3229 
3237  uiWindow * screenToWindow(Point & point);
3238 
3245  void showWindow(uiWindow * window, bool value);
3246 
3258  int showModalWindow(uiWindow * window);
3259 
3269  ModalWindowState * initModalWindow(uiWindow * window);
3270 
3281  bool processModalWindowEvents(ModalWindowState * state, int timeout);
3282 
3293  int endModalWindow(ModalWindowState * state);
3294 
3301  void maximizeFrame(uiFrame * frame, bool value);
3302 
3309  void minimizeFrame(uiFrame * frame, bool value);
3310 
3311  void combineMouseMoveEvents(bool value) { m_combineMouseMoveEvents = value; }
3312 
3313  void showCaret(uiWindow * window);
3314 
3315  void setCaret(bool value);
3316 
3317  void setCaret(Point const & pos);
3318 
3319  void setCaret(Rect const & rect);
3320 
3332  uiTimerHandle setTimer(uiEvtHandler * dest, int periodMS);
3333 
3341  void killTimer(uiTimerHandle handle);
3342 
3343  void killEvtHandlerTimers(uiEvtHandler * dest);
3344 
3350  uiAppProps & appProps() { return m_appProps; }
3351 
3357  void destroyWindow(uiWindow * window);
3358 
3359  void cleanWindowReferences(uiWindow * window);
3360 
3368  void enableKeyboardAndMouseEvents(bool value);
3369 
3382  uiMessageBoxResult messageBox(char const * title, char const * text, char const * button1Text, char const * button2Text = nullptr, char const * button3Text = nullptr, uiMessageBoxIcon icon = uiMessageBoxIcon::Question);
3383 
3399  uiMessageBoxResult inputBox(char const * title, char const * text, char * inOutString, int maxLength, char const * button1Text, char const * button2Text = nullptr);
3400 
3416  uiMessageBoxResult fileDialog(char const * title, char * inOutDirectory, int maxDirNameSize, char * inOutFilename, int maxFileNameSize, char const * buttonOKText, char const * buttonCancelText, int frameWidth = 200, int frameHeight = 250);
3417 
3421  virtual void init();
3422 
3428  void setStyle(uiStyle * value) { m_style = value; }
3429 
3435  uiStyle * style() { return m_style; }
3436 
3437  Keyboard * keyboard() { return m_keyboard; }
3438 
3439  Mouse * mouse() { return m_mouse; }
3440 
3441  BitmappedDisplayController * displayController() { return m_displayController; }
3442 
3443  int displayColors() { return m_displayColors; }
3444 
3445  Canvas * canvas() { return m_canvas; }
3446 
3452  int lastUserActionTime() { return m_lastUserActionTimeMS; }
3453 
3454 
3455  // delegates
3456 
3463  Delegate<uiTimerHandle> onTimer;
3464 
3465 
3466 protected:
3467 
3468  bool getEvent(uiEvent * event, int timeOutMS);
3469  bool peekEvent(uiEvent * event, int timeOutMS);
3470 
3471 
3472 private:
3473 
3474  void preprocessEvent(uiEvent * event);
3475  void preprocessMouseEvent(uiEvent * event);
3476  void preprocessKeyboardEvent(uiEvent * event);
3477  void filterModalEvent(uiEvent * event);
3478 
3479  static void timerFunc(TimerHandle_t xTimer);
3480 
3481  static void asyncRunTask(void * arg);
3482 
3483  void blinkCaret(bool forceOFF = false);
3484  void suspendCaret(bool value);
3485 
3486 
3487  BitmappedDisplayController * m_displayController;
3488 
3489  int m_displayColors;
3490 
3491  Canvas * m_canvas;
3492 
3493  Keyboard * m_keyboard;
3494 
3495  Mouse * m_mouse;
3496 
3497  uiAppProps m_appProps;
3498 
3499  QueueHandle_t m_eventsQueue;
3500 
3501  uiFrame * m_rootWindow;
3502 
3503  uiWindow * m_activeWindow; // foreground window. Also gets keyboard events (other than focused window)
3504 
3505  uiWindow * m_focusedWindow; // window that captures keyboard events (other than active window)
3506 
3507  uiWindow * m_lastFocusedWindow; // previous focused window
3508 
3509  uiWindow * m_capturedMouseWindow; // window that has captured mouse
3510 
3511  uiWindow * m_freeMouseWindow; // window where mouse is over
3512 
3513  uiWindow * m_modalWindow; // current modal window
3514 
3515  bool m_combineMouseMoveEvents;
3516 
3517  uiEvtHandler * m_keyDownHandler; // used to produce UIEVT_KEYTYPE
3518 
3519  uiWindow * m_caretWindow; // nullptr = caret is not visible
3520  Rect m_caretRect; // caret rect relative to m_caretWindow
3521  uiTimerHandle m_caretTimer;
3522  int m_caretInvertState; // -1 = suspended, 1 = rect reversed (cat visible), 0 = rect not reversed (caret invisible)
3523 
3524  int m_lastMouseUpTimeMS; // time (MS) at mouse up. Used to measure double clicks
3525  Point m_lastMouseUpPos; // screen position of last mouse up
3526 
3527  uiStyle * m_style;
3528 
3529  int m_lastUserActionTimeMS; // time when last user action (mouse/keyboard) has been received, measured in milliseconds since boot
3530 
3531  // associates event handler with FreeRTOS timer
3532  list<uiTimerAssoc> m_timers;
3533 
3534  // used to wait for asyncRunTask to terminate
3535  SemaphoreHandle_t m_asyncRunWait;
3536 };
3537 
3538 
3539 
3540 
3541 } // end of namespace
3542 
3543 
3544 // get out of namespace frequently used names
3545 using fabgl::uiObject;
3546 using fabgl::uiButtonKind;
3547 using fabgl::uiTimerHandle;
3548 using fabgl::uiTextEdit;
3549 using fabgl::uiApp;
3550 using fabgl::uiFrame;
3551 using fabgl::uiButton;
3552 using fabgl::uiLabel;
3553 using fabgl::uiImage;
3554 using fabgl::uiPanel;
3556 using fabgl::uiPaintBox;
3557 using fabgl::uiOrientation;
3558 using fabgl::uiListBox;
3559 using fabgl::uiComboBox;
3560 using fabgl::uiCheckBox;
3561 using fabgl::uiCheckBoxKind;
3562 using fabgl::uiSlider;
3563 using fabgl::uiStyle;
3564 using fabgl::uiWindowStyle;
3565 using fabgl::uiFrameStyle;
3567 using fabgl::uiButtonStyle;
3569 using fabgl::uiLabelStyle;
3570 using fabgl::uiHAlign;
3571 using fabgl::uiImageStyle;
3572 using fabgl::uiPanelStyle;
3574 using fabgl::uiListBoxStyle;
3577 using fabgl::uiSliderStyle;
3578 using fabgl::uiColorListBox;
3579 using fabgl::uiColorBox;
3581 using fabgl::uiProgressBar;
3583 using fabgl::uiKeyEventInfo;
3585 using fabgl::uiFileBrowser;
3586 using fabgl::uiSplitButton;
3587 using fabgl::uiSimpleMenu;
3588 
3589 
3590 
3591 
RGB888 mouseOverGripColor
Definition: fabui.h:2643
Represents a 24 bit RGB color.
uiLabelStyle & labelStyle()
Sets or gets label style.
Definition: fabui.h:1613
uiWindow * setActiveWindow(uiWindow *value)
Sets the active window.
Definition: fabui.cpp:662
uiWindowStyle & windowStyle()
Sets or gets window style.
Definition: fabui.h:550
RGB888 selectedTextColor
Definition: fabui.h:1900
void selectItem(int index, bool add=false, bool range=false)
Selects a listbox item.
Definition: fabui.cpp:4022
Delegate onChange
Change event delegate.
Definition: fabui.h:2337
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:2412
bool down()
Determines whether the switch button is down or up.
Definition: fabui.h:1311
int selectedItem()
Represents currently selected item.
Definition: fabui.h:2320
A class with a set of drawing methods.
Definition: canvas.h:70
uiComboBoxStyle & comboBoxStyle()
Sets or gets combobox style.
Definition: fabui.h:2299
Shows a list of 16 colors, one selectable.
Definition: fabui.h:2206
Shows a list of selectable string items. Selection is done clicking or pressing ENTER or SPACE key...
Definition: fabui.h:2844
Delegate onChangeVScrollBar
Vertical scrollbar change event delegate.
Definition: fabui.h:1157
uint8_t borderSize
Definition: fabui.h:373
uiSplitButton(uiWindow *parent, char const *text, const Point &pos, const Size &size, int listHeight, char const *itemsText, char separator=';', bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:5215
A frame is a window with a title bar, maximize/minimize/close buttons and that is resizeable or movea...
Definition: fabui.h:823
uint8_t left
Definition: fabui.h:390
int lastSelectedItem()
Gets the last selected item.
Definition: fabui.cpp:4130
Contains details about the key event.
Definition: fabui.h:156
Rect rect(uiOrigin origin)
Determines the window bounding box.
Definition: fabui.cpp:1565
uiMessageBoxResult fileDialog(char const *title, char *inOutDirectory, int maxDirNameSize, char *inOutFilename, int maxFileNameSize, char const *buttonOKText, char const *buttonCancelText, int frameWidth=200, int frameHeight=250)
Displays a modal open/save dialog box.
Definition: fabui.cpp:1269
ModalWindowState * initModalWindow(uiWindow *window)
Begins modal window processing.
Definition: fabui.cpp:837
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition: fabui.h:1446
uiTextEdit(uiWindow *parent, char const *text, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:2690
Bitmap const * bitmap
Definition: fabui.h:1228
uiOrientation
Item direction/orientation.
Definition: fabui.h:219
uiApp & runAsync(BitmappedDisplayController *displayController, int taskStack=3000, Keyboard *keyboard=nullptr, Mouse *mouse=nullptr)
Initializes application and executes asynchronously the main event loop.
Definition: fabui.cpp:355
void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:4139
int firstSelectedItem()
Gets the first selected item.
Definition: fabui.cpp:4120
Represents the whole application base class.
Definition: fabui.h:3030
uint16_t styleClassID()
Determines current style class for this UI element.
Definition: fabui.h:659
char const * text()
Determines button text.
Definition: fabui.h:1295
uiMessageBoxResult messageBox(char const *title, char const *text, char const *button1Text, char const *button2Text=nullptr, char const *button3Text=nullptr, uiMessageBoxIcon icon=uiMessageBoxIcon::Question)
Displays a modal dialog box with an icon, text and some buttons.
Definition: fabui.cpp:1081
bool insertEvent(uiEvent const *event)
Inserts (first position) an event in the event queue and returns without waiting for the receiver to ...
Definition: fabui.cpp:615
RGB888 downBackgroundColor
Definition: fabui.h:1220
uint8_t activable
Definition: fabui.h:355
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:2019
This is a combination of a listbox and another component, base of all combobox components.
Definition: fabui.h:2273
uiStyle * style()
Gets current application controls style.
Definition: fabui.h:3435
A scrollable control is a control with optionally vertical and/or horizontal scrollbars.
Definition: fabui.h:1060
void setText(char const *value)
Sets label text.
Definition: fabui.cpp:3207
int lastUserActionTime()
Returns time when last user action (mouse/keyboard) has been received, measured in milliseconds since...
Definition: fabui.h:3452
char const * text()
Gets current content of the text edit.
Definition: fabui.h:1478
VirtualKey VK
Definition: fabui.h:157
void selectItem(int index)
Selects an item.
Definition: fabui.cpp:4422
Base class for all visible UI elements (Frames and Controls)
Definition: fabui.h:403
void update()
Reloads current directory content and repaints.
Definition: fabui.cpp:4344
FileBrowser & content()
Contains current directory representation.
Definition: fabui.h:2181
int run(BitmappedDisplayController *displayController, Keyboard *keyboard=nullptr, Mouse *mouse=nullptr)
Initializes application and executes the main event loop.
Definition: fabui.cpp:237
char const * directory()
Determines current directory.
Definition: fabui.h:2146
void setup(int min, int max, int ticksFrequency)
Sets minimum, maximum position and ticks frequency.
Definition: fabui.cpp:4878
A color box is a control that shows a single color.
Definition: fabui.h:1843
void setParentProcessKbdEvents(bool value)
Enables a child window to send keyboard events to its parent.
Definition: fabui.h:668
uiColorBox(uiWindow *parent, const Point &pos, const Size &size, Color color=Color::BrightWhite, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3490
RGB888 mouseOverScrollBarForegroundColor
Definition: fabui.h:1028
uiColorComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4655
Delegate< Rect const & > onPaint
Paint event delegate.
Definition: fabui.h:1826
FontInfo const * textFont
Definition: fabui.h:1898
Shows a list of selectable string items.
Definition: fabui.h:2064
uiListBoxProps & listBoxProps()
Sets or gets list box properties.
Definition: fabui.h:1959
Bitmap const * bitmap()
Gets image bitmap.
Definition: fabui.h:1697
int16_t Y
void bringAfter(uiWindow *insertionPoint)
Brings this window after another one.
Definition: fabui.cpp:1526
RGB888 mouseDownBackgroundColor
Definition: fabui.h:1222
Size size()
Determines the window size.
Definition: fabui.h:500
RGB888 mouseOverBackgroundButtonColor
Definition: fabui.h:746
uiPanelStyle & panelStyle()
Sets or gets panel style.
Definition: fabui.h:1762
virtual void init()
Method to inherit to implement an application.
Definition: fabui.cpp:604
Contains the listbox style.
Definition: fabui.h:1892
RGB888 buttonColor
Definition: fabui.h:744
Contains the slider style.
Definition: fabui.h:2637
uiWindow * parent()
Determines the parent window.
Definition: fabui.h:557
uint16_t doubleClickTime
Definition: fabui.h:2978
RGB888 downTextColor
Definition: fabui.h:1225
void setFocusIndex(int value)
Sets the focus index (aka tab-index)
Definition: fabui.h:634
int count()
Determines number of files in current directory.
Definition: fabui.h:2153
uint8_t visible
Definition: fabui.h:348
uiAppProps & appProps()
Sets or gets application properties.
Definition: fabui.h:3350
uint8_t minimized
Definition: fabui.h:794
uiImage(uiWindow *parent, Bitmap const *bitmap, const Point &pos, const Size &size=Size(0, 0), bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3299
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:1337
RGB888 mouseOverBackgroundColor
Definition: fabui.h:1221
This file contains fabgl::BitmappedDisplayController definition.
Base class of all UI elements that can receive events.
Definition: fabui.h:303
Sets or gets text edit style.
Definition: fabui.h:1385
void quit(int exitCode)
Terminates application and free resources.
Definition: fabui.cpp:398
uint8_t active
Definition: fabui.h:349
Contains the paintbox style.
Definition: fabui.h:1780
Color
This enum defines named colors.
uiLabel(uiWindow *parent, char const *text, const Point &pos, const Size &size=Size(0, 0), bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3179
FontInfo const * textFont
Definition: fabui.h:1226
uiButton(uiWindow *parent, char const *text, const Point &pos, const Size &size, uiButtonKind kind=uiButtonKind::Button, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:2528
uiColorListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4239
Delegate< int > onSelect
Item select event.
Definition: fabui.h:2879
int showModalWindow(uiWindow *window)
Makes a window visible and handles it has a modal window.
Definition: fabui.cpp:903
uiFrameState frameState()
Determines the frame state.
Definition: fabui.h:893
Properties of the combobox.
Definition: fabui.h:2262
Delegate< uiKeyEventInfo const & > onKeyType
Key-type event delegate.
Definition: fabui.h:1491
int position()
Determines slider position.
Definition: fabui.h:2692
uiProgressBarProps & progressBarProps()
Sets or gets progress bar properties.
Definition: fabui.h:2816
The PS2 Keyboard controller class.
Definition: keyboard.h:77
Represents the base abstract class for bitmapped display controllers.
Color color()
Currently selected color.
This file contains fabgl::Canvas definition.
Size clientSize()
Determines the client area size.
Definition: fabui.cpp:1588
uiWindow * lastChild()
Gets last child.
Definition: fabui.h:456
A panel is used to contain and to group some controls.
Definition: fabui.h:1738
RGB888 backgroundColor
Definition: fabui.h:1781
Represents a checkbox or a radiobutton.
Definition: fabui.h:2541
Specifies current frame state.
Definition: fabui.h:792
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:1036
RGB888 mouseOverForegroundColor
Definition: fabui.h:2514
void moveWindow(uiWindow *window, int x, int y)
Moves a window.
Definition: fabui.cpp:802
void destroyWindow(uiWindow *window)
Destroys a window.
Definition: fabui.cpp:1042
uint16_t caretBlinkingTime
Definition: fabui.h:2977
Delegate onResize
Resize window event delegate.
Definition: fabui.h:918
Contains the progress bar style.
Definition: fabui.h:2757
uiButtonStyle & buttonStyle()
Sets or gets button style.
Definition: fabui.h:1302
uiCheckBoxKind
Specifies the combobox behaviour.
Definition: fabui.h:2529
uint8_t bottom
Definition: fabui.h:393
void setTitleFmt(const char *format,...)
Sets window title as formatted text.
Definition: fabui.cpp:1950
Delegate onChangeHScrollBar
Horizontal scrollbar change event delegate.
Definition: fabui.h:1152
Color selectedColor()
Determines current selected color.
Definition: fabui.h:2488
void setStyleClassID(uint16_t value)
Sets style class for this UI element.
Definition: fabui.h:652
void update()
Updates the label content.
Definition: fabui.cpp:3232
void setColor(Color value)
Sets current colorbox color.
Definition: fabui.cpp:3510
uiWindowProps & windowProps()
Sets or gets window properties.
Definition: fabui.h:543
Properties of the application.
Definition: fabui.h:2976
int VScrollBarRange()
Determines vertical scrollbar range.
Definition: fabui.h:1144
void setTextFmt(const char *format,...)
Sets label formatted text.
Definition: fabui.cpp:3216
Contains the scrollable control style.
Definition: fabui.h:1025
uiCustomComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible, uint32_t styleClassID)
Creates an instance of the object.
Definition: fabui.cpp:4391
RGB888 backgroundColor
Definition: fabui.h:1728
Represents a button control. A button can have text and optionally a bitmap.
Definition: fabui.h:1260
This is a combination of a button and a simple menu.
Definition: fabui.h:2903
uint8_t moveable
Definition: fabui.h:774
void setStyle(uiStyle *value)
Sets application controls style.
Definition: fabui.h:3428
uint8_t maximized
Definition: fabui.h:793
bool processModalWindowEvents(ModalWindowState *state, int timeout)
Processes all messages from modal window.
Definition: fabui.cpp:855
RGB888 focusedSelectedBackgroundColor
Definition: fabui.h:1896
int VScrollBarVisible()
Determines vertical scrollbar visible portion (aka thumb size) of the scrollable content.
Definition: fabui.h:1134
This file contains codepages declarations.
void setTextFmt(const char *format,...)
Replaces current text.
Definition: fabui.cpp:2737
uiButtonKind
Specifies the button kind.
Definition: fabui.h:1253
uiWindow * parentFrame()
Determines the parent frame.
Definition: fabui.cpp:1888
Contains the label style.
Definition: fabui.h:1549
uiMessageBoxResult inputBox(char const *title, char const *text, char *inOutString, int maxLength, char const *button1Text, char const *button2Text=nullptr)
Displays a modal dialog box with a text, a text edit and up to two buttons.
Definition: fabui.cpp:1180
Describes mouse absolute position, scroll wheel delta and buttons status.
Definition: fabutils.h:277
void deselectAll()
Deselects all selected items.
Definition: fabui.cpp:4062
uiFrameProps & frameProps()
Sets or gets frame properties.
Definition: fabui.h:880
Delegate onChange
Change event delegate.
Definition: fabui.h:1997
uiCustomListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3903
uint8_t focusable
Definition: fabui.h:356
void minimizeFrame(uiFrame *frame, bool value)
Minimizes or restores a frame.
Definition: fabui.cpp:919
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:2419
RGB888 buttonBackgroundColor
Definition: fabui.h:2251
int groupIndex()
Determines radiobutton group index.
Definition: fabui.h:2589
uiFrameStyle & frameStyle()
Sets or gets frame style.
Definition: fabui.h:873
void maximizeFrame(uiFrame *frame, bool value)
Maximizes or restores a frame.
Definition: fabui.cpp:912
StringList & items()
A list of strings representing the menu content.
Definition: fabui.h:2930
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:2306
RGB888 activeBorderColor
Definition: fabui.h:371
Represents the coordinate of a point.
Definition: fabutils.h:191
Represents an image.
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:1627
uiAnchors & anchors()
Allows to switch on or off anchors.
Definition: fabui.h:627
Contains the window style.
Definition: fabui.h:368
Properties of the frame.
Definition: fabui.h:772
void setPosition(int value)
Sets the slider position.
Definition: fabui.cpp:4868
This is a combination of a color listbox and a colorbox.
Definition: fabui.h:2457
This file contains some utility classes and functions.
uint8_t right
Definition: fabui.h:392
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:926
RGB888 mouseOverBackgroundColor
Definition: fabui.h:2513
uiSliderStyle & sliderStyle()
Sets or gets slider style.
Definition: fabui.h:2685
uiSlider(uiWindow *parent, const Point &pos, const Size &size, uiOrientation orientation, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4840
uiPaintBoxStyle & paintBoxStyle()
Sets or gets paintbox style.
Definition: fabui.h:1815
uiFrame(uiWindow *parent, char const *title, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:1906
Definition: canvas.cpp:36
uiControl(uiWindow *parent, const Point &pos, const Size &size, bool visible, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:2496
uiOrigin
Specifies window rectangle origin.
Definition: fabui.h:339
StringList & items()
A list of strings representing the simplemenu content.
Definition: fabui.h:2867
uint8_t top
Definition: fabui.h:391
Rect transformRect(Rect const &rect, uiWindow *baseWindow)
Transforms rectangle origins from current window to another one.
Definition: fabui.cpp:1543
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:3884
Specifies the object type.
Definition: fabui.h:241
MouseStatus status
Definition: fabui.h:169
Contains some window options.
Definition: fabui.h:354
Color color()
Gets current colorbox color.
Definition: fabui.h:1868
Delegate onClick
Mouse click event delegate.
Definition: fabui.h:2613
uiScrollableControlStyle & scrollableControlStyle()
Sets or gets control style.
Definition: fabui.h:1086
CursorName defaultCursor
Definition: fabui.h:369
Delegate< uiKeyEventInfo const & > onKeyDown
Key-down event delegate.
Definition: fabui.h:931
uint8_t activeLook
Definition: fabui.h:357
uiPaintBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3430
Contains the button style.
Definition: fabui.h:1218
void setDown(bool value)
Sets button state of a switch button.
Definition: fabui.cpp:2670
char const * filename()
Currently selected filename.
Definition: fabui.cpp:4318
uiMessageBoxResult
Return values from uiApp.messageBox() method.
Definition: fabui.h:2987
Represents a rectangle.
Definition: fabutils.h:226
uiWindow * screenToWindow(Point &point)
Determines which window a point belongs to.
Definition: fabui.cpp:585
uint8_t focusedBorderSize
Definition: fabui.h:374
RGB888 activeButtonColor
Definition: fabui.h:745
Delegate< uiTimerHandle > onTimer
Timer event delegate.
Definition: fabui.h:3463
RGB888 titleColor
Definition: fabui.h:741
uiHAlign
Text horizontal alignment.
Definition: fabui.h:228
int HScrollBarPos()
Determines position of the horizontal scrollbar thumb.
Definition: fabui.h:1096
Delegate onDblClick
Mouse double click event delegate.
Definition: fabui.h:2027
Represents a text edit control.
Definition: fabui.h:1421
uiWindow * prev()
Gets previous sibling.
Definition: fabui.h:442
uint8_t passwordMode
Definition: fabui.h:1405
void repaintWindow(uiWindow *window)
Repaints a window.
Definition: fabui.cpp:787
uiTextEditProps & textEditProps()
Sets or gets text edit properties.
Definition: fabui.h:1453
bool realtimeReshaping
Definition: fabui.h:2979
Contains details about the mouse event.
Definition: fabui.h:168
RGB888 backgroundColor
Definition: fabui.h:2511
RGB888 mouseOverButtonColor
Definition: fabui.h:747
CursorName
This enum defines a set of predefined mouse cursors.
int focusIndex()
Determines the focus index (aka tab-index)
Definition: fabui.h:643
RGB888 mouseOverBackgroundColor
Definition: fabui.h:1387
FontInfo const * textFont
Definition: fabui.h:1550
uiWindow * firstChild()
Gets first child.
Definition: fabui.h:449
void setPercentage(int value)
Sets percentage.
Definition: fabui.cpp:5135
Bitmap const * downBitmap
Definition: fabui.h:1229
uiCheckBoxStyle & checkBoxStyle()
Sets or gets checkbox style.
Definition: fabui.h:2566
char const * directory()
Determines absolute path of current directory.
Definition: fabutils.h:569
uint8_t hasMaximizeButton
Definition: fabui.h:776
void reshapeWindow(uiWindow *window, Rect const &rect)
Reshapes a window.
Definition: fabui.cpp:821
FontInfo const * titleFont
Definition: fabui.h:743
StringList & items()
A list of strings representing items of the combobox.
Definition: fabui.h:2405
Delegate< int > onSelect
Item select event.
Definition: fabui.h:2942
RGB888 activeTitleBackgroundColor
Definition: fabui.h:740
uiWindow * setFocusedWindow(uiWindow *value)
Sets the focused window (control)
Definition: fabui.cpp:705
This file contains FabGL library configuration settings, like number of supported colors...
uiHAlign textAlign
Definition: fabui.h:1553
RGB888 backgroundColor
Definition: fabui.h:1653
Base class of all UI elements like windows and controls.
Definition: fabui.h:277
int16_t X
void setBitmap(Bitmap const *bitmap)
Sets image bitmap.
Definition: fabui.cpp:3325
Delegate< uiKeyEventInfo const & > onKeyUp
Key-up event delegate.
Definition: fabui.h:936
A paintbox control allows applications to perform custom drawings providing uiPaintBox.onPaint delegate. A paintbox can have horizontal and vertical scrollbars.
Definition: fabui.h:1791
RGB888 foregroundColor
Definition: fabui.h:2515
RGB888 mouseOverTextColor
Definition: fabui.h:1223
StringList & items()
A list of strings representing the listbox content.
Definition: fabui.h:2087
Point pos()
Determines the window position relative to parent window.
Definition: fabui.h:484
virtual Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1581
void setChecked(bool value)
Sets current checkbox or radiobutton checked status.
Definition: fabui.cpp:4804
Represents a bidimensional size.
Definition: fabutils.h:209
uiCheckBox(uiWindow *parent, const Point &pos, const Size &size, uiCheckBoxKind kind=uiCheckBoxKind::CheckBox, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4691
Delegate onKillFocus
Kill focus event delegate.
Definition: fabui.h:2002
RGB888 backgroundColor
Definition: fabui.h:1386
uiComboBoxProps & comboBoxProps()
Sets or gets combobox properties.
Definition: fabui.h:2313
int VScrollBarPos()
Determines position of the vertical scrollbar thumb.
Definition: fabui.h:1125
RGB888 textColor
Definition: fabui.h:1552
uint8_t fillBackground
Definition: fabui.h:778
uiObjectType & objectType()
Determines the object type.
Definition: fabui.h:290
bool hasChildren()
Determines whether this window has children.
Definition: fabui.h:463
RGB888 focusedBorderColor
Definition: fabui.h:372
Delegate onShow
Show window event delegate.
Definition: fabui.h:904
uiTimerHandle setTimer(uiEvtHandler *dest, int periodMS)
Setups a timer.
Definition: fabui.cpp:936
bool isDirectory()
Determines whether currently selected item is a directory.
Definition: fabui.cpp:4324
int max()
Gets maximum position.
Definition: fabui.h:2713
RGB888 backgroundColor
Definition: fabui.h:1219
uiApp * app()
Determines the app that owns this object.
Definition: fabui.h:318
Contains the listbox style.
Definition: fabui.h:2250
FontInfo const * textFont
Definition: fabui.h:1390
void resizeWindow(uiWindow *window, int width, int height)
Resizes a window.
Definition: fabui.cpp:808
int endModalWindow(ModalWindowState *state)
Ends modal window processing.
Definition: fabui.cpp:891
bool postEvent(uiEvent const *event)
Places an event in the event queue and returns without waiting for the receiver to process the event...
Definition: fabui.cpp:609
uiScrollableControl(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3552
A label is a static text UI element.
Definition: fabui.h:1563
void processEvents()
Processes all events in queue.
Definition: fabui.cpp:380
uiSimpleMenu(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:5154
uiProgressBar(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:5068
Delegate< uiMouseEventInfo const & > onMouseUp
Mouse up event delegate.
Definition: fabui.h:1351
Properties of the text edit.
Definition: fabui.h:1402
uiComboBox(uiWindow *parent, const Point &pos, const Size &size, int listHeight, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4614
uiListBox(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4212
virtual void setScrollBar(uiOrientation orientation, int position, int visible, int range, bool repaintScrollbar=true)
Sets scrollbar position, visible portion and range.
Definition: fabui.cpp:3584
uint8_t hasCloseButton
Definition: fabui.h:775
void bringOnTop()
Brings this window on top.
Definition: fabui.cpp:1520
uint8_t changedButton
Definition: fabui.h:170
Contains the image style.
Definition: fabui.h:1652
uiWindowState state()
Determines the window state.
Definition: fabui.h:536
uiPanel(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:3373
void setGroupIndex(int value)
Sets radiobutton group index.
Definition: fabui.h:2596
Rect clientRect(uiOrigin origin)
Determines the client area bounding box.
Definition: fabui.cpp:1980
RGB888 borderColor
Definition: fabui.h:370
uiWindow * moveFocus(int delta)
Move focus to a control with current focus index plus a delta.
Definition: fabui.cpp:760
RGB888 checkedBackgroundColor
Definition: fabui.h:2512
void repaintRect(Rect const &rect)
Repaints a screen area.
Definition: fabui.cpp:793
This is the base class for all controls. A control can have focus and is not activable.
Definition: fabui.h:998
RGB888 titleBackgroundColor
Definition: fabui.h:739
Properties of the progress bar.
Definition: fabui.h:2774
bool hasFocus()
Determines whether this window or control has focus.
Definition: fabui.cpp:1855
uiWindow * capturedMouseWindow()
Determines which window is capturing mouse.
Definition: fabui.h:3180
Properties of the list box.
Definition: fabui.h:1915
uint8_t selectOnMouseOver
Definition: fabui.h:1917
int HScrollBarRange()
Determines horizontal scrollbar range.
Definition: fabui.h:1115
RGB888 activeTitleColor
Definition: fabui.h:742
char const * text()
Gets current content of the text edit.
Definition: fabui.h:2435
void repaint()
Repaints this window.
Definition: fabui.cpp:1559
uiFileBrowser(uiWindow *parent, const Point &pos, const Size &size, bool visible=true, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:4269
Contains anchors enable/disable switches.
Definition: fabui.h:389
uiProgressBarStyle & progressBarStyle()
Sets or gets progress bar style.
Definition: fabui.h:2809
char const * title()
Determines the window title.
Definition: fabui.h:848
RGB888 selectedBackgroundColor
Definition: fabui.h:1895
RGB888 backgroundColor
Definition: fabui.h:1551
Delegate onPaint
Paint event delegate.
Definition: fabui.h:941
RGB888 focusedBackgroundColor
Definition: fabui.h:1388
Shows generic a list of selectable items.
Definition: fabui.h:1928
uiWindow * next()
Gets next sibling.
Definition: fabui.h:433
Delegate onHide
Hide window event delegate.
Definition: fabui.h:911
void setDirectory(char const *path)
Sets current directory as absolute path.
Definition: fabui.cpp:4302
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition: fabui.h:1952
uint8_t height
A progress bar shows progress percentage using a colored bar.
Definition: fabui.h:2785
Delegate onChange
Button changed event delegate.
Definition: fabui.h:1330
Delegate onChange
Change event delegate.
Definition: fabui.h:2606
RGB888 backgroundColor
Definition: fabui.h:1893
RGB888 backgroundColor
Definition: fabui.h:2638
void setText(char const *value)
Replaces current text.
Definition: fabui.cpp:2724
void selectColor(Color value)
Sets current selected color.
Definition: fabui.h:2481
uiWindow * activeWindow()
Gets a pointer to the currently active window.
Definition: fabui.h:3120
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:2660
Point clientPos()
Determines position of the client area.
Definition: fabui.cpp:1594
uiWindow(uiWindow *parent, const Point &pos, const Size &size, bool visible, uint32_t styleClassID=0)
Creates an instance of the object.
Definition: fabui.cpp:1374
uiFrame * rootWindow()
Gets a pointer to the root window.
Definition: fabui.h:3110
Specifies current window state.
Definition: fabui.h:347
Delegate< uiMouseEventInfo const & > onMouseDown
Mouse down event delegate.
Definition: fabui.h:1344
RGB888 backgroundColor
Definition: fabui.h:738
void setText(char const *value)
Replaces current text.
Definition: fabui.h:2428
Delegate< uiKeyEventInfo const & > onKeyUp
Key-up event delegate.
Definition: fabui.h:2012
This is a combination of a listbox and a single-line editable textbox.
Definition: fabui.h:2379
Shows and navigates Virtual Filesystem content.
Definition: fabui.h:2108
The PS2 Mouse controller class.
Definition: mouse.h:111
uiImageStyle & imageStyle()
Sets or gets image style.
Definition: fabui.h:1704
int count()
Determines number of files in current directory.
Definition: fabutils.h:576
Contains the checkbox style.
Definition: fabui.h:2510
Delegate onChange
Text edit event delegate.
Definition: fabui.h:1486
bool isMouseOver()
Determines whether the mouse is over this window.
Definition: fabui.h:595
void joinAsyncRun()
Waits for runAsync termination.
Definition: fabui.cpp:371
uint8_t allowMultiSelect
Definition: fabui.h:1916
int HScrollBarVisible()
Determines horizontal scrollbar visible portion (aka thumb size) of the scrollable content...
Definition: fabui.h:1105
void showWindow(uiWindow *window, bool value)
Makes a window visible or invisible.
Definition: fabui.cpp:829
uint8_t hasMinimizeButton
Definition: fabui.h:777
RGB888 focusedBackgroundColor
Definition: fabui.h:1894
void exitModal(int modalResult)
Exits from a modal window.
Definition: fabui.cpp:1841
Contains the panel style.
Definition: fabui.h:1727
uint8_t width
uiWindow * focusedWindow()
Gets the focused window (control)
Definition: fabui.h:3145
bool isActiveWindow()
Determines wheter this window is the active window.
Definition: fabui.cpp:1849
void changeDirectory(char const *path)
Changes current directory as relative path.
Definition: fabui.cpp:4310
uint8_t bitmapTextSpace
Definition: fabui.h:1227
void setText(char const *value)
Sets button text.
Definition: fabui.cpp:2559
char const * text()
Determines label text.
Definition: fabui.h:1606
uint8_t resizeable
Definition: fabui.h:773
void setTitle(char const *value)
Sets window title.
Definition: fabui.cpp:1936
uiMessageBoxIcon
Icon displayed by the uiApp.messageBox() method.
Definition: fabui.h:2999
FontInfo const * textFont
Definition: fabui.h:2760
void enableKeyboardAndMouseEvents(bool value)
Enables or disables mouse and keyboard events.
Definition: fabui.cpp:1345
bool checked()
Determines whether the checkbox or radiobutton is checked.
Definition: fabui.h:2573
int min()
Gets minimum position.
Definition: fabui.h:2706
Image control to display a static bitmap.
Definition: fabui.h:1663
void killTimer(uiTimerHandle handle)
Kills a timer.
Definition: fabui.cpp:945
bool realtimeMoving
Definition: fabui.h:2980
Delegate< uiKeyEventInfo const & > onKeyType
Key-type event delegate.
Definition: fabui.h:2007
FileBrowser allows basic file system operations (dir, mkdir, remove and rename)
Definition: fabutils.h:532
Delegate onChange
Slider changed event delegate.
Definition: fabui.h:2730