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 )
306 NCWidget::wCreate( newrect );
310 wrect padrect( newrect.inside() );
314 if ( padrect.Sze.H > 1 )
325 padrect.Sze.H, padrect.Sze.W,
326 padrect.Pos.L, padrect.Pos.C,
334 if(win->
width() - bsize)
364 void NCPadWidget::wDelete()
390 void NCPadWidget::InitPad()
396 pad->SendSchrollCB(
this );
402 void NCPadWidget::AdjustPadSize(
wsze & minsze )
405 minsze = wsze::max( minsze, defPadSze() );
409 void NCPadWidget::AdjustPad(
wsze nsze )
418 void NCPadWidget::DelPad()
425 void NCPadWidget::setLabel(
const NClabel & nlabel )
433 void NCPadWidget::wRedraw()
438 yuiDebug() <<
"wRedraw called for: " << win << std::endl;
446 if ( !activeLabelOnly || GetState() == NC::WSactive )
447 label.drawAt( *win, style,
wpos( 0, 1 ),
448 wsze( 1, win->
width() - 2 ), NC::TOPLEFT,
false );
452 if ( !pad->Destwin() )
454 AdjustPad( minPadSze );
455 pad->Destwin( padwin );
466 void NCPadWidget::wRecoded()
475 void NCPadWidget::HScroll(
unsigned total,
unsigned visible,
unsigned start )
481 hsb->set( total, visible, start );
486 void NCPadWidget::VScroll(
unsigned total,
unsigned visible,
unsigned start )
492 vsb->set( total, visible, start );
497 void NCPadWidget::ScrollHead(
NCursesWindow & w,
unsigned ccol )
499 if ( hasHeadline && win )
501 w.
copywin( *win, 0, ccol, 1, 1, 1, win->
width() - 2,
false );
506 NCPad * NCPadWidget::CreatePad()
508 wsze psze( defPadSze() );
509 NCPad * npad =
new NCPad( psze.H, psze.W, *
this );
510 npad->
bkgd( wStyle().list.item.plain );
516 void NCPadWidget::DrawPad()
518 if ( pad && !inMultidraw() )
526 bool NCPadWidget::handleInput( wint_t key )
528 return pad->handleInput( key );