32 #include "NCTableItem.h"
50 std::vector<NCTableLine *>::iterator itemsBegin,
51 std::vector<NCTableLine *>::iterator itemsEnd
54 int getColumn ()
const {
return _column; }
55 void setColumn (
int column ) { _column = column; }
57 bool isReverse ()
const {
return _reverse; }
58 void setReverse (
bool reverse ) { _reverse = reverse; }
72 virtual void sort ( std::vector<NCTableLine *>::iterator itemsBegin,
73 std::vector<NCTableLine *>::iterator itemsEnd )
override;
79 Compare (
int column,
bool reverse )
80 : column(column), reverse(reverse)
89 std::wstring smartSortKey(
const NCTableLine * tableLine )
const;
91 long long toNumber(
const std::wstring& s,
bool* ok)
const;
107 bool single_selection;
111 NCTableTag( YItem *item,
bool sel =
false,
bool single_sel =
false )
115 , single_selection( single_sel )
118 yitem->setData(
this );
123 virtual void SetLabel(
const NClabel & ) { ; }
127 NCTableLine::STATE linestate,
128 unsigned colidx )
const
130 NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
134 setBkgd( w, tableStyle, linestate, DATA );
135 w.
addch( at.Pos.L, at.Pos.C + 1,
'x' );
139 virtual void SetSelected(
bool sel ) { selected = sel; }
141 virtual bool Selected()
const {
return selected; }
143 virtual bool SingleSelection()
const {
return single_selection; }
145 YItem *origItem()
const {
return yitem; }
153 friend std::ostream & operator<<( std::ostream & str,
const NCTablePad & obj );
166 std::vector<NCTableLine*> Items;
169 std::unique_ptr<NCTableSortStrategyBase> sortStrategy;
171 void assertLine(
unsigned idx );
175 void DirtyFormat() { dirty = dirtyFormat =
true; }
177 virtual wsze UpdateFormat();
179 virtual int dirtyPad() {
return setpos( CurPos() ); }
181 virtual int setpos(
const wpos & newpos );
182 virtual int DoRedraw();
183 virtual void updateScrollHint();
194 virtual void wRecoded();
196 virtual wpos CurPos()
const;
197 virtual bool handleInput( wint_t key );
199 bool setItemByKey(
int key );
203 return dirtyFormat ? UpdateFormat()
204 :
wsze( Lines(), ItemStyle.TableWidth() );
207 void setOrder(
int column,
bool do_reverse =
false );
213 bool SetHeadline(
const std::vector<NCstring> & head );
215 virtual void SendHead()
217 SetHead( Headpad, srect.Pos.C );
221 void SetSepChar(
const chtype colSepchar )
223 ItemStyle.SetSepChar( colSepchar );
226 void SetSepWidth(
const unsigned sepwidth )
228 ItemStyle.SetSepWidth( sepwidth );
231 void SetHotCol(
int hcol )
233 ItemStyle.SetHotCol( hcol );
236 unsigned Cols()
const {
return ItemStyle.Cols(); }
238 unsigned Lines()
const {
return Items.size(); }
240 unsigned HotCol()
const {
return ItemStyle.HotCol(); }
242 void SetLines(
unsigned idx );
243 void SetLines( std::vector<NCTableLine*> & nItems );
244 void ClearTable() { SetLines( 0 ); }
246 void Append(
NCTableLine * item ) { AddLine( Lines(), item ); }
248 void Append( std::vector<NCTableCol*> & nItems,
int index = -1 )
250 AddLine( Lines(),
new NCTableLine( nItems, index ) );
254 void DelLine(
unsigned idx );
263 if ( newSortStrategy != 0 )
264 sortStrategy.reset ( newSortStrategy );
virtual void directDraw(NCursesWindow &w, const wrect at, unsigned lineno)
Directly draw a table item at a specific location.
int addch(const char ch)
Put attributed character to the window.
WINDOW * w
the curses WINDOW
static int lines()
Number of lines on terminal, not window.
static int cols()
Number of cols on terminal, not window.