33 #include <yui/YTableItem.h>
42 friend std::ostream & operator<<( std::ostream & str,
const NCTableLine & obj );
61 std::vector<NCTableCol*> Items;
63 void assertCol(
unsigned idx );
83 NCTableLine(
unsigned cols,
int index = -1,
const unsigned s = S_NORMAL );
84 NCTableLine( std::vector<NCTableCol*> & nItems,
int index = -1,
const unsigned s = S_NORMAL );
85 void setOrigItem( YTableItem *it );
86 YTableItem *origItem()
const {
return yitem; }
90 unsigned Cols()
const {
return Items.size(); }
92 void SetCols(
unsigned idx );
93 void SetCols( std::vector<NCTableCol*> & nItems );
94 void ClearLine() { SetCols( 0 ); }
96 std::vector<NCTableCol*> GetItems()
const {
return Items; }
98 void Append(
NCTableCol * item ) { AddCol( Cols(), item ); }
100 void AddCol(
unsigned idx,
NCTableCol * item );
101 void DelCol(
unsigned idx );
104 const NCTableCol * GetCol(
unsigned idx )
const
106 return const_cast<NCTableLine*
>( this )->GetCol( idx );
109 void SetState(
const STATE s ) { state |= s; }
111 void ClearState(
const STATE s ) { state &= ~s; }
113 bool isHidden()
const {
return ( state & S_HIDDEN ); }
115 bool isDisabeled()
const {
return ( state & S_DISABELED ); }
117 bool isSpecial()
const {
return ( state & ( S_HIDDEN | S_DISABELED ) ); }
119 bool isActive()
const {
return ( state & S_ACTIVE ); }
121 virtual bool isVisible()
const {
return !isHidden(); }
123 virtual bool isEnabeled()
const {
return isVisible() && !isDisabeled(); }
125 int getIndex()
const {
return index; }
129 virtual int handleInput( wint_t key ) {
return 0; }
131 virtual int ChangeToVisible() {
return 0; }
133 virtual unsigned Hotspot(
unsigned & at )
const { at = 0;
return 0; }
149 friend std::ostream & operator<<( std::ostream & str,
const NCTableCol & obj );
173 const NClabel & Label()
const {
return label; }
175 virtual void SetLabel(
const NClabel & l ) { label = l; }
177 void stripHotkey() { label.stripHotkey(); }
183 NCTableLine::STATE linestate,
184 STYLE colstyle )
const ;
188 virtual wsze Size()
const {
return wsze( 1, label.width() ); }
192 NCTableLine::STATE linestate,
193 unsigned colidx )
const;
195 bool hasHotkey()
const {
return label.hasHotkey(); }
197 unsigned char hotkey()
const {
return label.hotkey(); }
225 friend std::ostream & operator<<( std::ostream & str,
const NCTableStyle & obj );
230 std::vector<unsigned> colWidth;
231 std::vector<NC::ADJUST> colAdjust;
235 unsigned colSepwidth;
241 static const chtype currentBG = ( chtype ) - 1;
246 bool SetStyleFrom(
const std::vector<NCstring> & head );
247 void SetSepChar(
const chtype sepchar ) { colSepchar = sepchar; }
249 void SetSepWidth(
const unsigned sepwidth ) { colSepwidth = sepwidth; }
251 void SetHotCol(
int hcol )
253 hotCol = ( hcol < 0 || Cols() <= ( unsigned )hcol ) ? -1 : hcol;
256 void ResetToMinCols()
259 AssertMinCols( headline.Cols() );
260 headline.UpdateFormat( *
this );
263 void AssertMinCols(
unsigned num )
265 if ( colWidth.size() < num )
267 colWidth.resize( num, 0 );
268 colAdjust.resize( colWidth.size(), NC::LEFT );
272 void MinColWidth(
unsigned num,
unsigned val )
274 AssertMinCols( num );
276 if ( val > colWidth[num] )
280 NC::ADJUST ColAdjust(
unsigned num )
const {
return colAdjust[num]; }
282 unsigned Cols()
const {
return colWidth.size(); }
284 unsigned ColWidth(
unsigned num )
const {
return colWidth[num]; }
286 unsigned ColSepwidth()
const {
return colSepwidth; }
288 chtype ColSepchar()
const {
return colSepchar; }
290 unsigned HotCol()
const {
return hotCol; }
294 chtype getBG()
const {
return listStyle().item.plain; }
296 chtype getBG(
const NCTableLine::STATE lstate,
297 const NCTableCol::STYLE cstyle = NCTableCol::PLAIN )
const;
299 chtype highlightBG(
const NCTableLine::STATE lstate,
300 const NCTableCol::STYLE cstyle,
301 const NCTableCol::STYLE dstyle = NCTableCol::PLAIN )
const ;
303 chtype hotBG(
const NCTableLine::STATE lstate,
unsigned colidx )
const
305 return ( colidx == hotCol ) ? getBG( lstate, NCTableCol::HINT ) : currentBG;
308 const NCTableLine & Headline()
const {
return headline; }
310 unsigned TableWidth()
const
314 for (
unsigned i = 0; i < Cols(); ++i )
315 twidth += colWidth[i];
318 twidth += colSepwidth * ( Cols() - 1 );