FabGL
ESP32 VGA Controller and Graphics Library
|
Represents the whole application base class. More...
#include <fabui.h>
Public Member Functions | |
uiWindow * | activeWindow () |
Gets a pointer to the currently active window. More... | |
uiApp * | app () |
Determines the app that owns this object. More... | |
uiAppProps & | appProps () |
Sets or gets application properties. More... | |
uiWindow * | capturedMouseWindow () |
Determines which window is capturing mouse. More... | |
void | destroyWindow (uiWindow *window) |
Destroys a window. More... | |
void | enableKeyboardAndMouseEvents (bool value) |
Enables or disables mouse and keyboard events. More... | |
int | endModalWindow (ModalWindowState *state) |
Ends modal window processing. More... | |
uiWindow * | focusedWindow () |
Gets the focused window (control) More... | |
virtual void | init () |
Method to inherit to implement an application. More... | |
ModalWindowState * | initModalWindow (uiWindow *window) |
Begins modal window processing. More... | |
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. More... | |
bool | insertEvent (uiEvent const *event) |
Inserts (first position) an event in the event queue and returns without waiting for the receiver to process the event. More... | |
void | killTimer (uiTimerHandle handle) |
Kills a timer. More... | |
void | maximizeWindow (uiWindow *window, bool value) |
Maximizes or restores a window. More... | |
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. More... | |
void | minimizeWindow (uiWindow *window, bool value) |
Minimizes or restores a window. More... | |
uiWindow * | moveFocus (int delta) |
Move focus to a control with current focus index plus a delta. More... | |
void | moveWindow (uiWindow *window, int x, int y) |
Moves a window. More... | |
uiObjectType & | objectType () |
Determines the object type. More... | |
bool | postEvent (uiEvent const *event) |
Places an event in the event queue and returns without waiting for the receiver to process the event. More... | |
void | processEvents () |
Processes all events in queue. More... | |
bool | processModalWindowEvents (ModalWindowState *state, int timeout) |
Processes all messages from modal window. More... | |
void | quit (int exitCode) |
Terminates application and free resources. More... | |
void | repaintRect (Rect const &rect) |
Repaints a screen area. More... | |
void | repaintWindow (uiWindow *window) |
Repaints a window. More... | |
void | reshapeWindow (uiWindow *window, Rect const &rect) |
Reshapes a window. More... | |
void | resizeWindow (uiWindow *window, int width, int height) |
Resizes a window. More... | |
void | resizeWindow (uiWindow *window, Size size) |
Resizes a window. More... | |
uiFrame * | rootWindow () |
Gets a pointer to the root window. More... | |
int | run () |
Initializes application and executes the main event loop. More... | |
uiWindow * | screenToWindow (Point &point) |
Determines which window a point belongs to. More... | |
uiWindow * | setActiveWindow (uiWindow *value) |
Sets the active window. More... | |
uiWindow * | setFocusedWindow (uiWindow *value) |
Sets the focused window (control) More... | |
uiTimerHandle | setTimer (uiEvtHandler *dest, int periodMS) |
Setups a timer. More... | |
int | showModalWindow (uiWindow *window) |
Makes a window visible and handles it has a modal window. More... | |
void | showWindow (uiWindow *window, bool value) |
Makes a window visible or invisible. More... | |
Public Attributes | |
Delegate< uiTimerHandle > | onTimer |
Timer event delegate. More... | |
Represents the whole application base class.
FabGL UI apps must inherit from uiApp, create UI elements in uiApp.init() method, and finally call uiApp.run() to start the application. uiApp is responsible for events queue handling, windows manager, windows and controls lifecycle and memory management.
|
inline |
Gets a pointer to the currently active window.
There is only one active window at the time. Active window is the foreground window and receives (along with focused control) all keyboard events. To set the active window call uiApp.setActiveWindow().
|
inlineinherited |
Determines the app that owns this object.
|
inline |
Sets or gets application properties.
|
inline |
Determines which window is capturing mouse.
Mouse is captured by a window when mouse is dragged (left button down while moving mouse) starting from window area.
void fabgl::uiApp::destroyWindow | ( | uiWindow * | window | ) |
Destroys a window.
window | Window to destroy |
void fabgl::uiApp::enableKeyboardAndMouseEvents | ( | bool | value | ) |
Enables or disables mouse and keyboard events.
For default mouse and keyboard events are enabled.
value | True to enable events, False to disable events |
int fabgl::uiApp::endModalWindow | ( | ModalWindowState * | state | ) |
Ends modal window processing.
Ends the modal window status. After this other windows can receive input. This method should be always called when processModalWindowEvents() returns False, or when modal window must be anyway closed.
state | This parameter comes from initModalWindow() and is used internally to maintain modal window status. |
|
inline |
Gets the focused window (control)
There is only one focused window or control at the time. Focused window is also the active window (or its parent is the active window). Focused window receives (along with active window) all keyboard events. Focused window can have a blinking caret. Finally, a focused window partecipates to the TAB "trip", respecting the tab-order (see uiWindow.focusIndex()).
To set the focoused window use uiApp.setFocusedWindow().
|
virtual |
Method to inherit to implement an application.
ModalWindowState * fabgl::uiApp::initModalWindow | ( | uiWindow * | window | ) |
Begins modal window processing.
initModalWindow(), processModalWindowEvents() and endModalWindow() are useful when a long processing operation is necessary inside a modal window.
window | The form to use as modal window |
uiMessageBoxResult fabgl::uiApp::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.
Pressing ENTER (RETURN) equals to press first button. Pressing ESC cancels the dialog box.
title | The dialog box title. If nullptr the messaebox has no title bar |
text | The message to be displayed |
inOutString | Initial string of the text edit |
maxLength | Maximum length of inOutString buffer (ending zero not included) |
button1Text | Left button text |
button2Text | Right button text (may be nullptr, if not present) |
bool fabgl::uiApp::insertEvent | ( | uiEvent const * | event | ) |
Inserts (first position) an event in the event queue and returns without waiting for the receiver to process the event.
event | Event to insert. A copy of the event is sent. |
void fabgl::uiApp::killTimer | ( | uiTimerHandle | handle | ) |
Kills a timer.
To create a timer use uiApp.setTimer().
handle | Handle identifying the timer to destroy |
void fabgl::uiApp::maximizeWindow | ( | uiWindow * | window, |
bool | value | ||
) |
Maximizes or restores a window.
window | Window to be maximized or restored |
value | True maximizes the window, False restores it from maximized state |
uiMessageBoxResult fabgl::uiApp::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.
title | The dialog box title. If nullptr the messaebox has no title bar |
text | The message to be displayed |
button1Text | Left button text |
button2Text | Middle button text (may be nullptr, if not present) |
button3Text | Right button text (may be nullptr, if not present) |
icon | Icon to be displayed |
void fabgl::uiApp::minimizeWindow | ( | uiWindow * | window, |
bool | value | ||
) |
Minimizes or restores a window.
window | Window to be minimized or restored |
value | True minimizes the window, False restores it from minimized state |
uiWindow * fabgl::uiApp::moveFocus | ( | int | delta | ) |
Move focus to a control with current focus index plus a delta.
A focused window partecipates to the TAB "trip", respecting the tab-order (see uiWindow.focusIndex()). Calling moveFocus(1) is the same of pressing TAB. Calling moveFocus(-1) is the same of pressing SHIFT-TAB.
delta | Specifies how many controls pass (1 = next control, -1 = previous control) |
void fabgl::uiApp::moveWindow | ( | uiWindow * | window, |
int | x, | ||
int | y | ||
) |
Moves a window.
window | Window to be moved |
x | New horizontal coordinate, relative to parent window |
y | New vertical coordinate, relative to parent window |
|
inlineinherited |
Determines the object type.
bool fabgl::uiApp::postEvent | ( | uiEvent const * | event | ) |
Places an event in the event queue and returns without waiting for the receiver to process the event.
event | Event to send. A copy of the event is sent. |
void fabgl::uiApp::processEvents | ( | ) |
Processes all events in queue.
This method is useful to update UI while running long time tasks.
bool fabgl::uiApp::processModalWindowEvents | ( | ModalWindowState * | state, |
int | timeout | ||
) |
Processes all messages from modal window.
This method must be called whenever UI needs to be updated.
state | This parameter comes from initModalWindow() and is used internally to maintain modal window status. |
timeout | Timeout in milliseconds to wait for messages. -1 = infinite timeout, 0 = no timeout. |
void fabgl::uiApp::quit | ( | int | exitCode | ) |
Terminates application and free resources.
exitCode | Value returned by uiApp.run(). |
void fabgl::uiApp::repaintRect | ( | Rect const & | rect | ) |
Repaints a screen area.
rect | Rectangle to be repainted (in screen coordiantes) |
void fabgl::uiApp::repaintWindow | ( | uiWindow * | window | ) |
Repaints a window.
window | The window to be repainted |
Reshapes a window.
window | Window to be reshaped |
rect | New window bounding box, relative to the parent window |
void fabgl::uiApp::resizeWindow | ( | uiWindow * | window, |
int | width, | ||
int | height | ||
) |
Resizes a window.
window | Window to be resized |
width | New horizontal size |
height | New vertical size |
Resizes a window.
window | Window to be resized |
size | New window size |
|
inline |
Gets a pointer to the root window.
The root window is the first window created and covers the whole screen. All windows and controls must have the root window as parent, or as ancestor.
int fabgl::uiApp::run | ( | ) |
Initializes application and executes the main event loop.
This is the last method that should be called: it never returns.
Determines which window a point belongs to.
point | A point relative to the screen |
Sets the active window.
There is only one active window at the time. Active window is the foreground window and receives (along with focused control) all keyboard events.
value | Pointer of the active window. nullptr to set no active window |
Sets the focused window (control)
There is only one focused window or control at the time. Focused window is also the active window (or its parent is the active window). Focused window receives (along with active window) all keyboard events. Focused window can have a blinking caret. Finally, a focused window partecipates to the TAB "trip", respecting the tab-order (see uiWindow.focusIndex()).
uiTimerHandle fabgl::uiApp::setTimer | ( | uiEvtHandler * | dest, |
int | periodMS | ||
) |
Setups a timer.
A timer fires uiApp.onTimer or uiFrame.onTimer delegate. To destroy a timer use uiApp.killTimer().
dest | Destination window or app |
periodMS | Timer period in milliseconds |
int fabgl::uiApp::showModalWindow | ( | uiWindow * | window | ) |
Makes a window visible and handles it has a modal window.
A modal window disables the main window but keeps it visible. Users must interact with the modal window before they can return to the parent window. A modal window exits from modal state using uiWindow.exitModal(). showModalWindow() is the combination of initModalWindow(), processModalWindowEvents() and endModalWindow() called in sequence.
window | Window to be made visible and modal |
void fabgl::uiApp::showWindow | ( | uiWindow * | window, |
bool | value | ||
) |
Makes a window visible or invisible.
window | Window to be made visible |
value | If true the window will be shown, if false the window will be hidden |
Delegate<uiTimerHandle> fabgl::uiApp::onTimer |
Timer event delegate.
This delegate is called when the timer expires. To create a timer use uiApp.setTimer().