25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
28 #include "NCCheckBoxFrame.h"
31 NCCheckBoxFrame::NCCheckBoxFrame( YWidget * parent,
const std::string & nlabel,
33 : YCheckBoxFrame( parent, nlabel, checked )
36 yuiDebug() << std::endl;
37 wstate = NC::WSnormal;
38 framedim.Pos =
wpos( 1 );
39 framedim.Sze =
wsze( 2 );
41 setLabel( YCheckBoxFrame::label() );
50 NCCheckBoxFrame::~NCCheckBoxFrame()
52 yuiDebug() << std::endl;
56 int NCCheckBoxFrame::preferredWidth()
58 defsze.W = hasChildren() ? firstChild()->preferredWidth() : 0;
60 if ( label.width() > ( unsigned )defsze.W )
61 defsze.W = label.width();
63 defsze.W += framedim.Sze.W + 4;
69 int NCCheckBoxFrame::preferredHeight()
71 defsze.H = hasChildren() ? firstChild()->preferredHeight() : 0;
72 defsze.H += framedim.Sze.H;
78 void NCCheckBoxFrame::setSize(
int newwidth,
int newheight )
80 wsze csze( newheight, newwidth );
81 wRelocate(
wpos( 0 ), csze );
82 csze = wsze::max( 0, csze - framedim.Sze );
85 firstChild()->setSize( csze.W, csze.H );
89 void NCCheckBoxFrame::setLabel(
const std::string & nlabel )
91 YCheckBoxFrame::setLabel( nlabel );
93 label =
NCstring( YCheckBoxFrame::label() );
99 bool NCCheckBoxFrame::getParentValue(
NCWidget * widget,
bool initial )
101 bool enabled = initial;
104 c && widget->IsDescendantOf( c );
110 enabled = frame->getValue();
113 if ( frame->invertAutoEnable() )
118 if ( frame->GetState() == NC::WSdisabeled )
129 YWidget::setEnabled( do_bv );
133 c && c->IsDescendantOf(
this );
136 if ( c->Value()->GetState() != NC::WSdumb )
138 do_it = getParentValue( c->Value(), do_it );
140 c->Value()->setEnabled( do_it );
142 c->Value()->SetState( do_it ? NC::WSnormal : NC::WSdisabeled,
true );
148 bool NCCheckBoxFrame::gotBuddy()
150 if ( !label.hasHotkey() )
154 c && c->IsDescendantOf(
this );
157 if ( c->Value()->GetState() != NC::WSdumb )
165 void NCCheckBoxFrame::wRedraw()
170 chtype bg = wStyle().dumb.text;
175 label.drawAt( *win, widgetStyle(),
wpos( 0, 5 ),
176 wsze( 1, win->
width() - 6 ), NC::TOPLEFT,
false );
178 label.drawAt( *win, bg, bg,
wpos( 0, 5 ),
179 wsze( 1, win->
width() - 6 ), NC::TOPLEFT,
false );
184 win->
printw( 0, 1,
"[ ] " );
187 win->
printw( 0, 2,
"%c",
'x' );
189 win->
printw( 0, 2,
"%c",
' ' );
196 NCursesEvent NCCheckBoxFrame::wHandleInput( wint_t key )
200 if ( key == KEY_SPACE ||
204 if ( getValue() ==
true )
217 ret = NCursesEvent::ValueChanged;
224 bool NCCheckBoxFrame::setKeyboardFocus()
227 return YWidget::setKeyboardFocus();
233 bool NCCheckBoxFrame::value()
int printw(const char *fmt,...)
int bkgd(const chtype ch)
virtual void setEnabled(bool do_bv)