[yast-commit] r40828 - in /branches/tmp/sh/mod-ui/ncurses/src: NCSelectionBox.cc NCSelectionBox.h
![](https://seccdn.libravatar.org/avatar/9d45ad4c714db4d170a42527a4a6b8dc.jpg?s=120&d=mm&r=g)
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/NCSelectionBox.cc?rev=40828&r1=40827&r2=40828&view=diff
==============================================================================
--- 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/NCSelectionBox.h?rev=40828&r1=40827&r2=40828&view=diff
==============================================================================
--- 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
participants (1)
-
gs@svn.opensuse.org