[yast-commit] r41452 - in /branches/tmp/sh/mod-ui/ncurses/src: NCMenuButton.cc NCMenuButton.h NCPopupMenu.cc NCPopupMenu.h
Author: gs
Date: Thu Oct 18 11:53:42 2007
New Revision: 41452
URL: http://svn.opensuse.org/viewcvs/yast?rev=41452&view=rev
Log:
MenuButton - Part 1
Modified:
branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc
branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.h
branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc
branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc?rev=41452&r1=41451&r2=41452&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc Thu Oct 18 11:53:42 2007
@@ -31,18 +31,19 @@
//
// DESCRIPTION :
//
-NCMenuButton::NCMenuButton( YWidget * parent, const YWidgetOpt & opt,
- YCPString nlabel )
- : YMenuButton( opt, nlabel )
+NCMenuButton::NCMenuButton( YWidget * parent,
+ string nlabel )
+ : YMenuButton( parent, nlabel )
, NCWidget( parent )
{
WIDDBG << endl;
setLabel( nlabel );
hotlabel = &label;
- if ( opt.isDefaultButton.value() )
- setKeyboardFocus();
- setFunctionHotkey( opt );
+ // FIXME
+ // if ( opt.isDefaultButton.value() )
+ // setKeyboardFocus();
+ // setFunctionHotkey( opt );
}
///////////////////////////////////////////////////////////////////
@@ -58,19 +59,6 @@
WIDDBG << endl;
}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCMenuButton::nicesize
-// METHOD TYPE : long
-//
-// DESCRIPTION :
-//
-long NCMenuButton::nicesize( YUIDimension dim )
-{
- return dim == YD_HORIZ ? wGetDefsze().W : wGetDefsze().H;
-}
-
int NCMenuButton::preferredWidth()
{
return wGetDefsze().W;
@@ -130,7 +118,7 @@
//
// DESCRIPTION :
//
-void NCMenuButton::setLabel( const YCPString & nlabel )
+void NCMenuButton::setLabel( const string & nlabel )
{
label = NCstring( nlabel );
label.stripHotkey();
@@ -168,18 +156,25 @@
win->addch( 0, win->maxx()-1, ACS_DARROW );
}
+#if 0
+void NCMenuButton::createMenu()
+{
+ YMenu * toplevel = getToplevelMenu();
+ setEnabled( toplevel && toplevel->hasChildren() );
+}
+#endif
+
///////////////////////////////////////////////////////////////////
//
//
-// METHOD NAME : NCMenuButton::createMenu
+// METHOD NAME : NCMenuButton::rebuildMenuTree
// METHOD TYPE : void
//
// DESCRIPTION :
//
-void NCMenuButton::createMenu()
+void NCMenuButton::rebuildMenuTree()
{
- YMenu * toplevel = getToplevelMenu();
- setEnabled( toplevel && toplevel->hasChildren() );
+ // NOP
}
///////////////////////////////////////////////////////////////////
@@ -193,7 +188,9 @@
NCursesEvent NCMenuButton::postMenu()
{
wpos at( ScreenPos() + wpos( win->height(), 0 ) );
- NCPopupMenu * dialog = new NCPopupMenu( at, *getToplevelMenu() );
+ NCPopupMenu * dialog = new NCPopupMenu( at,
+ itemsBegin(),
+ itemsEnd() );
int selection = dialog->post();
if ( selection < 0 ) {
@@ -203,8 +200,8 @@
NCursesEvent ret = NCursesEvent::menu;
// FIXME - check this
- YCPValue value = indexToId( selection );
- YStringWidgetID * selectionID = new YStringWidgetID( value->toString());
+ dialog->setSelectedItem( findMenuItem( selection ) );
+ YStringWidgetID * selectionID = new YStringWidgetID( dialog->selectedItem()->label() );
ret.selection = selectionID;
YDialog::deleteTopmostDialog();
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.h?rev=41452&r1=41451&r2=41452&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.h Thu Oct 18 11:53:42 2007
@@ -49,19 +49,18 @@
virtual void wRedraw();
- virtual void createMenu();
NCursesEvent postMenu();
public:
- NCMenuButton( YWidget * parent, const YWidgetOpt & opt,
- YCPString label );
+ NCMenuButton( YWidget * parent,
+ string label );
virtual ~NCMenuButton();
- virtual long nicesize( YUIDimension dim );
-
virtual int preferredWidth();
virtual int preferredHeight();
+
+ virtual void rebuildMenuTree();
/**
* Set the new size of the widget.
@@ -72,8 +71,8 @@
virtual NCursesEvent wHandleInput( wint_t key );
- virtual void setLabel( const YCPString & nlabel );
- //virtual void setEnabling( bool do_bv ) { NCWidget::setEnabling( enabled=do_bv ); }
+ virtual void setLabel( const string & nlabel );
+
virtual void setEnabled( bool do_bv );
virtual bool setKeyboardFocus() {
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc?rev=41452&r1=41451&r2=41452&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc Thu Oct 18 11:53:42 2007
@@ -30,16 +30,18 @@
//
// DESCRIPTION :
//
-NCPopupMenu::NCPopupMenu( const wpos at, YMenuItem & menuitem )
+NCPopupMenu::NCPopupMenu( const wpos at, YItemIterator begin, YItemIterator end )
: NCPopupTable( at )
- , menu( menuitem )
+ , _selectedItem( 0 )
{
vector<string> row( 2 );
createList( row );
- for ( YMenuItemListIterator entry = menu.itemList().begin();
- entry != menu.itemList().end(); ++entry ) {
- row[0] = (*entry)->getLabel()->value();
- row[1] = (*entry)->hasChildren() ? "..." : "";
+ for ( YItemIterator it = begin; it != end; ++it )
+ {
+ YMenuItem * item = dynamic_cast
participants (1)
-
gs@svn.opensuse.org