00001 #include "check_box.h"
00002
00003 namespace crs {
00004 check_box::check_box( base_control *Parent, check_events *Events, const std::string Caption, const bool Checked,
00005 const unsigned int Left, const unsigned int Top, const unsigned int Width,
00006 style::styles Style, chtype clb, chtype crb ):
00007 focused_ctrl( Parent, Events, Left, Top, Width, 1 ), styled_ctrl( Style, clb, crb ),
00008 mChecked(Checked),
00009 mCaption(Caption),
00010 checked( this, &check_box::getChecked, &check_box::setChecked) {
00011 }
00012
00013 void check_box::draw() {
00014 buffer.setText( mCaption, 4, 0 );
00015 buffer[ 0 ] = sc::getLeftBorder( mStyle, custom_left_border );
00016 buffer[ 2 ] = sc::getRightBorder( mStyle, custom_right_border );
00017 if( mChecked )
00018 buffer[ 1 ] = 'x';
00019 else
00020 buffer[ 1 ] = ' ';
00021 }
00022
00023 bool check_box::keyPress( const int key ) {
00024 if( key == 13 || key == ' ' )
00025 mChecked = !mChecked;
00026 return true;
00027 }
00028
00029 const bool &check_box::getChecked() {
00030 return mChecked;
00031 }
00032
00033 void check_box::setChecked( const bool &Checked ) {
00034 mChecked = Checked;
00035 }
00036
00037 }
00038