[yast-commit] r40828 - in /branches/tmp/sh/mod-ui/ncurses/src: NCSelectionBox.cc NCSelectionBox.h

Author: gs Date: Mon Sep 10 12:35:55 2007 New Revision: 40828 URL: http://svn.opensuse.org/viewcvs/yast?rev=40828&view=rev Log: add selectItem() Modified: branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.cc branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.h Modified: branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCSe... ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.cc (original) +++ branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.cc Mon Sep 10 12:35:55 2007 @@ -31,12 +31,10 @@ : YSelectionBox( parent, nlabel ) , NCPadWidget( parent ) , biglist( false ) - , immediate( false ) { WIDDBG << endl; InitPad(); setLabel( nlabel ); - immediate = immediateMode(); } /////////////////////////////////////////////////////////////////// @@ -95,7 +93,7 @@ { if ( !myPad()->Lines() ) return -1; - NCMIL << "Current pos: " << myPad()->CurPos().L << endl; + NCDBG << "Current pos: " << myPad()->CurPos().L << endl; return myPad()->CurPos().L; } @@ -146,6 +144,42 @@ /////////////////////////////////////////////////////////////////// // // +// METHOD NAME : NCSelectionBox::selectItem +// METHOD TYPE : void +// +// DESCRIPTION : +// +void NCSelectionBox::selectItem( YItem *item, bool selected ) +{ + NCDBG << "Select item (YItem *, bool) called" << endl; + YSelectionBox::selectItem( item, selected ); + myPad()->ScrlLine( selected ? item->index() : -1 ); +} + +void NCSelectionBox::selectItem( int index ) +{ + NCDBG << "Select item (index) called" << endl; + YSelectionBox::deselectAllItems(); + YItem * item = YSelectionBox::itemAt( index ); + + if ( item ) + { +#ifdef VERBOSE_SELECTION + y2debug( "%s \"%s\": Selecting item \"%s\"", + widgetClass(), + debugLabel().c_str(), + item->label().c_str() ); +#endif + + item->setSelected( true ); + } + else + YUI_THROW( YUIException( "Can't find selected item" ) ); +} + +/////////////////////////////////////////////////////////////////// +// +// // METHOD NAME : NCSelectionBox::itemAdded // METHOD TYPE : void // @@ -243,7 +277,7 @@ NCursesEvent ret = NCursesEvent::none; int citem = getCurrentItem(); - + // handle key event first if ( sendKeyEvents() && (key == KEY_LEFT || key == KEY_RIGHT)) @@ -263,15 +297,18 @@ // call handleInput of NCPad handleInput( key ); + selectItem( getCurrentItem() ); + switch ( key ) { case KEY_SPACE: case KEY_RETURN: if ( notify() && citem != -1 ) + { return NCursesEvent::Activated; + } break; } - - if ( notify() && immediate && citem != getCurrentItem() ) { + if ( notify() && immediateMode() && citem != getCurrentItem() ) { ret = NCursesEvent::SelectionChanged; } Modified: branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCSe... ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.h (original) +++ branches/tmp/sh/mod-ui/ncurses/src/NCSelectionBox.h Mon Sep 10 12:35:55 2007 @@ -49,7 +49,6 @@ { return dynamic_cast<NCTablePad*> ( NCPadWidget::myPad () ); } bool biglist; - bool immediate; protected: @@ -85,6 +84,9 @@ virtual int getCurrentItem(); virtual void setCurrentItem( int index ); + virtual void selectItem( YItem *item, bool selected ); + virtual void selectItem( int index ); + virtual NCursesEvent wHandleInput( wint_t key ); virtual void setEnabled( bool do_bv ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn.opensuse.org