libyui-ncurses
Loading...
Searching...
No Matches
NCTableLine Class Reference

#include <NCTableItem.h>

Inheritance diagram for NCTableLine:
Collaboration diagram for NCTableLine:

Public Types

enum  STATE {
  S_NORMAL = 0x00 , S_ACTIVE = 0x01 , S_DISABLED = 0x10 , S_HIDDEN = 0x20 ,
  S_HEADLINE = 0x40
}
 

Public Member Functions

 NCTableLine (std::vector< NCTableCol * > &cells, int index=-1, bool nested=false, unsigned state=S_NORMAL)
 
 NCTableLine (NCTableLine *parentLine, YItem *yitem, std::vector< NCTableCol * > &cells, int index=-1, bool nested=false, unsigned state=S_NORMAL)
 
 NCTableLine (unsigned colCount, int index=-1, bool nested=false, unsigned state=S_NORMAL)
 
 NCTableLine (NCTableLine *parentLine, YItem *yitem, unsigned colCount, int index=-1, bool nested=false, unsigned state=S_NORMAL)
 
virtual ~NCTableLine ()
 
YTableItem * origItem () const
 
void setOrigItem (YTableItem *yitem)
 
int index () const
 
unsigned Cols () const
 
void SetCols (unsigned idx)
 
void SetCols (std::vector< NCTableCol * > &newCells)
 
void ClearLine ()
 
std::vector< NCTableCol * > GetItems () const
 
void Append (NCTableCol *cell)
 
void AddCol (unsigned idx, NCTableCol *item)
 
void DelCol (unsigned idx)
 
NCTableColGetCol (unsigned idx)
 
const NCTableColGetCol (unsigned idx) const
 
void SetState (const STATE s)
 
void ClearState (const STATE s)
 
bool isHidden () const
 
bool isDisabled () const
 
bool isSpecial () const
 
bool isActive () const
 
virtual bool isVisible () const
 
virtual bool isEnabled () const
 
virtual bool isNested () const
 
virtual void setNested (bool val)
 
void openBranch ()
 
void closeBranch ()
 
void toggleOpenClosedState ()
 
virtual bool handleInput (wint_t key)
 
virtual bool ChangeToVisible ()
 
virtual unsigned Hotspot (unsigned &at) const
 
virtual void UpdateFormat (NCTableStyle &tableStyle)
 
virtual void updatePrefix ()
 
virtual void DrawAt (NCursesWindow &w, const wrect at, NCTableStyle &tableStyle, bool active) const
 
void stripHotkeys ()
 
virtual NCTableLineparent () const
 
virtual NCTableLinefirstChild () const
 
virtual NCTableLinenextSibling () const
 
void setParent (NCTableLine *newVal)
 
void setFirstChild (NCTableLine *newVal)
 
void setNextSibling (NCTableLine *newVal)
 
int treeLevel () const
 
void setTreeLevel (int newVal)
 
int prefixLen () const
 
NCTableTagtagCell () const
 
std::string indentationStr () const
 

Protected Member Functions

void treeInit (NCTableLine *parentLine, YItem *yitem)
 
void initPrefixPlaceholder ()
 
void addToTree (NCTableLine *parent)
 
bool isOpen (YItem *yitem) const
 
YItem * yitem () const
 
void setYItem (YItem *yitem)
 
virtual void DrawItems (NCursesWindow &w, const wrect at, NCTableStyle &tableStyle, bool active) const
 
void assertCol (unsigned idx)
 
const std::string & prefixPlaceholder () const
 
void drawPrefix (NCursesWindow &w, const wrect at, NCTableStyle &tableStyle) const
 

Protected Attributes

std::vector< NCTableCol * > _cells
 owned
 
unsigned _state
 Or'ed STATE flags.
 
int _index
 unique index to identify this line
 
YItem * _yitem
 not owned
 
bool _nested
 using nested (tree-like) items?
 
int _treeLevel
 
NCTableLine_parent
 
NCTableLine_nextSibling
 
NCTableLine_firstChild
 
STATE _vstate
 
chtype * _prefix
 
std::string _prefixPlaceholder
 

Friends

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

Detailed Description

One line in a NCTable with multiple cells and an optional tree hierarchy. Each line corresponds to a YItem subclass (YTableItem or YTreeItem).

This class is also the base class for NCTreeLine; it provides most its functionlity.

Notice that on the libyui level, the inheritance hierarchy is

YTableItem < YTreeItem < YItem

whereas on the libyui-ncurses level, it is

NCTreeLine < NCTableLine

i.e. it's just the other way round. This is why it is safer to do dynamic casts of the internal _yitem to YTreeItem rather than to YTableItem: If used from an NCTree (i.e. YTree) widget, the items will all be YTreeItems; a dynamic cast to YTableItem will fail.

NOTE: "col", "column", here refer to only one cell, not the entire table column.

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

Constructor & Destructor Documentation

◆ NCTableLine() [1/2]

NCTableLine::NCTableLine ( std::vector< NCTableCol * > & cells,
int index = -1,
bool nested = false,
unsigned state = S_NORMAL )

Constructor: Create an NCTableLine and fill it with 'cells'. This object takes over ownership of those cells and will delete it when appropriate.

'index' is a unique number with which to identify this line.

'nested' specifies whether any item in the table has any child items, i.e. whether line graphics to visualize the tree structure should be drawn.

'state' is an OR'ed combination of the STATE enum.

◆ NCTableLine() [2/2]

NCTableLine::NCTableLine ( unsigned colCount,
int index = -1,
bool nested = false,
unsigned state = S_NORMAL )

Constructor with a number of empty cells.

◆ ~NCTableLine()

NCTableLine::~NCTableLine ( )
virtual

Destructor.

Member Function Documentation

◆ addToTree()

void NCTableLine::addToTree ( NCTableLine * parent)
protected

Add this line to the parent's tree hierarchy.

◆ Append()

void NCTableLine::Append ( NCTableCol * cell)
inline

Append one cell. Ownership is transferred to this line.

◆ ChangeToVisible()

virtual bool NCTableLine::ChangeToVisible ( )
inlinevirtual

Change a line that may have been invisible until now to be visible.

Return 'true' if there was a status change, i.e. if it was invisible before, 'false' otherwise.

This default implementation does nothing and always returns 'false'. Derived classes that can handle invisible items may want to overwrite this.

Reimplemented in NCTreeLine.

◆ ClearLine()

void NCTableLine::ClearLine ( )
inline

Delete all content.

◆ closeBranch()

void NCTableLine::closeBranch ( )

Close this tree branch

◆ Cols()

unsigned NCTableLine::Cols ( ) const
inline

Return the number of columns (cells) in this line.

◆ DrawAt()

void NCTableLine::DrawAt ( NCursesWindow & w,
const wrect at,
NCTableStyle & tableStyle,
bool active ) const
virtual
Parameters
activeis the table cursor here

Reimplemented in NCTableHead.

◆ drawPrefix()

void NCTableLine::drawPrefix ( NCursesWindow & w,
const wrect at,
NCTableStyle & tableStyle ) const
protected

Draw the tree hierarchy line graphics prefix in _prefix in window 'w' into rectangle 'at' with style 'tableStyle'.

◆ GetCol() [1/2]

NCTableCol * NCTableLine::GetCol ( unsigned idx)

Return a non-const pointer for read/write operations to the column (the cell) with the specified index or 0 if there is no such cell.

This is the table cell counterpart to NCTablePad::ModifyLine(). This does not set any 'dirty' flag.

◆ GetCol() [2/2]

const NCTableCol * NCTableLine::GetCol ( unsigned idx) const
inline

Return a const pointer for read-only operatoins to the column (the cell) with the specified index or 0 if there is no such cell.

This is the table cell counterpart to NCTablePad::GetLine().

◆ GetItems()

std::vector< NCTableCol * > NCTableLine::GetItems ( ) const
inline

Return all columns (cells). Ownership of the cells remains with this line; do not delete them!

◆ handleInput()

bool NCTableLine::handleInput ( wint_t key)
virtual

Handle keyboard input. Return 'true' if the key event is handled, 'false' to propagate it up to the pad.

Reimplemented in NCTreeLine.

◆ indentationStr()

string NCTableLine::indentationStr ( ) const

Return a string of a number of blanks suitable for the indentation of this tree level.

◆ index()

int NCTableLine::index ( ) const
inline

Return the unique index by which this line can be identified.

◆ initPrefixPlaceholder()

void NCTableLine::initPrefixPlaceholder ( )
protected

Initialize _prefixPlaceholder, the placeholder for tree hierarchy line graphics.

◆ isNested()

virtual bool NCTableLine::isNested ( ) const
inlinevirtual

Return 'true' if this should be displayed as nested items, i.e. with line graphics connecting tree items and their children. This needs to be set from the outside.

◆ isOpen()

bool NCTableLine::isOpen ( YItem * yitem) const
protected

Return 'true' if yitem inherits YTreeItem or YTableItem and has its 'open' flag set to 'true'.

◆ openBranch()

void NCTableLine::openBranch ( )

Open this tree branch

◆ origItem()

YTableItem * NCTableLine::origItem ( ) const
inline

Return the YItem this line corresponds to.

◆ prefixLen()

int NCTableLine::prefixLen ( ) const
inline

Return the length of the prefix for tree hierarchy line graphics.

◆ prefixPlaceholder()

const std::string & NCTableLine::prefixPlaceholder ( ) const
inlineprotected

Return a placeholder for the prefix string for this line consisting of enough blanks for the tree hierarchy line graphics.

The real line graphics will be drawn over this in DrawAt().

◆ SetCols() [1/2]

void NCTableLine::SetCols ( std::vector< NCTableCol * > & newCells)

Set the columns (cells).

◆ SetCols() [2/2]

void NCTableLine::SetCols ( unsigned idx)

Set a number of (empty) columns (cells).

◆ setNested()

virtual void NCTableLine::setNested ( bool val)
inlinevirtual

Set the 'nested' status.

◆ setOrigItem()

void NCTableLine::setOrigItem ( YTableItem * yitem)

Set the YItem this line corresponds to.

◆ setTreeLevel()

void NCTableLine::setTreeLevel ( int newVal)
inline

Set the tree nesting level.

◆ setYItem()

void NCTableLine::setYItem ( YItem * yitem)
protected

Set the YItem this line corresponds to.

◆ tagCell()

NCTableTag * NCTableLine::tagCell ( ) const

Return the tag cell or 0 if there is none.

◆ toggleOpenClosedState()

void NCTableLine::toggleOpenClosedState ( )

Toggle the open/closed state of this branch

◆ treeInit()

void NCTableLine::treeInit ( NCTableLine * parentLine,
YItem * yitem )
protected

Common init for tree-related things in the constructors that have a 'parentLine' and a 'yitem' parameter.

◆ treeLevel()

int NCTableLine::treeLevel ( ) const
inline

Return the nesting level in the tree (toplevel is 0).

◆ UpdateFormat()

void NCTableLine::UpdateFormat ( NCTableStyle & tableStyle)
virtual

Update TableStyle so that this line fits in

◆ updatePrefix()

void NCTableLine::updatePrefix ( )
virtual

Create the real tree hierarchy line graphics prefix and store it in _prefix

◆ yitem()

YItem * NCTableLine::yitem ( ) const
inlineprotected

Return the YItem this line corresponds to as its base class.


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