35#include <yui/YTableItem.h>
95 unsigned state = S_NORMAL );
99 std::vector<NCTableCol*> & cells,
102 unsigned state = S_NORMAL );
110 unsigned state = S_NORMAL );
117 unsigned state = S_NORMAL );
152 void SetCols( std::vector<NCTableCol*> & newCells );
170 void AddCol(
unsigned idx,
NCTableCol * item );
171 void DelCol(
unsigned idx );
193 void SetState (
const STATE s ) {
_state |= s; }
194 void ClearState(
const STATE s ) {
_state &= ~s; }
196 bool isHidden()
const {
return (
_state & S_HIDDEN ); }
197 bool isDisabled()
const {
return (
_state & S_DISABLED ); }
198 bool isSpecial()
const {
return (
_state & ( S_HIDDEN | S_DISABLED ) ); }
199 bool isActive()
const {
return (
_state & S_ACTIVE ); }
201 virtual bool isVisible()
const;
203 virtual bool isEnabled()
const {
return isVisible() && !isDisabled(); }
250 virtual unsigned Hotspot(
unsigned & at )
const { at = 0;
return 0; }
276 virtual NCTableLine * parent()
const {
return _parent; }
277 virtual NCTableLine * firstChild()
const {
return _firstChild; }
278 virtual NCTableLine * nextSibling()
const {
return _nextSibling; }
280 void setParent (
NCTableLine * newVal ) { _parent = newVal; }
281 void setFirstChild (
NCTableLine * newVal ) { _firstChild = newVal; }
282 void setNextSibling(
NCTableLine * newVal ) { _nextSibling = newVal; }
349 void assertCol(
unsigned idx );
369 friend std::ostream & operator<<( std::ostream & str,
const NCTableLine & obj );
401 mutable STATE _vstate;
408 std::string _prefixPlaceholder;
424 friend std::ostream & operator<<( std::ostream & str,
const NCTableCol & obj );
443 const NClabel & Label()
const {
return _label; }
444 virtual void SetLabel(
const NClabel & newVal ) { _label = newVal; }
445 virtual void SetLabel(
const std::string & newVal ) { _label =
NCstring( newVal ); }
453 virtual void setPrefix(
const NClabel & newVal ) { _prefix = newVal; }
454 virtual void setPrefix(
const std::string & newVal ) { _prefix =
NCstring( newVal); }
455 int prefixWidth()
const {
return _prefix.width(); }
463 virtual wsze Size()
const {
return wsze( 1, _prefix.width() + _label.width() ); }
468 NCTableLine::STATE linestate,
469 unsigned colidx )
const;
471 void stripHotkey() { _label.stripHotkey(); }
473 bool hasHotkey()
const {
return _label.hasHotkey(); }
474 unsigned char hotkey()
const {
return _label.hotkey(); }
480 NCTableLine::STATE linestate,
481 STYLE colstyle )
const ;
503 NCTableHead( std::vector<NCTableCol*> & headCells )
525 friend std::ostream & operator<<( std::ostream & str,
const NCTableStyle & obj );
529 static const chtype currentBG = (chtype) - 1;
539 bool SetStyleFrom(
const std::vector<NCstring> & head );
541 void SetSepChar(
const chtype sepChar ) { _colSepChar = sepChar; }
544 void SetSepWidth(
const unsigned sepWidth ) { _colSepWidth = sepWidth; }
546 void SetHotCol(
int hcol )
548 _hotCol = ( hcol < 0 || Cols() <= (unsigned) hcol ) ? -1 : hcol;
562 if ( _colWidth.size() < num )
564 _colWidth.resize( num, 0 );
565 _colAdjust.resize( _colWidth.size(), NC::LEFT );
576 if ( val > _colWidth[num] )
577 _colWidth[ num ] = val;
580 NC::ADJUST ColAdjust(
unsigned num )
const {
return _colAdjust[num]; }
582 unsigned Cols()
const {
return _colWidth.size(); }
584 unsigned ColWidth(
unsigned num )
const {
return _colWidth[num]; }
586 unsigned ColSepWidth()
const {
return _colSepWidth; }
588 chtype ColSepChar()
const {
return _colSepChar; }
590 unsigned HotCol()
const {
return _hotCol; }
592 const NCstyle::StList & listStyle()
const {
return _parentWidget.listStyle(); }
594 chtype getBG()
const {
return listStyle().item.plain; }
596 chtype getBG(
const NCTableLine::STATE lstate,
597 const NCTableCol::STYLE cstyle = NCTableCol::PLAIN )
const;
599 chtype highlightBG(
const NCTableLine::STATE lstate,
600 const NCTableCol::STYLE cstyle,
601 const NCTableCol::STYLE dstyle = NCTableCol::PLAIN )
const ;
603 chtype hotBG(
const NCTableLine::STATE lstate,
unsigned colidx )
const
605 return ( colidx == _hotCol ) ?
606 getBG( lstate, NCTableCol::HINT ) : currentBG;
609 const NCTableLine & Headline()
const {
return _headline; }
616 for (
unsigned i = 0; i < Cols(); ++i )
617 twidth += _colWidth[i];
620 twidth += _colSepWidth * ( Cols() - 1 );
630 std::vector<unsigned> _colWidth;
631 std::vector<NC::ADJUST> _colAdjust;
635 unsigned _colSepWidth;
658 NCTableTag( YItem *item,
bool sel =
false,
bool singleSel =
false )
662 , _singleSelection( singleSel )
665 _yitem->setData(
this );
670 virtual void SetLabel(
const NClabel & ) { ; }
675 NCTableLine::STATE linestate,
676 unsigned colidx )
const
679 NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
685 setBkgd( w, tableStyle, linestate, DATA );
687 w.
addch( drawRect.Pos.L, drawRect.Pos.C + 1,
'x' );
691 virtual bool Selected()
const {
return _selected; }
693 virtual void SetSelected(
bool sel ) { _selected = sel; }
695 virtual bool SingleSelection()
const {
return _singleSelection; }
697 YItem *origItem()
const {
return _yitem; }
703 bool _singleSelection;
Definition NCTableItem.h:422
const NClabel & prefix() const
Definition NCTableItem.h:451
wrect prefixAdjusted(const wrect origRect) const
Definition NCTableItem.cc:640
Definition NCTableItem.h:495
virtual void DrawAt(NCursesWindow &w, const wrect at, NCTableStyle &tableStyle, bool active) const
Definition NCTableItem.cc:686
Definition NCTableItem.h:68
void drawPrefix(NCursesWindow &w, const wrect at, NCTableStyle &tableStyle) const
Definition NCTableItem.cc:441
void treeInit(NCTableLine *parentLine, YItem *yitem)
Definition NCTableItem.cc:138
NCTableTag * tagCell() const
Definition NCTableItem.cc:574
void setYItem(YItem *yitem)
Definition NCTableItem.cc:225
int _index
unique index to identify this line
Definition NCTableItem.h:386
void Append(NCTableCol *cell)
Definition NCTableItem.h:168
void SetCols(unsigned idx)
Definition NCTableItem.cc:241
virtual bool ChangeToVisible()
Definition NCTableItem.h:248
bool isOpen(YItem *yitem) const
Definition NCTableItem.cc:202
int index() const
Definition NCTableItem.h:137
std::vector< NCTableCol * > GetItems() const
Definition NCTableItem.h:163
YItem * yitem() const
Definition NCTableItem.h:337
virtual void setNested(bool val)
Definition NCTableItem.h:215
void closeBranch()
Definition NCTableItem.cc:535
YItem * _yitem
not owned
Definition NCTableItem.h:387
virtual bool handleInput(wint_t key)
Definition NCTableItem.cc:472
void addToTree(NCTableLine *parent)
Definition NCTableItem.cc:179
void setOrigItem(YTableItem *yitem)
Definition NCTableItem.cc:219
void openBranch()
Definition NCTableItem.cc:515
void setTreeLevel(int newVal)
Definition NCTableItem.h:292
void toggleOpenClosedState()
Definition NCTableItem.cc:555
YTableItem * origItem() const
Definition NCTableItem.h:127
int treeLevel() const
Definition NCTableItem.h:287
const NCTableCol * GetCol(unsigned idx) const
Definition NCTableItem.h:188
virtual ~NCTableLine()
Definition NCTableItem.cc:131
virtual void updatePrefix()
Definition NCTableItem.cc:407
unsigned Cols() const
Definition NCTableItem.h:142
NCTableCol * GetCol(unsigned idx)
Definition NCTableItem.cc:293
std::vector< NCTableCol * > _cells
owned
Definition NCTableItem.h:383
virtual void DrawAt(NCursesWindow &w, const wrect at, NCTableStyle &tableStyle, bool active) const
Definition NCTableItem.cc:319
virtual bool isNested() const
Definition NCTableItem.h:210
bool _nested
using nested (tree-like) items?
Definition NCTableItem.h:388
virtual void UpdateFormat(NCTableStyle &tableStyle)
Definition NCTableItem.cc:302
void initPrefixPlaceholder()
Definition NCTableItem.cc:161
unsigned _state
Or'ed STATE flags.
Definition NCTableItem.h:385
int prefixLen() const
Definition NCTableItem.h:297
void ClearLine()
Definition NCTableItem.h:157
std::string indentationStr() const
Definition NCTableItem.cc:173
const std::string & prefixPlaceholder() const
Definition NCTableItem.h:357
Styling for a NCTable: column widths, alignment and colors.
Definition NCTableItem.h:523
void SetSepWidth(const unsigned sepWidth)
total width of space between adjacent columns, including the separator character
Definition NCTableItem.h:544
void ResetToMinCols()
Forget sizing based on table content, resize according to headline only.
Definition NCTableItem.h:552
void AssertMinCols(unsigned num)
Ensure we know width and alignment for at least num columns.
Definition NCTableItem.h:560
bool SetStyleFrom(const std::vector< NCstring > &head)
Definition NCTableItem.cc:721
unsigned TableWidth() const
Add up the widths of columns with the separators.
Definition NCTableItem.h:612
void MinColWidth(unsigned num, unsigned val)
Definition NCTableItem.h:572
Definition NCTableItem.h:647
NCTableTag(YItem *item, bool sel=false, bool singleSel=false)
Definition NCTableItem.h:658
Multi-line string, with optional hotkey, drawable.
Definition NCtext.h:82
C++ class for windows.
Definition ncursesw.h:907
int addch(const char ch)
Definition ncursesw.h:1230
A rectangle is defined by its position and size: wpos Pos, wsze Sze.
Definition position.h:194
Screen dimension (screen size) in the order height, width: (H, W)
Definition position.h:154
ADJUST
Alignment aka justification: top/bottom, left/right, center.
Definition NCtypes.h:35