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.data(), &endptr1, 10 );
89 long int number2 = std::wcstol( w2.data(), &endptr2, 10 );
92 if ( w1.data() != endptr1 && w2.data() != endptr2 )
94 return number1 < number2;
98 int result = std::wcscoll ( w1.data(), w2.data() );
123 NCTableTag( YItem *item,
const bool sel =
false )
129 yitem->setData(
this );
134 virtual void SetLabel(
const NCstring & ) { ; }
138 NCTableLine::STATE linestate,
139 unsigned colidx )
const
141 NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
145 setBkgd( w, tableStyle, linestate, DATA );
146 w.
addch( at.Pos.L, at.Pos.C + 1,
'x' );
150 void SetSelected(
const bool sel ) { selected = sel; }
152 bool Selected()
const {
return selected; }
154 YItem *origItem() {
return yitem; }
160 friend std::ostream & operator<<( std::ostream & STREAM,
const NCTablePad & OBJ );
173 std::vector<NCTableLine*> Items;
176 std::auto_ptr<NCTableSortStrategyBase> sortStrategy;
178 void assertLine(
unsigned idx );
182 void DirtyFormat() { dirty = dirtyFormat =
true; }
184 virtual wsze UpdateFormat();
186 virtual int dirtyPad() {
return setpos( CurPos() ); }
188 virtual int setpos(
const wpos & newpos );
189 virtual int DoRedraw();
190 virtual void updateScrollHint();
201 virtual void wRecoded();
203 virtual wpos CurPos()
const;
204 virtual bool handleInput( wint_t key );
206 bool setItemByKey(
int key );
210 return dirtyFormat ? UpdateFormat()
211 :
wsze( Lines(), ItemStyle.TableWidth() );
214 void setOrder(
int column,
bool do_reverse =
false );
218 bool SetHeadline(
const std::vector<NCstring> & head );
220 virtual void SendHead()
222 SetHead( Headpad, srect.Pos.C );
226 void SetSepChar(
const chtype colSepchar )
228 ItemStyle.SetSepChar( colSepchar );
231 void SetSepWidth(
const unsigned sepwidth )
233 ItemStyle.SetSepWidth( sepwidth );
236 void SetHotCol(
const int hcol )
238 ItemStyle.SetHotCol( hcol );
241 unsigned Cols()
const {
return ItemStyle.Cols(); }
243 unsigned Lines()
const {
return Items.size(); }
245 unsigned HotCol()
const {
return ItemStyle.HotCol(); }
247 void SetLines(
unsigned idx );
248 void SetLines( std::vector<NCTableLine*> & nItems );
249 void ClearTable() { SetLines( 0 ); }
251 void Append(
NCTableLine * item ) { AddLine( Lines(), item ); }
253 void Append( std::vector<NCTableCol*> & nItems,
int index = -1 )
255 AddLine( Lines(),
new NCTableLine( nItems, index ) );
259 void DelLine(
unsigned idx );
268 if ( newSortStrategy != 0 )
269 sortStrategy.reset ( newSortStrategy );
274 #endif // NCTablePad_h
virtual void directDraw(NCursesWindow &w, const wrect at, unsigned lineno)