25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
28 #include "NCCheckBox.h"
29 #include "YNCursesUI.h"
32 unsigned char NCCheckBox::statetag[3] = {
'?',
' ',
'x' };
35 NCCheckBox::NCCheckBox( YWidget * parent,
36 const std::string & nlabel,
38 : YCheckBox( parent, nlabel )
41 , checkstate( checked ? S_ON : S_OFF )
43 yuiDebug() << std::endl;
49 NCCheckBox::~NCCheckBox()
51 yuiDebug() << std::endl;
55 int NCCheckBox::preferredWidth()
57 return wGetDefsze().W;
61 int NCCheckBox::preferredHeight()
63 return wGetDefsze().H;
70 YCheckBox::setEnabled( do_bv );
74 void NCCheckBox::setSize(
int newwidth,
int newheight )
76 wRelocate(
wpos( 0 ),
wsze( newheight, newwidth ) );
80 void NCCheckBox::setLabel(
const std::string & nlabel )
84 defsze =
wsze( label.height(), label.width() + 4 );
85 YCheckBox::setLabel( nlabel );
90 void NCCheckBox::setValue( YCheckBoxState state )
92 YCheckBoxState old = value();
106 case YCheckBox_dont_care:
115 if (old != state && notify())
124 YCheckBoxState NCCheckBox::value()
126 if ( checkstate == S_DC )
127 return YCheckBox_dont_care;
129 if ( checkstate == S_ON )
132 return YCheckBox_off;
136 void NCCheckBox::wRedraw()
145 win->
printw( 0, 0,
"[ ] " );
147 label.drawAt( *win, style,
wpos( 0, 4 ) );
151 win->
printw( 0, 1,
"%c", statetag[checkstate] );
165 switch ( checkstate )
176 checkstate = tristate ? S_DC : S_ON;
183 ret = NCursesEvent::ValueChanged;
virtual void setEnabled(bool do_bv)
Pure virtual to make sure every widget implements it.
int printw(const char *fmt,...)
Do a formatted print to the window.
void bkgdset(chtype ch)
Set the background property.
void sendEvent(NCursesEvent event)
Send an event to the UI.
static YNCursesUI * ui()
Access the global Y2NCursesUI.