32 #include "NCTableItem.h" 48 std::vector<NCTableLine *>::iterator itemsBegin,
49 std::vector<NCTableLine *>::iterator itemsEnd,
52 int getColumn () {
return _uiColumn; }
53 void setColumn (
int column) { _uiColumn = column; }
63 std::vector<NCTableLine *>::iterator itemsBegin,
64 std::vector<NCTableLine *>::iterator itemsEnd,
68 std::sort ( itemsBegin, itemsEnd, Compare(uiColumn) );
83 std::wstring w1 = first->GetCol( _uiCol )->Label().getText().begin()->str();
84 std::wstring w2 = second->GetCol( _uiCol )->Label().getText().begin()->str();
88 long int number1 = std::wcstol( w1.c_str(), &endptr1, 10 );
89 long int number2 = std::wcstol( w2.c_str(), &endptr2, 10 );
91 if ( *endptr1 == L
'\0' && *endptr2 == L
'\0' )
94 return number1 < number2;
99 int result = std::wcscoll ( w1.c_str(), w2.c_str() );
121 NCTableTag( YItem *item,
const bool sel =
false )
127 yitem->setData(
this );
132 virtual void SetLabel(
const NClabel & ) { ; }
136 NCTableLine::STATE linestate,
137 unsigned colidx )
const 139 NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
143 setBkgd( w, tableStyle, linestate, DATA );
144 w.
addch( at.Pos.L, at.Pos.C + 1,
'x' );
148 void SetSelected(
const bool sel ) { selected = sel; }
150 bool Selected()
const {
return selected; }
152 YItem *origItem() {
return yitem; }
158 friend std::ostream & operator<<( std::ostream & STREAM,
const NCTablePad & OBJ );
171 std::vector<NCTableLine*> Items;
174 std::unique_ptr<NCTableSortStrategyBase> sortStrategy;
176 void assertLine(
unsigned idx );
180 void DirtyFormat() { dirty = dirtyFormat =
true; }
182 virtual wsze UpdateFormat();
184 virtual int dirtyPad() {
return setpos( CurPos() ); }
186 virtual int setpos(
const wpos & newpos );
187 virtual int DoRedraw();
188 virtual void updateScrollHint();
199 virtual void wRecoded();
201 virtual wpos CurPos()
const;
202 virtual bool handleInput( wint_t key );
204 bool setItemByKey(
int key );
208 return dirtyFormat ? UpdateFormat()
209 :
wsze( Lines(), ItemStyle.TableWidth() );
212 void setOrder(
int column,
bool do_reverse =
false );
216 bool SetHeadline(
const std::vector<NCstring> & head );
218 virtual void SendHead()
220 SetHead( Headpad, srect.Pos.C );
224 void SetSepChar(
const chtype colSepchar )
226 ItemStyle.SetSepChar( colSepchar );
229 void SetSepWidth(
const unsigned sepwidth )
231 ItemStyle.SetSepWidth( sepwidth );
234 void SetHotCol(
const int hcol )
236 ItemStyle.SetHotCol( hcol );
239 unsigned Cols()
const {
return ItemStyle.Cols(); }
241 unsigned Lines()
const {
return Items.size(); }
243 unsigned HotCol()
const {
return ItemStyle.HotCol(); }
245 void SetLines(
unsigned idx );
246 void SetLines( std::vector<NCTableLine*> & nItems );
247 void ClearTable() { SetLines( 0 ); }
249 void Append(
NCTableLine * item ) { AddLine( Lines(), item ); }
251 void Append( std::vector<NCTableCol*> & nItems,
int index = -1 )
253 AddLine( Lines(),
new NCTableLine( nItems, index ) );
257 void DelLine(
unsigned idx );
266 if ( newSortStrategy != 0 )
267 sortStrategy.reset ( newSortStrategy );
272 #endif // NCTablePad_h
static int lines()
Number of lines on terminal, not window.
static int cols()
Number of cols on terminal, not window.
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