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();
87 int result = std::wcscoll ( w1.data(), w2.data() );
89 return ( result < 0 );
108 NCTableTag( YItem *item,
const bool sel =
false )
114 yitem->setData(
this );
119 virtual void SetLabel(
const NCstring & ) { ; }
123 NCTableLine::STATE linestate,
124 unsigned colidx )
const
126 NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
130 setBkgd( w, tableStyle, linestate, DATA );
131 w.
addch( at.Pos.L, at.Pos.C + 1,
'x' );
135 void SetSelected(
const bool sel ) { selected = sel; }
137 bool Selected()
const {
return selected; }
139 YItem *origItem() {
return yitem; }
145 friend std::ostream & operator<<( std::ostream & STREAM,
const NCTablePad & OBJ );
158 std::vector<NCTableLine*> Items;
161 std::auto_ptr<NCTableSortStrategyBase> sortStrategy;
163 void assertLine(
unsigned idx );
167 void DirtyFormat() { dirty = dirtyFormat =
true; }
169 virtual wsze UpdateFormat();
171 virtual int dirtyPad() {
return setpos( CurPos() ); }
173 virtual int setpos(
const wpos & newpos );
174 virtual int DoRedraw();
175 virtual void updateScrollHint();
186 virtual void wRecoded();
188 virtual wpos CurPos()
const;
189 virtual bool handleInput( wint_t key );
191 bool setItemByKey(
int key );
195 return dirtyFormat ? UpdateFormat()
196 :
wsze( Lines(), ItemStyle.TableWidth() );
199 void setOrder(
int column,
bool do_reverse =
false );
203 bool SetHeadline(
const std::vector<NCstring> & head );
205 virtual void SendHead()
207 SetHead( Headpad, srect.Pos.C );
211 void SetSepChar(
const chtype colSepchar )
213 ItemStyle.SetSepChar( colSepchar );
216 void SetSepWidth(
const unsigned sepwidth )
218 ItemStyle.SetSepWidth( sepwidth );
221 void SetHotCol(
const int hcol )
223 ItemStyle.SetHotCol( hcol );
226 unsigned Cols()
const {
return ItemStyle.Cols(); }
228 unsigned Lines()
const {
return Items.size(); }
230 unsigned HotCol()
const {
return ItemStyle.HotCol(); }
232 void SetLines(
unsigned idx );
233 void SetLines( std::vector<NCTableLine*> & nItems );
234 void ClearTable() { SetLines( 0 ); }
236 void Append(
NCTableLine * item ) { AddLine( Lines(), item ); }
238 void Append( std::vector<NCTableCol*> & nItems,
int index = -1 )
240 AddLine( Lines(),
new NCTableLine( nItems, index ) );
244 void DelLine(
unsigned idx );
253 if ( newSortStrategy != 0 )
254 sortStrategy.reset ( newSortStrategy );
259 #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