27 #define YUILogComponent "ncurses"
28 #include <yui/YUILog.h>
29 #include "NCTablePad.h"
33 NCTablePad::NCTablePad(
int lines,
int cols,
const NCWidget & p )
39 NCTablePad::~NCTablePad()
69 if ( lineNo <
Lines() )
77 yuiWarning() <<
"Illegal Line no " << lineNo <<
" (" <<
Lines() <<
")" << std::endl;
114 bool NCTablePad::setItemByKey(
int key )
116 if ( HotCol() >=
Cols() )
119 if ( key < 0 || UCHAR_MAX < key )
122 unsigned hcol = HotCol();
123 unsigned hkey = tolower( key );
127 if (
_items[i]->GetCol( hcol )->hasHotkey()
128 && (unsigned) tolower(
_items[i]->GetCol( hcol )->hotkey() ) == hkey )
139 void NCTablePad::stripHotkeys()
141 for (
unsigned i = 0; i <
Lines(); ++i )
145 _items[i]->stripHotkeys();
151 typedef std::vector<NCTableLine *>::const_iterator NCTableLineIterator;
155 NCTableLineIterator begin =
_items.begin();
156 NCTableLineIterator end =
_items.end();
157 NCTableLineIterator found = find_if( begin, end,
160 return line->
index() ==
id;
166 return found - begin;
virtual int DoRedraw()
Redraw the pad.
int ScrlLine(int line)
Scroll to a line, keeping the column.
unsigned Lines() const
Return the number of table lines (logical, not screen)
WINDOW * w
the curses WINDOW
virtual void prepareRedraw()
Prepare a redraw: Update the format if needed, set the background, clear the old content.
virtual void drawHeader()
Redraw the table header.
virtual bool handleInput(wint_t key)
Handle a keyboard input event.
unsigned visibleLines() const
Return the number of lines that are currently visible.
int currentLineNo() const
Return the current line number (the cursor position).
std::vector< NCTableLine * > _visibleItems
not owned
virtual void drawContentLines()
Redraw the (visible) content lines one by one.
int findIndexById(int id) const
Find the item index in a sorted table.
virtual bool handleInput(wint_t key)
Handle a keyboard input event.
std::vector< NCTableLine * > _items
(owned)
int index() const
Return the unique index by which this line can be identified.
bool paging() const
Whether the Pad is truncated (we're paging).
One line in a NCTable with multiple cells and an optional tree hierarchy.
A rectangle is defined by its position and size: wpos Pos, wsze Sze.
An NCPad for an NCTable or an NCTree.
unsigned Cols() const
Return the number of table columns (logical, not screen)
virtual void directDraw(NCursesWindow &w, const wrect at, unsigned lineno)
Directly draw a table item at a specific location.