Skip to content

Commit

Permalink
handle `invertAutoEnable correctly (bnc #805407)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabi2 committed May 28, 2013
1 parent 5fc6fb7 commit 7cf6a55
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/NCCheckBoxFrame.cc
Expand Up @@ -41,12 +41,9 @@ NCCheckBoxFrame::NCCheckBoxFrame( YWidget * parent, const std::string & nlabel,
setLabel( YCheckBoxFrame::label() );
hotlabel = &label;

if ( invertAutoEnable() )
setValue( !checked );
else
setValue( checked );
setValue( checked );

// setEnabled() is called in wRedraw()
// setEnabled( getValue() ); is called in wRedraw()
}


Expand Down Expand Up @@ -112,9 +109,15 @@ bool NCCheckBoxFrame::getParentValue( NCWidget * widget, bool initial )
{
enabled = frame->getValue();

// invert value if required
if ( frame->invertAutoEnable() )
enabled = !enabled;

// despite of frame->getValue(), don't enable child widgets if state
// of frame is NC::WSdisabeled
if ( frame->GetState() == NC::WSdisabeled )
enabled = false;

break;
}
}
Expand All @@ -125,7 +128,7 @@ void NCCheckBoxFrame::setEnabled( bool do_bv )
{
YWidget::setEnabled( do_bv );
bool do_it = do_bv;

for ( tnode<NCWidget*> * c = this->Next();
c && c->IsDescendantOf( this );
c = c->Next() )
Expand Down Expand Up @@ -180,20 +183,10 @@ void NCCheckBoxFrame::wRedraw()
win->bkgdset( style.plain );
win->printw( 0, 1, "[ ] " );

if ( !invertAutoEnable() )
{
if ( getValue() )
win->printw( 0, 2, "%c", 'x' );
else
win->printw( 0, 2, "%c", ' ' );
}
if ( getValue() )
win->printw( 0, 2, "%c", 'x' );
else
{
if ( getValue() )
win->printw( 0, 2, "%c", ' ' );
else
win->printw( 0, 2, "%c", 'x' );
}
win->printw( 0, 2, "%c", ' ' );

if ( autoEnable() )
setEnabled( getValue() );
Expand Down

0 comments on commit 7cf6a55

Please sign in to comment.