libyui-ncurses
|
#include <NCTableItem.h>
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) |
NCTableCol * | GetCol (unsigned idx) |
const NCTableCol * | GetCol (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 NCTableLine * | parent () const |
virtual NCTableLine * | firstChild () const |
virtual NCTableLine * | nextSibling () const |
void | setParent (NCTableLine *newVal) |
void | setFirstChild (NCTableLine *newVal) |
void | setNextSibling (NCTableLine *newVal) |
int | treeLevel () const |
void | setTreeLevel (int newVal) |
int | prefixLen () const |
NCTableTag * | tagCell () 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) |
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
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::NCTableLine | ( | unsigned | colCount, |
int | index = -1 , |
||
bool | nested = false , |
||
unsigned | state = S_NORMAL |
||
) |
Constructor with a number of empty cells.
|
virtual |
Destructor.
|
protected |
Add this line to the parent's tree hierarchy.
|
inline |
Append one cell. Ownership is transferred to this line.
|
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.
|
inline |
Delete all content.
void NCTableLine::closeBranch | ( | ) |
Close this tree branch
|
inline |
Return the number of columns (cells) in this line.
|
virtual |
active | is the table cursor here |
Reimplemented in NCTableHead.
|
protected |
Draw the tree hierarchy line graphics prefix in _prefix in window 'w' into rectangle 'at' with style 'tableStyle'.
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.
|
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().
|
inline |
Return all columns (cells). Ownership of the cells remains with this line; do not delete them!
|
virtual |
Handle keyboard input. Return 'true' if the key event is handled, 'false' to propagate it up to the pad.
Reimplemented in NCTreeLine.
string NCTableLine::indentationStr | ( | ) | const |
Return a string of a number of blanks suitable for the indentation of this tree level.
|
inline |
Return the unique index by which this line can be identified.
|
protected |
Initialize _prefixPlaceholder, the placeholder for tree hierarchy line graphics.
|
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.
|
protected |
Return 'true' if yitem inherits YTreeItem or YTableItem and has its 'open' flag set to 'true'.
void NCTableLine::openBranch | ( | ) |
Open this tree branch
|
inline |
Return the YItem this line corresponds to.
|
inline |
Return the length of the prefix for tree hierarchy line graphics.
|
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().
void NCTableLine::SetCols | ( | std::vector< NCTableCol * > & | newCells | ) |
Set the columns (cells).
void NCTableLine::SetCols | ( | unsigned | idx | ) |
Set a number of (empty) columns (cells).
|
inlinevirtual |
Set the 'nested' status.
void NCTableLine::setOrigItem | ( | YTableItem * | yitem | ) |
Set the YItem this line corresponds to.
|
inline |
Set the tree nesting level.
|
protected |
Set the YItem this line corresponds to.
NCTableTag * NCTableLine::tagCell | ( | ) | const |
Return the tag cell or 0 if there is none.
void NCTableLine::toggleOpenClosedState | ( | ) |
Toggle the open/closed state of this branch
|
protected |
Common init for tree-related things in the constructors that have a 'parentLine' and a 'yitem' parameter.
|
inline |
Return the nesting level in the tree (toplevel is 0).
|
virtual |
Update TableStyle so that this line fits in
|
virtual |
Create the real tree hierarchy line graphics prefix and store it in _prefix
|
inlineprotected |
Return the YItem this line corresponds to as its base class.