Author: gs Date: Thu Sep 6 14:35:49 2007 New Revision: 40783 URL: http://svn.opensuse.org/viewcvs/yast?rev=40783&view=rev Log: selectedItem() added Modified: branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc branches/tmp/sh/mod-ui/ncurses/src/NCTree.h Modified: branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc?rev=40783&r1=40782&r2=40783&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc (original) +++ branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc Thu Sep 6 14:35:49 2007 @@ -242,23 +242,25 @@ /////////////////////////////////////////////////////////////////// // // -// METHOD NAME : NCTree::nicesize -// METHOD TYPE : long +// METHOD NAME : NCTree::preferredWidth +// METHOD TYPE : int // // DESCRIPTION : // -long NCTree::nicesize( YUIDimension dim ) -{ - wsze sze = wsze::max( defsze, wsze( 0, labelWidht()+2 ) ); - return dim == YD_HORIZ ? sze.W : sze.H; -} - int NCTree::preferredWidth() { wsze sze = wsze::max( defsze, wsze( 0, labelWidht()+2 ) ); return sze.W; } +/////////////////////////////////////////////////////////////////// +// +// +// METHOD NAME : NCTree::preferredHeight +// METHOD TYPE : int +// +// DESCRIPTION : +// int NCTree::preferredHeight() { wsze sze = wsze::max( defsze, wsze( 0, labelWidht()+2 ) ); @@ -268,7 +270,8 @@ void NCTree::setEnabled( bool do_bv ) { NCWidget::setEnabled( do_bv ); - YTree::setEnabled( do_bv ); + //YTree::setEnabled( do_bv ); + YWidget::setEnabled( do_bv ); } /////////////////////////////////////////////////////////////////// @@ -328,6 +331,25 @@ } } +void NCTree::selectItem( YItem *item, bool selected ) +{ + if ( !myPad() ) + return; + + if ( selected ) + { + for ( unsigned i = 0; i < myPad()->Lines(); ++i ) { + const NCTreeLine * cline = getTreeLine( i ); + if ( &cline->Yitem() == (YTreeItem *)item ) { + NCMIL << "got " << item->label() << " at " << i << endl; + myPad()->ShowItem( cline ); + break; + } + } + YTree::selectItem( item, selected ); + } +} + /////////////////////////////////////////////////////////////////// // // @@ -425,10 +447,13 @@ if ( ! handleInput( key ) ) { switch ( key ) { - case KEY_SPACE: + case KEY_SPACE: // KEY_SPACE is handled in NCTreeLine::handleInput case KEY_RETURN: if ( notify() ) + { + NCDBG << "Return: NCursesEvent::Activated" << endl; return NCursesEvent::Activated; + } break; } } @@ -436,6 +461,7 @@ if ( notify() && oldCurrentItem != getCurrentItem() ) ret = NCursesEvent::SelectionChanged; + NCDBG << "Notify: " << (notify()?"true":"false") << " Return event: " << ret << endl; return ret; } Modified: branches/tmp/sh/mod-ui/ncurses/src/NCTree.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCTree.h?rev=40783&r1=40782&r2=40783&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/NCTree.h (original) +++ branches/tmp/sh/mod-ui/ncurses/src/NCTree.h Thu Sep 6 14:35:49 2007 @@ -68,8 +68,6 @@ NCTree( YWidget * parent, const string & label ); virtual ~NCTree(); - virtual long nicesize( YUIDimension dim ); - virtual int preferredWidth(); virtual int preferredHeight(); @@ -86,6 +84,8 @@ virtual const YTreeItem * getCurrentItem() const; virtual void setCurrentItem( YTreeItem * it ); + virtual void selectItem( YItem *item, bool selected ); + 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