The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
Namespaces | Classes | Macros
General definitions for the GUI

Description

This module provides general definitions for the ZXEcosystem GUI.

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 General definitions for 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

struct  zxeco::gui::WinColors
 Colors used in a GUI window. More...
 
class  zxeco::gui::TypingZone
 A zone of a widget where the user can type. More...
 
class  zxeco::gui::Label
 A non-empty label for a widget. More...
 
class  zxeco::gui::LabelList
 A list of labels to be displayed vertically, with possible marks on them. More...
 
class  zxeco::gui::LabelList::Iterator
 Bidirectional iterator to scan indexes in the list under a given view. More...
 
class  zxeco::gui::LabelList::IndsRange
 A range of indexes covering some part of the list. More...
 
class  zxeco::gui::LabelTree
 A tree of labels based on LabelList. More...
 
class  zxeco::gui::LabelTree::DepthFirstInserter
 Inserter of elements into the tree structure. More...
 
class  zxeco::gui::LabelDirBrowser
 A tree of labels that correspond to the entries in a directory tree. More...
 

Macros

#define ZXGUIVER   "3.0.0"
 Version of the GUI sublibrary. More...
 

Class Documentation

◆ zxeco::gui::WinColors

struct zxeco::gui::WinColors

Colors used in a GUI window.

Definition at line 52 of file ZXGUIGeneral.h.

Collaboration diagram for zxeco::gui::WinColors:

Static Public Attributes

static const WinColors kLight
 Colors for light background, with bright. More...
 
static const WinColors kDark
 Colors for dark background, with bright. More...
 

Public Attributes

AttrColors title
 For paper, ink, bright of title (flash ignored) More...
 
BrightColor backpaper
 For the background paper and bright. More...
 
BasicColor mainink
 For the ink of main enabled elements.
More...
 
BasicColor maindisink
 For the ink of main disabled elements. More...
 
BasicColor decink
 For the ink of enabled decorations. More...
 
BasicColor decdisink
 For the ink of disabled decorations. More...
 
BrightColor typingpaper
 For the paper of typing areas. More...
 
BrightColor typingdispaper
 For the paper of disabled typing areas. More...
 
BrightColor typingmarkpaper
 For marking some part of the typing areas. More...
 
AttrColors cursor
 For a cursor marking something. More...
 
AttrColors tooltip
 Colors for the tooltip. More...
 

Public Member Functions

uint8_t attrForBackground (void) const
 < Return an attribute suitable for filling a background attrmap. More...
 
void setTitleColorsFor (Screen &scr, bool forborder=false) const
 < Put the title colors in SCR. More...
 
void setBackgroundColorsFor (Screen &scr) const
 < Put the background colors in SCR. More...
 
void setMainColorsFor (Screen &scr, bool enabled) const
 < Put the main colors in SCR. More...
 
void setDecorColorsFor (Screen &scr, bool enabled) const
 < Put the decorations colors in SCR. More...
 
void setTypingColorsFor (Screen &scr, bool enabled) const
 < Put the colors for a typing area in SCR. More...
 
void setCursorColorsFor (Screen &scr) const
 < Put the cursor colors in SCR. More...
 
std::string to_string (void) const
 < Return textual information about the colors. More...
 

Member Function Documentation

◆ attrForBackground()

uint8_t zxeco::gui::WinColors::attrForBackground ( void  ) const
inline

< Return an attribute suitable for filling a background attrmap.

Definition at line 72 of file ZXGUIGeneral.h.

◆ setTitleColorsFor()

void zxeco::gui::WinColors::setTitleColorsFor ( Screen scr,
bool  forborder = false 
) const
inline

< Put the title colors in SCR.

Definition at line 77 of file ZXGUIGeneral.h.

◆ setBackgroundColorsFor()

void zxeco::gui::WinColors::setBackgroundColorsFor ( Screen scr) const
inline

< Put the background colors in SCR.

Definition at line 84 of file ZXGUIGeneral.h.

◆ setMainColorsFor()

void zxeco::gui::WinColors::setMainColorsFor ( Screen scr,
bool  enabled 
) const
inline

< Put the main colors in SCR.

Definition at line 90 of file ZXGUIGeneral.h.

◆ setDecorColorsFor()

void zxeco::gui::WinColors::setDecorColorsFor ( Screen scr,
bool  enabled 
) const
inline

< Put the decorations colors in SCR.

Definition at line 97 of file ZXGUIGeneral.h.

◆ setTypingColorsFor()

void zxeco::gui::WinColors::setTypingColorsFor ( Screen scr,
bool  enabled 
) const
inline

< Put the colors for a typing area in SCR.

Definition at line 104 of file ZXGUIGeneral.h.

◆ setCursorColorsFor()

void zxeco::gui::WinColors::setCursorColorsFor ( Screen scr) const
inline

< Put the cursor colors in SCR.

Definition at line 111 of file ZXGUIGeneral.h.

◆ to_string()

std::string zxeco::gui::WinColors::to_string ( void  ) const
inline

< Return textual information about the colors.

Definition at line 116 of file ZXGUIGeneral.h.

Member Data Documentation

◆ kLight

const WinColors zxeco::gui::WinColors::kLight
static

Colors for light background, with bright.

Definition at line 55 of file ZXGUIGeneral.h.

◆ kDark

const WinColors zxeco::gui::WinColors::kDark
static

Colors for dark background, with bright.

Definition at line 56 of file ZXGUIGeneral.h.

◆ title

AttrColors zxeco::gui::WinColors::title

For paper, ink, bright of title (flash ignored)

Definition at line 59 of file ZXGUIGeneral.h.

◆ backpaper

BrightColor zxeco::gui::WinColors::backpaper

For the background paper and bright.

Definition at line 60 of file ZXGUIGeneral.h.

◆ mainink

BasicColor zxeco::gui::WinColors::mainink

For the ink of main enabled elements.

Definition at line 61 of file ZXGUIGeneral.h.

◆ maindisink

BasicColor zxeco::gui::WinColors::maindisink

For the ink of main disabled elements.

Definition at line 62 of file ZXGUIGeneral.h.

◆ decink

BasicColor zxeco::gui::WinColors::decink

For the ink of enabled decorations.

Definition at line 63 of file ZXGUIGeneral.h.

◆ decdisink

BasicColor zxeco::gui::WinColors::decdisink

For the ink of disabled decorations.

Definition at line 64 of file ZXGUIGeneral.h.

◆ typingpaper

BrightColor zxeco::gui::WinColors::typingpaper

For the paper of typing areas.

Definition at line 65 of file ZXGUIGeneral.h.

◆ typingdispaper

BrightColor zxeco::gui::WinColors::typingdispaper

For the paper of disabled typing areas.

Definition at line 66 of file ZXGUIGeneral.h.

◆ typingmarkpaper

BrightColor zxeco::gui::WinColors::typingmarkpaper

For marking some part of the typing areas.

Definition at line 67 of file ZXGUIGeneral.h.

◆ cursor

AttrColors zxeco::gui::WinColors::cursor

For a cursor marking something.

Definition at line 68 of file ZXGUIGeneral.h.

◆ tooltip

AttrColors zxeco::gui::WinColors::tooltip

Colors for the tooltip.

Definition at line 69 of file ZXGUIGeneral.h.

◆ zxeco::gui::TypingZone

class zxeco::gui::TypingZone

A zone of a widget where the user can type.

Definition at line 144 of file ZXGUIGeneral.h.

Public Member Functions

 TypingZone (void)
 Default constructor. More...
 
void set (const CharRect &zone) noexcept
 Change current typing zone. More...
 
const CharRectget (void) const noexcept
 Return the current typing zone (updated by derived classes). More...
 
void move (IntDist xdiff, IntDist ydiff) noexcept
 < Shift typing zone. More...
 
void clear (Screen &globscr, const WinColors &wincols, bool enabled)
 Draw an empty typing zone in the current zone within GLOBSCR.
 

Constructor & Destructor Documentation

◆ TypingZone()

zxeco::gui::TypingZone::TypingZone ( void  )
inline

Default constructor.

Definition at line 148 of file ZXGUIGeneral.h.

Member Function Documentation

◆ set()

void zxeco::gui::TypingZone::set ( const CharRect zone)
inlinenoexcept

Change current typing zone.

Definition at line 151 of file ZXGUIGeneral.h.

◆ get()

const CharRect & zxeco::gui::TypingZone::get ( void  ) const
inlinenoexcept

Return the current typing zone (updated by derived classes).

Definition at line 154 of file ZXGUIGeneral.h.

◆ move()

void zxeco::gui::TypingZone::move ( IntDist  xdiff,
IntDist  ydiff 
)
inlinenoexcept

< Shift typing zone.

Definition at line 157 of file ZXGUIGeneral.h.

◆ zxeco::gui::Label

class zxeco::gui::Label

A non-empty label for a widget.

A label can contain colour controls but not location controls.

Definition at line 178 of file ZXGUIGeneral.h.

Public Types

using Vector = std::vector< Label >
 A vector of labels. More...
 

Public Member Functions

 Label (void)
 Default constructor: empty label. More...
 
 Label (const std::string &initlabel)
 Constructor from string. More...
 
 Label (const char *initlabel)
 Constructor from char array. More...
 
void set (const std::string &label)
 Set the label text to LABEL. More...
 
void set (const char *label)
 Set the label text to LABEL. More...
 
const std::string & get (void) const noexcept
 Get the current label text. More...
 

Member Typedef Documentation

◆ Vector

using zxeco::gui::Label::Vector = std::vector<Label>

A vector of labels.

Definition at line 183 of file ZXGUIGeneral.h.

Constructor & Destructor Documentation

◆ Label() [1/3]

zxeco::gui::Label::Label ( void  )
inline

Default constructor: empty label.

Definition at line 186 of file ZXGUIGeneral.h.

◆ Label() [2/3]

zxeco::gui::Label::Label ( const std::string &  initlabel)
inline

Constructor from string.

Definition at line 189 of file ZXGUIGeneral.h.

◆ Label() [3/3]

zxeco::gui::Label::Label ( const char *  initlabel)
inline

Constructor from char array.

Definition at line 192 of file ZXGUIGeneral.h.

Member Function Documentation

◆ set() [1/2]

void zxeco::gui::Label::set ( const std::string &  label)

Set the label text to LABEL.

If empty, throw.

◆ set() [2/2]

void zxeco::gui::Label::set ( const char *  label)

Set the label text to LABEL.

If nullptr or empty, throw.

◆ get()

const std::string & zxeco::gui::Label::get ( void  ) const
inlinenoexcept

Get the current label text.

Definition at line 203 of file ZXGUIGeneral.h.

◆ zxeco::gui::LabelList

class zxeco::gui::LabelList

A list of labels to be displayed vertically, with possible marks on them.

< Each label has a number of independent, associated marks equal to the character length of the constructor parameter MARKINMULTIPS. Each char in that string indicates whether that marking allows for multiple selection ('M'), or single selection ('S') or no selection ('N'). In multiple selection, any number of marks can be set or unset. In simple selection, either no mark is set or only one is set. In no selection, no mark can be set. The labels can be set as visible or not, independently from their marks. These lists can refer to other lists, with unlimited recursion length, although accesses to their elements will be slower as longer that length (linearly).

Definition at line 230 of file ZXGUIGeneral.h.

Inheritance diagram for zxeco::gui::LabelList:
Collaboration diagram for zxeco::gui::LabelList:

Public Types

using Observer = std::function< void(char)>
 
using Indexes = std::vector< size_t >
 A set of unique absolute indexes on the list. More...
 

Static Public Attributes

static const Observer kNullObserver
 An observer that does nothing. More...
 

Public Attributes

const std::string kMarkingMultips
 Multiple selection mode of markings. More...
 
const size_t kNumOfMarkings
 Number of independent markings for labels. More...
 

Public Member Functions

 LabelList (const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor: empty list and marks. More...
 
 LabelList (LabelList &oth, size_t begin, size_t length, const Observer &obs=kNullObserver) noexcept
 Constructor: sublist taken from indexes [begin,begin+length) from OTH. More...
 
 LabelList (const Label::Vector &labels, const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor from a vector of labels.
 
 LabelList (const LabelList &oth)
 
 LabelList (LabelList &&oth)
 Move constructor eaves OTH in undefined state if OTH has no ownership.
 
LabelListoperator= (const LabelList &oth)
 
LabelListoperator= (LabelList &&oth)
 Move copy leaves OTH in undefined state if OTH has no ownership.
 
virtual ~LabelList (void)
 Destructor. More...
 
virtual LabelListclone (void) const
 Clone operation for being overriden in derived classes to return them. More...
 
void checkMarking (unsigned marking) const
 If the given marking is not valid for the current list, throw.
 
void checkIndex (size_t who) const
 If the given index is not valid in the current list, throw.
 
size_t size (void) const noexcept
 Return the current number of labels in the list, either visible or not. More...
 
bool empty (void) const noexcept
 Return TRUE if the list is empty (O(1)). More...
 
CharArea areaForEntireList (void) const
 Return the area in chars that the visible items of the list would occpy. More...
 
const Observerobserver (void) const noexcept
 Return a reference to the current observer. More...
 
void changeObserver (const Observer &obs)
 Change the current observer by OBS. More...
 
Iterator begin (uint8_t conditions=Iterator::IT_ALL, unsigned marking=0) const
 Return an iterator to iterate in that fashion, pointing to beginning. More...
 
Iterator end (void) const
 Return an iterator pointing to the end of the list. More...
 
size_t sizeByIterator (Iterator it) const noexcept
 Return the current number of labels in the list that satisfy IT conds. More...
 
size_t longestLabel (Iterator it) const noexcept
 Return the maximum number of chars of any label scanned by IT, or 0. More...
 
virtual std::string labelText (size_t who) const
 Return a copy of the text of the WHO-th label. More...
 
Labellabel (size_t who)
 Return a reference to a modifiable label of the list. More...
 
bool marked (size_t who, unsigned marking=0) const
 Return the marked state of label WHO in marking MARKING. More...
 
bool visible (size_t who) const
 Return TRUE if that label is currently visible.
 
LabelList sublist (const Indexes &inds) const
 Return the given sublist as a copy of the elements of this one. More...
 
bool mark (size_t who, unsigned marking=0)
 Mark the WHO-th label, according to the mode of marks. More...
 
bool markAll (unsigned marking=0)
 Mark all labels in marking or do nothing if the multiplicity forbids. More...
 
bool unmark (size_t who, unsigned marking=0)
 Unmark the WHO-th label. More...
 
bool unmarkAll (unsigned marking=0)
 Unmark all labels at marking MARKING. More...
 
void toggle (size_t who, unsigned marking=0)
 Toggle the mark of WHO according to the mode of selections. More...
 
void toggleAll (unsigned marking=0)
 Like toggle on all marks. More...
 
virtual void setVisible (size_t who)
 Set that element to visible. More...
 
virtual void setInvisible (size_t who)
 Set that element to invisible. More...
 
virtual void toggleVisible (size_t who)
 Toggle visibility of the label WHO. More...
 
virtual void clear (void)
 Clear the content of the entire list, markings and visibilities. More...
 
size_t push_back (const Label &l)
 Insert an unmarked, visible label at the end of the list. More...
 
void push_back (const Label::Vector &v)
 
virtual size_t insert (const Label &l, size_t beforewho)
 Insert an unmarked, visible label before the given element. More...
 
void insert (const Label::Vector &v, size_t beforewho)
 
virtual void erase (size_t who)
 Erase the given element and its marks. More...
 
bool eraseMarked (unsigned marking=0)
 Erase all elements marked in the given marking. Return TRUE if any. More...
 
void append (const LabelList &oth)
 Append a copy of OTH to this.
 
void append (LabelList &&oth)
 Move the content of OTH to the end of this.
 
virtual void sort (char mode='A', std::vector< size_t > *order=nullptr)
 Sort all elements in the list, unregarding marks and visibility. More...
 
void fillWithFiles (const std::filesystem::path &path={}, char mode='T', bool onlyfiles=false, std::vector< std::string > *entries=nullptr)
 Clear the list and fill it with the files and folders in PATH. More...
 
virtual std::string to_string (void) const
 Return a (potentially long) text with all entries of the list and mrkrs. More...
 

Protected Types

using Marks = std::vector< bool >
 Marks that can be associated to labels in a given marking. More...
 

Protected Member Functions

void copyFrom (const LabelList &oth)
 
void moveFrom (LabelList &&oth)
 

Protected Attributes

Observer obs_
 
bool owner_
 
Label::Vector labels_
 
std::vector< Marksmarkings_
 
Marks visible_
 
LabelListsect_
 
IndsRange sectrange_
 

Member Typedef Documentation

◆ Observer

using zxeco::gui::LabelList::Observer = std::function<void(char)>
Parameters
charindicates the reason for calling the observer: 'm' -> change in marking of labels 'c' -> change in content of list 'v' -> change in visibility of labels

Definition at line 234 of file ZXGUIGeneral.h.

◆ Indexes

using zxeco::gui::LabelList::Indexes = std::vector<size_t>

A set of unique absolute indexes on the list.

Definition at line 241 of file ZXGUIGeneral.h.

◆ Marks

using zxeco::gui::LabelList::Marks = std::vector<bool>
protected

Marks that can be associated to labels in a given marking.

Definition at line 676 of file ZXGUIGeneral.h.

Constructor & Destructor Documentation

◆ LabelList() [1/2]

zxeco::gui::LabelList::LabelList ( const std::string &  markingmultips,
const Observer obs = kNullObserver 
)

Constructor: empty list and marks.

Observer will be called every time a method call in this class modifies the list or marks.

◆ LabelList() [2/2]

zxeco::gui::LabelList::LabelList ( LabelList oth,
size_t  begin,
size_t  length,
const Observer obs = kNullObserver 
)
noexcept

Constructor: sublist taken from indexes [begin,begin+length) from OTH.

If the range is out of the possibilities of OTH, it is automatically adjusted for fitting OTH. It will be adjusted automatically further on as elements are erased or inserted in the list.

Note
Any operation in a delegated list will occur at the end in the last supporting list; if the latter is a derived type, the base LabelList method will be called, not the derived ones.

◆ ~LabelList()

virtual zxeco::gui::LabelList::~LabelList ( void  )
inlinevirtual

Destructor.

In case of the list being supported by another, it does not clear it.

Definition at line 412 of file ZXGUIGeneral.h.

Member Function Documentation

◆ clone()

virtual LabelList * zxeco::gui::LabelList::clone ( void  ) const
inlinevirtual

Clone operation for being overriden in derived classes to return them.

Reimplemented in zxeco::gui::LabelTree, and zxeco::gui::LabelDirBrowser.

Definition at line 415 of file ZXGUIGeneral.h.

◆ size()

size_t zxeco::gui::LabelList::size ( void  ) const
noexcept

Return the current number of labels in the list, either visible or not.

This is O(1). If the list refers to another list, this size will count only the currently covered elements, according to the initially established range of indexes, in the supporting list.

◆ empty()

bool zxeco::gui::LabelList::empty ( void  ) const
inlinenoexcept

Return TRUE if the list is empty (O(1)).

Definition at line 431 of file ZXGUIGeneral.h.

◆ areaForEntireList()

CharArea zxeco::gui::LabelList::areaForEntireList ( void  ) const

Return the area in chars that the visible items of the list would occpy.

This method calls longestLabel() to get the width of the area. The returned area is the one needed if the list would be to be printed entirely in both dimensions.

◆ observer()

const Observer & zxeco::gui::LabelList::observer ( void  ) const
inlinenoexcept

Return a reference to the current observer.

Definition at line 440 of file ZXGUIGeneral.h.

◆ changeObserver()

void zxeco::gui::LabelList::changeObserver ( const Observer obs)
inline

Change the current observer by OBS.

If this is a list referring to another supporting one, the observer of the other will be called (possibly several times) each time a modifica- tion is done in this list, and then the observer of this list will be called once.

Definition at line 443 of file ZXGUIGeneral.h.

◆ begin()

Iterator zxeco::gui::LabelList::begin ( uint8_t  conditions = Iterator::IT_ALL,
unsigned  marking = 0 
) const

Return an iterator to iterate in that fashion, pointing to beginning.

If no elements in the list that satisfy the conditions, return end().

◆ end()

Iterator zxeco::gui::LabelList::end ( void  ) const
inline

Return an iterator pointing to the end of the list.

Definition at line 455 of file ZXGUIGeneral.h.

◆ sizeByIterator()

size_t zxeco::gui::LabelList::sizeByIterator ( Iterator  it) const
noexcept

Return the current number of labels in the list that satisfy IT conds.

Begin to count at IT and then count until end(). It does not modify IT since the argument is copied. It is O(n).

◆ longestLabel()

size_t zxeco::gui::LabelList::longestLabel ( Iterator  it) const
noexcept

Return the maximum number of chars of any label scanned by IT, or 0.

Consider labels begining by the one iterated by IT and after end(). This method deals with the labelText() of the appropriate class, either this one or a derived one in case of overriding.

◆ labelText()

virtual std::string zxeco::gui::LabelList::labelText ( size_t  who) const
virtual

Return a copy of the text of the WHO-th label.

Derived classes may modify the text, and that modified result will be the one used by longestLabel() and areaForList().

Reimplemented in zxeco::gui::LabelTree.

◆ label()

Label & zxeco::gui::LabelList::label ( size_t  who)

Return a reference to a modifiable label of the list.

Use the labelText() method if you only need to read the label text, since the list may return in labelText() a modified version of the string in some cases.

◆ marked()

bool zxeco::gui::LabelList::marked ( size_t  who,
unsigned  marking = 0 
) const

Return the marked state of label WHO in marking MARKING.

Recall that in 'N' mode, all marks will be false.

◆ sublist()

LabelList zxeco::gui::LabelList::sublist ( const Indexes inds) const

Return the given sublist as a copy of the elements of this one.

The observer in the sublist is the null one. All indexes are copied in the sublist, even if they are repeated (then they will appear more than once in the result).

◆ mark()

bool zxeco::gui::LabelList::mark ( size_t  who,
unsigned  marking = 0 
)

Mark the WHO-th label, according to the mode of marks.

Return TRUE if some mark has effectively changed. Consider both visible and invisible labels.

◆ markAll()

bool zxeco::gui::LabelList::markAll ( unsigned  marking = 0)

Mark all labels in marking or do nothing if the multiplicity forbids.

Consider both visible and invisible labels.

◆ unmark()

bool zxeco::gui::LabelList::unmark ( size_t  who,
unsigned  marking = 0 
)

Unmark the WHO-th label.

Return TRUE if some mark has effectively changed. Consider both visible and invisible labels.

◆ unmarkAll()

bool zxeco::gui::LabelList::unmarkAll ( unsigned  marking = 0)

Unmark all labels at marking MARKING.

Return TRUE if some mark has effectively changed. Consider both visible and invisible labels.

◆ toggle()

void zxeco::gui::LabelList::toggle ( size_t  who,
unsigned  marking = 0 
)

Toggle the mark of WHO according to the mode of selections.

Consider both visible and invisible labels.

◆ toggleAll()

void zxeco::gui::LabelList::toggleAll ( unsigned  marking = 0)

Like toggle on all marks.

Consider both visible and invisible labels.

◆ setVisible()

virtual void zxeco::gui::LabelList::setVisible ( size_t  who)
virtual

Set that element to visible.

Reimplemented in zxeco::gui::LabelTree.

◆ setInvisible()

virtual void zxeco::gui::LabelList::setInvisible ( size_t  who)
virtual

Set that element to invisible.

Reimplemented in zxeco::gui::LabelTree.

◆ toggleVisible()

virtual void zxeco::gui::LabelList::toggleVisible ( size_t  who)
virtual

Toggle visibility of the label WHO.

Reimplemented in zxeco::gui::LabelTree.

◆ clear()

virtual void zxeco::gui::LabelList::clear ( void  )
virtual

Clear the content of the entire list, markings and visibilities.

Reimplemented in zxeco::gui::LabelDirBrowser, and zxeco::gui::LabelTree.

◆ push_back() [1/2]

size_t zxeco::gui::LabelList::push_back ( const Label l)
inline

Insert an unmarked, visible label at the end of the list.

Return the position where the label has been inserted. If this is a list that refers to another, supporting one, the element will be inserted at the end of its section in the supporting one. Note that the insert() method called by this one is the one of the derived class, if the object is not a plain instance of LabelList.

Definition at line 536 of file ZXGUIGeneral.h.

◆ push_back() [2/2]

void zxeco::gui::LabelList::push_back ( const Label::Vector v)
inline
Parameters
vInsert all labels in V at the end of the list, as unmarked, visible.

Definition at line 543 of file ZXGUIGeneral.h.

◆ insert() [1/2]

virtual size_t zxeco::gui::LabelList::insert ( const Label l,
size_t  beforewho 
)
virtual

Insert an unmarked, visible label before the given element.

Consider both visible and invisible labels. Return the position where the label has been inserted (which will always be BEFOREWHO).

Reimplemented in zxeco::gui::LabelTree.

◆ insert() [2/2]

void zxeco::gui::LabelList::insert ( const Label::Vector v,
size_t  beforewho 
)
inline
Parameters
beforewhoInsert all labels in V before the given position.

Definition at line 552 of file ZXGUIGeneral.h.

◆ erase()

virtual void zxeco::gui::LabelList::erase ( size_t  who)
virtual

Erase the given element and its marks.

Consider both visible and invisible labels. Note that this modifes the size of the labels list and therefore their indexes.

Reimplemented in zxeco::gui::LabelTree.

◆ eraseMarked()

bool zxeco::gui::LabelList::eraseMarked ( unsigned  marking = 0)

Erase all elements marked in the given marking. Return TRUE if any.

Consider both visible and invisible labels. Internally, use erase() to erase each individual label.

◆ sort()

virtual void zxeco::gui::LabelList::sort ( char  mode = 'A',
std::vector< size_t > *  order = nullptr 
)
virtual

Sort all elements in the list, unregarding marks and visibility.

Parameters
modeindicates the mode: 'A'-> alphabetical increasing, 'D'-> alphabetical decreasing.
orderif not null will be filled with a vector of indexes in the label list that indicate the order established on the previously unordered list.

Reimplemented in zxeco::gui::LabelTree.

◆ fillWithFiles()

void zxeco::gui::LabelList::fillWithFiles ( const std::filesystem::path &  path = {},
char  mode = 'T',
bool  onlyfiles = false,
std::vector< std::string > *  entries = nullptr 
)

Clear the list and fill it with the files and folders in PATH.

If the path is left empty, the current path will be used. Only regular files and directories are included in the list. The list is ordered alphabetically increasing, case insensitive, directories first.

Parameters
modeis the mode in which the different types of entries are filled in the list: 'T' -> directories are preffixed with '/' while files are not.
onlyfilesindicates (TRUE) if filling only with files, or (FALSE) with files and directories.
entriesif not nullptr will be set to a vector with the directory entries corresponding to the filled list; each entry is a string that begins with a letter indicating the type of entry ('D' -> direc- tory, 'P' -> parent directory of PATH, 'F' -> regular file); being the rest the absolute path of the entry in string native format.

◆ to_string()

virtual std::string zxeco::gui::LabelList::to_string ( void  ) const
virtual

Return a (potentially long) text with all entries of the list and mrkrs.

Reimplemented in zxeco::gui::LabelTree.

Member Data Documentation

◆ kNullObserver

const Observer zxeco::gui::LabelList::kNullObserver
static

An observer that does nothing.

Note that this observer is static; if you have a LabelList that is created statically, it may found this observer uncreated depending on the order of creation of static objects in different compilation units.

Definition at line 373 of file ZXGUIGeneral.h.

◆ kMarkingMultips

const std::string zxeco::gui::LabelList::kMarkingMultips

Multiple selection mode of markings.

Definition at line 379 of file ZXGUIGeneral.h.

◆ kNumOfMarkings

const size_t zxeco::gui::LabelList::kNumOfMarkings

Number of independent markings for labels.

Definition at line 380 of file ZXGUIGeneral.h.

◆ obs_

Observer zxeco::gui::LabelList::obs_
protected

Definition at line 679 of file ZXGUIGeneral.h.

◆ owner_

bool zxeco::gui::LabelList::owner_
protected

Definition at line 680 of file ZXGUIGeneral.h.

◆ labels_

Label::Vector zxeco::gui::LabelList::labels_
protected

Definition at line 681 of file ZXGUIGeneral.h.

◆ markings_

std::vector<Marks> zxeco::gui::LabelList::markings_
protected

Definition at line 682 of file ZXGUIGeneral.h.

◆ visible_

Marks zxeco::gui::LabelList::visible_
protected

Definition at line 683 of file ZXGUIGeneral.h.

◆ sect_

LabelList* zxeco::gui::LabelList::sect_
protected

Definition at line 684 of file ZXGUIGeneral.h.

◆ sectrange_

IndsRange zxeco::gui::LabelList::sectrange_
protected

Definition at line 685 of file ZXGUIGeneral.h.

◆ zxeco::gui::LabelList::Iterator

class zxeco::gui::LabelList::Iterator

Bidirectional iterator to scan indexes in the list under a given view.

Definition at line 245 of file ZXGUIGeneral.h.

Public Types

enum  : uint8_t { IT_VISIBLE = 1 , IT_INVISIBLE = 2 , IT_MARKED = 4 , IT_UNMARKED = 8 }
 Conditions for iterating that define the view (can be OR-ed). More...
 
enum  IniPos : uint8_t { BEGIN , END }
 Iterator to create. More...
 

Static Public Member Functions

static bool labelSatisfiesCondition (uint8_t conditions, const LabelList &l, size_t who, unsigned marking=0)
 Test whether that label satisfies the given conditions. More...
 

Static Public Attributes

static const uint8_t IT_ANY_VISIBILITY = IT_VISIBLE | IT_INVISIBLE
 View of all labels unregarding visibility. More...
 
static const uint8_t IT_ANY_MARKABILITY = IT_MARKED | IT_UNMARKED
 View of all labels unregarding markability. More...
 
static const uint8_t IT_ALL = IT_ANY_VISIBILITY | IT_ANY_MARKABILITY
 View of all labels unregarding both visibility and markability. More...
 
static const uint8_t IT_ALL_VISIBLE = IT_VISIBLE | IT_ANY_MARKABILITY
 View of all visible labels, unregarding marks. More...
 

Public Member Functions

 Iterator (void)
 Default constructor: end iterator.
 
 Iterator (const LabelList &l, uint8_t conditions=IT_ALL, unsigned marking=0, IniPos inip=BEGIN)
 Construct an iterator for scanning label indexes in the given list. More...
 
 Iterator (const Iterator &oth, uint8_t newconds, unsigned newmarking=0) noexcept
 Construct iterator to the same label as OTH but with another view. More...
 
 Iterator (const Iterator &oth)
 
 Iterator (Iterator &&oth)
 
Iteratoroperator= (const Iterator &oth)
 
Iteratoroperator= (Iterator &&oth)
 
uint8_t conditions (void) const noexcept
 Return the conditions for which the iterator was created. More...
 
unsigned marking (void) const noexcept
 Return the marking for which the iterator was created. More...
 
size_t operator* (void) const
 Return the actual position of the label in the label list. More...
 
size_t advance (size_t n) noexcept
 Advance the iterator N steps; return the no. of steps not advanced. More...
 
size_t retreat (size_t n) noexcept
 Retreat the iterator N steps; return the no. of steps not retreatd. More...
 
Iteratoroperator++ (void) noexcept
 Prefix increment for the iterator. More...
 
Iteratoroperator-- (void) noexcept
 Prefix decrement for the iterator. More...
 
bool operator== (const Iterator &oth) const
 Return TRUE if both iterators are end or point to the same element. More...
 
bool operator!= (const Iterator &oth) const
 Return TRUE if any of them is not end or point to diffrnt elements.
 
int operator- (const Iterator &rhs) const
 Return the distance from OTH to THIS (negative if OTH comes before) More...
 
std::string to_string (void) const
 Return a text describing the iterator.
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : uint8_t

Conditions for iterating that define the view (can be OR-ed).

Enumerator
IT_VISIBLE 

Iterate on visible labels.

IT_INVISIBLE 

Iterate on invisible labels.

IT_MARKED 

Iterate on marked labels.

IT_UNMARKED 

Iterate on unmarked labels.

Definition at line 250 of file ZXGUIGeneral.h.

◆ IniPos

Iterator to create.

Enumerator
BEGIN 

One that points to the first index in view.

END 

One that points past the last index in view.

Definition at line 270 of file ZXGUIGeneral.h.

Constructor & Destructor Documentation

◆ Iterator() [1/4]

zxeco::gui::LabelList::Iterator::Iterator ( const LabelList l,
uint8_t  conditions = IT_ALL,
unsigned  marking = 0,
IniPos  inip = BEGIN 
)

Construct an iterator for scanning label indexes in the given list.

This is O(n), being N the length of the list.

Parameters
lis the list to iterate on. It must outlive the iterator. Any change in the list should be consider to invalidate the iterator.
conditionsis the view: an OR-ed set of conditions to iterate.
markingis considered only if IT_MARKED (xor) IT_UNMARKED; in that case, indicates the marking to use.
inipindicates whether the iterator is constructed to point to the first element in the list under that view or past the end.

◆ Iterator() [2/4]

zxeco::gui::LabelList::Iterator::Iterator ( const Iterator oth,
uint8_t  newconds,
unsigned  newmarking = 0 
)
noexcept

Construct iterator to the same label as OTH but with another view.

Construct the end() iterator if the new conditions are incompatible with that element of OTH. This method is O(n), being N the length of the list.

◆ Iterator() [3/4]

zxeco::gui::LabelList::Iterator::Iterator ( const Iterator oth)
inline

Definition at line 304 of file ZXGUIGeneral.h.

◆ Iterator() [4/4]

zxeco::gui::LabelList::Iterator::Iterator ( Iterator &&  oth)
inline

Definition at line 305 of file ZXGUIGeneral.h.

Member Function Documentation

◆ labelSatisfiesCondition()

static bool zxeco::gui::LabelList::Iterator::labelSatisfiesCondition ( uint8_t  conditions,
const LabelList l,
size_t  who,
unsigned  marking = 0 
)
static

Test whether that label satisfies the given conditions.

Marking is only used if IT_MARKED != IT_UNMARKED in conditions.

◆ operator=() [1/2]

Iterator & zxeco::gui::LabelList::Iterator::operator= ( const Iterator oth)
inline

Definition at line 306 of file ZXGUIGeneral.h.

◆ operator=() [2/2]

Iterator & zxeco::gui::LabelList::Iterator::operator= ( Iterator &&  oth)
inline

Definition at line 308 of file ZXGUIGeneral.h.

◆ conditions()

uint8_t zxeco::gui::LabelList::Iterator::conditions ( void  ) const
inlinenoexcept

Return the conditions for which the iterator was created.

Definition at line 312 of file ZXGUIGeneral.h.

◆ marking()

unsigned zxeco::gui::LabelList::Iterator::marking ( void  ) const
inlinenoexcept

Return the marking for which the iterator was created.

Definition at line 315 of file ZXGUIGeneral.h.

◆ operator*()

size_t zxeco::gui::LabelList::Iterator::operator* ( void  ) const

Return the actual position of the label in the label list.

Throw if end.

◆ advance()

size_t zxeco::gui::LabelList::Iterator::advance ( size_t  n)
noexcept

Advance the iterator N steps; return the no. of steps not advanced.

If end() is reached, does not add anything else. This is O(n).

◆ retreat()

size_t zxeco::gui::LabelList::Iterator::retreat ( size_t  n)
noexcept

Retreat the iterator N steps; return the no. of steps not retreatd.

If begin() is reached, does not add anything else. This is O(n).

◆ operator++()

Iterator & zxeco::gui::LabelList::Iterator::operator++ ( void  )
noexcept

Prefix increment for the iterator.

After end() is reached, no further increments have any effect. This is O(n), being N the length of the list.

◆ operator--()

Iterator & zxeco::gui::LabelList::Iterator::operator-- ( void  )
noexcept

Prefix decrement for the iterator.

After begin() is reached, no further decrements have any effect. This is O(n), being N the length of the list.

◆ operator==()

bool zxeco::gui::LabelList::Iterator::operator== ( const Iterator oth) const

Return TRUE if both iterators are end or point to the same element.

All end iterators are considered equal, unregarding the list and view they have been created for. For non-end iterators, equality requires same view and list (otherwise, throw).

◆ operator-()

int zxeco::gui::LabelList::Iterator::operator- ( const Iterator rhs) const

Return the distance from OTH to THIS (negative if OTH comes before)

Throw if both do not have the same view. This is O(1).

Member Data Documentation

◆ IT_ANY_VISIBILITY

const uint8_t zxeco::gui::LabelList::Iterator::IT_ANY_VISIBILITY = IT_VISIBLE | IT_INVISIBLE
static

View of all labels unregarding visibility.

Definition at line 258 of file ZXGUIGeneral.h.

◆ IT_ANY_MARKABILITY

const uint8_t zxeco::gui::LabelList::Iterator::IT_ANY_MARKABILITY = IT_MARKED | IT_UNMARKED
static

View of all labels unregarding markability.

Definition at line 261 of file ZXGUIGeneral.h.

◆ IT_ALL

const uint8_t zxeco::gui::LabelList::Iterator::IT_ALL = IT_ANY_VISIBILITY | IT_ANY_MARKABILITY
static

View of all labels unregarding both visibility and markability.

Definition at line 264 of file ZXGUIGeneral.h.

◆ IT_ALL_VISIBLE

const uint8_t zxeco::gui::LabelList::Iterator::IT_ALL_VISIBLE = IT_VISIBLE | IT_ANY_MARKABILITY
static

View of all visible labels, unregarding marks.

Definition at line 267 of file ZXGUIGeneral.h.

◆ zxeco::gui::LabelList::IndsRange

class zxeco::gui::LabelList::IndsRange

A range of indexes covering some part of the list.

Definition at line 606 of file ZXGUIGeneral.h.

Public Types

using IntervalType = Interval< size_t >
 

Public Member Functions

 IndsRange (size_t b, size_t e)
 
 IndsRange (const IntervalType &i)
 
size_t begin (void) const noexcept
 
size_t end (void) const noexcept
 
bool empty (void) const noexcept
 
size_t length (void) const noexcept
 
size_t first (void) const
 
size_t last (void) const
 
size_t nth (size_t offset) const
 
void clear (void)
 
void expand (size_t l)
 
void contract (size_t l)
 
Indexes toIndexes (void) const
 
IntervalType toInterval (void) const
 
std::string to_string (void) const
 

Member Typedef Documentation

◆ IntervalType

Definition at line 610 of file ZXGUIGeneral.h.

Constructor & Destructor Documentation

◆ IndsRange() [1/3]

zxeco::gui::LabelList::IndsRange::IndsRange ( void  )
inline

Definition at line 612 of file ZXGUIGeneral.h.

◆ IndsRange() [2/3]

zxeco::gui::LabelList::IndsRange::IndsRange ( size_t  b,
size_t  e 
)
inline

Definition at line 614 of file ZXGUIGeneral.h.

◆ IndsRange() [3/3]

zxeco::gui::LabelList::IndsRange::IndsRange ( const IntervalType i)
inline

Definition at line 617 of file ZXGUIGeneral.h.

Member Function Documentation

◆ begin()

size_t zxeco::gui::LabelList::IndsRange::begin ( void  ) const
inlinenoexcept

Definition at line 622 of file ZXGUIGeneral.h.

◆ end()

size_t zxeco::gui::LabelList::IndsRange::end ( void  ) const
inlinenoexcept

Definition at line 623 of file ZXGUIGeneral.h.

◆ empty()

bool zxeco::gui::LabelList::IndsRange::empty ( void  ) const
inlinenoexcept

Definition at line 625 of file ZXGUIGeneral.h.

◆ length()

size_t zxeco::gui::LabelList::IndsRange::length ( void  ) const
inlinenoexcept

Definition at line 626 of file ZXGUIGeneral.h.

◆ first()

size_t zxeco::gui::LabelList::IndsRange::first ( void  ) const
inline

Definition at line 629 of file ZXGUIGeneral.h.

◆ last()

size_t zxeco::gui::LabelList::IndsRange::last ( void  ) const
inline

Definition at line 632 of file ZXGUIGeneral.h.

◆ nth()

size_t zxeco::gui::LabelList::IndsRange::nth ( size_t  offset) const
inline

Definition at line 635 of file ZXGUIGeneral.h.

◆ clear()

void zxeco::gui::LabelList::IndsRange::clear ( void  )
inline

Definition at line 641 of file ZXGUIGeneral.h.

◆ expand()

void zxeco::gui::LabelList::IndsRange::expand ( size_t  l)
inline

Definition at line 643 of file ZXGUIGeneral.h.

◆ contract()

void zxeco::gui::LabelList::IndsRange::contract ( size_t  l)
inline

Definition at line 648 of file ZXGUIGeneral.h.

◆ toIndexes()

Indexes zxeco::gui::LabelList::IndsRange::toIndexes ( void  ) const
inline

Definition at line 654 of file ZXGUIGeneral.h.

◆ toInterval()

IntervalType zxeco::gui::LabelList::IndsRange::toInterval ( void  ) const
inline

Definition at line 660 of file ZXGUIGeneral.h.

◆ to_string()

std::string zxeco::gui::LabelList::IndsRange::to_string ( void  ) const
inline

Definition at line 664 of file ZXGUIGeneral.h.

◆ zxeco::gui::LabelTree

class zxeco::gui::LabelTree

A tree of labels based on LabelList.

< This class adds a depth level to each label, new methods to add/del labels with correct depths and a version of the text of a label that can include additional preffixes.

If you need a directory tree, do not use this class, but LabelDirBrowser instead since this class assumes a tree completely read in memory before browsing, which leads to problems in the case of large directories.

Definition at line 719 of file ZXGUIGeneral.h.

Inheritance diagram for zxeco::gui::LabelTree:
Collaboration diagram for zxeco::gui::LabelTree:

Public Member Functions

 LabelTree (const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor: empty tree. More...
 
 LabelTree (const LabelTree &oth)
 
 LabelTree (LabelTree &&oth)
 
LabelTreeoperator= (const LabelTree &oth)
 
LabelTreeoperator= (LabelTree &&oth)
 
LabelListclone (void) const override
 Clone operation for being overriden in derived classes to return them. More...
 
const std::string & preffixChars (void) const noexcept
 Return the current preffixes used by labelText();. More...
 
void changePreffixChars (const std::string &preffixchars)
 Set the chars used as preffixes by labelText(). More...
 
virtual std::string preffixForLabel (size_t who, size_t *posdeploy=nullptr) const
 Return the preffix corresponding to that label. More...
 
std::string labelText (size_t who) const override
 < Return the label of the text including a preffix indicating the tree. More...
 
size_t depth (size_t pos) const
 Return the depth of the given element in the tree (from 0 for root).
 
size_t depth (void) const
 Return the depth of the tree, i.e., the maximum depth in it. More...
 
bool hasChildren (size_t parent) const
 < Return whether the given element has any children. More...
 
Indexes firstBorn (size_t parent) const
 Return the set of indexes (ordered) for the firstborns of PARENT. More...
 
LabelTree subtree (size_t parent, bool withparent=false, Indexes *indexmap=nullptr) const
 Return a tree copied from the subtree of PARENT, with or without it. More...
 
size_t insert (const Label &l, size_t beforewho) override
 Insert the new label previously to BEFOREWHO, with its same depth. More...
 
virtual size_t insert_child (const Label &l, size_t parent)
 Insert the new label as the last child of PARENT, that must exist. More...
 
void erase (size_t who) override
 Erase WHO and all its children, at all depths. More...
 
virtual void erase_children (size_t who)
 Erase all children of WHO, at all depths, if any.
 
void setVisible (size_t who) override
 < Set visibility for WHO and all its children. More...
 
void setInvisible (size_t who) override
 < Unset visibility for WHO and all its children. More...
 
void toggleVisible (size_t who) override
 < Toggle visibility for WHO and all its children. More...
 
virtual void changeVisibilityDepth (size_t fromdepth, bool visib)
 Set visibility to VISIB for all elements with depth >= FROMDEPTH.
 
virtual void toggleFolding (size_t who)
 Toggle visibility of children of WHO for folding/unfolding it. More...
 
void sort (char mode='A', std::vector< size_t > *order=nullptr) override
 Do sort only if there is only one level in the tree; otherwise, throw. More...
 
void clear (void) override
 Clear the content of the entire list, markings and visibilities. More...
 
std::string to_string (void) const override
 Return a (potentially long) text with all entries of the list and mrkrs. More...
 
- Public Member Functions inherited from zxeco::gui::LabelList
 LabelList (const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor: empty list and marks. More...
 
 LabelList (LabelList &oth, size_t begin, size_t length, const Observer &obs=kNullObserver) noexcept
 Constructor: sublist taken from indexes [begin,begin+length) from OTH. More...
 
 LabelList (const Label::Vector &labels, const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor from a vector of labels.
 
 LabelList (const LabelList &oth)
 
 LabelList (LabelList &&oth)
 Move constructor eaves OTH in undefined state if OTH has no ownership.
 
LabelListoperator= (const LabelList &oth)
 
LabelListoperator= (LabelList &&oth)
 Move copy leaves OTH in undefined state if OTH has no ownership.
 
virtual ~LabelList (void)
 Destructor. More...
 
virtual LabelListclone (void) const
 Clone operation for being overriden in derived classes to return them. More...
 
void checkMarking (unsigned marking) const
 If the given marking is not valid for the current list, throw.
 
void checkIndex (size_t who) const
 If the given index is not valid in the current list, throw.
 
size_t size (void) const noexcept
 Return the current number of labels in the list, either visible or not. More...
 
bool empty (void) const noexcept
 Return TRUE if the list is empty (O(1)). More...
 
CharArea areaForEntireList (void) const
 Return the area in chars that the visible items of the list would occpy. More...
 
const Observerobserver (void) const noexcept
 Return a reference to the current observer. More...
 
void changeObserver (const Observer &obs)
 Change the current observer by OBS. More...
 
Iterator begin (uint8_t conditions=Iterator::IT_ALL, unsigned marking=0) const
 Return an iterator to iterate in that fashion, pointing to beginning. More...
 
Iterator end (void) const
 Return an iterator pointing to the end of the list. More...
 
size_t sizeByIterator (Iterator it) const noexcept
 Return the current number of labels in the list that satisfy IT conds. More...
 
size_t longestLabel (Iterator it) const noexcept
 Return the maximum number of chars of any label scanned by IT, or 0. More...
 
virtual std::string labelText (size_t who) const
 Return a copy of the text of the WHO-th label. More...
 
Labellabel (size_t who)
 Return a reference to a modifiable label of the list. More...
 
bool marked (size_t who, unsigned marking=0) const
 Return the marked state of label WHO in marking MARKING. More...
 
bool visible (size_t who) const
 Return TRUE if that label is currently visible.
 
LabelList sublist (const Indexes &inds) const
 Return the given sublist as a copy of the elements of this one. More...
 
bool mark (size_t who, unsigned marking=0)
 Mark the WHO-th label, according to the mode of marks. More...
 
bool markAll (unsigned marking=0)
 Mark all labels in marking or do nothing if the multiplicity forbids. More...
 
bool unmark (size_t who, unsigned marking=0)
 Unmark the WHO-th label. More...
 
bool unmarkAll (unsigned marking=0)
 Unmark all labels at marking MARKING. More...
 
void toggle (size_t who, unsigned marking=0)
 Toggle the mark of WHO according to the mode of selections. More...
 
void toggleAll (unsigned marking=0)
 Like toggle on all marks. More...
 
virtual void setVisible (size_t who)
 Set that element to visible. More...
 
virtual void setInvisible (size_t who)
 Set that element to invisible. More...
 
virtual void toggleVisible (size_t who)
 Toggle visibility of the label WHO. More...
 
virtual void clear (void)
 Clear the content of the entire list, markings and visibilities. More...
 
size_t push_back (const Label &l)
 Insert an unmarked, visible label at the end of the list. More...
 
void push_back (const Label::Vector &v)
 
virtual size_t insert (const Label &l, size_t beforewho)
 Insert an unmarked, visible label before the given element. More...
 
void insert (const Label::Vector &v, size_t beforewho)
 
virtual void erase (size_t who)
 Erase the given element and its marks. More...
 
bool eraseMarked (unsigned marking=0)
 Erase all elements marked in the given marking. Return TRUE if any. More...
 
void append (const LabelList &oth)
 Append a copy of OTH to this.
 
void append (LabelList &&oth)
 Move the content of OTH to the end of this.
 
virtual void sort (char mode='A', std::vector< size_t > *order=nullptr)
 Sort all elements in the list, unregarding marks and visibility. More...
 
void fillWithFiles (const std::filesystem::path &path={}, char mode='T', bool onlyfiles=false, std::vector< std::string > *entries=nullptr)
 Clear the list and fill it with the files and folders in PATH. More...
 
virtual std::string to_string (void) const
 Return a (potentially long) text with all entries of the list and mrkrs. More...
 

Protected Member Functions

Observer skipObserver (void)
 
void retrieveObserver (const Observer &obs, char reason)
 
IndsRange subtreeRange (size_t pos, bool withparent=true) const
 
size_t parent (size_t pos) const
 
size_t prevSibling (size_t pos) const
 
size_t nextSibling (size_t pos) const
 
size_t lastRoot (void) const
 
- Protected Member Functions inherited from zxeco::gui::LabelList
void copyFrom (const LabelList &oth)
 
void moveFrom (LabelList &&oth)
 

Protected Attributes

std::string chars_
 
std::vector< size_t > depths_
 
- Protected Attributes inherited from zxeco::gui::LabelList
Observer obs_
 
bool owner_
 
Label::Vector labels_
 
std::vector< Marksmarkings_
 
Marks visible_
 
LabelListsect_
 
IndsRange sectrange_
 

Additional Inherited Members

- Public Types inherited from zxeco::gui::LabelList
using Observer = std::function< void(char)>
 
using Indexes = std::vector< size_t >
 A set of unique absolute indexes on the list. More...
 
- Static Public Attributes inherited from zxeco::gui::LabelList
static const Observer kNullObserver
 An observer that does nothing. More...
 
- Public Attributes inherited from zxeco::gui::LabelList
const std::string kMarkingMultips
 Multiple selection mode of markings. More...
 
const size_t kNumOfMarkings
 Number of independent markings for labels. More...
 
- Protected Types inherited from zxeco::gui::LabelList
using Marks = std::vector< bool >
 Marks that can be associated to labels in a given marking. More...
 

Constructor & Destructor Documentation

◆ LabelTree()

zxeco::gui::LabelTree::LabelTree ( const std::string &  markingmultips,
const Observer obs = kNullObserver 
)

Constructor: empty tree.

Parameters
obswill be called every time a method call in this class modifies the list or marks.

Member Function Documentation

◆ clone()

LabelList * zxeco::gui::LabelTree::clone ( void  ) const
inlineoverridevirtual

Clone operation for being overriden in derived classes to return them.

Reimplemented from zxeco::gui::LabelList.

Reimplemented in zxeco::gui::LabelDirBrowser.

Definition at line 778 of file ZXGUIGeneral.h.

◆ preffixChars()

const std::string & zxeco::gui::LabelTree::preffixChars ( void  ) const
inlinenoexcept

Return the current preffixes used by labelText();.

Definition at line 780 of file ZXGUIGeneral.h.

◆ changePreffixChars()

void zxeco::gui::LabelTree::changePreffixChars ( const std::string &  preffixchars)

Set the chars used as preffixes by labelText().

Parameters
preffixcharsmust contain a character for each of the special characters used in preffixes when returning a label text: 0-> an element with no parent; 1-> an element that has a parent and no siblings; 2-> an element that has a parent and siblings before but not after; 3-> an element that has a parent and siblings after but not before; 4-> an element that has a parent and siblings both after and before; 5-> to fill indentation; 6-> an element that has no children; 7-> an element that has children but it is not deployed; 8-> an element that has children and it is deployed.

◆ preffixForLabel()

virtual std::string zxeco::gui::LabelTree::preffixForLabel ( size_t  who,
size_t *  posdeploy = nullptr 
) const
virtual

Return the preffix corresponding to that label.

If not null, fill *POSDEPLOY with the position in the preffix of the char used for deployments.

Reimplemented in zxeco::gui::LabelDirBrowser.

◆ labelText()

std::string zxeco::gui::LabelTree::labelText ( size_t  who) const
inlineoverridevirtual

< Return the label of the text including a preffix indicating the tree.

< The preffix will contain characters from the preffixchars argument of the constructor. In particular, the preffix will have as many indentation characters as its depth, then 1 character indicating whether the element has a parent (either no parent, parent and no siblings, parent and siblings before but no siblings after, parent and siblings after but not before, or parent and siblings both before and after), then 1 char indicating the existence of children (either no children, children that are deployed, or children not deployed).

Reimplemented from zxeco::gui::LabelList.

Definition at line 800 of file ZXGUIGeneral.h.

◆ depth()

size_t zxeco::gui::LabelTree::depth ( void  ) const

Return the depth of the tree, i.e., the maximum depth in it.

Return 0 if the tree is empty, 1 if it has only 1 level, and so on. This is O(n).

◆ hasChildren()

bool zxeco::gui::LabelTree::hasChildren ( size_t  parent) const
inline

< Return whether the given element has any children.

< Throw if PARENT does not exist.

Definition at line 820 of file ZXGUIGeneral.h.

◆ firstBorn()

Indexes zxeco::gui::LabelTree::firstBorn ( size_t  parent) const

Return the set of indexes (ordered) for the firstborns of PARENT.

Only return the children that have 1 more depth than the parent. If PARENT is >= size of the tree, return the root nodes of the tree.

◆ subtree()

LabelTree zxeco::gui::LabelTree::subtree ( size_t  parent,
bool  withparent = false,
Indexes indexmap = nullptr 
) const

Return a tree copied from the subtree of PARENT, with or without it.

The markings are the same as in this tree but are all cleared in the new one. The observer is null. If INDEXMAP != nullptr, fill it with the indexes of each of the subtree labels in the original tree.

◆ insert()

size_t zxeco::gui::LabelTree::insert ( const Label l,
size_t  beforewho 
)
overridevirtual

Insert the new label previously to BEFOREWHO, with its same depth.

This is O(1). Return the position where L is in the list. If BEFOREWHO is the number of elements in the tree, insert the label as a sibling of the last one.

/note - push_back() adds siblings of the last element of the tree after that last element.

Reimplemented from zxeco::gui::LabelList.

◆ insert_child()

virtual size_t zxeco::gui::LabelTree::insert_child ( const Label l,
size_t  parent 
)
virtual

Insert the new label as the last child of PARENT, that must exist.

Return the position where the child has been inserted. This is O(n).

◆ erase()

void zxeco::gui::LabelTree::erase ( size_t  who)
overridevirtual

Erase WHO and all its children, at all depths.

This is O(n).

Reimplemented from zxeco::gui::LabelList.

◆ setVisible()

void zxeco::gui::LabelTree::setVisible ( size_t  who)
inlineoverridevirtual

< Set visibility for WHO and all its children.

< This is O(n).

Reimplemented from zxeco::gui::LabelList.

Definition at line 857 of file ZXGUIGeneral.h.

◆ setInvisible()

void zxeco::gui::LabelTree::setInvisible ( size_t  who)
inlineoverridevirtual

< Unset visibility for WHO and all its children.

< This is O(n).

Reimplemented from zxeco::gui::LabelList.

Definition at line 862 of file ZXGUIGeneral.h.

◆ toggleVisible()

void zxeco::gui::LabelTree::toggleVisible ( size_t  who)
inlineoverridevirtual

< Toggle visibility for WHO and all its children.

< This is O(n).

Reimplemented from zxeco::gui::LabelList.

Definition at line 867 of file ZXGUIGeneral.h.

◆ toggleFolding()

virtual void zxeco::gui::LabelTree::toggleFolding ( size_t  who)
virtual

Toggle visibility of children of WHO for folding/unfolding it.

Reimplemented in zxeco::gui::LabelDirBrowser.

◆ sort()

void zxeco::gui::LabelTree::sort ( char  mode = 'A',
std::vector< size_t > *  order = nullptr 
)
overridevirtual

Do sort only if there is only one level in the tree; otherwise, throw.

Reimplemented from zxeco::gui::LabelList.

◆ clear()

void zxeco::gui::LabelTree::clear ( void  )
overridevirtual

Clear the content of the entire list, markings and visibilities.

Reimplemented from zxeco::gui::LabelList.

Reimplemented in zxeco::gui::LabelDirBrowser.

◆ to_string()

std::string zxeco::gui::LabelTree::to_string ( void  ) const
overridevirtual

Return a (potentially long) text with all entries of the list and mrkrs.

Reimplemented from zxeco::gui::LabelList.

Member Data Documentation

◆ chars_

std::string zxeco::gui::LabelTree::chars_
protected

Definition at line 889 of file ZXGUIGeneral.h.

◆ depths_

std::vector<size_t> zxeco::gui::LabelTree::depths_
protected

Definition at line 890 of file ZXGUIGeneral.h.

◆ zxeco::gui::LabelTree::DepthFirstInserter

class zxeco::gui::LabelTree::DepthFirstInserter

Inserter of elements into the tree structure.

For more confortable and readable insertions than using the insert(), insert_child() and push_back() methods.

Definition at line 726 of file ZXGUIGeneral.h.

Public Member Functions

 DepthFirstInserter (LabelTree &lt, size_t parentpos=0)
 Constructor to insert elements as subtree of PARENTPOS in LT. More...
 
size_t add (const Label &l)
 Add the given element as another child of the current parent. More...
 
void add (const Label::Vector &v)
 Add each of the elements in V in that order. More...
 
void openSubtree (void)
 Make the last added element a parent of a new subtree.
 
void closeSubtree (void)
 Close the last parent and consider its parent as the new one. More...
 

Constructor & Destructor Documentation

◆ DepthFirstInserter()

zxeco::gui::LabelTree::DepthFirstInserter::DepthFirstInserter ( LabelTree lt,
size_t  parentpos = 0 
)
inline

Constructor to insert elements as subtree of PARENTPOS in LT.

If PARENTPOS >= size of LT, elements will be added either as siblings of the last element in the tree (if any) or as top-level-siblings (if the tree is empty), until a subtree is opened.

Definition at line 730 of file ZXGUIGeneral.h.

Member Function Documentation

◆ add() [1/2]

size_t zxeco::gui::LabelTree::DepthFirstInserter::add ( const Label l)

Add the given element as another child of the current parent.

Return the index in the tree of the inserted element. If it is the first insertion of this inserter, either there is no current parent set in the constructor (then L will become the current parent and will be created as indicated in the constructor) or there is (then L will become a child of it and the current parent will be unchanged).

◆ add() [2/2]

void zxeco::gui::LabelTree::DepthFirstInserter::add ( const Label::Vector v)
inline

Add each of the elements in V in that order.

Definition at line 747 of file ZXGUIGeneral.h.

◆ closeSubtree()

void zxeco::gui::LabelTree::DepthFirstInserter::closeSubtree ( void  )

Close the last parent and consider its parent as the new one.

If no more closing can be done, do nothing.

◆ zxeco::gui::LabelDirBrowser

class zxeco::gui::LabelDirBrowser

A tree of labels that correspond to the entries in a directory tree.

< The visibility of the labels are made private in this class to avoid erroneous manipulations, as well as insertion / deletion of elements.

Definition at line 921 of file ZXGUIGeneral.h.

Inheritance diagram for zxeco::gui::LabelDirBrowser:
Collaboration diagram for zxeco::gui::LabelDirBrowser:

Public Member Functions

 LabelDirBrowser (const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor. Empty directory. More...
 
 LabelDirBrowser (const LabelDirBrowser &oth)
 
 LabelDirBrowser (LabelDirBrowser &&oth)
 
LabelDirBrowseroperator= (const LabelDirBrowser &oth)
 
LabelDirBrowseroperator= (LabelDirBrowser &&oth)
 
LabelListclone (void) const override
 Clone operation for being overriden in derived classes to return them. More...
 
void clear (void)
 Clear the entire content of the tree. More...
 
size_t readStartingPath (const std::filesystem::path &p)
 Clear the content of the list and fill it with the 1st level dirs in P. More...
 
std::string preffixForLabel (size_t who, size_t *posdeploy=nullptr) const override
 Return the preffix corresponding to that label (see LabelTree). More...
 
std::filesystem::path absolutePath (size_t who) const
 Return the absolute path in the disk corresponding to the WHO label.
 
bool isParent (size_t who) const
 Return TRUE if the given index is the parent directory of the tree.
 
void toggleFolding (size_t who) override
 Fold or unfold the given parent directory. More...
 
- Public Member Functions inherited from zxeco::gui::LabelTree
 LabelTree (const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor: empty tree. More...
 
 LabelTree (const LabelTree &oth)
 
 LabelTree (LabelTree &&oth)
 
LabelTreeoperator= (const LabelTree &oth)
 
LabelTreeoperator= (LabelTree &&oth)
 
LabelListclone (void) const override
 Clone operation for being overriden in derived classes to return them. More...
 
const std::string & preffixChars (void) const noexcept
 Return the current preffixes used by labelText();. More...
 
void changePreffixChars (const std::string &preffixchars)
 Set the chars used as preffixes by labelText(). More...
 
virtual std::string preffixForLabel (size_t who, size_t *posdeploy=nullptr) const
 Return the preffix corresponding to that label. More...
 
std::string labelText (size_t who) const override
 < Return the label of the text including a preffix indicating the tree. More...
 
size_t depth (size_t pos) const
 Return the depth of the given element in the tree (from 0 for root).
 
size_t depth (void) const
 Return the depth of the tree, i.e., the maximum depth in it. More...
 
bool hasChildren (size_t parent) const
 < Return whether the given element has any children. More...
 
Indexes firstBorn (size_t parent) const
 Return the set of indexes (ordered) for the firstborns of PARENT. More...
 
LabelTree subtree (size_t parent, bool withparent=false, Indexes *indexmap=nullptr) const
 Return a tree copied from the subtree of PARENT, with or without it. More...
 
size_t insert (const Label &l, size_t beforewho) override
 Insert the new label previously to BEFOREWHO, with its same depth. More...
 
virtual size_t insert_child (const Label &l, size_t parent)
 Insert the new label as the last child of PARENT, that must exist. More...
 
void erase (size_t who) override
 Erase WHO and all its children, at all depths. More...
 
virtual void erase_children (size_t who)
 Erase all children of WHO, at all depths, if any.
 
void setVisible (size_t who) override
 < Set visibility for WHO and all its children. More...
 
void setInvisible (size_t who) override
 < Unset visibility for WHO and all its children. More...
 
void toggleVisible (size_t who) override
 < Toggle visibility for WHO and all its children. More...
 
virtual void changeVisibilityDepth (size_t fromdepth, bool visib)
 Set visibility to VISIB for all elements with depth >= FROMDEPTH.
 
virtual void toggleFolding (size_t who)
 Toggle visibility of children of WHO for folding/unfolding it. More...
 
void sort (char mode='A', std::vector< size_t > *order=nullptr) override
 Do sort only if there is only one level in the tree; otherwise, throw. More...
 
void clear (void) override
 Clear the content of the entire list, markings and visibilities. More...
 
std::string to_string (void) const override
 Return a (potentially long) text with all entries of the list and mrkrs. More...
 
- Public Member Functions inherited from zxeco::gui::LabelList
 LabelList (const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor: empty list and marks. More...
 
 LabelList (LabelList &oth, size_t begin, size_t length, const Observer &obs=kNullObserver) noexcept
 Constructor: sublist taken from indexes [begin,begin+length) from OTH. More...
 
 LabelList (const Label::Vector &labels, const std::string &markingmultips, const Observer &obs=kNullObserver)
 Constructor from a vector of labels.
 
 LabelList (const LabelList &oth)
 
 LabelList (LabelList &&oth)
 Move constructor eaves OTH in undefined state if OTH has no ownership.
 
LabelListoperator= (const LabelList &oth)
 
LabelListoperator= (LabelList &&oth)
 Move copy leaves OTH in undefined state if OTH has no ownership.
 
virtual ~LabelList (void)
 Destructor. More...
 
virtual LabelListclone (void) const
 Clone operation for being overriden in derived classes to return them. More...
 
void checkMarking (unsigned marking) const
 If the given marking is not valid for the current list, throw.
 
void checkIndex (size_t who) const
 If the given index is not valid in the current list, throw.
 
size_t size (void) const noexcept
 Return the current number of labels in the list, either visible or not. More...
 
bool empty (void) const noexcept
 Return TRUE if the list is empty (O(1)). More...
 
CharArea areaForEntireList (void) const
 Return the area in chars that the visible items of the list would occpy. More...
 
const Observerobserver (void) const noexcept
 Return a reference to the current observer. More...
 
void changeObserver (const Observer &obs)
 Change the current observer by OBS. More...
 
Iterator begin (uint8_t conditions=Iterator::IT_ALL, unsigned marking=0) const
 Return an iterator to iterate in that fashion, pointing to beginning. More...
 
Iterator end (void) const
 Return an iterator pointing to the end of the list. More...
 
size_t sizeByIterator (Iterator it) const noexcept
 Return the current number of labels in the list that satisfy IT conds. More...
 
size_t longestLabel (Iterator it) const noexcept
 Return the maximum number of chars of any label scanned by IT, or 0. More...
 
virtual std::string labelText (size_t who) const
 Return a copy of the text of the WHO-th label. More...
 
Labellabel (size_t who)
 Return a reference to a modifiable label of the list. More...
 
bool marked (size_t who, unsigned marking=0) const
 Return the marked state of label WHO in marking MARKING. More...
 
bool visible (size_t who) const
 Return TRUE if that label is currently visible.
 
LabelList sublist (const Indexes &inds) const
 Return the given sublist as a copy of the elements of this one. More...
 
bool mark (size_t who, unsigned marking=0)
 Mark the WHO-th label, according to the mode of marks. More...
 
bool markAll (unsigned marking=0)
 Mark all labels in marking or do nothing if the multiplicity forbids. More...
 
bool unmark (size_t who, unsigned marking=0)
 Unmark the WHO-th label. More...
 
bool unmarkAll (unsigned marking=0)
 Unmark all labels at marking MARKING. More...
 
void toggle (size_t who, unsigned marking=0)
 Toggle the mark of WHO according to the mode of selections. More...
 
void toggleAll (unsigned marking=0)
 Like toggle on all marks. More...
 
virtual void setVisible (size_t who)
 Set that element to visible. More...
 
virtual void setInvisible (size_t who)
 Set that element to invisible. More...
 
virtual void toggleVisible (size_t who)
 Toggle visibility of the label WHO. More...
 
virtual void clear (void)
 Clear the content of the entire list, markings and visibilities. More...
 
size_t push_back (const Label &l)
 Insert an unmarked, visible label at the end of the list. More...
 
void push_back (const Label::Vector &v)
 
virtual size_t insert (const Label &l, size_t beforewho)
 Insert an unmarked, visible label before the given element. More...
 
void insert (const Label::Vector &v, size_t beforewho)
 
virtual void erase (size_t who)
 Erase the given element and its marks. More...
 
bool eraseMarked (unsigned marking=0)
 Erase all elements marked in the given marking. Return TRUE if any. More...
 
void append (const LabelList &oth)
 Append a copy of OTH to this.
 
void append (LabelList &&oth)
 Move the content of OTH to the end of this.
 
virtual void sort (char mode='A', std::vector< size_t > *order=nullptr)
 Sort all elements in the list, unregarding marks and visibility. More...
 
void fillWithFiles (const std::filesystem::path &path={}, char mode='T', bool onlyfiles=false, std::vector< std::string > *entries=nullptr)
 Clear the list and fill it with the files and folders in PATH. More...
 
virtual std::string to_string (void) const
 Return a (potentially long) text with all entries of the list and mrkrs. More...
 

Additional Inherited Members

- Public Types inherited from zxeco::gui::LabelList
using Observer = std::function< void(char)>
 
using Indexes = std::vector< size_t >
 A set of unique absolute indexes on the list. More...
 
- Static Public Attributes inherited from zxeco::gui::LabelList
static const Observer kNullObserver
 An observer that does nothing. More...
 
- Public Attributes inherited from zxeco::gui::LabelList
const std::string kMarkingMultips
 Multiple selection mode of markings. More...
 
const size_t kNumOfMarkings
 Number of independent markings for labels. More...
 
- Protected Types inherited from zxeco::gui::LabelList
using Marks = std::vector< bool >
 Marks that can be associated to labels in a given marking. More...
 
- Protected Member Functions inherited from zxeco::gui::LabelTree
Observer skipObserver (void)
 
void retrieveObserver (const Observer &obs, char reason)
 
IndsRange subtreeRange (size_t pos, bool withparent=true) const
 
size_t parent (size_t pos) const
 
size_t prevSibling (size_t pos) const
 
size_t nextSibling (size_t pos) const
 
size_t lastRoot (void) const
 
- Protected Member Functions inherited from zxeco::gui::LabelList
void copyFrom (const LabelList &oth)
 
void moveFrom (LabelList &&oth)
 
- Protected Attributes inherited from zxeco::gui::LabelTree
std::string chars_
 
std::vector< size_t > depths_
 
- Protected Attributes inherited from zxeco::gui::LabelList
Observer obs_
 
bool owner_
 
Label::Vector labels_
 
std::vector< Marksmarkings_
 
Marks visible_
 
LabelListsect_
 
IndsRange sectrange_
 

Constructor & Destructor Documentation

◆ LabelDirBrowser()

zxeco::gui::LabelDirBrowser::LabelDirBrowser ( const std::string &  markingmultips,
const Observer obs = kNullObserver 
)

Constructor. Empty directory.

Parameters
obswill be called every time a method call in this class modifies the list or marks.

Member Function Documentation

◆ clone()

LabelList * zxeco::gui::LabelDirBrowser::clone ( void  ) const
inlineoverridevirtual

Clone operation for being overriden in derived classes to return them.

Reimplemented from zxeco::gui::LabelTree.

Definition at line 936 of file ZXGUIGeneral.h.

◆ clear()

void zxeco::gui::LabelDirBrowser::clear ( void  )
virtual

Clear the entire content of the tree.

Reimplemented from zxeco::gui::LabelTree.

◆ readStartingPath()

size_t zxeco::gui::LabelDirBrowser::readStartingPath ( const std::filesystem::path &  p)

Clear the content of the list and fill it with the 1st level dirs in P.

If P does not exist, only clear the tree. Return the index in the list of P, or size() if none.

Parameters
pis the path from which the directories must be read. Only the 1st level directories within P are read. The tree is formed by adding first a parent path to go up P, if any. If P is empty, the current dir is used. To use the root path, pass std::filesystem::current_path().root_path().

◆ preffixForLabel()

std::string zxeco::gui::LabelDirBrowser::preffixForLabel ( size_t  who,
size_t *  posdeploy = nullptr 
) const
overridevirtual

Return the preffix corresponding to that label (see LabelTree).

If not null, fill *POSDEPLOY with the position in the preffix of the char used for deployments.

Reimplemented from zxeco::gui::LabelTree.

◆ toggleFolding()

void zxeco::gui::LabelDirBrowser::toggleFolding ( size_t  who)
overridevirtual

Fold or unfold the given parent directory.

If WHO has children, unfold it; otherwise, fold it. Folding involves to erase its children. Unfolding involves to re-read directory children.

Reimplemented from zxeco::gui::LabelTree.

Macro Definition Documentation

◆ ZXGUIVER

#define ZXGUIVER   "3.0.0"

#include <ZXGUIGeneral.h>

Version of the GUI sublibrary.

Definition at line 24 of file ZXGUIGeneral.h.