25 #define YUILogComponent "ncurses" 26 #include <yui/YUILog.h> 27 #include "NCPadWidget.h" 34 enum orientation { HORZ, VERT };
57 if ( visible > total )
59 yuiDebug() <<
"adjust visible " << visible <<
" > total " << total << std::endl;
63 if ( at + visible > total )
65 yuiDebug() <<
"adjust at " << at <<
" + visible " << visible <<
" > total " << total << std::endl;
70 void draw_line(
unsigned p,
unsigned l, chtype ch = 0 )
76 win->
hline( 0, p, l, ch );
78 win->
vline( p, 0, l, ch );
81 void draw_bar(
unsigned p,
unsigned l )
89 win->
addch( 0, p, ch_barone );
91 win->
addch( p, 0, ch_barone );
96 unsigned e = p + l - 1;
102 win->
addch( 0, p, ch_barbeg );
103 win->
addch( 0, e, ch_barend );
106 win->
hline( 0, p + 1, l );
110 win->
addch( p, 0, ch_barbeg );
111 win->
addch( e, 0, ch_barend );
114 win->
vline( p + 1, 0, l );
123 bool topvis = ( at == 0 );
125 bool botvis = ( at + visible == total );
133 if ( topvis && botvis )
144 if ( topvis == botvis )
147 win->
addch( 0, 0, ch_barone );
151 win->
addch( 0, 0, ( topvis ? ch_forward : ch_backward ) );
160 win->
addch( 0, 0, ch_backward );
174 if ( visible + 1 == total )
182 blen = ( visible * ( len - 2 ) / total ) + 1;
184 if ( topvis == botvis )
187 bat = ( at * ( len - 2 ) / total ) + 1;
191 bat = ( topvis ? 0 : len - blen );
199 draw_bar( bat, blen );
209 : ch_forward( orient == HORZ ? ACS_RARROW : ACS_DARROW )
210 , ch_backward( orient == HORZ ? ACS_LARROW : ACS_UARROW )
211 , ch_barbeg( orient == HORZ ? ACS_LTEE : ACS_TTEE )
212 , ch_barend( orient == HORZ ? ACS_RTEE : ACS_BTEE )
213 , ch_barone( orient == HORZ ? ACS_VLINE : ACS_HLINE )
225 ( type == HORZ ? 1 : len ),
226 ( type == VERT ? 1 : len ),
230 catch ( NCursesException & err )
232 yuiDebug() <<
"NCScrollbar: " << err.message
233 <<
": at " << p <<
" len " << len <<
" in " << par << std::endl;
245 void set(
unsigned tot,
unsigned vis,
unsigned start )
259 NCPadWidget::NCPadWidget(
NCWidget * myparent )
266 , hasHeadline( false )
267 , activeLabelOnly( false )
269 yuiDebug() << std::endl;
271 defsze =
wsze( 3, 10 ) + 2;
275 NCPadWidget::NCPadWidget( YWidget * myparent )
282 , hasHeadline( false )
283 , activeLabelOnly( false )
285 yuiDebug() << std::endl;
287 defsze =
wsze( 3, 10 ) + 2;
291 NCPadWidget::~NCPadWidget()
298 yuiDebug() << std::endl;
302 void NCPadWidget::wCreate(
const wrect & newrect )
304 NCWidget::wCreate( newrect );
308 wrect padrect( newrect.inside() );
312 if ( padrect.Sze.H > 1 )
323 padrect.Sze.H, padrect.Sze.W,
324 padrect.Pos.L, padrect.Pos.C,
338 void NCPadWidget::wDelete()
364 void NCPadWidget::InitPad()
370 pad->SendSchrollCB(
this );
376 void NCPadWidget::AdjustPadSize(
wsze & minsze )
379 minsze = wsze::max( minsze, defPadSze() );
383 void NCPadWidget::AdjustPad(
wsze nsze )
392 void NCPadWidget::DelPad()
399 void NCPadWidget::setLabel(
const NClabel & nlabel )
407 void NCPadWidget::wRedraw()
412 yuiDebug() <<
"wRedraw called for: " << win << std::endl;
420 if ( !activeLabelOnly || GetState() == NC::WSactive )
421 label.drawAt( *win, style,
wpos( 0, 1 ),
422 wsze( 1, win->
width() - 2 ), NC::TOPLEFT,
false );
426 if ( !pad->Destwin() )
428 AdjustPad( minPadSze );
429 pad->Destwin( padwin );
440 void NCPadWidget::wRecoded()
449 void NCPadWidget::HScroll(
unsigned total,
unsigned visible,
unsigned start )
451 hsb->set( total, visible, start );
455 void NCPadWidget::VScroll(
unsigned total,
unsigned visible,
unsigned start )
457 vsb->set( total, visible, start );
461 void NCPadWidget::ScrollHead(
NCursesWindow & w,
unsigned ccol )
463 if ( hasHeadline && win )
465 w.
copywin( *win, 0, ccol, 1, 1, 1, win->
width() - 2, false );
470 NCPad * NCPadWidget::CreatePad()
472 wsze psze( defPadSze() );
473 NCPad * npad =
new NCPad( psze.H, psze.W, *
this );
474 npad->
bkgd( wStyle().list.item.plain );
480 void NCPadWidget::DrawPad()
482 if ( pad && !inMultidraw() )
490 bool NCPadWidget::handleInput( wint_t key )
492 return pad->handleInput( key );
int height() const
Number of lines in this window.
int vline(int len, chtype ch=0)
Draw a vertical line of len characters with the given character.
int bkgd(const chtype ch)
Set the background property and apply it to the window.
void bkgdset(chtype ch)
Set the background property.
int box()
Draw a box around the window with the given vertical and horizontal drawing characters.
int hline(int len, chtype ch=0)
Draw a horizontal line of len characters with the given character.
int copywin(NCursesWindow &win, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, bool overlay=TRUE)
Overlay or overwrite the rectangle in win given by dminrow,dmincol, dmaxrow,dmaxcol with the rectangl...
int addch(const char ch)
Put attributed character to the window.
int maxx() const
Largest x coord in window.
int width() const
Number of columns in this window.
int maxy() const
Largest y coord in window.