Mailinglist Archive: yast-commit (535 mails)

< Previous Next >
[yast-commit] r41452 - in /branches/tmp/sh/mod-ui/ncurses/src: NCMenuButton.cc NCMenuButton.h NCPopupMenu.cc NCPopupMenu.h
  • From: gs@xxxxxxxxxxxxxxxx
  • Date: Thu, 18 Oct 2007 09:53:42 -0000
  • Message-id: <20071018095342.E104223F5B@xxxxxxxxxxxxxxxx>
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<YMenuItem *> (*it);
+    YUI_CHECK_PTR( item );
+    row[0] = item->label();
+    row[1] = item->hasChildren() ? "..." : "";
     /*addItem( (*entry)->getId(), row );*/
   }
   stripHotkeys();
@@ -70,8 +72,9 @@
   NCursesEvent ret;
   switch ( ch ) {
   case KEY_RIGHT:
-    if ( menu.itemList()[getCurrentItem()]->hasChildren() )
-      ret = NCursesEvent::button;
+      //if ( menu.itemList()[getCurrentItem()]->hasChildren() )
+      if ( selectedItem()->hasChildren() )
+       ret = NCursesEvent::button;
     break;
   case KEY_LEFT:
     ret = NCursesEvent::cancel;
@@ -100,15 +103,18 @@
                                                          : -1;
 
   if ( selection != -1 ) {
-    if ( menu.itemList()[selection]->hasChildren() ) {
+      if ( _selectedItem && _selectedItem->hasChildren() ) {
       // post submenu
       wpos at( ScreenPos() + wpos( selection, inparent.Sze.W - 1 ) );
-      NCPopupMenu * dialog = new NCPopupMenu( at, *menu.itemList()[selection] );
+      NCPopupMenu * dialog = new NCPopupMenu( at,
+                                             _selectedItem->childrenBegin(),
+                                             _selectedItem->childrenEnd() );
       again = (dialog->post( &postevent ) == NCursesEvent::CONTINUE);
       YDialog::deleteTopmostDialog();
     } else {
       // store selection
-      postevent.detail = menu.itemList()[selection]->getIndex();
+      //postevent.detail = menu.itemList()[selection]->getIndex();
+      postevent.detail = _selectedItem->index();
     }
   }
   return again;

Modified: branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h?rev=41452&r1=41451&r2=41452&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h Thu Oct 18 11:53:42 2007
@@ -26,7 +26,6 @@
 
 #include "NCPopupTable.h"
 
-class YMenuItem;
 
 ///////////////////////////////////////////////////////////////////
 //
@@ -41,7 +40,7 @@
 
   private:
 
-    YMenuItem & menu;
+    YMenuItem * _selectedItem;
 
   protected:
 
@@ -50,12 +49,13 @@
 
   public:
 
-    NCPopupMenu( const wpos at, YMenuItem & menuitem );
+    NCPopupMenu( const wpos at, YItemIterator begin, YItemIterator end );
     virtual ~NCPopupMenu();
 //    virtual void itemAdded( const YCPString & string,
 //                         int index,
 //                         bool selected );
-
+    YMenuItem * selectedItem() { return _selectedItem; }
+    void setSelectedItem ( YMenuItem * item ) { _selectedItem = item; }
 };
 
 ///////////////////////////////////////////////////////////////////

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages