The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations
Base for all widgets in the GUI

Description

This module provides the base definitions for the widgets system.

http://jafma.net

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.

Collaboration diagram for Base for all widgets in the GUI:

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 Documentation

◆ zxeco::gui::Widget

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.

Inheritance diagram for zxeco::gui::Widget:
Collaboration diagram for zxeco::gui::Widget:

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...
 
Widgetoperator= (const Widget &)=delete
 Constructor. More...
 
Widgetoperator= (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 WinColorsgetWinColors (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...
 
WidgetgetParent (void) const noexcept
 Return a pointer to the parent of the widget, or nullptr if none. More...
 
WidgetgetRoot (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...
 
WidgetsearchID (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...
 
WidgetwhoIsFocused (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...
 
WidgetredrawAll (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 AreaFittingcalcFittingNeeds (const CharArea &area)=0
 Must calculate the widget fitting within the dimensions of AREA. More...
 
const AreaFittingfittingNeeds (void) const noexcept
 < Return the last calculation of the fitting needs of the widget. More...
 
virtual WidgetsetDrawingZone (const CharRect &zone)
 Set the final drawing zone for the widget and the aligned one. More...
 
const CharRectdrawingZone (void) const noexcept
 < Get the drawing zone decided for the widget within the global screen. More...
 
const CharRectalignedDrawingZone (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 CallbackRoutgetCallback (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 WinColorspwincols_
 
const uint8_t * udgs_
 
Windowpwin_
 
CallbackRout callback_
 
std::string tooltiptext_
 
HorAlign hal_
 
VertAlign val_
 
AreaFitting fitting_needs_
 
CharRect drawing_zone_
 
CharRect aligned_drawing_zone_
 
Widgetparent_
 
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...
 

Member Typedef Documentation

◆ CallbackRout

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.

Member Enumeration Documentation

◆ HorAlign

enum class zxeco::gui::Widget::HorAlign
strong

Horizontal alignment of widgets within the areas of their containers.

Definition at line 252 of file ZXWidgetsBase.h.

◆ VertAlign

enum class zxeco::gui::Widget::VertAlign
strong

Vertical alignment of widgets within the areas of their containers.

Definition at line 259 of file ZXWidgetsBase.h.

◆ EventType

enum class zxeco::gui::Widget::EventType
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.

◆ SubEvType

enum class zxeco::gui::Widget::SubEvType
strong

Concrete events for each event kind.

Enumerator
MOUSE_MOVE 

movement of the mouse

MOUSE_CLICK 

click of the mouse

MOUSE_UNCLICK 

unclick of the mouse

MOUSE_WHEEL 

mouse wheel motion

KEYB_PRESS 

key pressing

KEYB_UNPRESS 

key unpressing

KEYB_TEXT 

a char is recognized by the OS

FOCUS_GOT 

widget got focus

FOCUS_LOST 

widget lost focus

Definition at line 279 of file ZXWidgetsBase.h.

Constructor & Destructor Documentation

◆ Widget() [1/3]

zxeco::gui::Widget::Widget ( ID  id,
const std::string &  name,
const std::string &  tooltiptext = "",
HorAlign  hal = HorAlign::LEFT,
VertAlign  val = VertAlign::TOP 
)
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.

Parameters
idis the ID of the widget, not necessarily unique.
nameis 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.
tooltiptextis the tooltiptext for the widget.
halis the horizontal alignment within its parent.
valis the vertical alignment within its parent.

Definition at line 655 of file ZXWidgetsBase.h.

◆ Widget() [2/3]

zxeco::gui::Widget::Widget ( const Widget )
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.

Parameters
idis the ID of the widget, not necessarily unique.
nameis 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.
tooltiptextis the tooltiptext for the widget.
halis the horizontal alignment within its parent.
valis the vertical alignment within its parent.

◆ Widget() [3/3]

zxeco::gui::Widget::Widget ( Widget &&  )
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.

Parameters
idis the ID of the widget, not necessarily unique.
nameis 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.
tooltiptextis the tooltiptext for the widget.
halis the horizontal alignment within its parent.
valis the vertical alignment within its parent.

Member Function Documentation

◆ addGlobalTraces()

static void zxeco::gui::Widget::addGlobalTraces ( Trace::Type  traces)
inlinestaticnoexcept

< Add TRACES to the currently active traces (initially none).

Definition at line 629 of file ZXWidgetsBase.h.

◆ delGlobalTraces()

static void zxeco::gui::Widget::delGlobalTraces ( Trace::Type  traces)
inlinestaticnoexcept

< Delete the given traces from the current active ones.

Definition at line 633 of file ZXWidgetsBase.h.

◆ isTracing()

static Trace::Type zxeco::gui::Widget::isTracing ( Trace::Type  traces)
inlinestaticnoexcept

< Return a non-zero value if any of TRACES is currently active.

Definition at line 637 of file ZXWidgetsBase.h.

◆ printIfTrace()

static void zxeco::gui::Widget::printIfTrace ( Trace::Type  trace,
const std::string &  tr 
)
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.

◆ operator=() [1/2]

Widget & zxeco::gui::Widget::operator= ( const Widget )
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.

Parameters
idis the ID of the widget, not necessarily unique.
nameis 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.
tooltiptextis the tooltiptext for the widget.
halis the horizontal alignment within its parent.
valis the vertical alignment within its parent.

◆ operator=() [2/2]

Widget & zxeco::gui::Widget::operator= ( Widget &&  )
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.

Parameters
idis the ID of the widget, not necessarily unique.
nameis 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.
tooltiptextis the tooltiptext for the widget.
halis the horizontal alignment within its parent.
valis the vertical alignment within its parent.

◆ className()

virtual const char * zxeco::gui::Widget::className ( void  ) const
pure virtualnoexcept

◆ idText()

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.

◆ isContainer()

virtual bool zxeco::gui::Widget::isContainer ( void  ) const
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.

◆ isUserContainer()

bool zxeco::gui::Widget::isUserContainer ( void  ) const
noexcept

Return whether the widget is a USER-type container.

See also
ContainerWidget class.

◆ getID()

ID zxeco::gui::Widget::getID ( void  ) const
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.

◆ changeID()

void zxeco::gui::Widget::changeID ( ID  id)
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.

◆ getName()

const std::string & zxeco::gui::Widget::getName ( void  ) const
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.

◆ operator==()

bool zxeco::gui::Widget::operator== ( const Widget oth) const
inlinenoexcept

Operator to detect unique identities in widgets.

Definition at line 730 of file ZXWidgetsBase.h.

◆ operator!=()

bool zxeco::gui::Widget::operator!= ( const Widget oth) const
inlinenoexcept

Operator to detect unique identities in widgets.

Definition at line 733 of file ZXWidgetsBase.h.

◆ hasFocusZone()

virtual std::pair< bool, const CharRect * > zxeco::gui::Widget::hasFocusZone ( void  ) const
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.

◆ setWindow()

virtual void zxeco::gui::Widget::setWindow ( Window win)
inlinevirtualnoexcept

Set the Window where the widget is being managed.

Reimplemented in zxeco::gui::ContainerWidget.

Definition at line 745 of file ZXWidgetsBase.h.

◆ setWinColors()

virtual void zxeco::gui::Widget::setWinColors ( const WinColors wincols)
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.

◆ getWinColors()

const WinColors & zxeco::gui::Widget::getWinColors ( void  ) const
inlinenoexcept

Return the current window colors.

Definition at line 752 of file ZXWidgetsBase.h.

◆ setUDGs()

virtual void zxeco::gui::Widget::setUDGs ( const uint8_t *  udgs)
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.

◆ getUDGs()

const uint8_t * zxeco::gui::Widget::getUDGs ( void  )
inline

Return the current UDGs. *‍/.

Definition at line 759 of file ZXWidgetsBase.h.

◆ setTooltip()

virtual void zxeco::gui::Widget::setTooltip ( const std::string &  ttt)
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.

Parameters
tttChange 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.

◆ getTooltip()

const std::string & zxeco::gui::Widget::getTooltip ( void  ) const
inlinenoexcept

Return the tooltip for the widget.

Definition at line 768 of file ZXWidgetsBase.h.

◆ setParent()

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.

◆ getParent()

Widget * zxeco::gui::Widget::getParent ( void  ) const
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.

◆ getRoot()

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.

◆ isRoot()

bool zxeco::gui::Widget::isRoot ( void  ) const
inlinenoexcept

Return TRUE if this widget is the root of the tree.

Definition at line 790 of file ZXWidgetsBase.h.

◆ isDescendantOf()

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.

◆ searchID()

Widget * zxeco::gui::Widget::searchID ( ID  id) const

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.

◆ maxUsedID()

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.

◆ traverse()

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).

◆ revTraverse()

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:

  • FINISH_OK for finishing the traversing successfully at that point (after having observed that widget),
  • FINISH_FAIL for the same but indicating failure,
  • CONTINUE to go on with the next widget. This method only returns FINISH_OK, FINISH_FAIL or CONTINUE (if all widgets have been traversed).

◆ setVisibility()

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.

◆ setVisibilityNoRedrawing()

void zxeco::gui::Widget::setVisibilityNoRedrawing ( bool  vis)
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.

See also
setVisibility.

Definition at line 844 of file ZXWidgetsBase.h.

◆ getVisibility()

bool zxeco::gui::Widget::getVisibility ( void  ) const
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.

◆ setEnabled()

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.

◆ getEnabled()

bool zxeco::gui::Widget::getEnabled ( void  ) const
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.

◆ isFocusable()

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.

◆ isInFocusPath()

bool zxeco::gui::Widget::isInFocusPath ( void  ) const
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.

◆ isLeafFocused()

bool zxeco::gui::Widget::isLeafFocused ( void  ) const
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.

◆ whoIsFocused()

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.

◆ acquireFocus()

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.

◆ releaseFocus()

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.

◆ drawAll()

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.

◆ redrawAll()

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.

◆ redrawMe()

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.

◆ drawMe()

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.

◆ calcFittingNeeds()

virtual const AreaFitting & zxeco::gui::Widget::calcFittingNeeds ( const CharArea area)
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.

◆ fittingNeeds()

const AreaFitting & zxeco::gui::Widget::fittingNeeds ( void  ) const
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.

◆ setDrawingZone()

virtual Widget * zxeco::gui::Widget::setDrawingZone ( const CharRect zone)
virtual

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.

◆ drawingZone()

const CharRect & zxeco::gui::Widget::drawingZone ( void  ) const
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.

◆ alignedDrawingZone()

const CharRect & zxeco::gui::Widget::alignedDrawingZone ( void  ) const
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.

◆ moveDrawingZones()

virtual void zxeco::gui::Widget::moveDrawingZones ( IntDist  incx,
IntDist  incy 
)
virtualnoexcept

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.

◆ drawn()

bool zxeco::gui::Widget::drawn ( void  ) const
inlinenoexcept

Return TRUE if the widget has already been drawn in current dimensions.

Definition at line 1032 of file ZXWidgetsBase.h.

◆ undraw()

void zxeco::gui::Widget::undraw ( void  )
inlinenoexcept

Method for external agents (e.g., Windows) to mark the widget undrawn.

Definition at line 1035 of file ZXWidgetsBase.h.

◆ setExplanations()

void zxeco::gui::Widget::setExplanations ( bool  setit = true)
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.

◆ getExplanations()

bool zxeco::gui::Widget::getExplanations ( void  ) const
inlinenoexcept

Return the current status of drawing explanations.

Definition at line 1054 of file ZXWidgetsBase.h.

◆ traceOfDrawing()

std::string zxeco::gui::Widget::traceOfDrawing ( bool  withoutprivate = true) const
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.

◆ traceOfDrawingRecursive()

virtual void zxeco::gui::Widget::traceOfDrawingRecursive ( size_t  level,
std::stringstream &  ss,
bool  withoutprivate = true 
) const
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().

◆ chainEvent()

virtual ChainEventResult zxeco::gui::Widget::chainEvent ( const EventData data)
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.

◆ setCallback()

virtual void zxeco::gui::Widget::setCallback ( const CallbackRout callback = NullCallback)
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).

Parameters
callbackSet the callback routine that will be called during event processing.

Definition at line 1097 of file ZXWidgetsBase.h.

◆ getCallback()

const CallbackRout & zxeco::gui::Widget::getCallback ( void  ) const
inlinenoexcept

Get the current callback routine.

Definition at line 1101 of file ZXWidgetsBase.h.

◆ addCallback()

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.

◆ drawRaw()

virtual void zxeco::gui::Widget::drawRaw ( void  )
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.

◆ processEvent()

virtual int zxeco::gui::Widget::processEvent ( const EventData evdata,
Widget who 
)
inlineprotectedvirtual
Parameters
whoMust 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.

◆ addLineToExplanation()

void zxeco::gui::Widget::addLineToExplanation ( const std::string &  line)
protected

Add LINE to the existing explanation in fitting_needs_.

If explaindrawing_ is false, add nothing.

Member Data Documentation

◆ NullCallback

const CallbackRout zxeco::gui::Widget::NullCallback
static

Callback routine that does nothing.

Definition at line 600 of file ZXWidgetsBase.h.

◆ kTraceBegin

const std::string zxeco::gui::Widget::kTraceBegin
static

< Add TRACES to the currently active traces (initially none).

Definition at line 626 of file ZXWidgetsBase.h.

◆ kTraceEnd

const std::string zxeco::gui::Widget::kTraceEnd
static

< Add TRACES to the currently active traces (initially none).

Definition at line 627 of file ZXWidgetsBase.h.

◆ traces_

Trace::Type zxeco::gui::Widget::traces_
staticprotected

Currently active traces.

Definition at line 1114 of file ZXWidgetsBase.h.

◆ id_

ID zxeco::gui::Widget::id_
protected

Definition at line 1117 of file ZXWidgetsBase.h.

◆ name_

const std::string zxeco::gui::Widget::name_
protected

Definition at line 1118 of file ZXWidgetsBase.h.

◆ pwincols_

const WinColors* zxeco::gui::Widget::pwincols_
protected

Definition at line 1120 of file ZXWidgetsBase.h.

◆ udgs_

const uint8_t* zxeco::gui::Widget::udgs_
protected

Definition at line 1121 of file ZXWidgetsBase.h.

◆ pwin_

Window* zxeco::gui::Widget::pwin_
protected

Definition at line 1122 of file ZXWidgetsBase.h.

◆ callback_

CallbackRout zxeco::gui::Widget::callback_
protected

Definition at line 1126 of file ZXWidgetsBase.h.

◆ tooltiptext_

std::string zxeco::gui::Widget::tooltiptext_
protected

Definition at line 1127 of file ZXWidgetsBase.h.

◆ hal_

HorAlign zxeco::gui::Widget::hal_
protected

Definition at line 1128 of file ZXWidgetsBase.h.

◆ val_

VertAlign zxeco::gui::Widget::val_
protected

Definition at line 1129 of file ZXWidgetsBase.h.

◆ fitting_needs_

AreaFitting zxeco::gui::Widget::fitting_needs_
protected

Definition at line 1130 of file ZXWidgetsBase.h.

◆ drawing_zone_

CharRect zxeco::gui::Widget::drawing_zone_
protected

Definition at line 1131 of file ZXWidgetsBase.h.

◆ aligned_drawing_zone_

CharRect zxeco::gui::Widget::aligned_drawing_zone_
protected

Definition at line 1132 of file ZXWidgetsBase.h.

◆ parent_

Widget* zxeco::gui::Widget::parent_
protected

Definition at line 1133 of file ZXWidgetsBase.h.

◆ explaindrawing_

bool zxeco::gui::Widget::explaindrawing_
protected

Definition at line 1134 of file ZXWidgetsBase.h.

◆ zxeco::gui::Widget::PVector

class zxeco::gui::Widget::PVector

A vector of ptrs to widgets.

Definition at line 77 of file ZXWidgetsBase.h.

Inheritance diagram for zxeco::gui::Widget::PVector:
Collaboration diagram for zxeco::gui::Widget::PVector:

Public Types

using Base = std::vector< Ptr >
 Shortcut. More...
 

Public Member Functions

WidgetaddChildOf (const Ptr &w, Widget &parent)
 < Reuse constructors More...
 

Member Typedef Documentation

◆ Base

using zxeco::gui::Widget::PVector::Base = std::vector<Ptr>

Shortcut.

Definition at line 81 of file ZXWidgetsBase.h.

Member Function Documentation

◆ addChildOf()

Widget * zxeco::gui::Widget::PVector::addChildOf ( const Ptr w,
Widget parent 
)
inline

< Reuse constructors

Parameters
parentAdd 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.

◆ zxeco::gui::Widget::Path

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.

Inheritance diagram for zxeco::gui::Widget::Path:
Collaboration diagram for zxeco::gui::Widget::Path:

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.
 

Member Typedef Documentation

◆ Base

using zxeco::gui::Widget::Path::Base = std::vector<Widget *>

Definition at line 99 of file ZXWidgetsBase.h.

Constructor & Destructor Documentation

◆ Path() [1/2]

zxeco::gui::Widget::Path::Path ( bool  downorup)
inline

Create an empty path that goes downwards (TRUE) or upwards (FALSE).

Definition at line 101 of file ZXWidgetsBase.h.

◆ Path() [2/2]

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.

Member Function Documentation

◆ isDownwards()

bool zxeco::gui::Widget::Path::isDownwards ( void  ) const
inlinenoexcept

Return TRUE if the path goes downwards.

Definition at line 109 of file ZXWidgetsBase.h.

◆ isUpwards()

bool zxeco::gui::Widget::Path::isUpwards ( void  ) const
inlinenoexcept

Return TRUE if the path goes upwards.

Definition at line 112 of file ZXWidgetsBase.h.

◆ zxeco::gui::Widget::AreaFitting

struct zxeco::gui::Widget::AreaFitting

Information about the fitting of widgets drawings into rectangular areas.

Definition at line 147 of file ZXWidgetsBase.h.

Collaboration diagram for zxeco::gui::Widget::AreaFitting:

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...
 
Widgetwidget
 Ptr (no ownerwhip) to the widget that produces fit. More...
 
Widgetwidgetcause
 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)
 
AreaFittingoperator= (const AreaFitting &oaf)
 
AreaFittingoperator= (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.
 

Member Typedef Documentation

◆ Vector

Several, ordered fittings.

Definition at line 149 of file ZXWidgetsBase.h.

Member Enumeration Documentation

◆ Fit

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

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.

Constructor & Destructor Documentation

◆ AreaFitting() [1/5]

zxeco::gui::Widget::AreaFitting::AreaFitting ( const CharArea prov,
Widget wi,
const std::string &  expl = "" 
)
inline

Default constructor: UNFIT.

Definition at line 176 of file ZXWidgetsBase.h.

◆ AreaFitting() [2/5]

zxeco::gui::Widget::AreaFitting::AreaFitting ( const CharArea prov,
Widget wi,
const CharArea ndd,
uint8_t  fds = 0 
)
inline

Definition at line 186 of file ZXWidgetsBase.h.

◆ AreaFitting() [3/5]

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.

◆ AreaFitting() [4/5]

zxeco::gui::Widget::AreaFitting::AreaFitting ( Widget wi,
const AreaFitting oaf 
)
inline

Definition at line 206 of file ZXWidgetsBase.h.

◆ AreaFitting() [5/5]

zxeco::gui::Widget::AreaFitting::AreaFitting ( Widget wi,
AreaFitting &&  oaf 
)
inline

< The origin fitting is set as UNFIT.

Definition at line 210 of file ZXWidgetsBase.h.

Member Function Documentation

◆ operator=() [1/2]

AreaFitting & zxeco::gui::Widget::AreaFitting::operator= ( const AreaFitting oaf)
inline
Parameters
oafAssignment, preserving all.

Definition at line 215 of file ZXWidgetsBase.h.

◆ operator=() [2/2]

AreaFitting & zxeco::gui::Widget::AreaFitting::operator= ( AreaFitting &&  oaf)
inline
Parameters
oafMove assignment, preserving all.

Definition at line 219 of file ZXWidgetsBase.h.

◆ assign() [1/2]

void zxeco::gui::Widget::AreaFitting::assign ( Widget wi,
const AreaFitting oaf 
)
inline
Parameters
oafAssignment preserving everything but the widget.

Definition at line 223 of file ZXWidgetsBase.h.

◆ assign() [2/2]

void zxeco::gui::Widget::AreaFitting::assign ( Widget wi,
AreaFitting &&  oaf 
)
inline
Parameters
oafMove assignment preserving everything but the widget and time. The origin fitting is set as UNFIT.

Definition at line 227 of file ZXWidgetsBase.h.

◆ operator bool()

zxeco::gui::Widget::AreaFitting::operator bool ( void  ) const
inlinenoexcept

Return FALSE if UNFIT or TRUE otherwise.

Definition at line 234 of file ZXWidgetsBase.h.

Member Data Documentation

◆ creattime

LongestUnsignedType zxeco::gui::Widget::AreaFitting::creattime

Time of creation.

Definition at line 166 of file ZXWidgetsBase.h.

◆ widget

Widget* zxeco::gui::Widget::AreaFitting::widget

Ptr (no ownerwhip) to the widget that produces fit.

Definition at line 167 of file ZXWidgetsBase.h.

◆ widgetcause

Widget* zxeco::gui::Widget::AreaFitting::widgetcause

Ptr (no owner) to first widget that was unfit.

Definition at line 168 of file ZXWidgetsBase.h.

◆ provided

CharArea zxeco::gui::Widget::AreaFitting::provided

Area that was provided for the calculation.

Definition at line 169 of file ZXWidgetsBase.h.

◆ fitting

Fit zxeco::gui::Widget::AreaFitting::fitting

How the widget fits in the provided area.

Definition at line 170 of file ZXWidgetsBase.h.

◆ needed

CharArea zxeco::gui::Widget::AreaFitting::needed

Area decided if FIT or min. area needed if FLEXFIT.

Definition at line 171 of file ZXWidgetsBase.h.

◆ flexdim

uint8_t zxeco::gui::Widget::AreaFitting::flexdim

Dimension along which a FLEXFIT can vary.

Definition at line 172 of file ZXWidgetsBase.h.

◆ explanation

std::string zxeco::gui::Widget::AreaFitting::explanation

Explanation of the fit (optional).

Definition at line 173 of file ZXWidgetsBase.h.

◆ zxeco::gui::Widget::EventData

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.

Collaboration diagram for zxeco::gui::Widget::EventData:

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)
 
EventDataoperator= (const EventData &o)
 
EventDataoperator= (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.
 

Constructor & Destructor Documentation

◆ EventData() [1/5]

zxeco::gui::Widget::EventData::EventData ( void  )
inline

Default constructor: FOCUS_LOST.

Definition at line 356 of file ZXWidgetsBase.h.

◆ EventData() [2/5]

zxeco::gui::Widget::EventData::EventData ( int32_t  wincr)
inline

Constructor for MOUSE_WHEEL.

Definition at line 360 of file ZXWidgetsBase.h.

◆ EventData() [3/5]

zxeco::gui::Widget::EventData::EventData ( const char *  chutf8)
inline

Constructor for KEYB_TEXT event.

Definition at line 371 of file ZXWidgetsBase.h.

◆ EventData() [4/5]

zxeco::gui::Widget::EventData::EventData ( const EventData o)
inline

Definition at line 376 of file ZXWidgetsBase.h.

◆ EventData() [5/5]

zxeco::gui::Widget::EventData::EventData ( EventData &&  o)
inline

Definition at line 377 of file ZXWidgetsBase.h.

Member Function Documentation

◆ operator=() [1/2]

EventData & zxeco::gui::Widget::EventData::operator= ( const EventData o)
inline

Definition at line 378 of file ZXWidgetsBase.h.

◆ operator=() [2/2]

EventData & zxeco::gui::Widget::EventData::operator= ( EventData &&  o)
inline

Definition at line 380 of file ZXWidgetsBase.h.

◆ keyOrWheelIntoKey()

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.

◆ isMouseClick()

bool zxeco::gui::Widget::EventData::isMouseClick ( void  ) const
inlinenoexcept

< Return TRUE if the event is a click of the mouse.

Definition at line 389 of file ZXWidgetsBase.h.

◆ isMouseUnclick()

bool zxeco::gui::Widget::EventData::isMouseUnclick ( void  ) const
inlinenoexcept

< Return TRUE if the event is an unclick of the mouse.

Definition at line 394 of file ZXWidgetsBase.h.

◆ isMouseRightClick()

bool zxeco::gui::Widget::EventData::isMouseRightClick ( void  ) const
inlinenoexcept

< Return TRUE if the event is the right click of the mouse.

Definition at line 399 of file ZXWidgetsBase.h.

◆ isMouseLeftClick()

bool zxeco::gui::Widget::EventData::isMouseLeftClick ( void  ) const
inlinenoexcept

< Return TRUE if the event is the left click of the mouse.

Definition at line 403 of file ZXWidgetsBase.h.

◆ isMouseRightUnclick()

bool zxeco::gui::Widget::EventData::isMouseRightUnclick ( void  ) const
inlinenoexcept

< Return TRUE if the event is the right unclick of the mouse.

Definition at line 407 of file ZXWidgetsBase.h.

◆ isMouseLeftUnclick()

bool zxeco::gui::Widget::EventData::isMouseLeftUnclick ( void  ) const
inlinenoexcept

< Return TRUE if the event is the left unclick of the mouse.

Definition at line 411 of file ZXWidgetsBase.h.

◆ isMouseMove()

bool zxeco::gui::Widget::EventData::isMouseMove ( void  ) const
inlinenoexcept

< Return TRUE if the event is a motion of the mouse.

Definition at line 415 of file ZXWidgetsBase.h.

◆ isMouseWheel()

bool zxeco::gui::Widget::EventData::isMouseWheel ( void  ) const
inlinenoexcept

< Return TRUE if the event is mouse wheel.

Definition at line 420 of file ZXWidgetsBase.h.

◆ isKeyPressed()

bool zxeco::gui::Widget::EventData::isKeyPressed ( void  ) const
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.

◆ isKeyUnpressed()

bool zxeco::gui::Widget::EventData::isKeyUnpressed ( void  ) const
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.

◆ isRecognizedText()

bool zxeco::gui::Widget::EventData::isRecognizedText ( void  ) const
inlinenoexcept

< Return TRUE if the event is the recognition of a char by the OS.

Definition at line 439 of file ZXWidgetsBase.h.

◆ isGotFocus()

bool zxeco::gui::Widget::EventData::isGotFocus ( void  ) const
inlinenoexcept

< Return TRUE if the event is the acquisition of focus to the widget.

Definition at line 444 of file ZXWidgetsBase.h.

◆ isLostFocus()

bool zxeco::gui::Widget::EventData::isLostFocus ( void  ) const
inlinenoexcept

< Return TRUE if the event is the lost of focus by the widget.

Definition at line 449 of file ZXWidgetsBase.h.

◆ needsFocus()

bool zxeco::gui::Widget::EventData::needsFocus ( void  ) const
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.

◆ hasMouse()

bool zxeco::gui::Widget::EventData::hasMouse ( void  ) const
inlinenoexcept

< Return TRUE if the event contains info of mouse coordinates.

Definition at line 470 of file ZXWidgetsBase.h.

Member Data Documentation

◆ evt

EventType zxeco::gui::Widget::EventData::evt

Event kind.

Definition at line 303 of file ZXWidgetsBase.h.

◆ subevt

SubEvType zxeco::gui::Widget::EventData::subevt

Concrete event.

Definition at line 304 of file ZXWidgetsBase.h.

◆ zxeco::gui::Widget::EventData::EvData

struct zxeco::gui::Widget::EventData::EvData

Event data.

Definition at line 306 of file ZXWidgetsBase.h.

Collaboration diagram for zxeco::gui::Widget::EventData::EvData:

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)
 
EvDataoperator= (const EvData &o)
 
EvDataoperator= (EvData &&o)
 

Constructor & Destructor Documentation

◆ EvData() [1/6]

zxeco::gui::Widget::EventData::EvData::EvData ( int32_t  wi)
inline

Definition at line 336 of file ZXWidgetsBase.h.

◆ EvData() [2/6]

zxeco::gui::Widget::EventData::EvData::EvData ( const PointingStatus m)
inline

Definition at line 337 of file ZXWidgetsBase.h.

◆ EvData() [3/6]

zxeco::gui::Widget::EventData::EvData::EvData ( const DesktopInterface::KeyID  k)
inline

Definition at line 338 of file ZXWidgetsBase.h.

◆ EvData() [4/6]

zxeco::gui::Widget::EventData::EvData::EvData ( const char *  chutf8)
inline

Definition at line 339 of file ZXWidgetsBase.h.

◆ EvData() [5/6]

zxeco::gui::Widget::EventData::EvData::EvData ( const EvData o)
inline

Definition at line 340 of file ZXWidgetsBase.h.

◆ EvData() [6/6]

zxeco::gui::Widget::EventData::EvData::EvData ( EvData &&  o)
inline

Definition at line 341 of file ZXWidgetsBase.h.

◆ ~EvData()

zxeco::gui::Widget::EventData::EvData::~EvData ( void  )
inline

Definition at line 346 of file ZXWidgetsBase.h.

Member Function Documentation

◆ operator=() [1/2]

EvData & zxeco::gui::Widget::EventData::EvData::operator= ( const EvData o)
inline

Definition at line 342 of file ZXWidgetsBase.h.

◆ operator=() [2/2]

EvData & zxeco::gui::Widget::EventData::EvData::operator= ( EvData &&  o)
inline

Definition at line 344 of file ZXWidgetsBase.h.

Member Data Documentation

◆ wheelincr

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.

◆ mouse

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.

◆ key

DesktopInterface::KeyID zxeco::gui::Widget::EventData::EvData::key
Initial value:
{
DesktopInterface::KeyID::NUM_OF_KEY_IDS}

If event is KEYB_PRESS/UNPRESS.

Key pressed or unpressed.

Definition at line 329 of file ZXWidgetsBase.h.

◆ text

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.

◆ zxeco::gui::Widget::ChainEventResult

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.

Collaboration diagram for zxeco::gui::Widget::ChainEventResult:

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...
 
Widgetwho
 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...
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Possible results when the event is chained to a given widget.

Enumerator
PROCESSED_OK 

The widget or its descendants processed it.

PROCESSED_FINISH 

The same, but the chaining must stop.

NOT_PROCESSED 

Neither widget or its descendants took it.

WINCLOSE 

A window close event catched during the chaining.

Definition at line 495 of file ZXWidgetsBase.h.

Constructor & Destructor Documentation

◆ ChainEventResult() [1/3]

zxeco::gui::Widget::ChainEventResult::ChainEventResult ( bool  winclose = false)
inline

Default constructor. Not processed / winclose events.

Definition at line 508 of file ZXWidgetsBase.h.

◆ ChainEventResult() [2/3]

zxeco::gui::Widget::ChainEventResult::ChainEventResult ( int  r)
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.

◆ ChainEventResult() [3/3]

zxeco::gui::Widget::ChainEventResult::ChainEventResult ( int  r,
Widget p 
)
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.

Member Function Documentation

◆ to_string()

std::string zxeco::gui::Widget::ChainEventResult::to_string ( void  ) const
inline

< Return a text describing the result.

Definition at line 523 of file ZXWidgetsBase.h.

Member Data Documentation

◆ result

int zxeco::gui::Widget::ChainEventResult::result

One of the possible result values.

Definition at line 503 of file ZXWidgetsBase.h.

◆ who

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.

◆ zxeco::gui::Widget::CallbackParms

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.

Collaboration diagram for zxeco::gui::Widget::CallbackParms:

Public Attributes

char moment
 Either 'B' (before processing event) or 'A' (after). More...
 
Widgetwhoprocessed
 If 'B', nullptr; if 'A': who processed event. More...
 
const EventDatapevd
 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
 

Member Function Documentation

◆ isAfterWithData()

bool zxeco::gui::Widget::CallbackParms::isAfterWithData ( void  ) const
inlinenoexcept

Return TRUE for parameters that occur in 'A' moment and have data.

Definition at line 551 of file ZXWidgetsBase.h.

◆ isBeforeWithData()

bool zxeco::gui::Widget::CallbackParms::isBeforeWithData ( void  ) const
inlinenoexcept

Definition at line 554 of file ZXWidgetsBase.h.

◆ isToGetFocus()

bool zxeco::gui::Widget::CallbackParms::isToGetFocus ( void  ) const
inlinenoexcept

Return TRUE for parameters indicating right before getting focus.

Definition at line 558 of file ZXWidgetsBase.h.

◆ hasBeenLeftClicked()

bool zxeco::gui::Widget::CallbackParms::hasBeenLeftClicked ( void  ) const
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.

◆ hasPressedKey()

bool zxeco::gui::Widget::CallbackParms::hasPressedKey ( DesktopInterface::KeyID  k) const
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.

◆ hasPressedEnter()

bool zxeco::gui::Widget::CallbackParms::hasPressedEnter ( void  ) const
inlinenoexcept

Return TRUE for parameters indicating ENTER has been pressed.

Definition at line 575 of file ZXWidgetsBase.h.

◆ hasBeenLeftClickedOrEnter()

bool zxeco::gui::Widget::CallbackParms::hasBeenLeftClickedOrEnter ( void  ) const
inlinenoexcept

Return TRUE for parameters indicating left click or enter.

Definition at line 579 of file ZXWidgetsBase.h.

◆ to_string()

std::string zxeco::gui::Widget::CallbackParms::to_string ( void  ) const
inline

Definition at line 583 of file ZXWidgetsBase.h.

Member Data Documentation

◆ moment

char zxeco::gui::Widget::CallbackParms::moment

Either 'B' (before processing event) or 'A' (after).

Definition at line 543 of file ZXWidgetsBase.h.

◆ whoprocessed

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.

◆ pevd

const EventData* zxeco::gui::Widget::CallbackParms::pevd

Data about the event (no ownership).

Definition at line 547 of file ZXWidgetsBase.h.

◆ zxeco::gui::Widget::Trace

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
 

Member Typedef Documentation

◆ Type

using zxeco::gui::Widget::Trace::Type = uint8_t

Definition at line 617 of file ZXWidgetsBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : Type
Enumerator
Drawing 

Traces in the placing/drawing process.

Definition at line 619 of file ZXWidgetsBase.h.

◆ zxeco::gui::ContainerWidget

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.

Inheritance diagram for zxeco::gui::ContainerWidget:
Collaboration diagram for zxeco::gui::ContainerWidget:

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...
 
- Public Types inherited from zxeco::gui::Widget
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 PVectorchildren (void) noexcept
 Return the widgets contained into the container. More...
 
WidgetaddChild (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 AreaFittingcalcFittingNeeds (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...
 
WidgetsetDrawingZone (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...
 
- Public Member Functions inherited from zxeco::gui::Widget
 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...
 
Widgetoperator= (const Widget &)=delete
 Constructor. More...
 
Widgetoperator= (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 WinColorsgetWinColors (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...
 
WidgetgetParent (void) const noexcept
 Return a pointer to the parent of the widget, or nullptr if none. More...
 
WidgetgetRoot (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...
 
WidgetsearchID (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...
 
WidgetwhoIsFocused (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...
 
WidgetredrawAll (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 AreaFittingfittingNeeds (void) const noexcept
 < Return the last calculation of the fitting needs of the widget. More...
 
const CharRectdrawingZone (void) const noexcept
 < Get the drawing zone decided for the widget within the global screen. More...
 
const CharRectalignedDrawingZone (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 CallbackRoutgetCallback (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 Public Member Functions inherited from zxeco::gui::Widget
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 Public Attributes inherited from zxeco::gui::Widget
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...
 
- Protected Member Functions inherited from zxeco::gui::Widget
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 inherited from zxeco::gui::Widget
ID id_
 
const std::string name_
 
const WinColorspwincols_
 
const uint8_t * udgs_
 
Windowpwin_
 
CallbackRout callback_
 
std::string tooltiptext_
 
HorAlign hal_
 
VertAlign val_
 
AreaFitting fitting_needs_
 
CharRect drawing_zone_
 
CharRect aligned_drawing_zone_
 
Widgetparent_
 
bool explaindrawing_
 
- Static Protected Attributes inherited from zxeco::gui::Widget
static Trace::Type traces_
 Currently active traces. More...
 

Member Enumeration Documentation

◆ OrType

Types of containers according to the spatial orientation of their contnt.

Enumerator
VERTICAL 

Content arranged vertically.

HORIZONTAL 

Content arranged horizontally.

DEEP 

Content arranged in depth.

In the DEEP case, only one of the widgets contained in the container is visible at a time; the user may select one if the container is tabbed or it may be an internal selection otherwise. In the non-tabbed case, the container may have title and frame or not, just like the VERTICAL or HORIZONTAL cases.

Definition at line 1237 of file ZXWidgetsBase.h.

◆ CCType

Types of container according to the creation of their children.

Enumerator
USER 

The user (public) create children.

This is useful for widgets that the user employs to hold other ones (a variable set according to the user's needs).

OWN 

The container create children.

This is useful for widgets that are composed of a fixed, pre-defined combination of other, simpler ones. Their children are not meant to be accessible or meaningful outside.

Definition at line 1252 of file ZXWidgetsBase.h.

◆ FMType

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.

Constructor & Destructor Documentation

◆ ContainerWidget()

zxeco::gui::ContainerWidget::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 = "" 
)
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.

Note
- The widget will not show its title unless it has a frame.
- DEEP tabbed containers always use a frame to surround the different tabs. A DEEP container is tabbed if all its children have non-empty names (those names will become the tab texts); otherwise it is non-tabbed and may have title and/or frame as any normal container.
- If TIT contains location control codes (AT, TAB, COMMA, ENTER, DEL, ARROWS), they are removed. Other control codes and tokens are safe (i.e., colors).

Definition at line 1283 of file ZXWidgetsBase.h.

Member Function Documentation

◆ ccType()

CCType zxeco::gui::ContainerWidget::ccType ( void  ) const
inlinenoexcept

Return its children creation type.

Definition at line 1323 of file ZXWidgetsBase.h.

◆ orType()

OrType zxeco::gui::ContainerWidget::orType ( void  ) const
inlinenoexcept

Return its orientation type.

Definition at line 1326 of file ZXWidgetsBase.h.

◆ focusMngType()

FMType zxeco::gui::ContainerWidget::focusMngType ( void  ) const
inlinenoexcept

Return its focus management type.

Definition at line 1329 of file ZXWidgetsBase.h.

◆ getFrame()

bool zxeco::gui::ContainerWidget::getFrame ( void  ) const
inlinenoexcept

Return whether the widget has currently a frame.

Note
- DEEP tabbed containers ignore frame since they always use a frame to surround the different tabs.

Definition at line 1332 of file ZXWidgetsBase.h.

◆ getTitle()

const std::string & zxeco::gui::ContainerWidget::getTitle ( void  ) const
inlinenoexcept

Return the widtget current title, or empty if none.

Definition at line 1336 of file ZXWidgetsBase.h.

◆ cursorInTopFrame()

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.

◆ children()

const PVector & zxeco::gui::ContainerWidget::children ( void  )
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.

◆ addChild()

Widget * zxeco::gui::ContainerWidget::addChild ( const Ptr ch)
inline

Return its children creation type.

Parameters
chAdd 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.

◆ setDeepSelected()

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.

◆ getDeepSelected()

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.

◆ className()

const char * zxeco::gui::ContainerWidget::className ( void  ) const
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.

◆ isContainer()

bool zxeco::gui::ContainerWidget::isContainer ( void  ) const
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.

◆ calcFittingNeeds()

const AreaFitting & zxeco::gui::ContainerWidget::calcFittingNeeds ( const CharArea area)
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.

◆ drawRaw()

void zxeco::gui::ContainerWidget::drawRaw ( void  )
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.

◆ setDrawingZone()

Widget * zxeco::gui::ContainerWidget::setDrawingZone ( const CharRect zone)
overridevirtual

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.

◆ moveDrawingZones()

void zxeco::gui::ContainerWidget::moveDrawingZones ( IntDist  incx,
IntDist  incy 
)
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.

◆ setWindow()

void zxeco::gui::ContainerWidget::setWindow ( Window win)
overridevirtualnoexcept

Set the Window where the widget is being managed.

Reimplemented from zxeco::gui::Widget.

◆ setWinColors()

void zxeco::gui::ContainerWidget::setWinColors ( const WinColors wincols)
overridevirtualnoexcept

< Assign the colors used to draw the widget. WINCOLS must outlive this.

Reimplemented from zxeco::gui::Widget.

◆ chainEvent()

ChainEventResult zxeco::gui::ContainerWidget::chainEvent ( const EventData data)
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.

Typedef Documentation

◆ ID

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.

◆ Ptr

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.

◆ TraverseObserver

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.

Enumeration Type Documentation

◆ TravResult

enum class zxeco::gui::Widget::TravResult
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.