libyui-ncurses  2.57.2
NCTableItem.cc
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.cc
21 
22  Authors: Michael Andres <ma@suse.de>
23  Stefan Hundhammer <shundhammer@suse.de>
24 
25 /-*/
26 
27 #define YUILogComponent "ncurses"
28 #include <yui/YUILog.h>
29 #include "NCTableItem.h"
30 #include "NCTable.h"
31 #include "stringutil.h"
32 #include "stdutil.h"
33 
34 using stdutil::form;
35 using std::string;
36 using std::wstring;
37 using std::endl;
38 
39 
40 NCTableLine::NCTableLine( std::vector<NCTableCol*> & cells,
41  int index,
42  bool nested,
43  unsigned state )
44  : _cells( cells )
45  , _state( state )
46  , _index( index )
47  , _yitem( 0 )
48  , _nested( nested )
49  , _treeLevel( 0 )
50  , _parent( 0 )
51  , _nextSibling( 0 )
52  , _firstChild( 0 )
53  , _vstate( S_HIDDEN )
54  , _prefix( 0 )
55 {
57 }
58 
59 
61  YItem * yitem,
62  std::vector<NCTableCol*> & cells,
63  int index,
64  bool nested,
65  unsigned state )
66  : _cells( cells )
67  , _state( state )
68  , _index( index )
69  , _yitem( yitem )
70  , _nested( nested )
71  , _treeLevel( 0 )
72  , _parent( parentLine )
73  , _nextSibling( 0 )
74  , _firstChild( 0 )
75  , _vstate( S_HIDDEN )
76  , _prefix( 0 )
77 {
78  setYItem( yitem );
79  treeInit( parentLine, yitem );
80  initPrefixPlaceholder(); // This needs to be done AFTER treeInit()!
81 
82  if ( ! cells.empty() && nested )
83  cells[0]->setPrefix( _prefixPlaceholder );
84 }
85 
86 
87 NCTableLine::NCTableLine( unsigned colCount,
88  int index,
89  bool nested,
90  unsigned state )
91  : _cells( colCount, (NCTableCol *) 0 )
92  , _state( state )
93  , _index( index )
94  , _yitem( 0 )
95  , _nested( nested )
96  , _treeLevel( 0 )
97  , _parent( 0 )
98  , _nextSibling( 0 )
99  , _firstChild( 0 )
100  , _vstate( S_HIDDEN )
101  , _prefix( 0 )
102 {
104 }
105 
106 
108  YItem * yitem,
109  unsigned colCount,
110  int index,
111  bool nested,
112  unsigned state )
113  : _cells( colCount, (NCTableCol *) 0 )
114  , _state( state )
115  , _index( index )
116  , _yitem( yitem )
117  , _nested( nested )
118  , _treeLevel( 0 )
119  , _parent( parentLine )
120  , _nextSibling( 0 )
121  , _firstChild( 0 )
122  , _vstate( S_HIDDEN )
123  , _prefix( 0 )
124 {
125  setYItem( yitem );
126  treeInit( parentLine, yitem );
127  initPrefixPlaceholder(); // This needs to be done AFTER treeInit()!
128 }
129 
130 
132 {
133  ClearLine();
134  delete [] _prefix;
135 }
136 
137 
139  YItem * yitem )
140 {
141  _parent = parentLine;
142 
143  if ( _parent )
144  {
145  addToTree( _parent );
146  _treeLevel = _parent->treeLevel() + 1;
147  _nested = true;
148 
149  if ( ! isOpen( parentLine->yitem() ) )
150  SetState( S_HIDDEN );
151  }
152  else
153  {
154  _firstChild = 0;
155  _nextSibling = 0;
156  _treeLevel = 0;
157  }
158 }
159 
160 
162 {
163  // Notice that this needs to be done AFTER treeInit() because prefixLen()
164  // depends on treeLevel() which is only known after the parent is set.
165 
166  // Just reserve enough space with blanks. They will be overwritten later in
167  // DrawAt() with real line graphics.
168 
169  _prefixPlaceholder = indentationStr();
170 }
171 
172 
174 {
175  return _nested ? string( prefixLen(), ' ' ) : "";
176 }
177 
178 
180 {
181  if ( parent )
182  {
183  if ( parent->firstChild() ) // The parent already has children
184  {
185  // Find the last child of the parent
186 
187  NCTableLine * lastChild = parent->firstChild();
188 
189  while ( lastChild->nextSibling() )
190  lastChild = lastChild->nextSibling();
191 
192  lastChild->setNextSibling( this );
193  }
194  else // The parent does not have any children yet
195  {
196  parent->setFirstChild( this );
197  }
198  }
199 }
200 
201 
202 bool NCTableLine::isOpen( YItem * yitem ) const
203 {
204  if ( ! yitem )
205  return false;
206 
207  YTreeItem * treeItem = dynamic_cast<YTreeItem *>( yitem );
208 
209  if ( treeItem )
210  return treeItem->isOpen();
211 
212  // No need to dynamic_cast to YTableItem as well:
213  // YTableItem now (as of 8/2020) inherits YTreeItem.
214 
215  return false;
216 }
217 
218 
219 void NCTableLine::setOrigItem( YTableItem * yitem )
220 {
221  setYItem( yitem );
222 }
223 
224 
225 void NCTableLine::setYItem( YItem * yitem )
226 {
227  _yitem = yitem;
228 
229  if ( _yitem )
230  _yitem->setData( this ) ;
231 }
232 
233 
234 void NCTableLine::assertCol( unsigned idx )
235 {
236  if ( idx >= Cols() )
237  SetCols( idx + 1 );
238 }
239 
240 
241 void NCTableLine::SetCols( unsigned idx )
242 {
243  if ( idx == Cols() )
244  return;
245 
246  if ( idx < Cols() )
247  {
248  for ( unsigned i = idx; i < Cols(); ++i )
249  {
250  delete _cells[i];
251  }
252  }
253 
254  _cells.resize( idx, 0 );
255 }
256 
257 
258 void NCTableLine::stripHotkeys()
259 {
260  for ( unsigned i = 0; i < Cols(); ++i )
261  {
262  if ( _cells[i] )
263  _cells[i]->stripHotkey();
264  }
265 }
266 
267 
268 void NCTableLine::SetCols( std::vector<NCTableCol*> & newCells )
269 {
270  SetCols( 0 );
271  _cells = newCells;
272 }
273 
274 
275 void NCTableLine::AddCol( unsigned idx, NCTableCol * cell )
276 {
277  assertCol( idx );
278  delete _cells[idx];
279  _cells[idx] = cell;
280 }
281 
282 
283 void NCTableLine::DelCol( unsigned idx )
284 {
285  if ( idx < Cols() )
286  {
287  delete _cells[idx];
288  _cells[idx] = 0;
289  }
290 }
291 
292 
294 {
295  if ( idx < Cols() )
296  return _cells[idx];
297 
298  return 0;
299 }
300 
301 
303 {
304  tableStyle.AssertMinCols( Cols() );
305 
306  for ( unsigned col = 0; col < Cols(); ++col )
307  {
308  if ( !_cells[ col ] )
309  continue;
310 
311  tableStyle.MinColWidth( col, _cells[ col ]->Size().W );
312  }
313 
314  if ( _nested && ! _prefix )
315  updatePrefix(); // Put together line graphics for the tree hierarchy
316 }
317 
318 
320  const wrect at,
321  NCTableStyle & tableStyle,
322  bool active ) const
323 {
324  _vstate = S_HIDDEN;
325 
326  if ( isVisible() )
327  {
328  if ( isDisabled() )
329  _vstate = S_DISABLED;
330  else
331  _vstate = active ? S_ACTIVE : S_NORMAL;
332  }
333 
334  w.bkgdset( tableStyle.getBG( _vstate ) );
335 
336  for ( int i = 0; i < at.Sze.H; ++i )
337  {
338  w.move( at.Pos.L + i, at.Pos.C );
339  w.clrtoeol();
340  }
341 
342  DrawItems( w, at, tableStyle, active );
343 }
344 
345 
346 void NCTableLine::DrawItems( NCursesWindow & w,
347  const wrect at,
348  NCTableStyle & tableStyle,
349  bool active ) const
350 {
351  if ( !( at.Sze > wsze( 0 ) ) )
352  return;
353 
354  wrect lRect( at );
355  unsigned destWidth;
356 
357  for ( unsigned col = 0; col < Cols(); ++col )
358  {
359  if ( col > 0 && tableStyle.ColSepWidth() )
360  {
361  // draw centered
362  destWidth = tableStyle.ColSepWidth() / 2;
363 
364  if ( destWidth < (unsigned) lRect.Sze.W )
365  {
366  w.bkgdset( tableStyle.getBG( _vstate, NCTableCol::SEPARATOR ) );
367  w.vline( lRect.Pos.L, lRect.Pos.C + destWidth,
368  lRect.Sze.H, tableStyle.ColSepChar() );
369  // skip over
370  destWidth = tableStyle.ColSepWidth();
371 
372  if ( (unsigned) lRect.Sze.W <= destWidth )
373  break;
374 
375  lRect.Pos.C += destWidth;
376  lRect.Sze.W -= destWidth;
377  }
378  }
379 
380  destWidth = tableStyle.ColWidth( col );
381 
382  wrect cRect( lRect );
383 
384  // Adjust drawing rectangle for the screen space we just used
385  lRect.Pos.C += destWidth;
386  lRect.Sze.W -= destWidth;
387 
388  if ( lRect.Sze.W < 0 )
389  cRect.Sze.W = destWidth + lRect.Sze.W;
390  else
391  cRect.Sze.W = destWidth;
392 
393  if ( _cells[ col ] )
394  {
395  // Draw item
396  _cells[ col ]->DrawAt( w, cRect, tableStyle, _vstate, col );
397 
398  // Draw tree hierarchy line graphics over the prefix placeholder
399 
400  if ( col == 0 && _prefix )
401  drawPrefix( w, cRect, tableStyle );
402  }
403  }
404 }
405 
406 
408 {
409  if ( _prefix )
410  delete[] _prefix;
411 
412  // Build from right to left: Start with the line for this (deepest) level
413 
414  _prefix = new chtype[ prefixLen() ];
415  chtype * tagend = &_prefix[ prefixLen()-1 ];
416  *tagend-- = ACS_HLINE;
417  *tagend-- = firstChild() ? ACS_TTEE : ACS_HLINE;
418 
419  if ( _parent )
420  {
421  // Draw vertical connector for the siblings on this level
422 
423  *tagend-- = nextSibling() ? ACS_LTEE : ACS_LLCORNER;
424 
425 
426  // From right to left, for each higher level, draw a vertical line
427  // or a blank if this is the last branch on that level
428 
429  for ( NCTableLine * p = parent(); p; p = p->parent() )
430  {
431  *tagend-- = p->nextSibling() ? ACS_VLINE : ( ' '&A_CHARTEXT );
432  }
433  }
434  else // This is a toplevel item
435  {
436  *tagend-- = ACS_HLINE; // One more horizontal line to the left
437  }
438 }
439 
440 
442  const wrect at,
443  NCTableStyle & tableStyle ) const
444 {
445  if ( ! _prefix )
446  return;
447 
448  w.move( at.Pos.L, at.Pos.C );
449 
450  for ( int i = 0; i < prefixLen(); ++i )
451  w.addch( _prefix[i] );
452 
453 
454  // Draw the "+" indicator if this branch can be opened
455 
456  w.move( at.Pos.L, at.Pos.C + prefixLen() - 2 );
457 
458  if ( firstChild() && !isSpecial() )
459  {
460  w.bkgdset( tableStyle.highlightBG( _vstate,
461  NCTableCol::HINT,
462  NCTableCol::SEPARATOR ) );
463  }
464 
465  if ( firstChild() && !firstChild()->isVisible() )
466  w.addch( '+' );
467  else
468  w.addch( _prefix[ prefixLen() - 2 ] );
469 }
470 
471 
472 bool NCTableLine::handleInput( wint_t key )
473 {
474  bool handled = false;
475 
476  switch ( key )
477  {
478  case '?':
479  yuiMilestone() << _yitem << ": index: " << index() << endl;
480  break;
481 
482  case KEY_IC: // "Insert" key ("Insert Character")
483  case '+':
484  openBranch();
485  handled = true;
486  break;
487 
488  case KEY_DC: // "Delete" key ("Delete Character")
489  case '-':
490  closeBranch();
491  handled = true;
492  break;
493 
494  case KEY_RETURN:
495  // Propagate up to the pad; see bsc#67350
496  break;
497 
498  case KEY_SPACE: // Toggle open/closed state of this branch
499 
500  if ( _nested )
501  {
503  handled = true;
504  }
505  // else
506  // cascade the event up to NCTable::wHandleInput()
507  // to let it toggle the selection status in multiSelection mode
508  break;
509  }
510 
511  return handled;
512 }
513 
514 
516 {
517  if ( firstChild() && ! firstChild()->isVisible() )
518  {
519  // YTableItem inherits YTreeItem which inherits YItem,
520  // so we need to cast the YItem to YTreeItem which has the _isOpen flag.
521  YTreeItem * treeItem = dynamic_cast<YTreeItem *>( _yitem );
522 
523  if ( treeItem )
524  {
525  treeItem->setOpen( true );
526  yuiDebug() << "Opening item " << treeItem->label() << endl;
527 
528  for ( NCTableLine * child = firstChild(); child; child = child->nextSibling() )
529  child->ClearState( S_HIDDEN );
530  }
531  }
532 }
533 
534 
536 {
537  if ( firstChild() && firstChild()->isVisible() )
538  {
539  // YTableItem inherits YTreeItem which inherits YItem,
540  // so we need to cast the YItem to YTreeItem which has the _isOpen flag.
541  YTreeItem * treeItem = dynamic_cast<YTreeItem *>( _yitem );
542 
543  if ( treeItem )
544  {
545  treeItem->setOpen( false );
546  yuiDebug() << "Closing item " << treeItem->label() << endl;
547 
548  for ( NCTableLine * child = firstChild(); child; child = child->nextSibling() )
549  child->SetState( S_HIDDEN );
550  }
551  }
552 }
553 
554 
556 {
557  if ( firstChild() )
558  {
559  if ( firstChild()->isVisible() )
560  closeBranch();
561  else
562  openBranch();
563  }
564 }
565 
566 
567 bool NCTableLine::isVisible() const
568 {
569  return ! parent() || ( !isHidden() && parent()->isVisible() );
570 }
571 
572 
573 
575 {
576  NCTableTag * ret = 0;
577 
578  if ( ! _cells.empty() )
579  ret = dynamic_cast<NCTableTag *>( _cells[0] );
580 
581  return ret;
582 }
583 
584 
585 std::ostream & operator<<( std::ostream & str, const NCTableLine & obj )
586 {
587  str << "Line: cols " << obj.Cols() << endl;
588 
589  for ( unsigned idx = 0; idx < obj.Cols(); ++idx )
590  {
591  str << " " << idx << " ";
592  const NCTableCol * cell = obj.GetCol( idx );
593 
594  if ( cell )
595  str << *cell;
596  else
597  str << "NO_ITEM";
598 
599  str << endl;
600  }
601 
602  return str;
603 }
604 
605 
606 
607 //
608 //----------------------------------------------------------------------
609 //
610 
611 
612 NCTableCol::NCTableCol( const NCstring & label, STYLE style )
613  : _label( label )
614  , _style( style )
615 {
616 }
617 
618 
619 NCTableCol::~NCTableCol()
620 {
621 }
622 
623 
624 chtype NCTableCol::setBkgd( NCursesWindow & w,
625  NCTableStyle & tableStyle,
626  NCTableLine::STATE linestate,
627  STYLE colstyle ) const
628 {
629  chtype bkgdstyle = tableStyle.getBG( linestate, colstyle );
630 
631  if ( bkgdstyle != NCTableStyle::currentBG )
632  w.bkgdset( bkgdstyle );
633  else
634  bkgdstyle = w.getbkgd();
635 
636  return bkgdstyle;
637 }
638 
639 
640 wrect NCTableCol::prefixAdjusted( const wrect origRect ) const
641 {
642  wrect newRect = origRect;
643 
644  if ( _prefix.width() > 0 )
645  {
646  newRect.Pos.C += _prefix.width();
647  newRect.Sze.W -= _prefix.width();
648  }
649 
650  return newRect;
651 }
652 
653 
654 void NCTableCol::DrawAt( NCursesWindow & w,
655  const wrect at,
656  NCTableStyle & tableStyle,
657  NCTableLine::STATE linestate,
658  unsigned colidx ) const
659 {
660  chtype bg = setBkgd( w, tableStyle, linestate, _style );
661  chtype hbg = tableStyle.hotBG( linestate, colidx );
662 
663  if ( hbg == NCTableStyle::currentBG )
664  hbg = bg;
665 
666  if ( _prefix.width() > 0 )
667  _prefix.drawAt( w, bg, hbg, at );
668 
669  _label.drawAt( w, bg, hbg,
670  prefixAdjusted( at ),
671  tableStyle.ColAdjust( colidx ) );
672 }
673 
674 
675 std::ostream & operator<<( std::ostream & str, const NCTableCol & obj )
676 {
677  return str << obj._label;
678 }
679 
680 
681 //
682 //----------------------------------------------------------------------
683 //
684 
685 
687  const wrect at,
688  NCTableStyle & tableStyle,
689  bool active ) const
690 {
691  _vstate = S_HEADLINE;
692  w.bkgdset( tableStyle.getBG( _vstate ) );
693 
694  for ( int i = 0; i < at.Sze.H; ++i )
695  {
696  w.move( at.Pos.L + i, at.Pos.C );
697  w.clrtoeol();
698  }
699 
700  DrawItems( w, at, tableStyle, active );
701 }
702 
703 
704 //
705 //----------------------------------------------------------------------
706 //
707 
708 
709 NCTableStyle::NCTableStyle( const NCWidget & parentWidget )
710  : _parentWidget( parentWidget )
711  , _headline( 0 )
712  , _colWidth( 0 )
713  , _colAdjust( 0 )
714  , _colSepWidth( 1 )
715  , _colSepChar( ACS_VLINE )
716  , _hotCol( (unsigned) - 1 )
717 {
718 }
719 
720 
721 bool NCTableStyle::SetStyleFrom( const std::vector<NCstring> & head )
722 {
723  unsigned ncols = head.size();
724 
725  _headline.ClearLine();
726  _headline.SetCols( ncols );
727 
728  _colWidth.clear();
729  _colAdjust.clear();
730  AssertMinCols( ncols );
731 
732  bool hasContent = false;
733 
734  for ( unsigned i = 0; i < head.size(); ++i )
735  {
736  const wstring & entry( head[i].str() );
737  bool strip = false;
738 
739  if ( entry.length() )
740  {
741  switch ( entry[0] )
742  {
743  case 'R':
744  strip = true;
745  _colAdjust[i] = NC::RIGHT;
746  break;
747 
748  case 'C':
749  strip = true;
750  _colAdjust[i] = NC::CENTER;
751  break;
752 
753  case 'L':
754  strip = true;
755  _colAdjust[i] = NC::LEFT;
756  break;
757 
758  default:
759  yuiWarning() << "No style char [LRC] at beginning of '" << entry << "'" << std::endl;
760  break;
761  }
762  }
763 
764  NCstring coltxt = strip ? entry.substr( 1 ) : entry;
765  _headline.AddCol( i, new NCTableCol( coltxt ) );
766 
767  if ( ! hasContent && coltxt.str().length() )
768  hasContent = true;
769  }
770 
771  return hasContent;
772 }
773 
774 
775 chtype NCTableStyle::highlightBG( const NCTableLine::STATE lstate,
776  const NCTableCol::STYLE cstyle,
777  const NCTableCol::STYLE dstyle ) const
778 {
779  return getBG( lstate, cstyle );
780 }
781 
782 
783 chtype NCTableStyle::getBG( const NCTableLine::STATE lstate,
784  const NCTableCol::STYLE cstyle ) const
785 {
786  switch ( lstate )
787  {
788  case NCTableLine::S_NORMAL:
789 
790  switch ( cstyle )
791  {
792  case NCTableCol::PLAIN: return listStyle().item.plain;
793  case NCTableCol::DATA: return listStyle().item.data;
794  case NCTableCol::ACTIVEDATA: return listStyle().item.plain;
795  case NCTableCol::HINT: return listStyle().item.hint;
796  case NCTableCol::SEPARATOR: return listStyle().item.plain;
797  case NCTableCol::NONE: return currentBG;
798  }
799  break;
800 
801 
802  case NCTableLine::S_ACTIVE:
803 
804  switch ( cstyle )
805  {
806  case NCTableCol::PLAIN: return listStyle().selected.plain;
807  case NCTableCol::DATA: return listStyle().selected.data;
808  case NCTableCol::ACTIVEDATA: return listStyle().selected.data;
809  case NCTableCol::HINT: return listStyle().selected.hint;
810  case NCTableCol::SEPARATOR: return listStyle().selected.plain;
811  case NCTableCol::NONE: return currentBG;
812  }
813  break;
814 
815  case NCTableLine::S_DISABLED:
816 
817  switch ( cstyle )
818  {
819  case NCTableCol::PLAIN: return _parentWidget.wStyle().disabledList.item.plain;
820  case NCTableCol::DATA: return _parentWidget.wStyle().disabledList.item.data;
821  case NCTableCol::ACTIVEDATA: return _parentWidget.wStyle().disabledList.item.plain;
822  case NCTableCol::HINT: return _parentWidget.wStyle().disabledList.item.hint;
823  case NCTableCol::SEPARATOR: return listStyle().item.plain;
824  case NCTableCol::NONE: return currentBG;
825  }
826  break;
827 
828 
829  case NCTableLine::S_HEADLINE:
830  return listStyle().title;
831  break;
832 
833  case NCTableLine::S_HIDDEN:
834  return currentBG;
835  break;
836  }
837 
838  return currentBG;
839 }
840 
841 
842 std::ostream & operator<<( std::ostream & str, const NCTableStyle & obj )
843 {
844  str << form( "cols %d, sep %d (%lx)\n",
845  obj.Cols(), obj.ColSepWidth(), (unsigned long)obj.ColSepChar() );
846 
847  for ( unsigned i = 0; i < obj.Cols(); ++i )
848  {
849  str << form( "%2d %d(%3d) ", i, obj.ColAdjust( i ), obj.ColWidth( i ) );
850 
851  if ( obj.Headline().GetCol( i ) )
852  str << obj.Headline().GetCol( i )->Label();
853 
854  str << std::endl;
855  }
856 
857  return str;
858 }
859 
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::toggleOpenClosedState
void toggleOpenClosedState()
Toggle the open/closed state of this branch.
Definition: NCTableItem.cc:555
NCursesWindow::getbkgd
chtype getbkgd() const
Get current background setting.
Definition: ncursesw.h:1440
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::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
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::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
NCursesWindow::clrtoeol
int clrtoeol()
Clear to the end of the line.
Definition: ncursesw.h:1540
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::DrawAt
virtual void DrawAt(NCursesWindow &w, const wrect at, NCTableStyle &tableStyle, bool active) const
Definition: NCTableItem.cc:319
NCursesWindow::move
int move(int y, int x)
Move cursor the this position.
Definition: ncursesw.h:1157
NCursesWindow::vline
int vline(int len, chtype ch=0)
Draw a vertical line of len characters with the given character.
Definition: ncursesw.h:1501
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::~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
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
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
NCTableLine::addToTree
void addToTree(NCTableLine *parent)
Add this line to the parent's tree hierarchy.
Definition: NCTableItem.cc:179
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
NCursesWindow::bkgdset
void bkgdset(chtype ch)
Set the background property.
Definition: ncursesw.h:1450
NCTableLine::updatePrefix
virtual void updatePrefix()
Create the real tree hierarchy line graphics prefix and store it in _prefix.
Definition: NCTableItem.cc:407
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