libyui-ncurses  2.57.2
NCTree Class Reference

A tree selection widget with one-column tree items and optionally multy selection. More...

#include <NCTree.h>

Inheritance diagram for NCTree:
Collaboration diagram for NCTree:

Public Member Functions

 NCTree (YWidget *parent, const std::string &label, bool multiselection=false, bool recursiveselection=false)
 
virtual void rebuildTree ()
 Recursively build the tree in this widget according to the items. More...
 
virtual YTreeItem * getCurrentItem () const
 Return a pointer to the current item (the item under the cursor).
 
virtual YTreeItem * currentItem ()
 Get the current item. More...
 
virtual void deselectAllItems ()
 
virtual void selectItem (YItem *item, bool selected)
 Select or deselect an item. More...
 
virtual void selectItem (int index)
 Select the item with the specified index.
 
virtual void deleteAllItems ()
 Delete all items and clear the TreePad. More...
 
virtual int preferredWidth ()
 libyui geometry management: Return the preferred width for this widget. More...
 
virtual int preferredHeight ()
 libyui geometry management: Return the preferred height for this widget. More...
 
virtual void setSize (int newWidth, int newHeight)
 libyui geometry management: Apply the width and height assigned from the parent layout widget. More...
 
virtual void setLabel (const std::string &nlabel)
 Set the label (the caption) above the tree. More...
 
virtual void setEnabled (bool do_bv)
 Enable or disable this widget. More...
 
virtual bool setKeyboardFocus ()
 Set the keyboard focus to this widget. More...
 
virtual void activate ()
 Activate the item selected in the tree. More...
 
virtual NCursesEvent wHandleInput (wint_t key)
 Keyboard input handler. More...
 
- Public Member Functions inherited from NCPadWidget
 NCPadWidget (NCWidget *myparent=0)
 
 NCPadWidget (YWidget *parent)
 
size_t Columns ()
 
void setLabel (const NClabel &nlabel)
 
- Public Member Functions inherited from NCWidget
void grabSet (NCWidget *ngrab)
 
void grabRelease (NCWidget *ograb)
 
 NCWidget (NCWidget *myparent)
 
 NCWidget (YWidget *parent=0)
 
bool isValid () const
 
bool winExist () const
 
virtual const NCstyle::StylewStyle () const
 
const NCstyle::StWidgetwidgetStyle (bool nonactive=false) const
 
const NCstyle::StWidgetframeStyle () const
 
const NCstyle::StListlistStyle () const
 
wsze wGetDefsze () const
 
wrect wGetSize () const
 
void Update ()
 
void Redraw (bool sub=false)
 
void Recoded ()
 
NC::WState GetState () const
 
void SetState (const NC::WState newstate, bool force=false)
 
virtual bool HasHotkey (int key)
 
virtual bool HasFunctionHotkey (int key) const
 
virtual NCursesEvent wHandleHotkey (wint_t key)
 
void DumpOn (std::ostream &str, std::string prfx) const
 
- Public Member Functions inherited from tnode< NCWidget * >
 tnode (NCWidget * v, self *p=0, bool behind=true)
 New node, added as the last child by default (which is natural). More...
 
 tnode (NCWidget * v, self &p, bool behind=true)
 New node, added as the last child by default (which is natural). More...
 
 tnode (NCWidget * v, self &p, self &s, bool behind=true)
 New node under p, just after s (or before s if behind==false) More...
 
void Disconnect ()
 Disconnect from the parent and siblings, but keep children.
 
bool ReparentTo (self &p, bool behind=true)
 Disconnect from old parent, connect to new parent p. More...
 
bool ReparentTo (self &p, self &s, bool behind=true)
 Disconnect from old parent, connect to new parent p and sibling s. More...
 
NCWidget * & Value () const
 
NCWidget * & operator() () const
 Alias for Value.
 
selfParent ()
 
const selfParent () const
 
selfPsibling ()
 Previous sibling.
 
const selfPsibling () const
 Previous sibling.
 
selfNsibling ()
 Next sibling.
 
const selfNsibling () const
 Next sibling.
 
selfFchild ()
 First child.
 
const selfFchild () const
 First child.
 
selfLchild ()
 Last child.
 
const selfLchild () const
 Last child.
 
bool HasParent () const
 
bool HasSiblings () const
 
bool HasChildren () const
 
bool IsParentOf (const self &c) const
 
bool IsSiblingOf (const self &s) const
 
bool IsChildOf (const self &p) const
 
unsigned Depth () const
 Depth: zero if no parent, otherwise 1 + parent's depth.
 
bool IsDescendantOf (const self &n) const
 
bool IsDescendantOf (const self *n) const
 
selfTop ()
 Root of the tree.
 
const selfTop () const
 
selfNext (bool restart=false)
 Next node: depth first, pre-order. More...
 
selfNext (self *&c, bool restart=false)
 Return Next and assign it to c.
 
const selfNext (bool restart=false) const
 
const selfNext (const self *&c, bool restart=false) const
 
selfPrev (bool restart=false)
 
selfPrev (self *&c, bool restart=false)
 Return Prev and assign it to c.
 
const selfPrev (bool restart=false) const
 
const selfPrev (const self *&c, bool restart=false) const
 

Protected Member Functions

virtual const char * location () const
 Code location for logging. More...
 
virtual NCPadCreatePad ()
 Create an empty pad.
 
virtual NCTreePadmyPad () const
 Return the TreePad that belongs to this widget. More...
 
virtual void DrawPad ()
 Fill the TreePad with lines (using CreateTreeLines to create them)
 
const NCTreeLinegetTreeLine (unsigned idx) const
 Return a const pointer to the tree line at the specified index for read-only operations.
 
NCTreeLinemodifyTreeLine (unsigned idx)
 Return a non-const pointer to the tree line at the specified index for read-write operations. More...
 
virtual void startMultipleChanges ()
 Optimization for NCurses from libyui: Notification that multiple changes are about to come. More...
 
virtual void doneMultipleChanges ()
 Optimization for NCurses from libyui: Notification that multiple changes are now finished. More...
 
void CreateTreeLines (NCTreeLine *parentLine, NCTreePad *pad, YItem *item)
 Create TreeLines and append them to the TreePad. More...
 
- Protected Member Functions inherited from NCPadWidget
void startMultidraw ()
 
void stopMultidraw ()
 
bool inMultidraw () const
 
unsigned labelWidth () const
 
virtual void wCreate (const wrect &newrect)
 
virtual void wDelete ()
 
virtual void wRedraw ()
 
virtual void wRecoded ()
 
wsze defPadSze () const
 
void InitPad ()
 
void AdjustPad (wsze nsze)
 
void DelPad ()
 
virtual void HScroll (unsigned total, unsigned visible, unsigned start)
 
virtual void VScroll (unsigned total, unsigned visible, unsigned start)
 
virtual void ScrollHead (NCursesWindow &w, unsigned ccol)
 
virtual void AdjustPadSize (wsze &minsze)
 
virtual bool handleInput (wint_t key)
 
- Protected Member Functions inherited from NCWidget
virtual void PreDisconnect ()
 
virtual void PostDisconnect ()
 
virtual void PreReparent ()
 
virtual void PostReparent ()
 
NCursesWindowParentWin ()
 
bool grabFocus ()
 
virtual void grabNotify (NCWidget *)
 
virtual bool wantFocus (NCWidget &ngrab)
 
void wMoveChildTo (NCWidget &child, const wpos &newpos)
 
void wRelocate (const wrect &newrect)
 
void wRelocate (const wpos &newpos, const wsze &newsze)
 
virtual void wMoveTo (const wpos &newpos)
 
virtual void wUpdate (bool forced_br=false)
 
wpos ScreenPos () const
 
- Protected Member Functions inherited from NCursesError
 NCursesError (const char *msg="unknown error",...)
 
 NCursesError (int val, const char *msg="unknown error",...)
 
NCursesErrorNCError (const char *msg="unknown error",...)
 
NCursesErrorNCError (int val, const char *msg="unknown error",...)
 

Friends

std::ostream & operator<< (std::ostream &str, const NCTree &obj)
 

Additional Inherited Members

- Protected Types inherited from tnode< NCWidget * >
typedef tnode< NCWidget * > self
 
- Protected Attributes inherited from NCPadWidget
bool hasHeadline
 
bool activeLabelOnly
 
- Protected Attributes inherited from NCWidget
NCWidget *const grabedBy
 
NCursesWindowwin
 (owned)
 
wsze defsze
 
wrect framedim
 
wrect inparent
 
bool noUpdates
 
bool skipNoDimWin
 
NC::WState wstate
 
NClabelhotlabel
 
- Protected Attributes inherited from tnode< NCWidget * >
NCWidgetval
 
- Protected Attributes inherited from NCursesError
int errval_i
 
std::string errmsg_t
 

Detailed Description

A tree selection widget with one-column tree items and optionally multy selection.

See also https://github.com/libyui/libyui-ncurses/blob/master/doc/nctable-and-nctree.md

Definition at line 46 of file NCTree.h.

Member Function Documentation

◆ activate()

void NCTree::activate ( )
virtual

Activate the item selected in the tree.

This can be used in tests to simulate user input.

Implemented from YSelectionWidget.

Definition at line 395 of file NCTree.cc.

Here is the call graph for this function:

◆ CreateTreeLines()

void NCTree::CreateTreeLines ( NCTreeLine parentLine,
NCTreePad pad,
YItem *  item 
)
protected

Create TreeLines and append them to the TreePad.

If 'item' has any children, this is called recursively for them.

Definition at line 240 of file NCTree.cc.

Here is the call graph for this function:

◆ currentItem()

YTreeItem * NCTree::currentItem ( )
virtual

Get the current item.

This is an alias for getCurrentItem.

Implemented from YSelectionWidget.

Definition at line 291 of file NCTree.cc.

Here is the call graph for this function:

◆ deleteAllItems()

void NCTree::deleteAllItems ( )
virtual

Delete all items and clear the TreePad.

Implemented from YSelectionWidget.

Definition at line 405 of file NCTree.cc.

Here is the call graph for this function:

◆ doneMultipleChanges()

virtual void NCTree::doneMultipleChanges ( )
inlineprotectedvirtual

Optimization for NCurses from libyui: Notification that multiple changes are now finished.

Implemented from YWidget.

Definition at line 222 of file NCTree.h.

◆ location()

virtual const char* NCTree::location ( ) const
inlineprotectedvirtual

Code location for logging.

Implemented from NCWidget.

Reimplemented from NCPadWidget.

Definition at line 173 of file NCTree.h.

◆ modifyTreeLine()

NCTreeLine * NCTree::modifyTreeLine ( unsigned  idx)
inlineprotected

Return a non-const pointer to the tree line at the specified index for read-write operations.

This also marks that line as "dirty", i.e. it needs to be updated on the screen.

Definition at line 76 of file NCTree.cc.

Here is the call graph for this function:

◆ myPad()

virtual NCTreePad* NCTree::myPad ( ) const
inlineprotectedvirtual

Return the TreePad that belongs to this widget.

Overloaded from NCPadWidget to narrow the type to the actual one used in this widget.

Reimplemented from NCPadWidget.

Definition at line 186 of file NCTree.h.

Here is the call graph for this function:

◆ preferredHeight()

int NCTree::preferredHeight ( )
virtual

libyui geometry management: Return the preferred height for this widget.

Implemented from YWidget.

Definition at line 92 of file NCTree.cc.

◆ preferredWidth()

int NCTree::preferredWidth ( )
virtual

libyui geometry management: Return the preferred width for this widget.

Implemented from YWidget.

Definition at line 85 of file NCTree.cc.

◆ rebuildTree()

void NCTree::rebuildTree ( )
virtual

Recursively build the tree in this widget according to the items.

Implemented from YTree.

Definition at line 223 of file NCTree.cc.

◆ selectItem()

void NCTree::selectItem ( YItem *  item,
bool  selected 
)
virtual

Select or deselect an item.

Implemented from YSelectionWidget.

Definition at line 146 of file NCTree.cc.

Here is the call graph for this function:

◆ setEnabled()

void NCTree::setEnabled ( bool  do_bv)
virtual

Enable or disable this widget.

Implemented from YWidget.

Reimplemented from NCPadWidget.

Definition at line 99 of file NCTree.cc.

Here is the call graph for this function:

◆ setKeyboardFocus()

virtual bool NCTree::setKeyboardFocus ( )
inlinevirtual

Set the keyboard focus to this widget.

Implemented from YWidget.

Definition at line 142 of file NCTree.h.

◆ setLabel()

void NCTree::setLabel ( const std::string &  nlabel)
virtual

Set the label (the caption) above the tree.

Implemented from YTree.

Definition at line 216 of file NCTree.cc.

◆ setSize()

void NCTree::setSize ( int  newWidth,
int  newHeight 
)
virtual

libyui geometry management: Apply the width and height assigned from the parent layout widget.

Implemented from YWidget.

Definition at line 106 of file NCTree.cc.

◆ startMultipleChanges()

virtual void NCTree::startMultipleChanges ( )
inlineprotectedvirtual

Optimization for NCurses from libyui: Notification that multiple changes are about to come.

Implemented from YWidget.

Definition at line 214 of file NCTree.h.

◆ wHandleInput()

NCursesEvent NCTree::wHandleInput ( wint_t  key)
virtual

Keyboard input handler.

Implemented from NCWidget.

Reimplemented from NCWidget.

Definition at line 321 of file NCTree.cc.

Here is the call graph for this function:

The documentation for this class was generated from the following files: