![]() |
The ZX Ecosystem v5.1.0;_GUI_v3.1.0
|
This module provides the base definitions for the widgets system.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Namespaces | |
namespace | zxeco |
The main namespace of the library, that spans across all the zx modules. | |
namespace | zxeco::gui |
The namespace of the GUI companion sub-library. | |
Classes | |
class | zxeco::gui::Widget |
All widgets must inherit from this. More... | |
class | zxeco::gui::Widget::PVector |
A vector of ptrs to widgets. More... | |
class | zxeco::gui::Widget::Path |
A path in the widget tree. More... | |
struct | zxeco::gui::Widget::AreaFitting |
Information about the fitting of widgets drawings into rectangular areas. More... | |
struct | zxeco::gui::Widget::EventData |
Data passed to a widget when an event occurs. More... | |
struct | zxeco::gui::Widget::EventData::EvData |
Event data. More... | |
struct | zxeco::gui::Widget::ChainEventResult |
Result of chaining an event, i.e., flowing it through the widget tree. More... | |
struct | zxeco::gui::Widget::CallbackParms |
A class to contain the parameters received by a callback routine. More... | |
struct | zxeco::gui::Widget::Trace |
Kinds of tracings that can be activated in the whole widget system. More... | |
class | zxeco::gui::ContainerWidget |
A container of other widgets. More... | |
Typedefs | |
using | zxeco::gui::Widget::ID = int |
A numeric ID associated to the widget. More... | |
using | zxeco::gui::Widget::Ptr = std::shared_ptr< Widget > |
A polymorphic ptr to a widget. More... | |
using | zxeco::gui::Widget::TraverseObserver = std::function< TravResult(Widget &) > |
Enumerations | |
enum class | zxeco::gui::Widget::TravResult { FINISH_OK , FINISH_FAIL , BACKTRACK , CONTINUE } |
Possible results of observer when traversing widgets in the widget tree. More... | |
class zxeco::gui::Widget |
All widgets must inherit from this.
There are 2 basic kinds of widgets: non-containers and containers. The former inherit from this class and cannot contain other widgets within their drawing areas; the latter inherit from ContainerWidget and can contain other widgets. In this way, a set of widgets always form a tree structure with a container at its root.
Definition at line 55 of file ZXWidgetsBase.h.
Public Types | |
enum class | TravResult { FINISH_OK , FINISH_FAIL , BACKTRACK , CONTINUE } |
Possible results of observer when traversing widgets in the widget tree. More... | |
using | ID = int |
A numeric ID associated to the widget. More... | |
using | Ptr = std::shared_ptr< Widget > |
A polymorphic ptr to a widget. More... | |
using | TraverseObserver = std::function< TravResult(Widget &) > |
enum class | HorAlign { LEFT , RIGHT , CENTER } |
Horizontal alignment of widgets within the areas of their containers. More... | |
enum class | VertAlign { TOP , BOTTOM , MIDDLE } |
Vertical alignment of widgets within the areas of their containers. More... | |
Public Member Functions | |
Widget (ID id, const std::string &name, const std::string &tooltiptext="", HorAlign hal=HorAlign::LEFT, VertAlign val=VertAlign::TOP) | |
Constructor. More... | |
Widget (const Widget &)=delete | |
Constructor. More... | |
Widget (Widget &&)=delete | |
Constructor. More... | |
Widget & | operator= (const Widget &)=delete |
Constructor. More... | |
Widget & | operator= (Widget &&)=delete |
Constructor. More... | |
virtual | ~Widget (void)=default |
Just to activate polymorphic deletes. | |
virtual const char * | className (void) const noexcept=0 |
Must return a text with the name of the class. More... | |
std::string | idText (bool withpointer=false) const |
Return a text with the identification of this widget. More... | |
virtual bool | isContainer (void) const noexcept |
Return whether the widget is a container of other widgets. More... | |
bool | isUserContainer (void) const noexcept |
Return whether the widget is a USER-type container. More... | |
ID | getID (void) const noexcept |
Return the ID assigned to the widget at creation. More... | |
void | changeID (ID id) noexcept |
Change the ID without checking for duplicates in this widget tree. More... | |
const std::string & | getName (void) const noexcept |
Return the name of the widget. More... | |
bool | operator== (const Widget &oth) const noexcept |
Operator to detect unique identities in widgets. More... | |
bool | operator!= (const Widget &oth) const noexcept |
Operator to detect unique identities in widgets. More... | |
virtual std::pair< bool, const CharRect * > | hasFocusZone (void) const noexcept |
< Must return TRUE and the zone if the widget contains a focus-able zone. More... | |
virtual void | setWindow (Window &win) noexcept |
Set the Window where the widget is being managed. More... | |
virtual void | setWinColors (const WinColors &wincols) noexcept |
< Assign the colors used to draw the widget. WINCOLS must outlive this. More... | |
const WinColors & | getWinColors (void) const noexcept |
Return the current window colors. More... | |
virtual void | setUDGs (const uint8_t *udgs) |
Assign an UDG character set for the widget drawing (do not copy them). More... | |
const uint8_t * | getUDGs (void) |
Return the current UDGs. */. More... | |
virtual void | setTooltip (const std::string &ttt) |
Must return a text with the name of the class. More... | |
const std::string & | getTooltip (void) const noexcept |
Return the tooltip for the widget. More... | |
void | setParent (Widget *parent) |
Sets the parent of the widget to PARENT, that must outlive it. More... | |
Widget * | getParent (void) const noexcept |
Return a pointer to the parent of the widget, or nullptr if none. More... | |
Widget * | getRoot (void) |
Return a pointer to the root widget of the tree. More... | |
bool | isRoot (void) const noexcept |
Return TRUE if this widget is the root of the tree. More... | |
bool | isDescendantOf (Widget &w) const |
Return TRUE if this is W or a descendant of W. More... | |
Widget * | searchID (ID id) const |
Search the first appearance of the given ID in this and its descendants. More... | |
ID | maxUsedID (void) const |
Search in this widget and its descendants the maximum ID used. More... | |
TravResult | traverse (const TraverseObserver &obs) |
Traverse this widget and its descendants, calling OBS on each one. More... | |
TravResult | revTraverse (const TraverseObserver &obs) |
Traverse this widget and its ascendants, calling OBS on each one. More... | |
void | setVisibility (bool visible=true) |
Set the desired visibility of the widget. More... | |
void | setVisibilityNoRedrawing (bool vis) noexcept |
Set the widget visibility without redrawing or modifying focus. More... | |
bool | getVisibility (void) const noexcept |
Get current visibility of the widget, considering also its parents. More... | |
void | setEnabled (bool enabled=true) |
Set whether the widget is enabld or disabld; drawRaw() widget if changd. More... | |
bool | getEnabled (void) const noexcept |
Get current enabled state of the widget, considering its parents. More... | |
bool | isFocusable (bool drawntoo=true) const |
Return TRUE if the widget is focusable now. More... | |
bool | isInFocusPath (void) const noexcept |
Return TRUE if the widget is in the path from root to the leaf focused. More... | |
bool | isLeafFocused (void) const noexcept |
< Return TRUE if it is in the focus path and it is the leaf of that path. More... | |
Widget * | whoIsFocused (void) |
Get the leaf focused widget in the tree, or nullptr if none. More... | |
void | acquireFocus (const PointingStatus *m=nullptr) |
Give the focus to this widget and quit it from the current focused one. More... | |
void | releaseFocus (void) |
Quit focus from this leaf widget or below it; no one acquires it. More... | |
void | drawAll (const CharRect &rect) |
Calculate and set the placement of all widgets within RECT and draw'em. More... | |
Widget * | redrawAll (void) |
Recalculate, place and redraw all widgets that have changed in the tree. More... | |
void | redrawMe (void) |
Recalculate and place all widgets in the tree forcing this to be drawn. More... | |
void | drawMe (void) |
Just force to draw the widget in the current drawing zone. More... | |
virtual const AreaFitting & | calcFittingNeeds (const CharArea &area)=0 |
Must calculate the widget fitting within the dimensions of AREA. More... | |
const AreaFitting & | fittingNeeds (void) const noexcept |
< Return the last calculation of the fitting needs of the widget. More... | |
virtual Widget * | setDrawingZone (const CharRect &zone) |
Set the final drawing zone for the widget and the aligned one. More... | |
const CharRect & | drawingZone (void) const noexcept |
< Get the drawing zone decided for the widget within the global screen. More... | |
const CharRect & | alignedDrawingZone (void) const noexcept |
< Get the part of the drawing zone that is already aligned. More... | |
virtual void | moveDrawingZones (IntDist incx, IntDist incy) noexcept |
Move the drawing and aligned zones corners by those increments. More... | |
bool | drawn (void) const noexcept |
Return TRUE if the widget has already been drawn in current dimensions. More... | |
void | undraw (void) noexcept |
Method for external agents (e.g., Windows) to mark the widget undrawn. More... | |
void | setExplanations (bool setit=true) noexcept |
< Set/unset the generation of explanations when calculating drawing. More... | |
bool | getExplanations (void) const noexcept |
Return the current status of drawing explanations. More... | |
std::string | traceOfDrawing (bool withoutprivate=true) const |
< Return an explanation with the drawing status of this and child widgets More... | |
virtual void | traceOfDrawingRecursive (size_t level, std::stringstream &ss, bool withoutprivate=true) const |
Same as traceOfDrawing() but indicating the depth level and using SS. More... | |
virtual ChainEventResult | chainEvent (const EventData &data) |
Deal with the event at this widget and its descendants (if container). More... | |
virtual void | setCallback (const CallbackRout &callback=NullCallback) |
Deal with the event at this widget and its descendants (if container). More... | |
const CallbackRout & | getCallback (void) const noexcept |
Get the current callback routine. More... | |
void | addCallback (const CallbackRout &cbk) |
Add callback CBK to the end of the current callback routine. More... | |
Protected Member Functions | |
virtual void | drawRaw (void) |
Must draw itself in the decided aligned zone withing the drawing zone. More... | |
virtual int | processEvent (const EventData &evdata, Widget *who) |
void | addLineToExplanation (const std::string &line) |
Add LINE to the existing explanation in fitting_needs_. More... | |
Protected Attributes | |
ID | id_ |
const std::string | name_ |
const WinColors * | pwincols_ |
const uint8_t * | udgs_ |
Window * | pwin_ |
CallbackRout | callback_ |
std::string | tooltiptext_ |
HorAlign | hal_ |
VertAlign | val_ |
AreaFitting | fitting_needs_ |
CharRect | drawing_zone_ |
CharRect | aligned_drawing_zone_ |
Widget * | parent_ |
bool | explaindrawing_ |
Static Protected Attributes | |
static Trace::Type | traces_ |
Currently active traces. More... | |
enum class | EventType { MOUSE , KEYBOARD , FOCUS } |
Kinds of events that the widgets may process from the graphical environ. More... | |
enum class | SubEvType { MOUSE_MOVE , MOUSE_CLICK , MOUSE_UNCLICK , MOUSE_WHEEL , KEYB_PRESS , KEYB_UNPRESS , KEYB_TEXT , FOCUS_GOT , FOCUS_LOST } |
Concrete events for each event kind. More... | |
using | CallbackRout = std::function< bool(Widget &, const CallbackParms &)> |
static const CallbackRout | NullCallback |
Callback routine that does nothing. More... | |
static const std::string | kTraceBegin |
< Add TRACES to the currently active traces (initially none). More... | |
static const std::string | kTraceEnd |
< Add TRACES to the currently active traces (initially none). More... | |
static void | addGlobalTraces (Trace::Type traces) noexcept |
< Add TRACES to the currently active traces (initially none). More... | |
static void | delGlobalTraces (Trace::Type traces) noexcept |
< Delete the given traces from the current active ones. More... | |
static Trace::Type | isTracing (Trace::Type traces) noexcept |
< Return a non-zero value if any of TRACES is currently active. More... | |
static void | printTrace (Trace::Type trace, const std::string &tr) |
Put TR in console as a trace, with a mark indicating TRACE. | |
static void | printIfTrace (Trace::Type trace, const std::string &tr) |
The same as printTrace() but only print if any of TRACE is active. More... | |
using zxeco::gui::Widget::CallbackRout = std::function< bool(Widget &, const CallbackParms &)> |
Callback routines are routines called before and after an event is processed during chaining. Each widget may register a callback. Leaf widgets only call the routine once (after processing the event), while the rest of widgets in the event flow path call the routine both before and after. The routine must return FALSE to make the window manager to return from its management, or TRUE to go on.
Definition at line 591 of file ZXWidgetsBase.h.
|
strong |
Horizontal alignment of widgets within the areas of their containers.
Definition at line 252 of file ZXWidgetsBase.h.
|
strong |
Vertical alignment of widgets within the areas of their containers.
Definition at line 259 of file ZXWidgetsBase.h.
|
strong |
Kinds of events that the widgets may process from the graphical environ.
Enumerator | |
---|---|
MOUSE | movement, clicking, ... |
KEYBOARD | pressing, unpressing |
FOCUS | focus change |
Definition at line 272 of file ZXWidgetsBase.h.
|
strong |
Concrete events for each event kind.
Definition at line 279 of file ZXWidgetsBase.h.
|
inline |
Constructor.
The widget is enabled and visible at creation, yet not focused or drawn The root widget in the widget tree is always considered visible.
id | is the ID of the widget, not necessarily unique. |
name | is the name of the widget, not unique and used for the tabbed title in the case of the children of tabbed DEEP containers. It may be empty. |
tooltiptext | is the tooltiptext for the widget. |
hal | is the horizontal alignment within its parent. |
val | is the vertical alignment within its parent. |
Definition at line 655 of file ZXWidgetsBase.h.
|
delete |
Constructor.
The widget is enabled and visible at creation, yet not focused or drawn The root widget in the widget tree is always considered visible.
id | is the ID of the widget, not necessarily unique. |
name | is the name of the widget, not unique and used for the tabbed title in the case of the children of tabbed DEEP containers. It may be empty. |
tooltiptext | is the tooltiptext for the widget. |
hal | is the horizontal alignment within its parent. |
val | is the vertical alignment within its parent. |
|
delete |
Constructor.
The widget is enabled and visible at creation, yet not focused or drawn The root widget in the widget tree is always considered visible.
id | is the ID of the widget, not necessarily unique. |
name | is the name of the widget, not unique and used for the tabbed title in the case of the children of tabbed DEEP containers. It may be empty. |
tooltiptext | is the tooltiptext for the widget. |
hal | is the horizontal alignment within its parent. |
val | is the vertical alignment within its parent. |
|
inlinestaticnoexcept |
< Add TRACES to the currently active traces (initially none).
Definition at line 629 of file ZXWidgetsBase.h.
|
inlinestaticnoexcept |
< Delete the given traces from the current active ones.
Definition at line 633 of file ZXWidgetsBase.h.
|
inlinestaticnoexcept |
< Return a non-zero value if any of TRACES is currently active.
Definition at line 637 of file ZXWidgetsBase.h.
|
static |
The same as printTrace() but only print if any of TRACE is active.
This version is more expensive in resources than printTrace() since TR has been formed unregarding it is finally printed or not.
Constructor.
The widget is enabled and visible at creation, yet not focused or drawn The root widget in the widget tree is always considered visible.
id | is the ID of the widget, not necessarily unique. |
name | is the name of the widget, not unique and used for the tabbed title in the case of the children of tabbed DEEP containers. It may be empty. |
tooltiptext | is the tooltiptext for the widget. |
hal | is the horizontal alignment within its parent. |
val | is the vertical alignment within its parent. |
Constructor.
The widget is enabled and visible at creation, yet not focused or drawn The root widget in the widget tree is always considered visible.
id | is the ID of the widget, not necessarily unique. |
name | is the name of the widget, not unique and used for the tabbed title in the case of the children of tabbed DEEP containers. It may be empty. |
tooltiptext | is the tooltiptext for the widget. |
hal | is the horizontal alignment within its parent. |
val | is the vertical alignment within its parent. |
|
pure virtualnoexcept |
Must return a text with the name of the class.
The text should be a literal local to the method, since text literals have static storage and therefore exist for the entire duration of the program.
Implemented in zxeco::gui::CanvasWidget, zxeco::gui::ComboBoxWidget, zxeco::gui::CounterWidget, zxeco::gui::FileBrowserWidget, zxeco::gui::ListWidget, zxeco::gui::MenuBarWidget, zxeco::gui::ContainerWidget, zxeco::gui::SlideWidget, zxeco::gui::LabelWidget, zxeco::gui::ButtonWidget, zxeco::gui::SwitchWidget, zxeco::gui::LineInputWidget, zxeco::gui::ChoiceWidget, zxeco::gui::SeparatorWidget, zxeco::gui::ImageWidget, and zxeco::gui::TextEditorWidget.
std::string zxeco::gui::Widget::idText | ( | bool | withpointer = false | ) | const |
Return a text with the identification of this widget.
If WITHPOINTER, includes the unique identification integer of the widget.
|
inlinevirtualnoexcept |
Return whether the widget is a container of other widgets.
The derived class ContainerWidget overrides this to return TRUE.
Reimplemented in zxeco::gui::ContainerWidget.
Definition at line 710 of file ZXWidgetsBase.h.
|
noexcept |
Return whether the widget is a USER-type container.
|
inlinenoexcept |
Return the ID assigned to the widget at creation.
Notice that the ID of a widget is not necessarily unique. For assure unique identity among widgets, use the == operator below.
Definition at line 717 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Change the ID without checking for duplicates in this widget tree.
Do not use this method unless really needed, since the searches for the IDs get compromised if the IDs change or are duplicated.
Definition at line 721 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return the name of the widget.
Names of widgets are strings without ctrl codes. They are not intended to be unique among widgets, and they can be empty. In the case of the direct children of DEEP-containers, these names are used as tab texts.
Definition at line 725 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Operator to detect unique identities in widgets.
Definition at line 730 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Operator to detect unique identities in widgets.
Definition at line 733 of file ZXWidgetsBase.h.
|
inlinevirtualnoexcept |
< Must return TRUE and the zone if the widget contains a focus-able zone.
< Those kinds of zones are where some events can be redirected; otherwise any event received that does not convey screen position information would not know where to be dealt with. A widget can only have one focusable zone. A feasible focusable zone in a widget is its aligned_drawing_zone_. This base method returns no focusable zone.
Reimplemented in zxeco::gui::FileBrowserWidget, zxeco::gui::ListWidget, zxeco::gui::LineInputWidget, and zxeco::gui::TextEditorWidget.
Definition at line 736 of file ZXWidgetsBase.h.
|
inlinevirtualnoexcept |
Set the Window where the widget is being managed.
Reimplemented in zxeco::gui::ContainerWidget.
Definition at line 745 of file ZXWidgetsBase.h.
|
inlinevirtualnoexcept |
< Assign the colors used to draw the widget. WINCOLS must outlive this.
Reimplemented in zxeco::gui::ContainerWidget.
Definition at line 748 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return the current window colors.
Definition at line 752 of file ZXWidgetsBase.h.
|
inlinevirtual |
Assign an UDG character set for the widget drawing (do not copy them).
The drawing method should use udgs_ member to set its UDGs. By default, the member is nullptr.
Reimplemented in zxeco::gui::ListWidget.
Definition at line 755 of file ZXWidgetsBase.h.
|
inline |
Return the current UDGs. */.
Definition at line 759 of file ZXWidgetsBase.h.
|
inlinevirtual |
Must return a text with the name of the class.
The text should be a literal local to the method, since text literals have static storage and therefore exist for the entire duration of the program.
ttt | Change the tooltip text to TTT, that can be empty but with no ctrl chrs Virtual for the case that a container wish to deploy the tooltip to one of its descendants. |
Reimplemented in zxeco::gui::CanvasWidget, and zxeco::gui::ListWidget.
Definition at line 762 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return the tooltip for the widget.
Definition at line 768 of file ZXWidgetsBase.h.
void zxeco::gui::Widget::setParent | ( | Widget * | parent | ) |
Sets the parent of the widget to PARENT, that must outlive it.
Parent must be a container, since they are the only ones able to contain other widgets.
|
inlinenoexcept |
Return a pointer to the parent of the widget, or nullptr if none.
The parent should be none only for the root widget in the tree.
Definition at line 782 of file ZXWidgetsBase.h.
Widget * zxeco::gui::Widget::getRoot | ( | void | ) |
Return a pointer to the root widget of the tree.
Start looking at this widget. This is O(h), being H the depth of the tree.
|
inlinenoexcept |
Return TRUE if this widget is the root of the tree.
Definition at line 790 of file ZXWidgetsBase.h.
bool zxeco::gui::Widget::isDescendantOf | ( | Widget & | w | ) | const |
Return TRUE if this is W or a descendant of W.
This is O(h), being H the depth of the tree.
Search the first appearance of the given ID in this and its descendants.
If not found, return nullptr. It does not search in children of containers that are of type OWN, since those IDs are private.
ID zxeco::gui::Widget::maxUsedID | ( | void | ) | const |
Search in this widget and its descendants the maximum ID used.
It does not search in children of containers that are of type OWN, since those IDs are private.
TravResult zxeco::gui::Widget::traverse | ( | const TraverseObserver & | obs | ) |
Traverse this widget and its descendants, calling OBS on each one.
OBS should return: FINISH_OK for finishing the traversing successfully at that point (after having observed that widget), FINISH_FAIL for the same but indicating failure, BACKTRACK to skip all descendants of that widget, or CONTINUE to go on with the next widget. This method only returns FINISH_OK, FINISH_FAIL or CONTINUE (if all widgets have been traversed).
TravResult zxeco::gui::Widget::revTraverse | ( | const TraverseObserver & | obs | ) |
Traverse this widget and its ascendants, calling OBS on each one.
OBS is firstly called in this very widget. It should return:
void zxeco::gui::Widget::setVisibility | ( | bool | visible = true | ) |
Set the desired visibility of the widget.
Notice that if a parent is invisible, the widget will not get visible in practice until the parent gets; also, if set to invisible, all children will be not visible after this method. This redraw() the widget if it changes to visible from invisible, and release the focus in that case if the widget is focused; if it gets invisible from visible, set drawn_ flag to false (it will remain that way while it is invisible, since no calls to further drawings or setting zones are done). If it does not change visibility, does nothing.
|
inlinenoexcept |
Set the widget visibility without redrawing or modifying focus.
Do not use this method unles completely necessary; use setVisibility() instread. This is useful when a container has private children which visibility is to be dynamically calculated (without redrawing) whithin the calcFittingNeeds() or setDrawingZone() methods.
Definition at line 844 of file ZXWidgetsBase.h.
|
noexcept |
Get current visibility of the widget, considering also its parents.
If it is root, return TRUE unregarding its visible flag. If it is set as invisible, if any parent is invisible, or if a parent is a DEEP container and this falls in the non-selected branch, return invisible. This is O(h), where H is the depth of the widget tree.
void zxeco::gui::Widget::setEnabled | ( | bool | enabled = true | ) |
Set whether the widget is enabld or disabld; drawRaw() widget if changd.
An enabled widget can interact with the user; a disabled one cannot. An enabled widget remains disabled in practice if any parent is disabled. The method does nothing if enabled does not change. If passing to disabled and is focused, release focus.
|
noexcept |
Get current enabled state of the widget, considering its parents.
If any parent is disabled, return disabled. This is O(D), where D is the depth of the widget tree.
bool zxeco::gui::Widget::isFocusable | ( | bool | drawntoo = true | ) | const |
Return TRUE if the widget is focusable now.
If DRAWNTOO is FALSE, does not require to be drawn.
|
inlinenoexcept |
Return TRUE if the widget is in the path from root to the leaf focused.
If, in addition, it is not a container, then it is the focused leaf widget.
Definition at line 874 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if it is in the focus path and it is the leaf of that path.
Definition at line 878 of file ZXWidgetsBase.h.
Widget * zxeco::gui::Widget::whoIsFocused | ( | void | ) |
Get the leaf focused widget in the tree, or nullptr if none.
This is O(h), being H the depth of the tree.
void zxeco::gui::Widget::acquireFocus | ( | const PointingStatus * | m = nullptr | ) |
Give the focus to this widget and quit it from the current focused one.
Use M as pointed location on the focusable area if not null; otherwise use the top-left corner of the focusable area. This method sends the FOCUS-GOT event to the widget, but ignores any finishing or not-processing resulting flag. Throw if this widget is not focusable, e.g., it is a container or it is invisible, disabled, etc.
void zxeco::gui::Widget::releaseFocus | ( | void | ) |
Quit focus from this leaf widget or below it; no one acquires it.
This method send the FOCUS-LOST event to the root of the tree, but ignores any finishing or not-processing resulting flag. Do nothing if this widget is not focused.
void zxeco::gui::Widget::drawAll | ( | const CharRect & | rect | ) |
Calculate and set the placement of all widgets within RECT and draw'em.
Use this method for drawing the entire content of a window for the first time, without bothering with the methods below, that refer to particular parts of that process.
The sequence of jobs during the process are: calcFittingNeeds() in top-down and then bottom-up fashion to estimate the needs of all widgets; then setDrawingZone() in top-down fashion to set all their final placements; then drawRaw() in top-down fashion for all widgets to draw them.
RECT cannot be changed while the drawing process is running, thus it should not be a reference to the current drawing zone of any of the widgets.
Throw if any widget is unfit within that area.
Widget * zxeco::gui::Widget::redrawAll | ( | void | ) |
Recalculate, place and redraw all widgets that have changed in the tree.
Only redraw those widgets that have different aligned_zones than before this recalculation (although the recalculation and setting of zones is done in the entire tree), those that lie below them and the parent of the highest one (to clear interspaces between children). This is useful when the dimensions and locations of all the widgets in the entire tree may have been affected by some change in one widget. If the root is not drawn yet, do nothing.
Return NULLPTR if nothing is redrawn or the highest widget in the tree that has been redrawn.
void zxeco::gui::Widget::redrawMe | ( | void | ) |
Recalculate and place all widgets in the tree forcing this to be drawn.
Do the same as redrawAll(), but assures that, if there is no change in the drawing zone of this widget, it will be drawn anyway. Do nothing if this widget is invisible or not drawn yet.
void zxeco::gui::Widget::drawMe | ( | void | ) |
Just force to draw the widget in the current drawing zone.
Assume that there have been no changes in dimensions or location; if they have occurred, use redrawMe(); otherwise, unpredictable results will occur. If this widget is invisible or not yet drawn, do nothing.
|
pure virtual |
Must calculate the widget fitting within the dimensions of AREA.
It must consider all the content of the widget, set the visibility or invisibility of the children if it is a container with dynamically visible children (e.g., scroll slides), store internally the result of the fitting into the protected member fitting_needs_, and return a reference to it.
If the calculations lead to an unfitting situation, the widgetcause field of the result must indicate the first (lowest) widget that produced that unfit.
The area needed calculated by this method must be equal or smaller than AREA, and must be considered to begin at the corner (0,0) of AREA. It'll be used for drawing.
This method will be called at least once before a widget can be drawn (it needs not to be called again as long as the widget drawing dimensions do not change). It will not be called if the widget is invisible (invisible widgets occupy no space when drawing). Recall that the root widget of the widget tree is always considered visible.
The ContainerWidget class provide code for this in charge of calling their children method. Derived containers should call that base method to complete their calculations.
Implemented in zxeco::gui::CanvasWidget, zxeco::gui::ListWidget, zxeco::gui::MenuBarWidget, zxeco::gui::ContainerWidget, zxeco::gui::LabelWidget, zxeco::gui::ButtonWidget, zxeco::gui::SwitchWidget, zxeco::gui::LineInputWidget, zxeco::gui::ChoiceWidget, zxeco::gui::SeparatorWidget, zxeco::gui::ImageWidget, and zxeco::gui::TextEditorWidget.
|
inlinenoexcept |
< Return the last calculation of the fitting needs of the widget.
< Right after creation, the widget fitting needs are set to UNFIT.
Definition at line 980 of file ZXWidgetsBase.h.
Set the final drawing zone for the widget and the aligned one.
Return a pointer to the first (higher) widget in the tree equal or below this that gets an aligned drawing zone different from its current one (or its first zone if not drawn before), or nullptr if all widgets below this (including this) get the same zones as before. The available drawing zone of the widget is the space where it can align its content; the aligned zone is the final rectangle where it must be drawn, already aligned within the drawing zone.
ZONE.corner uses absolute coords within the global screen. ZONE can have the same area as the needed one or a different, larger one (that leaves room for alignment), but not smaller.
This method will be called after calculating the widget fitting needs & before drawing. It will be called at least once before a widget can be drawn (it needs not to be called again as long as the widget drawing dimensions do not change).
Container widgets override this method to deploy it to their children. Also, widgets derived from containers can override it to adjust the visibility of some children if that is to be calculated dynamically, since ZONE may be larger than the one proposed by calcFittingNeeds(), which may affect that visibility.
If the calculated aligned drawing zone is different from the previous one or if the widget was not previously drawn, sets the drawn_ flag to false. Otherwise, leave it unchanged.
Reimplemented in zxeco::gui::CanvasWidget, zxeco::gui::ListWidget, zxeco::gui::ContainerWidget, and zxeco::gui::TextEditorWidget.
|
inlinenoexcept |
< Get the drawing zone decided for the widget within the global screen.
< The corner of this rectangle is w.r.t. the global screen.
Definition at line 1014 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Get the part of the drawing zone that is already aligned.
< The corner of this rectangle is w.r.t. the global screen. This aligned zone is the one to be used for drawing the widget.
Definition at line 1019 of file ZXWidgetsBase.h.
Move the drawing and aligned zones corners by those increments.
Does not change the areas or the drawn_ flag. In general, this method should not be overriden by derived classes unless they need to move something else in addition to the drawing and aligned zones.
Reimplemented in zxeco::gui::ContainerWidget, zxeco::gui::LineInputWidget, and zxeco::gui::TextEditorWidget.
|
inlinenoexcept |
Return TRUE if the widget has already been drawn in current dimensions.
Definition at line 1032 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Method for external agents (e.g., Windows) to mark the widget undrawn.
Definition at line 1035 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Set/unset the generation of explanations when calculating drawing.
< Derived classes must use the explaindrawing_ member to generate those explanations after their calcFittingNeeds()/setDrawingZone() methods. The explanation must be stored in the AreaFitting object "fitting_needs_", and reset each time a calcFittingNeeds() is called.
Definition at line 1046 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return the current status of drawing explanations.
Definition at line 1054 of file ZXWidgetsBase.h.
|
inline |
< Return an explanation with the drawing status of this and child widgets
< The result may be very large and it is multi-line. If WITHOUTPRIVATE, does not go into children of OWN-type containers.
Definition at line 1057 of file ZXWidgetsBase.h.
|
virtual |
Same as traceOfDrawing() but indicating the depth level and using SS.
The output is accumulated into SS instead of returning a string. The starting, top level is 0. This method is not recommended but for derived classes. Use instead traceOfDrawing().
|
virtual |
Deal with the event at this widget and its descendants (if container).
This method call processEvent() for processing the event, both in downwards and upwards event paths if it is a container. It also deals with the focus; it does nothing if the widget is invisible or disabled or not drawn yet.
Return: PROCESSED_OK if the event is processed by this widget or its descen- dants (they can cover it) and the widget manager should continue afterwards; PROCESSED_FINISH if the event is processed by this widget of its descendants and the window manager should end its work at this point; NOT_PROCESSED if this widget or its descendants cannot deal with the event (it is not covered by them); WINCLOSE if a window close event is catched while process- ing the event (that may occur in some widgets that open new windows and manage them).
This code is for non-container widgets; container widgets override it to provide propragation (OWN-containers do not need to override again).
Reimplemented in zxeco::gui::ContainerWidget.
|
inlinevirtual |
Deal with the event at this widget and its descendants (if container).
This method call processEvent() for processing the event, both in downwards and upwards event paths if it is a container. It also deals with the focus; it does nothing if the widget is invisible or disabled or not drawn yet.
Return: PROCESSED_OK if the event is processed by this widget or its descen- dants (they can cover it) and the widget manager should continue afterwards; PROCESSED_FINISH if the event is processed by this widget of its descendants and the window manager should end its work at this point; NOT_PROCESSED if this widget or its descendants cannot deal with the event (it is not covered by them); WINCLOSE if a window close event is catched while process- ing the event (that may occur in some widgets that open new windows and manage them).
This code is for non-container widgets; container widgets override it to provide propragation (OWN-containers do not need to override again).
callback | Set the callback routine that will be called during event processing. |
Definition at line 1097 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Get the current callback routine.
Definition at line 1101 of file ZXWidgetsBase.h.
void zxeco::gui::Widget::addCallback | ( | const CallbackRout & | cbk | ) |
Add callback CBK to the end of the current callback routine.
The composed sequence of callback routines will end as soon as one of the routines return FALSE.
|
inlineprotectedvirtual |
Must draw itself in the decided aligned zone withing the drawing zone.
Use aligned_drawing_zone to get the final, aligned zone where the entire widget must be drawn. The zone is assured to be cleared with the background colours of the window before calling drawRaw(). The best way to go is to create a subscreen on the aligned_drawing_zone_ and work on it.
This method will not be called if the widget is invisible.
NOTE: Do not call this method directly on your derived code; just implement it and call drawMe() or redrawMe().
Reimplemented in zxeco::gui::ContainerWidget.
Definition at line 1137 of file ZXWidgetsBase.h.
|
inlineprotectedvirtual |
who | Must be overriden in derived classes to process events. Results: > 0 : processed ok; < 0 : winclose event catched; == 0 : the chaining of event must end. |
In non-container widgets it will be called once after processing the event chain downwards and the focus, and will receive THIS in WHO; then, the user's callback will be called. In container widgets it will be called twice: once before chaining the event to children, with WHO == NULLPTR, and another one going upwards in the tree after processing children, with WHO == the leaf widget that has dealt with the event. The user's callback will also be called before and after this method. In container widgets, the focus will not be updated in the first call. In DEEP tabbed containers, the user's event that selects one of the children also generates calls to the callbacks, both before and after.
It will not be called at all if the widget is invisible or disabled or not drawn yet. FALSE is returned to indicate the window manager to end its management; otherwise it should go on with the chain.
This base implementation ignores the event and produces no effects.
Definition at line 1148 of file ZXWidgetsBase.h.
|
protected |
Add LINE to the existing explanation in fitting_needs_.
If explaindrawing_ is false, add nothing.
|
static |
Callback routine that does nothing.
Definition at line 600 of file ZXWidgetsBase.h.
|
static |
< Add TRACES to the currently active traces (initially none).
Definition at line 626 of file ZXWidgetsBase.h.
|
static |
< Add TRACES to the currently active traces (initially none).
Definition at line 627 of file ZXWidgetsBase.h.
|
staticprotected |
Currently active traces.
Definition at line 1114 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1117 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1118 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1120 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1121 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1122 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1126 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1127 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1128 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1129 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1130 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1131 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1132 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1133 of file ZXWidgetsBase.h.
|
protected |
Definition at line 1134 of file ZXWidgetsBase.h.
class zxeco::gui::Widget::PVector |
A vector of ptrs to widgets.
Definition at line 77 of file ZXWidgetsBase.h.
Public Types | |
using | Base = std::vector< Ptr > |
Shortcut. More... | |
Public Member Functions | |
Widget * | addChildOf (const Ptr &w, Widget &parent) |
< Reuse constructors More... | |
using zxeco::gui::Widget::PVector::Base = std::vector<Ptr> |
Shortcut.
Definition at line 81 of file ZXWidgetsBase.h.
< Reuse constructors
parent | Add a child to the back of the vector and set its parent. A copy of the Ptr is stored into the vector. Return a pointer to the added child. |
Definition at line 85 of file ZXWidgetsBase.h.
class zxeco::gui::Widget::Path |
A path in the widget tree.
It can be downwards (the first widget is an ascendant of the rest) or upwards (the first widget is a descendant of the rest).
Definition at line 95 of file ZXWidgetsBase.h.
Public Types | |
using | Base = std::vector< Widget * > |
Public Member Functions | |
Path (bool downorup) | |
Create an empty path that goes downwards (TRUE) or upwards (FALSE). More... | |
Path (Widget *pw) | |
Create an upwards path from PW to the root (both included). More... | |
bool | isDownwards (void) const noexcept |
Return TRUE if the path goes downwards. More... | |
bool | isUpwards (void) const noexcept |
Return TRUE if the path goes upwards. More... | |
std::string | to_string (void) const |
Construct a text describint the path. | |
using zxeco::gui::Widget::Path::Base = std::vector<Widget *> |
Definition at line 99 of file ZXWidgetsBase.h.
|
inline |
Create an empty path that goes downwards (TRUE) or upwards (FALSE).
Definition at line 101 of file ZXWidgetsBase.h.
zxeco::gui::Widget::Path::Path | ( | Widget * | pw | ) |
Create an upwards path from PW to the root (both included).
If PW is nullptr, create empty upwards path. This is O(h), where H is the depth of the tree.
|
inlinenoexcept |
Return TRUE if the path goes downwards.
Definition at line 109 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return TRUE if the path goes upwards.
Definition at line 112 of file ZXWidgetsBase.h.
struct zxeco::gui::Widget::AreaFitting |
Information about the fitting of widgets drawings into rectangular areas.
Definition at line 147 of file ZXWidgetsBase.h.
Public Types | |
enum class | Fit { UNFIT , FIT , FLEXFIT } |
Kinds of fittings of the drawing of a widget in a given area. More... | |
enum | : uint8_t { FLEX_HOR = 1 , FLEX_VER = 2 } |
In FLEXFIT case, which dimension(s) can vary if more room is given. More... | |
using | Vector = std::vector< AreaFitting > |
Several, ordered fittings. More... | |
Public Attributes | |
LongestUnsignedType | creattime |
Time of creation. More... | |
Widget * | widget |
Ptr (no ownerwhip) to the widget that produces fit. More... | |
Widget * | widgetcause |
Ptr (no owner) to first widget that was unfit. More... | |
CharArea | provided |
Area that was provided for the calculation. More... | |
Fit | fitting |
How the widget fits in the provided area. More... | |
CharArea | needed |
Area decided if FIT or min. area needed if FLEXFIT. More... | |
uint8_t | flexdim |
Dimension along which a FLEXFIT can vary. More... | |
std::string | explanation |
Explanation of the fit (optional). More... | |
Public Member Functions | |
AreaFitting (const CharArea &prov, Widget *wi, const std::string &expl="") | |
Default constructor: UNFIT. More... | |
AreaFitting (const CharArea &prov, Widget *wi, const CharArea &ndd, uint8_t fds=0) | |
AreaFitting (Widget *wi, const CharArea &ndd, const CharArea &availablearea) | |
Constructor for UNFIT, FLEXFIT or FIT type. More... | |
AreaFitting (Widget *wi, const AreaFitting &oaf) | |
AreaFitting (Widget *wi, AreaFitting &&oaf) | |
AreaFitting & | operator= (const AreaFitting &oaf) |
AreaFitting & | operator= (AreaFitting &&oaf) |
void | assign (Widget *wi, const AreaFitting &oaf) |
void | assign (Widget *wi, AreaFitting &&oaf) |
operator bool (void) const noexcept | |
Return FALSE if UNFIT or TRUE otherwise. More... | |
std::string | to_string (void) const |
Return textual information about the fitting. | |
using zxeco::gui::Widget::AreaFitting::Vector = std::vector<AreaFitting> |
Several, ordered fittings.
Definition at line 149 of file ZXWidgetsBase.h.
|
strong |
Kinds of fittings of the drawing of a widget in a given area.
Enumerator | |
---|---|
UNFIT | Cannot fit in the area. |
FIT | Can fit in the area with a fixed size. |
FLEXFIT | Can fit in the area at different sizes. |
Definition at line 152 of file ZXWidgetsBase.h.
anonymous enum : uint8_t |
In FLEXFIT case, which dimension(s) can vary if more room is given.
These can be OR-ed.
Enumerator | |
---|---|
FLEX_HOR | Can be flexible in horizontal. |
FLEX_VER | Can be flexible in vertical. |
Definition at line 160 of file ZXWidgetsBase.h.
|
inline |
Default constructor: UNFIT.
Definition at line 176 of file ZXWidgetsBase.h.
|
inline |
Definition at line 186 of file ZXWidgetsBase.h.
zxeco::gui::Widget::AreaFitting::AreaFitting | ( | Widget * | wi, |
const CharArea & | ndd, | ||
const CharArea & | availablearea | ||
) |
Constructor for UNFIT, FLEXFIT or FIT type.
AVAILABLE area becomes the provided field. If NDD cannot be contained into AVAILABLEAREA, create an UNFIT and stores that cause as the explanation. Else, if NDD fits exactly in AVAILABLEAREA, create a FIT. Else, create a FLEXFIT and set the flexible direction(s) according to which one(s) have margin to grow within AVAILABLEAREA.
|
inline |
Definition at line 206 of file ZXWidgetsBase.h.
|
inline |
< The origin fitting is set as UNFIT.
Definition at line 210 of file ZXWidgetsBase.h.
|
inline |
oaf | Assignment, preserving all. |
Definition at line 215 of file ZXWidgetsBase.h.
|
inline |
oaf | Move assignment, preserving all. |
Definition at line 219 of file ZXWidgetsBase.h.
|
inline |
oaf | Assignment preserving everything but the widget. |
Definition at line 223 of file ZXWidgetsBase.h.
|
inline |
oaf | Move assignment preserving everything but the widget and time. The origin fitting is set as UNFIT. |
Definition at line 227 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return FALSE if UNFIT or TRUE otherwise.
Definition at line 234 of file ZXWidgetsBase.h.
LongestUnsignedType zxeco::gui::Widget::AreaFitting::creattime |
Time of creation.
Definition at line 166 of file ZXWidgetsBase.h.
Widget* zxeco::gui::Widget::AreaFitting::widget |
Ptr (no ownerwhip) to the widget that produces fit.
Definition at line 167 of file ZXWidgetsBase.h.
Widget* zxeco::gui::Widget::AreaFitting::widgetcause |
Ptr (no owner) to first widget that was unfit.
Definition at line 168 of file ZXWidgetsBase.h.
CharArea zxeco::gui::Widget::AreaFitting::provided |
Area that was provided for the calculation.
Definition at line 169 of file ZXWidgetsBase.h.
Fit zxeco::gui::Widget::AreaFitting::fitting |
How the widget fits in the provided area.
Definition at line 170 of file ZXWidgetsBase.h.
CharArea zxeco::gui::Widget::AreaFitting::needed |
Area decided if FIT or min. area needed if FLEXFIT.
Definition at line 171 of file ZXWidgetsBase.h.
uint8_t zxeco::gui::Widget::AreaFitting::flexdim |
Dimension along which a FLEXFIT can vary.
Definition at line 172 of file ZXWidgetsBase.h.
std::string zxeco::gui::Widget::AreaFitting::explanation |
Explanation of the fit (optional).
Definition at line 173 of file ZXWidgetsBase.h.
struct zxeco::gui::Widget::EventData |
Data passed to a widget when an event occurs.
Events are received first by the root widget of the tree and flow down until reaching a "leaf" widget that can process them. The leaf is either a non-container widget, or a DEEP-container widget if the event is left click on the tabbed title of that container. Some concrete events can only be processed by "focusable" widgets (those that have a focus area), since they do not convey any screen position info, e.g., focus lost, typing, ... Only one focused widget is allowed in the tree at any time.
Definition at line 301 of file ZXWidgetsBase.h.
Public Attributes | |
EventType | evt |
Event kind. More... | |
SubEvType | subevt |
struct zxeco::gui::Widget::EventData::EvData | evdata |
Public Member Functions | |
EventData (void) | |
Default constructor: FOCUS_LOST. More... | |
EventData (int32_t wincr) | |
Constructor for MOUSE_WHEEL. More... | |
EventData (EventType e, SubEvType s, const PointingStatus &m) | |
Constructor for MOUSE (not wheel) or FOCUS_GOT event. | |
EventData (SubEvType s, DesktopInterface::KeyID key) | |
Constructor for KEYB_* event. | |
EventData (const char *chutf8) | |
Constructor for KEYB_TEXT event. More... | |
EventData (const EventData &o) | |
EventData (EventData &&o) | |
EventData & | operator= (const EventData &o) |
EventData & | operator= (EventData &&o) |
DesktopInterface::KeyID | keyOrWheelIntoKey (void) const |
If the event is mouse wheel, return either UP or DOWN. More... | |
bool | isMouseClick (void) const noexcept |
< Return TRUE if the event is a click of the mouse. More... | |
bool | isMouseUnclick (void) const noexcept |
< Return TRUE if the event is an unclick of the mouse. More... | |
bool | isMouseRightClick (void) const noexcept |
< Return TRUE if the event is the right click of the mouse. More... | |
bool | isMouseLeftClick (void) const noexcept |
< Return TRUE if the event is the left click of the mouse. More... | |
bool | isMouseRightUnclick (void) const noexcept |
< Return TRUE if the event is the right unclick of the mouse. More... | |
bool | isMouseLeftUnclick (void) const noexcept |
< Return TRUE if the event is the left unclick of the mouse. More... | |
bool | isMouseMove (void) const noexcept |
< Return TRUE if the event is a motion of the mouse. More... | |
bool | isMouseWheel (void) const noexcept |
< Return TRUE if the event is mouse wheel. More... | |
bool | isKeyPressed (void) const noexcept |
< Return TRUE if the event is a key pressed. More... | |
bool | isKeyUnpressed (void) const noexcept |
< Return TRUE if the event is a key unpressed. More... | |
bool | isRecognizedText (void) const noexcept |
< Return TRUE if the event is the recognition of a char by the OS. More... | |
bool | isGotFocus (void) const noexcept |
< Return TRUE if the event is the acquisition of focus to the widget. More... | |
bool | isLostFocus (void) const noexcept |
< Return TRUE if the event is the lost of focus by the widget. More... | |
bool | needsFocus (void) const noexcept |
< Return TRUE if the event needs some focused widget to be sent to. More... | |
bool | hasMouse (void) const noexcept |
< Return TRUE if the event contains info of mouse coordinates. More... | |
std::string | to_string (void) const |
Return a text explaining the event. | |
|
inline |
Default constructor: FOCUS_LOST.
Definition at line 356 of file ZXWidgetsBase.h.
|
inline |
Constructor for MOUSE_WHEEL.
Definition at line 360 of file ZXWidgetsBase.h.
|
inline |
Constructor for KEYB_TEXT event.
Definition at line 371 of file ZXWidgetsBase.h.
|
inline |
Definition at line 376 of file ZXWidgetsBase.h.
|
inline |
Definition at line 377 of file ZXWidgetsBase.h.
Definition at line 378 of file ZXWidgetsBase.h.
Definition at line 380 of file ZXWidgetsBase.h.
DesktopInterface::KeyID zxeco::gui::Widget::EventData::keyOrWheelIntoKey | ( | void | ) | const |
If the event is mouse wheel, return either UP or DOWN.
If the event is key, return the key. In any other case, return NUM_OF_KEY_IDS.
|
inlinenoexcept |
< Return TRUE if the event is a click of the mouse.
Definition at line 389 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is an unclick of the mouse.
Definition at line 394 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is the right click of the mouse.
Definition at line 399 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is the left click of the mouse.
Definition at line 403 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is the right unclick of the mouse.
Definition at line 407 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is the left unclick of the mouse.
Definition at line 411 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is a motion of the mouse.
Definition at line 415 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is mouse wheel.
Definition at line 420 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is a key pressed.
< Notice that in this case the last known mouse position is also stored in the event.
Definition at line 425 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is a key unpressed.
< Notice that in this case the last known mouse position is also stored in the event.
Definition at line 432 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is the recognition of a char by the OS.
Definition at line 439 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is the acquisition of focus to the widget.
Definition at line 444 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event is the lost of focus by the widget.
Definition at line 449 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event needs some focused widget to be sent to.
< Those events that need focus are dealt with by the focused widget without requiring to occur within its spatial area.
Definition at line 454 of file ZXWidgetsBase.h.
|
inlinenoexcept |
< Return TRUE if the event contains info of mouse coordinates.
Definition at line 470 of file ZXWidgetsBase.h.
EventType zxeco::gui::Widget::EventData::evt |
Event kind.
Definition at line 303 of file ZXWidgetsBase.h.
SubEvType zxeco::gui::Widget::EventData::subevt |
Concrete event.
Definition at line 304 of file ZXWidgetsBase.h.
struct zxeco::gui::Widget::EventData::EvData |
Event data.
Definition at line 306 of file ZXWidgetsBase.h.
Public Attributes | |
int32_t | wheelincr {0} |
Vertical wheel incr. for MOUSE_WHEEL. More... | |
PointingStatus | mouse |
If the event is MOUSE or FOCUS_GOT. More... | |
DesktopInterface::KeyID | key |
If event is KEYB_PRESS/UNPRESS. More... | |
std::string | text |
If the event is KEYB_TEXT. More... | |
Public Member Functions | |
EvData (int32_t wi) | |
EvData (const PointingStatus &m) | |
EvData (const DesktopInterface::KeyID k) | |
EvData (const char *chutf8) | |
EvData (const EvData &o) | |
EvData (EvData &&o) | |
EvData & | operator= (const EvData &o) |
EvData & | operator= (EvData &&o) |
|
inline |
Definition at line 336 of file ZXWidgetsBase.h.
|
inline |
Definition at line 337 of file ZXWidgetsBase.h.
|
inline |
Definition at line 338 of file ZXWidgetsBase.h.
|
inline |
Definition at line 339 of file ZXWidgetsBase.h.
|
inline |
Definition at line 340 of file ZXWidgetsBase.h.
|
inline |
Definition at line 341 of file ZXWidgetsBase.h.
|
inline |
Definition at line 346 of file ZXWidgetsBase.h.
Definition at line 342 of file ZXWidgetsBase.h.
Definition at line 344 of file ZXWidgetsBase.h.
int32_t zxeco::gui::Widget::EventData::EvData::wheelincr {0} |
Vertical wheel incr. for MOUSE_WHEEL.
The increment is in ticks of the wheel, not pixels on the screen. Negative downwards, positive upwards.
Definition at line 310 of file ZXWidgetsBase.h.
PointingStatus zxeco::gui::Widget::EventData::EvData::mouse |
If the event is MOUSE or FOCUS_GOT.
(Or if the event is Key press/unpres or mouse wheel, storing the last mouse position). Only one button will be true if the subevent is MOUSE_CLICK, and only one button will be false if the subevent is MOUSE_UNCLICK. If it is MOUSE_MOVE, the buttons will be as in the mouse currently. MOUSE_WHEEL is not dealt here. The coords of the mouse will be relative to the drawable screen, where all coordinates of widgets are.
Definition at line 314 of file ZXWidgetsBase.h.
DesktopInterface::KeyID zxeco::gui::Widget::EventData::EvData::key |
If event is KEYB_PRESS/UNPRESS.
Key pressed or unpressed.
Definition at line 329 of file ZXWidgetsBase.h.
std::string zxeco::gui::Widget::EventData::EvData::text |
If the event is KEYB_TEXT.
Recognized char in UTF-8, as a string.
Definition at line 333 of file ZXWidgetsBase.h.
struct zxeco::gui::Widget::ChainEventResult |
Result of chaining an event, i.e., flowing it through the widget tree.
< Events are first received by the root widget of the widget tree, then they flow downwards through the tree seeking for a leaf widget that can process them, then flow back upwards through the same path for the case some parent of the leaf widget desires to do anything after it. See chainEvent() method.
Definition at line 492 of file ZXWidgetsBase.h.
Public Types | |
enum | { PROCESSED_OK , PROCESSED_FINISH , NOT_PROCESSED , WINCLOSE } |
Possible results when the event is chained to a given widget. More... | |
Public Attributes | |
int | result |
One of the possible result values. More... | |
Widget * | who |
Leaf widget that dealt with widget or null if unknown. More... | |
Public Member Functions | |
ChainEventResult (bool winclose=false) | |
Default constructor. Not processed / winclose events. More... | |
ChainEventResult (int r) | |
Constructor for event that does not know yet the leaf widget. More... | |
ChainEventResult (int r, Widget *p) | |
Constructor for the case we know the leaf widget dealing with event. More... | |
std::string | to_string (void) const |
< Return a text describing the result. More... | |
anonymous enum |
Possible results when the event is chained to a given widget.
Definition at line 495 of file ZXWidgetsBase.h.
|
inline |
Default constructor. Not processed / winclose events.
Definition at line 508 of file ZXWidgetsBase.h.
|
inline |
Constructor for event that does not know yet the leaf widget.
The leaf widget is the one at the end of the tree that deals with the event (it is either a non-container or a DEEP-container in case the event is a left click on the tabbed title of such a container).
Definition at line 513 of file ZXWidgetsBase.h.
|
inline |
Constructor for the case we know the leaf widget dealing with event.
We know the leaf widget only in the upwards flow back chaining time.
Definition at line 518 of file ZXWidgetsBase.h.
|
inline |
< Return a text describing the result.
Definition at line 523 of file ZXWidgetsBase.h.
int zxeco::gui::Widget::ChainEventResult::result |
One of the possible result values.
Definition at line 503 of file ZXWidgetsBase.h.
Widget* zxeco::gui::Widget::ChainEventResult::who |
Leaf widget that dealt with widget or null if unknown.
Only known in upwards direction of the chaining.
Definition at line 504 of file ZXWidgetsBase.h.
struct zxeco::gui::Widget::CallbackParms |
A class to contain the parameters received by a callback routine.
< Particular widgets may derive from this to add parameters. They also can provide routines to detect situations that are of common use for them.
Definition at line 541 of file ZXWidgetsBase.h.
Public Attributes | |
char | moment |
Either 'B' (before processing event) or 'A' (after). More... | |
Widget * | whoprocessed |
If 'B', nullptr; if 'A': who processed event. More... | |
const EventData * | pevd |
Data about the event (no ownership). More... | |
Public Member Functions | |
bool | isAfterWithData (void) const noexcept |
Return TRUE for parameters that occur in 'A' moment and have data. More... | |
bool | isBeforeWithData (void) const noexcept |
bool | isToGetFocus (void) const noexcept |
Return TRUE for parameters indicating right before getting focus. More... | |
bool | hasBeenLeftClicked (void) const noexcept |
Return TRUE for parameters indicating a left click has been produced. More... | |
bool | hasPressedKey (DesktopInterface::KeyID k) const noexcept |
Return TRUE for parameters indicating KEY has been pressed. More... | |
bool | hasPressedEnter (void) const noexcept |
Return TRUE for parameters indicating ENTER has been pressed. More... | |
bool | hasBeenLeftClickedOrEnter (void) const noexcept |
Return TRUE for parameters indicating left click or enter. More... | |
std::string | to_string (void) const |
|
inlinenoexcept |
Return TRUE for parameters that occur in 'A' moment and have data.
Definition at line 551 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Definition at line 554 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return TRUE for parameters indicating right before getting focus.
Definition at line 558 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return TRUE for parameters indicating a left click has been produced.
Unclick is used to assure the click event and the unclick event have occurred already.
Definition at line 564 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return TRUE for parameters indicating KEY has been pressed.
Unpressed is used to assure the press event and the unpress event have occurred already.
Definition at line 570 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return TRUE for parameters indicating ENTER has been pressed.
Definition at line 575 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return TRUE for parameters indicating left click or enter.
Definition at line 579 of file ZXWidgetsBase.h.
|
inline |
Definition at line 583 of file ZXWidgetsBase.h.
char zxeco::gui::Widget::CallbackParms::moment |
Either 'B' (before processing event) or 'A' (after).
Definition at line 543 of file ZXWidgetsBase.h.
Widget* zxeco::gui::Widget::CallbackParms::whoprocessed |
If 'B', nullptr; if 'A': who processed event.
More concretely, this field holds the leaf widget that processed the event.
Definition at line 544 of file ZXWidgetsBase.h.
const EventData* zxeco::gui::Widget::CallbackParms::pevd |
Data about the event (no ownership).
Definition at line 547 of file ZXWidgetsBase.h.
struct zxeco::gui::Widget::Trace |
Kinds of tracings that can be activated in the whole widget system.
< Several traces can be activated at once by OR-ing them. Traces are issued to std::cout and set/unset globally for all widgets in the same executable program. These traces are pretty exhaustive; it is often advisable to copy them from console to a proper word processor in order to analyze them thoroughly.
Definition at line 615 of file ZXWidgetsBase.h.
Public Types | |
enum | : Type { Drawing = 1 } |
using | Type = uint8_t |
using zxeco::gui::Widget::Trace::Type = uint8_t |
Definition at line 617 of file ZXWidgetsBase.h.
anonymous enum : Type |
Enumerator | |
---|---|
Drawing | Traces in the placing/drawing process. |
Definition at line 619 of file ZXWidgetsBase.h.
class zxeco::gui::ContainerWidget |
A container of other widgets.
< Containers always adapt their sizes to the contained widgets.
Definition at line 1229 of file ZXWidgetsBase.h.
Public Types | |
enum class | OrType { VERTICAL , HORIZONTAL , DEEP } |
Types of containers according to the spatial orientation of their contnt. More... | |
enum class | CCType { USER , OWN } |
Types of container according to the creation of their children. More... | |
enum class | FMType { NORMAL , PRESERVE } |
Types of management of focus among descendant widgets. More... | |
![]() | |
enum class | TravResult { FINISH_OK , FINISH_FAIL , BACKTRACK , CONTINUE } |
Possible results of observer when traversing widgets in the widget tree. More... | |
using | ID = int |
A numeric ID associated to the widget. More... | |
using | Ptr = std::shared_ptr< Widget > |
A polymorphic ptr to a widget. More... | |
using | TraverseObserver = std::function< TravResult(Widget &) > |
enum class | HorAlign { LEFT , RIGHT , CENTER } |
Horizontal alignment of widgets within the areas of their containers. More... | |
enum class | VertAlign { TOP , BOTTOM , MIDDLE } |
Vertical alignment of widgets within the areas of their containers. More... | |
enum class | EventType { MOUSE , KEYBOARD , FOCUS } |
Kinds of events that the widgets may process from the graphical environ. More... | |
enum class | SubEvType { MOUSE_MOVE , MOUSE_CLICK , MOUSE_UNCLICK , MOUSE_WHEEL , KEYB_PRESS , KEYB_UNPRESS , KEYB_TEXT , FOCUS_GOT , FOCUS_LOST } |
Concrete events for each event kind. More... | |
using | CallbackRout = std::function< bool(Widget &, const CallbackParms &)> |
Public Member Functions | |
ContainerWidget (ID id, const std::string &name, CCType cctype=CCType::USER, OrType ortype=OrType::VERTICAL, FMType foctype=FMType::NORMAL, bool withframe=false, const std::string &title="", HorAlign hal=HorAlign::LEFT, VertAlign val=VertAlign::TOP, const std::string &tooltiptext="") | |
Constructor. More... | |
CCType | ccType (void) const noexcept |
Return its children creation type. More... | |
OrType | orType (void) const noexcept |
Return its orientation type. More... | |
FMType | focusMngType (void) const noexcept |
Return its focus management type. More... | |
bool | getFrame (void) const noexcept |
Return whether the widget has currently a frame. More... | |
const std::string & | getTitle (void) const noexcept |
Return the widtget current title, or empty if none. More... | |
bool | cursorInTopFrame (const CharCursor &cc) const |
Return TRUE if CC lies in the top (title) line of the container frame. More... | |
const PVector & | children (void) noexcept |
Return the widgets contained into the container. More... | |
Widget * | addChild (const Ptr &ch) |
Return its children creation type. More... | |
void | setDeepSelected (PVector::size_type who) |
Set the WHO-th children as the one visible if the container is DEEP. More... | |
PVector::size_type | getDeepSelected (void) const |
Get the WHO-th children that is the one visible if the cont. is DEEP. More... | |
const char * | className (void) const noexcept |
Must return a text with the name of the class. More... | |
bool | isContainer (void) const noexcept override |
Return whether the widget is a container of other widgets. More... | |
const AreaFitting & | calcFittingNeeds (const CharArea &area) |
Must calculate the widget fitting within the dimensions of AREA. More... | |
void | drawRaw (void) |
Must draw itself in the decided aligned zone withing the drawing zone. More... | |
Widget * | setDrawingZone (const CharRect &zone) override |
Set the final drawing zone for the widget and the aligned one. More... | |
void | moveDrawingZones (IntDist incx, IntDist incy) noexcept override |
Move the drawing and aligned zones corners by those increments. More... | |
void | setWindow (Window &win) noexcept override |
Set the Window where the widget is being managed. More... | |
void | setWinColors (const WinColors &wincols) noexcept override |
< Assign the colors used to draw the widget. WINCOLS must outlive this. More... | |
ChainEventResult | chainEvent (const EventData &data) override |
Deal with the event at this widget and its descendants (if container). More... | |
![]() | |
Widget (ID id, const std::string &name, const std::string &tooltiptext="", HorAlign hal=HorAlign::LEFT, VertAlign val=VertAlign::TOP) | |
Constructor. More... | |
Widget (const Widget &)=delete | |
Constructor. More... | |
Widget (Widget &&)=delete | |
Constructor. More... | |
Widget & | operator= (const Widget &)=delete |
Constructor. More... | |
Widget & | operator= (Widget &&)=delete |
Constructor. More... | |
virtual | ~Widget (void)=default |
Just to activate polymorphic deletes. | |
std::string | idText (bool withpointer=false) const |
Return a text with the identification of this widget. More... | |
bool | isUserContainer (void) const noexcept |
Return whether the widget is a USER-type container. More... | |
ID | getID (void) const noexcept |
Return the ID assigned to the widget at creation. More... | |
void | changeID (ID id) noexcept |
Change the ID without checking for duplicates in this widget tree. More... | |
const std::string & | getName (void) const noexcept |
Return the name of the widget. More... | |
bool | operator== (const Widget &oth) const noexcept |
Operator to detect unique identities in widgets. More... | |
bool | operator!= (const Widget &oth) const noexcept |
Operator to detect unique identities in widgets. More... | |
virtual std::pair< bool, const CharRect * > | hasFocusZone (void) const noexcept |
< Must return TRUE and the zone if the widget contains a focus-able zone. More... | |
const WinColors & | getWinColors (void) const noexcept |
Return the current window colors. More... | |
virtual void | setUDGs (const uint8_t *udgs) |
Assign an UDG character set for the widget drawing (do not copy them). More... | |
const uint8_t * | getUDGs (void) |
Return the current UDGs. */. More... | |
virtual void | setTooltip (const std::string &ttt) |
Must return a text with the name of the class. More... | |
const std::string & | getTooltip (void) const noexcept |
Return the tooltip for the widget. More... | |
void | setParent (Widget *parent) |
Sets the parent of the widget to PARENT, that must outlive it. More... | |
Widget * | getParent (void) const noexcept |
Return a pointer to the parent of the widget, or nullptr if none. More... | |
Widget * | getRoot (void) |
Return a pointer to the root widget of the tree. More... | |
bool | isRoot (void) const noexcept |
Return TRUE if this widget is the root of the tree. More... | |
bool | isDescendantOf (Widget &w) const |
Return TRUE if this is W or a descendant of W. More... | |
Widget * | searchID (ID id) const |
Search the first appearance of the given ID in this and its descendants. More... | |
ID | maxUsedID (void) const |
Search in this widget and its descendants the maximum ID used. More... | |
TravResult | traverse (const TraverseObserver &obs) |
Traverse this widget and its descendants, calling OBS on each one. More... | |
TravResult | revTraverse (const TraverseObserver &obs) |
Traverse this widget and its ascendants, calling OBS on each one. More... | |
void | setVisibility (bool visible=true) |
Set the desired visibility of the widget. More... | |
void | setVisibilityNoRedrawing (bool vis) noexcept |
Set the widget visibility without redrawing or modifying focus. More... | |
bool | getVisibility (void) const noexcept |
Get current visibility of the widget, considering also its parents. More... | |
void | setEnabled (bool enabled=true) |
Set whether the widget is enabld or disabld; drawRaw() widget if changd. More... | |
bool | getEnabled (void) const noexcept |
Get current enabled state of the widget, considering its parents. More... | |
bool | isFocusable (bool drawntoo=true) const |
Return TRUE if the widget is focusable now. More... | |
bool | isInFocusPath (void) const noexcept |
Return TRUE if the widget is in the path from root to the leaf focused. More... | |
bool | isLeafFocused (void) const noexcept |
< Return TRUE if it is in the focus path and it is the leaf of that path. More... | |
Widget * | whoIsFocused (void) |
Get the leaf focused widget in the tree, or nullptr if none. More... | |
void | acquireFocus (const PointingStatus *m=nullptr) |
Give the focus to this widget and quit it from the current focused one. More... | |
void | releaseFocus (void) |
Quit focus from this leaf widget or below it; no one acquires it. More... | |
void | drawAll (const CharRect &rect) |
Calculate and set the placement of all widgets within RECT and draw'em. More... | |
Widget * | redrawAll (void) |
Recalculate, place and redraw all widgets that have changed in the tree. More... | |
void | redrawMe (void) |
Recalculate and place all widgets in the tree forcing this to be drawn. More... | |
void | drawMe (void) |
Just force to draw the widget in the current drawing zone. More... | |
const AreaFitting & | fittingNeeds (void) const noexcept |
< Return the last calculation of the fitting needs of the widget. More... | |
const CharRect & | drawingZone (void) const noexcept |
< Get the drawing zone decided for the widget within the global screen. More... | |
const CharRect & | alignedDrawingZone (void) const noexcept |
< Get the part of the drawing zone that is already aligned. More... | |
bool | drawn (void) const noexcept |
Return TRUE if the widget has already been drawn in current dimensions. More... | |
void | undraw (void) noexcept |
Method for external agents (e.g., Windows) to mark the widget undrawn. More... | |
void | setExplanations (bool setit=true) noexcept |
< Set/unset the generation of explanations when calculating drawing. More... | |
bool | getExplanations (void) const noexcept |
Return the current status of drawing explanations. More... | |
std::string | traceOfDrawing (bool withoutprivate=true) const |
< Return an explanation with the drawing status of this and child widgets More... | |
virtual void | setCallback (const CallbackRout &callback=NullCallback) |
Deal with the event at this widget and its descendants (if container). More... | |
const CallbackRout & | getCallback (void) const noexcept |
Get the current callback routine. More... | |
void | addCallback (const CallbackRout &cbk) |
Add callback CBK to the end of the current callback routine. More... | |
Additional Inherited Members | |
![]() | |
static void | addGlobalTraces (Trace::Type traces) noexcept |
< Add TRACES to the currently active traces (initially none). More... | |
static void | delGlobalTraces (Trace::Type traces) noexcept |
< Delete the given traces from the current active ones. More... | |
static Trace::Type | isTracing (Trace::Type traces) noexcept |
< Return a non-zero value if any of TRACES is currently active. More... | |
static void | printTrace (Trace::Type trace, const std::string &tr) |
Put TR in console as a trace, with a mark indicating TRACE. | |
static void | printIfTrace (Trace::Type trace, const std::string &tr) |
The same as printTrace() but only print if any of TRACE is active. More... | |
![]() | |
static const CallbackRout | NullCallback |
Callback routine that does nothing. More... | |
static const std::string | kTraceBegin |
< Add TRACES to the currently active traces (initially none). More... | |
static const std::string | kTraceEnd |
< Add TRACES to the currently active traces (initially none). More... | |
![]() | |
virtual void | drawRaw (void) |
Must draw itself in the decided aligned zone withing the drawing zone. More... | |
virtual int | processEvent (const EventData &evdata, Widget *who) |
void | addLineToExplanation (const std::string &line) |
Add LINE to the existing explanation in fitting_needs_. More... | |
![]() | |
ID | id_ |
const std::string | name_ |
const WinColors * | pwincols_ |
const uint8_t * | udgs_ |
Window * | pwin_ |
CallbackRout | callback_ |
std::string | tooltiptext_ |
HorAlign | hal_ |
VertAlign | val_ |
AreaFitting | fitting_needs_ |
CharRect | drawing_zone_ |
CharRect | aligned_drawing_zone_ |
Widget * | parent_ |
bool | explaindrawing_ |
![]() | |
static Trace::Type | traces_ |
Currently active traces. More... | |
|
strong |
Types of containers according to the spatial orientation of their contnt.
Definition at line 1237 of file ZXWidgetsBase.h.
|
strong |
Types of container according to the creation of their children.
Definition at line 1252 of file ZXWidgetsBase.h.
|
strong |
Types of management of focus among descendant widgets.
NORMAL management means: when a descendant D1 of the container has focus and another descendant D2 of the container is clicked, D1 loses the focus and, if D2 is focusable, gets the focus. PRESERVE means the same except when D2 is not focusable: in that case, D1 does not lose the focus.
Definition at line 1272 of file ZXWidgetsBase.h.
|
inline |
Constructor.
The widget is enabled and visible at creation, yet not focused or drawn If the container is DEEP, the selected child is set to 0, even when no children has been added yet. Note that all children might be invisible by decision of the user. The root widget in the widget tree, which must be a container, is always considered visible.
Definition at line 1283 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return its children creation type.
Definition at line 1323 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return its orientation type.
Definition at line 1326 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return its focus management type.
Definition at line 1329 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return whether the widget has currently a frame.
Definition at line 1332 of file ZXWidgetsBase.h.
|
inlinenoexcept |
Return the widtget current title, or empty if none.
Definition at line 1336 of file ZXWidgetsBase.h.
bool zxeco::gui::ContainerWidget::cursorInTopFrame | ( | const CharCursor & | cc | ) | const |
Return TRUE if CC lies in the top (title) line of the container frame.
If the container has no frame or it is not visible or it has not been drawn yet, return FALSE.
|
inlinenoexcept |
Return the widgets contained into the container.
The returned vector can be used to consult only. Use addChild() to add new children.
Definition at line 1344 of file ZXWidgetsBase.h.
Return its children creation type.
ch | Add at the end of the vector a new child of this container. A copy of the Ptr is stored into the vector. |
Definition at line 1348 of file ZXWidgetsBase.h.
void zxeco::gui::ContainerWidget::setDeepSelected | ( | PVector::size_type | who | ) |
Set the WHO-th children as the one visible if the container is DEEP.
By default, the selected child is 0. If the children that loses its selection was focused, the focus is released from it. Throw if it is not DEEP or if WHO is out of range.
PVector::size_type zxeco::gui::ContainerWidget::getDeepSelected | ( | void | ) | const |
Get the WHO-th children that is the one visible if the cont. is DEEP.
Throw if it is not DEEP.
|
inlinevirtualnoexcept |
Must return a text with the name of the class.
The text should be a literal local to the method, since text literals have static storage and therefore exist for the entire duration of the program.
Implements zxeco::gui::Widget.
Reimplemented in zxeco::gui::SlideWidget.
Definition at line 1369 of file ZXWidgetsBase.h.
|
inlineoverridevirtualnoexcept |
Return whether the widget is a container of other widgets.
The derived class ContainerWidget overrides this to return TRUE.
Reimplemented from zxeco::gui::Widget.
Definition at line 1370 of file ZXWidgetsBase.h.
|
virtual |
Must calculate the widget fitting within the dimensions of AREA.
It must consider all the content of the widget, set the visibility or invisibility of the children if it is a container with dynamically visible children (e.g., scroll slides), store internally the result of the fitting into the protected member fitting_needs_, and return a reference to it.
If the calculations lead to an unfitting situation, the widgetcause field of the result must indicate the first (lowest) widget that produced that unfit.
The area needed calculated by this method must be equal or smaller than AREA, and must be considered to begin at the corner (0,0) of AREA. It'll be used for drawing.
This method will be called at least once before a widget can be drawn (it needs not to be called again as long as the widget drawing dimensions do not change). It will not be called if the widget is invisible (invisible widgets occupy no space when drawing). Recall that the root widget of the widget tree is always considered visible.
The ContainerWidget class provide code for this in charge of calling their children method. Derived containers should call that base method to complete their calculations.
Implements zxeco::gui::Widget.
|
virtual |
Must draw itself in the decided aligned zone withing the drawing zone.
Use aligned_drawing_zone to get the final, aligned zone where the entire widget must be drawn. The zone is assured to be cleared with the background colours of the window before calling drawRaw(). The best way to go is to create a subscreen on the aligned_drawing_zone_ and work on it.
This method will not be called if the widget is invisible.
NOTE: Do not call this method directly on your derived code; just implement it and call drawMe() or redrawMe().
Reimplemented from zxeco::gui::Widget.
Set the final drawing zone for the widget and the aligned one.
Return a pointer to the first (higher) widget in the tree equal or below this that gets an aligned drawing zone different from its current one (or its first zone if not drawn before), or nullptr if all widgets below this (including this) get the same zones as before. The available drawing zone of the widget is the space where it can align its content; the aligned zone is the final rectangle where it must be drawn, already aligned within the drawing zone.
ZONE.corner uses absolute coords within the global screen. ZONE can have the same area as the needed one or a different, larger one (that leaves room for alignment), but not smaller.
This method will be called after calculating the widget fitting needs & before drawing. It will be called at least once before a widget can be drawn (it needs not to be called again as long as the widget drawing dimensions do not change).
Container widgets override this method to deploy it to their children. Also, widgets derived from containers can override it to adjust the visibility of some children if that is to be calculated dynamically, since ZONE may be larger than the one proposed by calcFittingNeeds(), which may affect that visibility.
If the calculated aligned drawing zone is different from the previous one or if the widget was not previously drawn, sets the drawn_ flag to false. Otherwise, leave it unchanged.
Reimplemented from zxeco::gui::Widget.
|
overridevirtualnoexcept |
Move the drawing and aligned zones corners by those increments.
Does not change the areas or the drawn_ flag. In general, this method should not be overriden by derived classes unless they need to move something else in addition to the drawing and aligned zones.
Reimplemented from zxeco::gui::Widget.
|
overridevirtualnoexcept |
Set the Window where the widget is being managed.
Reimplemented from zxeco::gui::Widget.
|
overridevirtualnoexcept |
< Assign the colors used to draw the widget. WINCOLS must outlive this.
Reimplemented from zxeco::gui::Widget.
|
overridevirtual |
Deal with the event at this widget and its descendants (if container).
This method call processEvent() for processing the event, both in downwards and upwards event paths if it is a container. It also deals with the focus; it does nothing if the widget is invisible or disabled or not drawn yet.
Return: PROCESSED_OK if the event is processed by this widget or its descen- dants (they can cover it) and the widget manager should continue afterwards; PROCESSED_FINISH if the event is processed by this widget of its descendants and the window manager should end its work at this point; NOT_PROCESSED if this widget or its descendants cannot deal with the event (it is not covered by them); WINCLOSE if a window close event is catched while process- ing the event (that may occur in some widgets that open new windows and manage them).
This code is for non-container widgets; container widgets override it to provide propragation (OWN-containers do not need to override again).
Reimplemented from zxeco::gui::Widget.
using zxeco::gui::Widget::ID = int |
A numeric ID associated to the widget.
This IDs may be non-unique, thus any operation on widgets depending on widget uniqueness should use the operator==() instead.
Definition at line 67 of file ZXWidgetsBase.h.
using zxeco::gui::Widget::Ptr = std::shared_ptr<Widget> |
A polymorphic ptr to a widget.
This type is used by the widget system just to create the widgets and delete them safely; for all other operations, plain pointers to widgets are much more efficient and enough, since widgets, once created, are not deleted until the whole widget system is deleted.
Definition at line 74 of file ZXWidgetsBase.h.
using zxeco::gui::Widget::TraverseObserver = std::function< TravResult(Widget &) > |
The Widget class has the traverse() method to do traversing on its nodes. The traverse() method calls a routine of this type for each widget that is traversed in the tree, which must return a result to continue or not the traversing.
Definition at line 133 of file ZXWidgetsBase.h.
|
strong |
Possible results of observer when traversing widgets in the widget tree.
< The Widget class has the traverse() method to do traversing on its nodes.
Definition at line 126 of file ZXWidgetsBase.h.