libyui-ncurses  2.57.2
NCTableItem.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  Copyright (C) 2020 SUSE LLC
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as
6  published by the Free Software Foundation; either version 2.1 of the
7  License, or (at your option) version 3.0 of the License. This library
8  is distributed in the hope that it will be useful, but WITHOUT ANY
9  WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11  License for more details. You should have received a copy of the GNU
12  Lesser General Public License along with this library; if not, write
13  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14  Floor, Boston, MA 02110-1301 USA
15 */
16 
17 
18 /*-/
19 
20  File: NCTableItem.h
21 
22  Authors: Michael Andres <ma@suse.de>
23  Stefan Hundhammer <shundhammer@suse.de>
24 
25 /-*/
26 
27 #ifndef NCTableItem_h
28 #define NCTableItem_h
29 
30 #include <iosfwd>
31 #include <vector>
32 
33 #include "position.h"
34 #include "NCWidget.h"
35 #include <yui/YTableItem.h>
36 
37 class NCTableCol;
38 class NCTableStyle;
39 class NCTableTag;
40 
41 
42 /**
43  * One line in a NCTable with multiple cells and an optional tree hierarchy.
44  * Each line corresponds to a YItem subclass (YTableItem or YTreeItem).
45  *
46  * This class is also the base class for NCTreeLine; it provides most its
47  * functionlity.
48  *
49  * Notice that on the libyui level, the inheritance hierarchy is
50  *
51  * YTableItem < YTreeItem < YItem
52  *
53  * whereas on the libyui-ncurses level, it is
54  *
55  * NCTreeLine < NCTableLine
56  *
57  * i.e. it's just the other way round. This is why it is safer to do dynamic
58  * casts of the internal _yitem to YTreeItem rather than to YTableItem: If
59  * used from an NCTree (i.e. YTree) widget, the items will all be YTreeItems; a
60  * dynamic cast to YTableItem will fail.
61  *
62  * NOTE: "col", "column", here refer to only one cell, not the entire table column.
63  *
64  * See also
65  * https://github.com/libyui/libyui-ncurses/blob/master/doc/nctable-and-nctree.md
66  **/
68 {
69 public:
70 
71  enum STATE
72  {
73  S_NORMAL = 0x00,
74  S_ACTIVE = 0x01,
75  S_DISABLED = 0x10,
76  S_HIDDEN = 0x20,
77  S_HEADLINE = 0x40
78  };
79 
80 
81  /**
82  * Constructor: Create an NCTableLine and fill it with 'cells'. This object
83  * takes over ownership of those cells and will delete it when appropriate.
84  *
85  * 'index' is a unique number with which to identify this line.
86  *
87  * 'nested' specifies whether any item in the table has any child items,
88  * i.e. whether line graphics to visualize the tree structure should be drawn.
89  *
90  * 'state' is an OR'ed combination of the STATE enum.
91  **/
92  NCTableLine( std::vector<NCTableCol*> & cells,
93  int index = -1,
94  bool nested = false,
95  unsigned state = S_NORMAL );
96 
97  NCTableLine( NCTableLine * parentLine,
98  YItem * yitem,
99  std::vector<NCTableCol*> & cells,
100  int index = -1,
101  bool nested = false,
102  unsigned state = S_NORMAL );
103 
104  /**
105  * Constructor with a number of empty cells.
106  **/
107  NCTableLine( unsigned colCount,
108  int index = -1,
109  bool nested = false,
110  unsigned state = S_NORMAL );
111 
112  NCTableLine( NCTableLine * parentLine,
113  YItem * yitem,
114  unsigned colCount,
115  int index = -1,
116  bool nested = false,
117  unsigned state = S_NORMAL );
118 
119  /**
120  * Destructor.
121  **/
122  virtual ~NCTableLine();
123 
124  /**
125  * Return the YItem this line corresponds to.
126  **/
127  YTableItem * origItem() const { return dynamic_cast<YTableItem *>( _yitem ); }
128 
129  /**
130  * Set the YItem this line corresponds to.
131  **/
132  void setOrigItem( YTableItem *yitem );
133 
134  /**
135  * Return the unique index by which this line can be identified.
136  **/
137  int index() const { return _index; }
138 
139  /**
140  * Return the number of columns (cells) in this line.
141  **/
142  unsigned Cols() const { return _cells.size(); }
143 
144  /**
145  * Set a number of (empty) columns (cells).
146  **/
147  void SetCols( unsigned idx );
148 
149  /**
150  * Set the columns (cells).
151  **/
152  void SetCols( std::vector<NCTableCol*> & newCells );
153 
154  /**
155  * Delete all content.
156  **/
157  void ClearLine() { SetCols( 0 ); }
158 
159  /**
160  * Return all columns (cells).
161  * Ownership of the cells remains with this line; do not delete them!
162  **/
163  std::vector<NCTableCol*> GetItems() const { return _cells; }
164 
165  /**
166  * Append one cell. Ownership is transferred to this line.
167  **/
168  void Append( NCTableCol * cell ) { AddCol( Cols(), cell ); }
169 
170  void AddCol( unsigned idx, NCTableCol * item );
171  void DelCol( unsigned idx );
172 
173  /**
174  * Return a non-const pointer for read/write operations to the column (the
175  * cell) with the specified index or 0 if there is no such cell.
176  *
177  * This is the table cell counterpart to NCTablePad::ModifyLine(). This
178  * does not set any 'dirty' flag.
179  **/
180  NCTableCol * GetCol( unsigned idx );
181 
182  /**
183  * Return a const pointer for read-only operatoins to the column (the cell)
184  * with the specified index or 0 if there is no such cell.
185  *
186  * This is the table cell counterpart to NCTablePad::GetLine().
187  **/
188  const NCTableCol * GetCol( unsigned idx ) const
189  {
190  return const_cast<NCTableLine*>( this )->GetCol( idx );
191  }
192 
193  void SetState ( const STATE s ) { _state |= s; }
194  void ClearState( const STATE s ) { _state &= ~s; }
195 
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 ); }
200 
201  virtual bool isVisible() const;
202 
203  virtual bool isEnabled() const { return isVisible() && !isDisabled(); }
204 
205  /**
206  * Return 'true' if this should be displayed as nested items, i.e.
207  * with line graphics connecting tree items and their children.
208  * This needs to be set from the outside.
209  **/
210  virtual bool isNested() const { return _nested; }
211 
212  /**
213  * Set the 'nested' status.
214  **/
215  virtual void setNested( bool val ) { _nested = val; }
216 
217  /**
218  * Open this tree branch
219  **/
220  void openBranch();
221 
222  /**
223  * Close this tree branch
224  **/
225  void closeBranch();
226 
227  /**
228  * Toggle the open/closed state of this branch
229  **/
230  void toggleOpenClosedState();
231 
232  /**
233  * Handle keyboard input. Return 'true' if the key event is handled,
234  * 'false' to propagate it up to the pad.
235  **/
236  virtual bool handleInput( wint_t key );
237 
238  /**
239  * Change a line that may have been invisible until now to be visible.
240  *
241  * Return 'true' if there was a status change, i.e. if it was invisible
242  * before, 'false' otherwise.
243  *
244  * This default implementation does nothing and always returns 'false'.
245  * Derived classes that can handle invisible items may want to overwrite
246  * this.
247  **/
248  virtual bool ChangeToVisible() { return false; }
249 
250  virtual unsigned Hotspot( unsigned & at ) const { at = 0; return 0; }
251 
252  /**
253  * Update TableStyle so that this line fits in
254  **/
255  virtual void UpdateFormat( NCTableStyle & tableStyle );
256 
257  /**
258  * Create the real tree hierarchy line graphics prefix and store it in
259  * _prefix
260  **/
261  virtual void updatePrefix();
262 
263 
264  /// @param active is the table cursor here
265  virtual void DrawAt( NCursesWindow & w,
266  const wrect at,
267  NCTableStyle & tableStyle,
268  bool active ) const;
269 
270  void stripHotkeys();
271 
272  //
273  // Tree operations
274  //
275 
276  virtual NCTableLine * parent() const { return _parent; }
277  virtual NCTableLine * firstChild() const { return _firstChild; }
278  virtual NCTableLine * nextSibling() const { return _nextSibling; }
279 
280  void setParent ( NCTableLine * newVal ) { _parent = newVal; }
281  void setFirstChild ( NCTableLine * newVal ) { _firstChild = newVal; }
282  void setNextSibling( NCTableLine * newVal ) { _nextSibling = newVal; }
283 
284  /**
285  * Return the nesting level in the tree (toplevel is 0).
286  **/
287  int treeLevel() const { return _treeLevel; }
288 
289  /**
290  * Set the tree nesting level.
291  **/
292  void setTreeLevel( int newVal ) { _treeLevel = newVal; }
293 
294  /**
295  * Return the length of the prefix for tree hierarchy line graphics.
296  **/
297  int prefixLen() const { return _nested ? treeLevel() + 3 : 0; }
298 
299  /**
300  * Return the tag cell or 0 if there is none.
301  **/
302  NCTableTag * tagCell() const;
303 
304  /**
305  * Return a string of a number of blanks suitable for the indentation of
306  * this tree level.
307  **/
308  std::string indentationStr() const;
309 
310 protected:
311 
312  /**
313  * Common init for tree-related things in the constructors that have a
314  * 'parentLine' and a 'yitem' parameter.
315  **/
316  void treeInit( NCTableLine * parentLine, YItem * yitem );
317 
318  /**
319  * Initialize _prefixPlaceholder, the placeholder for tree hierarchy line graphics.
320  **/
321  void initPrefixPlaceholder();
322 
323  /**
324  * Add this line to the parent's tree hierarchy.
325  **/
326  void addToTree( NCTableLine * parent );
327 
328  /**
329  * Return 'true' if yitem inherits YTreeItem or YTableItem and has its
330  * 'open' flag set to 'true'.
331  **/
332  bool isOpen( YItem * yitem ) const;
333 
334  /**
335  * Return the YItem this line corresponds to as its base class.
336  **/
337  YItem * yitem() const { return _yitem; }
338 
339  /**
340  * Set the YItem this line corresponds to.
341  **/
342  void setYItem( YItem * yitem );
343 
344  virtual void DrawItems( NCursesWindow & w,
345  const wrect at,
346  NCTableStyle & tableStyle,
347  bool active ) const;
348 
349  void assertCol( unsigned idx );
350 
351  /**
352  * Return a placeholder for the prefix string for this line consisting of
353  * enough blanks for the tree hierarchy line graphics.
354  *
355  * The real line graphics will be drawn over this in DrawAt().
356  **/
357  const std::string & prefixPlaceholder() const { return _prefixPlaceholder; }
358 
359  /**
360  * Draw the tree hierarchy line graphics prefix in _prefix in window 'w'
361  * into rectangle 'at' with style 'tableStyle'.
362  **/
363  void drawPrefix( NCursesWindow & w,
364  const wrect at,
365  NCTableStyle & tableStyle ) const;
366 
367 private:
368 
369  friend std::ostream & operator<<( std::ostream & str, const NCTableLine & obj );
370 
371  // Disable unwanted assignment operator and copy constructor
372 
373  NCTableLine & operator=( const NCTableLine & );
374  NCTableLine( const NCTableLine & );
375 
376 
377  //
378  // Data members
379  //
380 
381 protected:
382 
383  std::vector<NCTableCol*> _cells; ///< owned
384 
385  unsigned _state; ///< Or'ed STATE flags
386  int _index; ///< unique index to identify this line
387  YItem * _yitem; ///< not owned
388  bool _nested; ///< using nested (tree-like) items?
389 
390  // Tree-related
391 
392  int _treeLevel;
393  NCTableLine * _parent;
394  NCTableLine * _nextSibling;
395  NCTableLine * _firstChild;
396 
397  // This should have been an argument for DrawItems.
398  //
399  // It needs to be mutable because some methods that change it promise to be
400  // const, but they break that promise with this variable.
401  mutable STATE _vstate;
402 
403  // Tree hierarchy line graphics for this line.
404  //
405  // chtype is a very basic NCurses type to store one character with its
406  // attributes (bg/fg color).
407  chtype * _prefix;
408  std::string _prefixPlaceholder;
409 };
410 
411 
412 /**
413  * One cell in an NCTableLine with a label and a cell-specific style.
414  *
415  * 'Col' in this context means just this one cell, not the entire column in the
416  * table.
417  *
418  * The style (NCTableCol::STYLE) is just color information,
419  * don't confuse with table sizing+alignment info, NCTableStyle.
420  **/
422 {
423 
424  friend std::ostream & operator<<( std::ostream & str, const NCTableCol & obj );
425 
426 public:
427 
428  enum STYLE
429  {
430  NONE = 0, // use current bg
431  PLAIN, // plain text
432  DATA, // data style
433  ACTIVEDATA, // data style if line active, else plain
434  HINT, // hint
435  SEPARATOR // separator
436  };
437 
438 
439  NCTableCol( const NCstring & label = "", STYLE st = ACTIVEDATA );
440 
441  virtual ~NCTableCol();
442 
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 ); }
446 
447  /**
448  * Return the prefix that is drawn (without delimiter) before the label.
449  * This can be used for an empty placeholder for tree hierarchy graphics.
450  **/
451  const NClabel & prefix() const { return _prefix; }
452 
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(); }
456 
457  /**
458  * Return a wrect that is adjusted for the size of the prefix, i.e. a
459  * little to the right and a little narrower.
460  **/
461  wrect prefixAdjusted( const wrect origRect ) const;
462 
463  virtual wsze Size() const { return wsze( 1, _prefix.width() + _label.width() ); }
464 
465  virtual void DrawAt( NCursesWindow & w,
466  const wrect at,
467  NCTableStyle & tableStyle,
468  NCTableLine::STATE linestate,
469  unsigned colidx ) const;
470 
471  void stripHotkey() { _label.stripHotkey(); }
472 
473  bool hasHotkey() const { return _label.hasHotkey(); }
474  unsigned char hotkey() const { return _label.hotkey(); }
475 
476 protected:
477 
478  chtype setBkgd( NCursesWindow & w,
479  NCTableStyle & tableStyle,
480  NCTableLine::STATE linestate,
481  STYLE colstyle ) const ;
482 
483 private:
484 
485  NClabel _prefix;
486  NClabel _label;
487  STYLE _style;
488 };
489 
490 
491 /**
492  * The header line of an NCTable.
493  **/
494 class NCTableHead : public NCTableLine
495 {
496 
497 public:
498 
499  NCTableHead( unsigned cols )
500  : NCTableLine( cols )
501  {}
502 
503  NCTableHead( std::vector<NCTableCol*> & headCells )
504  : NCTableLine( headCells )
505  {}
506 
507  virtual ~NCTableHead()
508  {}
509 
510  /**
511  * Draw the header line with special attributes. That is the whole reason
512  * of having a separate class for this.
513  **/
514  virtual void DrawAt( NCursesWindow & w,
515  const wrect at,
516  NCTableStyle & tableStyle,
517  bool active ) const;
518 };
519 
520 
521 /// Styling for a NCTable: column widths, alignment and colors.
523 {
524 
525  friend std::ostream & operator<<( std::ostream & str, const NCTableStyle & obj );
526 
527 public:
528 
529  static const chtype currentBG = (chtype) - 1;
530 
531  NCTableStyle( const NCWidget & parentWidget );
532  ~NCTableStyle() {}
533 
534  /// Reset columns, setting their alignment and optionally titles.
535  /// Column widths are zeroed.
536  /// @param head List of strings where their first character
537  /// is the alignment (L, R, C) and the optional rest is the column heading
538  /// @return do we have a column heading
539  bool SetStyleFrom( const std::vector<NCstring> & head );
540 
541  void SetSepChar( const chtype sepChar ) { _colSepChar = sepChar; }
542 
543  /// total width of space between adjacent columns, including the separator character
544  void SetSepWidth( const unsigned sepWidth ) { _colSepWidth = sepWidth; }
545 
546  void SetHotCol( int hcol )
547  {
548  _hotCol = ( hcol < 0 || Cols() <= (unsigned) hcol ) ? -1 : hcol;
549  }
550 
551  /// Forget sizing based on table content, resize according to headline only
553  {
554  _colWidth.clear();
555  AssertMinCols( _headline.Cols() );
556  _headline.UpdateFormat( *this );
557  }
558 
559  /// Ensure we know width and alignment for at least *num* columns.
560  void AssertMinCols( unsigned num )
561  {
562  if ( _colWidth.size() < num )
563  {
564  _colWidth.resize( num, 0 );
565  _colAdjust.resize( _colWidth.size(), NC::LEFT );
566  }
567  }
568 
569  /// Update colWidth[num] to be at least *val*.
570  /// @param num column number (may be bigger than previously)
571  /// @param val width of that column for some line
572  void MinColWidth( unsigned num, unsigned val )
573  {
574  AssertMinCols( num );
575 
576  if ( val > _colWidth[num] )
577  _colWidth[ num ] = val;
578  }
579 
580  NC::ADJUST ColAdjust( unsigned num ) const { return _colAdjust[num]; }
581 
582  unsigned Cols() const { return _colWidth.size(); }
583 
584  unsigned ColWidth( unsigned num ) const { return _colWidth[num]; }
585 
586  unsigned ColSepWidth() const { return _colSepWidth; }
587 
588  chtype ColSepChar() const { return _colSepChar; }
589 
590  unsigned HotCol() const { return _hotCol; }
591 
592  const NCstyle::StList & listStyle() const { return _parentWidget.listStyle(); }
593 
594  chtype getBG() const { return listStyle().item.plain; }
595 
596  chtype getBG( const NCTableLine::STATE lstate,
597  const NCTableCol::STYLE cstyle = NCTableCol::PLAIN ) const;
598 
599  chtype highlightBG( const NCTableLine::STATE lstate,
600  const NCTableCol::STYLE cstyle,
601  const NCTableCol::STYLE dstyle = NCTableCol::PLAIN ) const ;
602 
603  chtype hotBG( const NCTableLine::STATE lstate, unsigned colidx ) const
604  {
605  return ( colidx == _hotCol ) ?
606  getBG( lstate, NCTableCol::HINT ) : currentBG;
607  }
608 
609  const NCTableLine & Headline() const { return _headline; }
610 
611  /// Add up the widths of columns with the separators
612  unsigned TableWidth() const
613  {
614  unsigned twidth = 0;
615 
616  for ( unsigned i = 0; i < Cols(); ++i )
617  twidth += _colWidth[i];
618 
619  if ( Cols() > 1 )
620  twidth += _colSepWidth * ( Cols() - 1 );
621 
622  return twidth;
623  }
624 
625 
626 private:
627 
628  const NCWidget & _parentWidget;
629  NCTableHead _headline;
630  std::vector<unsigned> _colWidth; ///< column widths
631  std::vector<NC::ADJUST> _colAdjust; ///< column alignment
632 
633 
634  /// total width of space between adjacent columns, including the separator character
635  unsigned _colSepWidth;
636 
637  chtype _colSepChar; ///< column separator character
638  unsigned _hotCol; ///< which column is "hot"
639 };
640 
641 
642 /**
643  * A column (one cell) used as a selection marker:
644  * `[ ]`/`[x]` or `( )`/`(x)`.
645  **/
646 class NCTableTag : public NCTableCol
647 {
648 public:
649 
650  /**
651  * Constructor.
652  *
653  * @param item (must not be nullptr, not owned)
654  * @param sel currently selected, draw an `x` inside
655  * @param singleSel if true draw this in a radio-button style `(x)`;
656  * if false draw this in a checkbox style `[x]`
657  **/
658  NCTableTag( YItem *item, bool sel = false, bool singleSel = false )
659  : NCTableCol( NCstring( singleSel ? "( )" : "[ ]" ), SEPARATOR )
660  , _yitem( item )
661  , _selected( sel )
662  , _singleSelection( singleSel )
663  {
664  // store pointer to this tag in Yitem data
665  _yitem->setData( this );
666  }
667 
668  virtual ~NCTableTag() {}
669 
670  virtual void SetLabel( const NClabel & ) { /*NOOP*/; }
671 
672  virtual void DrawAt( NCursesWindow & w,
673  const wrect at,
674  NCTableStyle & tableStyle,
675  NCTableLine::STATE linestate,
676  unsigned colidx ) const
677  {
678  // Use parent DrawAt to draw the static part: "[ ]"
679  NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
680 
681  if ( _selected )
682  {
683  // Draw the "x" inside the "[ ]" with different attributes
684 
685  setBkgd( w, tableStyle, linestate, DATA );
686  wrect drawRect = prefixAdjusted( at );
687  w.addch( drawRect.Pos.L, drawRect.Pos.C + 1, 'x' );
688  }
689  }
690 
691  virtual bool Selected() const { return _selected; }
692 
693  virtual void SetSelected( bool sel ) { _selected = sel; }
694 
695  virtual bool SingleSelection() const { return _singleSelection; }
696 
697  YItem *origItem() const { return _yitem; }
698 
699 private:
700 
701  YItem * _yitem; ///< (not owned, never nullptr, should have been a reference)
702  bool _selected;
703  bool _singleSelection;
704 };
705 
706 
707 #endif // NCTableItem_h
NCursesWindow::addch
int addch(const char ch)
Put attributed character to the window.
Definition: ncursesw.h:1230
wsze
Screen dimension (screen size) in the order height, width: (H, W)
Definition: position.h:154
NCTableLine::treeLevel
int treeLevel() const
Return the nesting level in the tree (toplevel is 0).
Definition: NCTableItem.h:287
NCstring
A string with an optional hot key.
Definition: NCstring.h:36
NCTableLine::isOpen
bool isOpen(YItem *yitem) const
Return 'true' if yitem inherits YTreeItem or YTableItem and has its 'open' flag set to 'true'.
Definition: NCTableItem.cc:202
NCTableLine::closeBranch
void closeBranch()
Close this tree branch.
Definition: NCTableItem.cc:535
NCTableCol
One cell in an NCTableLine with a label and a cell-specific style.
Definition: NCTableItem.h:422
NCursesWindow
C++ class for windows.
Definition: ncursesw.h:907
NCTableLine::_state
unsigned _state
Or'ed STATE flags.
Definition: NCTableItem.h:385
NCTableLine::toggleOpenClosedState
void toggleOpenClosedState()
Toggle the open/closed state of this branch.
Definition: NCTableItem.cc:555
NCTableStyle::ResetToMinCols
void ResetToMinCols()
Forget sizing based on table content, resize according to headline only.
Definition: NCTableItem.h:552
NCTableHead
The header line of an NCTable.
Definition: NCTableItem.h:495
NC::ADJUST
ADJUST
Alignment aka justification: top/bottom, left/right, center.
Definition: NCtypes.h:35
NCTableLine::Cols
unsigned Cols() const
Return the number of columns (cells) in this line.
Definition: NCTableItem.h:142
NCTableHead::DrawAt
virtual void DrawAt(NCursesWindow &w, const wrect at, NCTableStyle &tableStyle, bool active) const
Draw the header line with special attributes.
Definition: NCTableItem.cc:686
NCTableLine::ClearLine
void ClearLine()
Delete all content.
Definition: NCTableItem.h:157
NCTableLine::_nested
bool _nested
using nested (tree-like) items?
Definition: NCTableItem.h:388
NCTableCol::prefix
const NClabel & prefix() const
Return the prefix that is drawn (without delimiter) before the label.
Definition: NCTableItem.h:451
NCTableCol::prefixAdjusted
wrect prefixAdjusted(const wrect origRect) const
Return a wrect that is adjusted for the size of the prefix, i.e.
Definition: NCTableItem.cc:640
NClabel
Multi-line string, with optional hotkey, drawable.
Definition: NCtext.h:82
NCTableLine::prefixLen
int prefixLen() const
Return the length of the prefix for tree hierarchy line graphics.
Definition: NCTableItem.h:297
NCTableLine::drawPrefix
void drawPrefix(NCursesWindow &w, const wrect at, NCTableStyle &tableStyle) const
Draw the tree hierarchy line graphics prefix in _prefix in window 'w' into rectangle 'at' with style ...
Definition: NCTableItem.cc:441
NCTableLine::GetCol
const NCTableCol * GetCol(unsigned idx) const
Return a const pointer for read-only operatoins to the column (the cell) with the specified index or ...
Definition: NCTableItem.h:188
NCTableLine::GetItems
std::vector< NCTableCol * > GetItems() const
Return all columns (cells).
Definition: NCTableItem.h:163
NCTableLine::initPrefixPlaceholder
void initPrefixPlaceholder()
Initialize _prefixPlaceholder, the placeholder for tree hierarchy line graphics.
Definition: NCTableItem.cc:161
NCWidget
Definition: NCWidget.h:46
NCTableLine::indentationStr
std::string indentationStr() const
Return a string of a number of blanks suitable for the indentation of this tree level.
Definition: NCTableItem.cc:173
NCTableLine::prefixPlaceholder
const std::string & prefixPlaceholder() const
Return a placeholder for the prefix string for this line consisting of enough blanks for the tree hie...
Definition: NCTableItem.h:357
NCTableStyle::MinColWidth
void MinColWidth(unsigned num, unsigned val)
Update colWidth[num] to be at least val.
Definition: NCTableItem.h:572
NCTableLine::openBranch
void openBranch()
Open this tree branch.
Definition: NCTableItem.cc:515
NCTableLine::isNested
virtual bool isNested() const
Return 'true' if this should be displayed as nested items, i.e.
Definition: NCTableItem.h:210
NCTableLine::DrawAt
virtual void DrawAt(NCursesWindow &w, const wrect at, NCTableStyle &tableStyle, bool active) const
Definition: NCTableItem.cc:319
NCTableLine::_index
int _index
unique index to identify this line
Definition: NCTableItem.h:386
NCTableLine::origItem
YTableItem * origItem() const
Return the YItem this line corresponds to.
Definition: NCTableItem.h:127
NCTableStyle::SetStyleFrom
bool SetStyleFrom(const std::vector< NCstring > &head)
Reset columns, setting their alignment and optionally titles.
Definition: NCTableItem.cc:721
NCTableStyle::AssertMinCols
void AssertMinCols(unsigned num)
Ensure we know width and alignment for at least num columns.
Definition: NCTableItem.h:560
NCTableLine::ChangeToVisible
virtual bool ChangeToVisible()
Change a line that may have been invisible until now to be visible.
Definition: NCTableItem.h:248
NCTableLine::~NCTableLine
virtual ~NCTableLine()
Destructor.
Definition: NCTableItem.cc:131
NCTableLine::index
int index() const
Return the unique index by which this line can be identified.
Definition: NCTableItem.h:137
NCTableLine::UpdateFormat
virtual void UpdateFormat(NCTableStyle &tableStyle)
Update TableStyle so that this line fits in.
Definition: NCTableItem.cc:302
NCTableLine::GetCol
NCTableCol * GetCol(unsigned idx)
Return a non-const pointer for read/write operations to the column (the cell) with the specified inde...
Definition: NCTableItem.cc:293
NCTableStyle::TableWidth
unsigned TableWidth() const
Add up the widths of columns with the separators.
Definition: NCTableItem.h:612
NCTableLine::setNested
virtual void setNested(bool val)
Set the 'nested' status.
Definition: NCTableItem.h:215
NCTableLine::tagCell
NCTableTag * tagCell() const
Return the tag cell or 0 if there is none.
Definition: NCTableItem.cc:574
NCTableLine::yitem
YItem * yitem() const
Return the YItem this line corresponds to as its base class.
Definition: NCTableItem.h:337
NCTableLine
One line in a NCTable with multiple cells and an optional tree hierarchy.
Definition: NCTableItem.h:68
NCTableLine::setOrigItem
void setOrigItem(YTableItem *yitem)
Set the YItem this line corresponds to.
Definition: NCTableItem.cc:219
NCTableLine::_yitem
YItem * _yitem
not owned
Definition: NCTableItem.h:387
NCTableStyle::SetSepWidth
void SetSepWidth(const unsigned sepWidth)
total width of space between adjacent columns, including the separator character
Definition: NCTableItem.h:544
NCTableStyle
Styling for a NCTable: column widths, alignment and colors.
Definition: NCTableItem.h:523
NCTableLine::SetCols
void SetCols(unsigned idx)
Set a number of (empty) columns (cells).
Definition: NCTableItem.cc:241
NCTableLine::_cells
std::vector< NCTableCol * > _cells
owned
Definition: NCTableItem.h:383
NCTableTag::NCTableTag
NCTableTag(YItem *item, bool sel=false, bool singleSel=false)
Constructor.
Definition: NCTableItem.h:658
NCTableLine::Append
void Append(NCTableCol *cell)
Append one cell.
Definition: NCTableItem.h:168
NCTableLine::addToTree
void addToTree(NCTableLine *parent)
Add this line to the parent's tree hierarchy.
Definition: NCTableItem.cc:179
NCstyle::StList
Definition: NCstyle.h:367
wrect
A rectangle is defined by its position and size: wpos Pos, wsze Sze.
Definition: position.h:194
NCTableLine::treeInit
void treeInit(NCTableLine *parentLine, YItem *yitem)
Common init for tree-related things in the constructors that have a 'parentLine' and a 'yitem' parame...
Definition: NCTableItem.cc:138
NCTableLine::handleInput
virtual bool handleInput(wint_t key)
Handle keyboard input.
Definition: NCTableItem.cc:472
NCTableLine::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'.
Definition: NCTableItem.cc:40
NCTableLine::updatePrefix
virtual void updatePrefix()
Create the real tree hierarchy line graphics prefix and store it in _prefix.
Definition: NCTableItem.cc:407
NCTableLine::setTreeLevel
void setTreeLevel(int newVal)
Set the tree nesting level.
Definition: NCTableItem.h:292
NCTableLine::setYItem
void setYItem(YItem *yitem)
Set the YItem this line corresponds to.
Definition: NCTableItem.cc:225
NCTableTag
A column (one cell) used as a selection marker: [ ]/[x] or ( )/(x).
Definition: NCTableItem.h:647