25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
27 #include "NCPadWidget.h"
52 enum orientation { HORZ, VERT };
76 if ( visible > total )
82 if ( at + visible > total )
90 void draw_line(
unsigned p,
unsigned l, chtype ch = 0 )
96 win->
hline( 0, p, l, ch );
98 win->
vline( p, 0, l, ch );
101 void draw_bar(
unsigned p,
unsigned l )
109 win->
addch( 0, p, ch_barone );
111 win->
addch( p, 0, ch_barone );
116 unsigned e = p + l - 1;
122 win->
addch( 0, p, ch_barbeg );
123 win->
addch( 0, e, ch_barend );
126 win->
hline( 0, p + 1, l );
130 win->
addch( p, 0, ch_barbeg );
131 win->
addch( e, 0, ch_barend );
134 win->
vline( p + 1, 0, l );
143 bool topvis = ( at == 0 );
145 bool botvis = ( at + visible == total );
153 if ( topvis && botvis )
164 if ( topvis == botvis )
167 win->
addch( 0, 0, ch_barone );
171 win->
addch( 0, 0, ( topvis ? ch_forward : ch_backward ) );
180 win->
addch( 0, 0, ch_backward );
194 if ( visible + 1 == total )
202 blen = ( visible * ( len - 2 ) / total ) + 1;
204 if ( topvis == botvis )
207 bat = ( at * ( len - 2 ) / total ) + 1;
211 bat = ( topvis ? 0 : len - blen );
219 draw_bar( bat, blen );
234 : ch_forward( orient == HORZ ? ACS_RARROW : ACS_DARROW )
235 , ch_backward( orient == HORZ ? ACS_LARROW : ACS_UARROW )
236 , ch_barbeg( orient == HORZ ? ACS_LTEE : ACS_TTEE )
237 , ch_barend( orient == HORZ ? ACS_RTEE : ACS_BTEE )
238 , ch_barone( orient == HORZ ? ACS_VLINE : ACS_HLINE )
250 ( type == HORZ ? 1 : len ),
251 ( type == VERT ? 1 : len ),
255 catch ( NCursesException & err )
276 void set(
unsigned tot,
unsigned vis,
unsigned start )
290 NCPadWidget::NCPadWidget(
NCWidget * myparent )
297 , hasHeadline( false )
298 , activeLabelOnly( false )
302 defsze =
wsze( 3, 10 ) + 2;
306 NCPadWidget::NCPadWidget( YWidget * myparent )
313 , hasHeadline( false )
314 , activeLabelOnly( false )
318 defsze =
wsze( 3, 10 ) + 2;
322 NCPadWidget::~NCPadWidget()
333 void NCPadWidget::wCreate(
const wrect & newrect )
337 NCWidget::wCreate( newrect );
341 wrect padrect( newrect.inside() );
345 if ( padrect.Sze.H > 1 )
355 padrect.Sze.H, padrect.Sze.W,
356 padrect.Pos.L, padrect.Pos.C,
394 void NCPadWidget::wDelete()
420 void NCPadWidget::InitPad()
432 void NCPadWidget::AdjustPadSize(
wsze & minsze )
435 minsze = wsze::max( minsze, defPadSze() );
439 void NCPadWidget::AdjustPad(
wsze nsze )
448 void NCPadWidget::DelPad()
455 void NCPadWidget::setLabel(
const NClabel & nlabel )
463 void NCPadWidget::wRedraw()
476 if ( !activeLabelOnly || GetState() == NC::WSactive )
477 label.drawAt( *
win, style,
wpos( 0, 1 ),
482 if ( !pad->Destwin() )
484 AdjustPad( minPadSze );
485 pad->Destwin( padwin );
496 void NCPadWidget::wRecoded()
511 hsb->
set( total, visible, start );
522 vsb->
set( total, visible, start );
527 void NCPadWidget::ScrollHead(
NCursesWindow & w,
unsigned ccol )
529 if ( hasHeadline &&
win )
536 NCPad * NCPadWidget::CreatePad()
538 wsze psze( defPadSze() );
539 NCPad * npad =
new NCPad( psze.H, psze.W, *
this );
540 npad->
bkgd( wStyle().list.item.plain );
546 void NCPadWidget::DrawPad()
548 if ( pad && !inMultidraw() )
556 bool NCPadWidget::handleInput( wint_t key )
558 return pad->handleInput( key );