33 #include <yui/YTableItem.h>
42 friend std::ostream & operator<<( std::ostream & STREAM,
const NCTableLine & OBJ );
60 std::vector<NCTableCol*> Items;
61 void assertCol(
unsigned idx );
78 NCTableLine(
unsigned cols,
int index = -1,
const unsigned s = S_NORMAL );
79 NCTableLine( std::vector<NCTableCol*> & nItems,
int index = -1,
const unsigned s = S_NORMAL );
80 void setOrigItem( YTableItem *it );
81 YTableItem *origItem()
const {
return yitem; }
85 unsigned Cols()
const {
return Items.size(); }
87 void SetCols(
unsigned idx );
88 void SetCols( std::vector<NCTableCol*> & nItems );
89 void ClearLine() { SetCols( 0 ); }
91 std::vector<NCTableCol*> GetItems()
const {
return Items; }
93 void Append(
NCTableCol * item ) { AddCol( Cols(), item ); }
95 void AddCol(
unsigned idx,
NCTableCol * item );
96 void DelCol(
unsigned idx );
99 const NCTableCol * GetCol(
unsigned idx )
const
101 return const_cast<NCTableLine*
>( this )->GetCol( idx );
104 void SetState(
const STATE s ) { state |= s; }
106 void ClearState(
const STATE s ) { state &= ~s; }
108 bool isHidden()
const {
return ( state & S_HIDDEN ); }
110 bool isDisabeled()
const {
return ( state & S_DISABELED ); }
112 bool isSpecial()
const {
return ( state & ( S_HIDDEN | S_DISABELED ) ); }
114 bool isActive()
const {
return ( state & S_ACTIVE ); }
116 virtual bool isVisible()
const {
return !isHidden(); }
118 virtual bool isEnabeled()
const {
return isVisible() && !isDisabeled(); }
120 int getIndex()
const {
return index; }
124 virtual int handleInput( wint_t key ) {
return 0; }
126 virtual int ChangeToVisible() {
return 0; }
128 virtual unsigned Hotspot(
unsigned & at )
const { at = 0;
return 0; }
144 friend std::ostream & operator<<( std::ostream & STREAM,
const NCTableCol & OBJ );
168 const NClabel & Label()
const {
return label; }
170 virtual void SetLabel(
const NClabel & l ) { label = l; }
172 void stripHotkey() { label.stripHotkey(); }
178 NCTableLine::STATE linestate,
179 STYLE colstyle )
const ;
183 virtual wsze Size()
const {
return wsze( 1, label.width() ); }
187 NCTableLine::STATE linestate,
188 unsigned colidx )
const;
190 bool hasHotkey()
const {
return label.hasHotkey(); }
192 unsigned char hotkey()
const {
return label.hotkey(); }
220 friend std::ostream & operator<<( std::ostream & STREAM,
const NCTableStyle & OBJ );
225 std::vector<unsigned> colWidth;
226 std::vector<NC::ADJUST> colAdjust;
230 unsigned colSepwidth;
236 static const chtype currentBG = ( chtype ) - 1;
241 bool SetStyleFrom(
const std::vector<NCstring> & head );
242 void SetSepChar(
const chtype sepchar ) { colSepchar = sepchar; }
244 void SetSepWidth(
const unsigned sepwidth ) { colSepwidth = sepwidth; }
246 void SetHotCol(
const int hcol )
248 hotCol = ( hcol < 0 || Cols() <= ( unsigned )hcol ) ? -1 : hcol;
251 void ResetToMinCols()
254 AssertMinCols( headline.Cols() );
255 headline.UpdateFormat( *
this );
258 void AssertMinCols(
unsigned num )
260 if ( colWidth.size() < num )
262 colWidth.resize( num, 0 );
263 colAdjust.resize( colWidth.size(), NC::LEFT );
267 void MinColWidth(
unsigned num,
unsigned val )
269 AssertMinCols( num );
271 if ( val > colWidth[num] )
275 NC::ADJUST ColAdjust(
unsigned num )
const {
return colAdjust[num]; }
277 unsigned Cols()
const {
return colWidth.size(); }
279 unsigned ColWidth(
unsigned num )
const {
return colWidth[num]; }
281 unsigned ColSepwidth()
const {
return colSepwidth; }
283 chtype ColSepchar()
const {
return colSepchar; }
285 unsigned HotCol()
const {
return hotCol; }
289 chtype getBG()
const {
return listStyle().item.plain; }
291 chtype getBG(
const NCTableLine::STATE lstate,
292 const NCTableCol::STYLE cstyle = NCTableCol::PLAIN )
const;
294 chtype highlightBG(
const NCTableLine::STATE lstate,
295 const NCTableCol::STYLE cstyle,
296 const NCTableCol::STYLE dstyle = NCTableCol::PLAIN )
const ;
298 chtype hotBG(
const NCTableLine::STATE lstate,
unsigned colidx )
const
300 return ( colidx == hotCol ) ? getBG( lstate, NCTableCol::HINT ) : currentBG;
303 const NCTableLine & Headline()
const {
return headline; }
305 unsigned TableWidth()
const
309 for (
unsigned i = 0; i < Cols(); ++i )
310 twidth += colWidth[i];
313 twidth += colSepwidth * ( Cols() - 1 );
320 #endif // NCTableItem_h