Author: gs Date: Tue Jul 17 14:59:25 2007 New Revision: 39468 URL: http://svn.opensuse.org/viewcvs/yast?rev=39468&view=rev Log: implement/use text(), setText(), addItem(YItem *) Modified: branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.cc branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.h branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupSearch.cc branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc Modified: branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.cc?rev=39468&r1=39467&r2=39468&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.cc (original) +++ branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.cc Tue Jul 17 14:59:25 2007 @@ -31,12 +31,12 @@ // // DESCRIPTION : // -NCComboBox::NCComboBox( YWidget * parent, const YWidgetOpt & opt, - const YCPString & nlabel ) - : YComboBox( opt, nlabel ) +NCComboBox::NCComboBox( YWidget * parent, const string & nlabel, + bool editable ) + : YComboBox( parent, nlabel, editable ) , NCWidget( parent ) - , mayedit( opt.isEditable.value() ) - , text( "" ) + , mayedit( editable ) + , privText( "" ) , lwin( 0 ) , twin( 0 ) , fldstart ( 0 ) @@ -48,7 +48,7 @@ WIDDBG << endl; setLabel( nlabel ); hotlabel = &label; - setValue( YCPString( string("") ) ); + setValue( "" ); } /////////////////////////////////////////////////////////////////// @@ -66,19 +66,6 @@ WIDDBG << endl; } -/////////////////////////////////////////////////////////////////// -// -// -// METHOD NAME : NCComboBox::nicesize -// METHOD TYPE : long -// -// DESCRIPTION : -// -long NCComboBox::nicesize( YUIDimension dim ) -{ - return dim == YD_HORIZ ? wGetDefsze().W : wGetDefsze().H; -} - int NCComboBox::preferredWidth() { return wGetDefsze().W; @@ -89,6 +76,12 @@ return wGetDefsze().H; } +void NCComboBox::setEnabled( bool do_bv ) +{ + NCWidget::setEnabled( do_bv ); + YComboBox::setEnabled( do_bv ); +} + /////////////////////////////////////////////////////////////////// // // @@ -168,14 +161,7 @@ NCWidget::wDelete(); } -/////////////////////////////////////////////////////////////////// -// -// -// METHOD NAME : NCComboBox::itemAdded -// METHOD TYPE : void -// -// DESCRIPTION : -// +#if 0 void NCComboBox::itemAdded( const YCPString & ntext, int idx, bool selected ) @@ -186,6 +172,30 @@ index = idx; } } +#endif + +/////////////////////////////////////////////////////////////////// +// +// +// METHOD NAME : NCComboBox::addItem +// METHOD TYPE : void +// +// DESCRIPTION : +// +void NCComboBox::addItem( YItem * item ) +{ + if ( item ) + { + YComboBox::addItem( item ); + + deflist.push_back( item->label() ); + if ( item->selected() || index == -1 ) + { + setValue( item->label() ); + index = item->index(); + } + } +} /////////////////////////////////////////////////////////////////// // @@ -195,7 +205,7 @@ // // DESCRIPTION : // -void NCComboBox::setLabel( const YCPString & nlabel ) +void NCComboBox::setLabel( const string & nlabel ) { label = NCstring( nlabel ); label.stripHotkey(); @@ -252,10 +262,23 @@ // // DESCRIPTION : // -void NCComboBox::setValue( const YCPString & ntext ) +void NCComboBox::setValue( const string & ntext ) +{ + privText = ntext; + buffer = privText.str(); + modified = false; + fldstart = 0; + curpos = mayedit ? buffer.length() : 0; + index = -1; + setDefsze(); + tUpdate(); + Redraw(); +} + +void NCComboBox::setText( const string & ntext ) { - text = ntext; - buffer = text.str(); + privText = ntext; + buffer = privText.str(); modified = false; fldstart = 0; curpos = mayedit ? buffer.length() : 0; @@ -265,6 +288,7 @@ Redraw(); } +#if 0 /////////////////////////////////////////////////////////////////// // // @@ -290,6 +314,25 @@ return text.YCPstr(); } +#endif + +string NCComboBox::text() +{ + if ( modified ) + return NCstring( buffer ).Str(); + + if ( index != -1 ) { + int idx = 0; + list<string>::const_iterator entry; + for ( entry = deflist.begin(); entry != deflist.end(); ++entry, ++idx ) { + if ( idx == index ) { + return *entry; + } + } + } + + return privText.Str(); +} /////////////////////////////////////////////////////////////////// // @@ -338,10 +381,10 @@ void NCComboBox::wRecoded() { if ( modified ) { - text = NCstring( buffer ); + privText = NCstring( buffer ); modified = false; } - buffer = text.str(); + buffer = privText.str(); wRedraw(); } @@ -615,7 +658,7 @@ void NCComboBox::deleteAllItems() { YComboBox::deleteAllItems(); deflist.clear(); - setValue( YCPString( string("") ) ); + setValue( "" ); } Modified: branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.h?rev=39468&r1=39467&r2=39468&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.h (original) +++ branches/tmp/sh/mod-ui/ncurses/src/NCComboBox.h Tue Jul 17 14:59:25 2007 @@ -26,6 +26,7 @@ #include "YComboBox.h" #include "NCWidget.h" +#include "YItem.h" class NCComboBox; @@ -46,7 +47,7 @@ bool mayedit; NClabel label; - NCstring text; + NCstring privText; wstring buffer; bool modified; NCursesWindow * lwin; @@ -58,7 +59,7 @@ NCstring validChars; - list<YCPString> deflist; + list<string> deflist; int index; void setDefsze(); @@ -83,16 +84,18 @@ public: - NCComboBox( YWidget * parent, const YWidgetOpt & opt, - const YCPString & label ); + NCComboBox( YWidget * parent, + const string & label, + bool editable ); virtual ~NCComboBox(); +#if 0 virtual void itemAdded( const YCPString & string, int index, bool selected ); - - virtual long nicesize( YUIDimension dim ); - +#endif + virtual void addItem ( YItem * item ); + virtual int preferredWidth(); virtual int preferredHeight(); @@ -103,10 +106,16 @@ **/ virtual void setSize( int newWidth, int newHeight ); - virtual void setLabel( const YCPString & nlabel ); + virtual void setLabel( const string & nlabel ); - virtual void setValue( const YCPString & ntext ); +#if 0 + // FIXME - obsolete? same as setText() ? + virtual void setValue( const string & ntext ); virtual YCPString getValue() const; +#endif + + virtual void setText( const string & ntext ); + virtual string text(); virtual void setValidChars( const YCPString & validchars ); @@ -115,7 +124,6 @@ virtual NCursesEvent wHandleInput( wint_t key ); - //virtual void setEnabling( bool do_bv ) { NCWidget::setEnabling( enabled=do_bv ); } virtual void setEnabled( bool do_bv ); virtual bool setKeyboardFocus() { Modified: branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupSearch.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupSearch.cc?rev=39468&r1=39467&r2=39468&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupSearch.cc (original) +++ branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupSearch.cc Tue Jul 17 14:59:25 2007 @@ -109,14 +109,20 @@ NCLayoutBox * vSplit2 = new NCLayoutBox( frame0, YD_VERT ); - opt.isEditable.setValue( true ); - searchExpr = new NCComboBox( frame0, opt, YCPString(NCPkgNames::SearchPhrase()) ); + searchExpr = new NCComboBox( frame0, + NCPkgNames::SearchPhrase(), + true ); // editable = true YStringWidgetID * searchID = new YStringWidgetID ("search_box" ); searchExpr->setId( searchID ); +#if 0 searchExpr->itemAdded( YCPString( "" ), // set initial value 0, // index false ); // not selected +#endif + YItem * item = new YItem( "", false ); // selected = false + searchExpr->addItem( item ); + //vSplit2->addChild( new NCSpacing( vSplit, opt, 0.6, false, true ) ); new NCSpacing( vSplit, YD_VERT, false, 0.6 ); @@ -207,21 +213,26 @@ // YCPString NCPkgPopupSearch::getSearchExpression() const { - YCPString value = YCPNull(); + string value; unsigned int i = 0; if ( searchExpr ) { // get the expression and store it in combo box list - value = searchExpr->getValue(); - i = searchExpr->getListSize(); + // value = searchExpr->getValue(); + value = searchExpr->text(); + i = searchExpr->getListSize(); +#if 0 searchExpr->itemAdded( value, // the search expression i, // index true ); // selected +#endif + YItem * item = new YItem( value, true ); //selected = true + searchExpr->addItem( item ); } - return value; + return YCPString( value ); } /////////////////////////////////////////////////////////////////// @@ -331,17 +342,18 @@ bool NCPkgPopupSearch::getCheckBoxValue( NCCheckBox * checkBox ) { - YCPValue value = YCPNull(); - + //YCPValue value = YCPNull(); + YCheckBoxState value = YCheckBox_off; + if ( checkBox ) { - value = checkBox->getValue(); + value = checkBox->value(); // return whether the option is selected or not - if ( !value.isNull() ) - { - return ( value->asBoolean()->toString() == "true" ? true : false ); - } + //if ( !value.isNull() ) + // return ( value->asBoolean()->toString() == "true" ? true : false ); + + return ( value == YCheckBox_on ? true : false ); } return false; Modified: branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc?rev=39468&r1=39467&r2=39468&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc (original) +++ branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc Tue Jul 17 14:59:25 2007 @@ -73,7 +73,8 @@ YWidgetOpt opt; opt.notifyMode.setValue( true ); - opt.vWeight.setValue( 70 ); + // FIXME + //opt.vWeight.setValue( 70 ); // the vertical split is the (only) child of the dialog NCLayoutBox * split = new NCLayoutBox( this, YD_VERT ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org