25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
27 #include "NCPopupMenu.h"
30 #include <yui/YMenuButton.h>
33 NCPopupMenu::NCPopupMenu(
const wpos at, YItemIterator begin, YItemIterator end )
37 std::vector<std::string> row( 2 );
40 for ( YItemIterator it = begin; it != end; ++it )
42 YMenuItem * item =
dynamic_cast<YMenuItem *
>( *it );
43 YUI_CHECK_PTR( item );
45 row[0] = item->label();
46 row[1] = item->hasChildren() ?
"..." :
"";
48 YTableItem *tableItem =
new YTableItem( row[0], row[1] );
49 yuiDebug() <<
"Add to std::map: TableItem: " << tableItem <<
" Menu item: " << item << std::endl;
52 itemsMap[tableItem] = item;
59 NCPopupMenu::~NCPopupMenu()
73 yuiDebug() <<
"CurrentItem: " << getCurrentItem() << std::endl;
74 YTableItem * tableItem =
dynamic_cast<YTableItem *
> ( getCurrentItemPointer() );
78 YMenuItem * item = itemsMap[ tableItem ];
80 if ( item && item->hasChildren() )
81 ret = NCursesEvent::button;
88 ret = NCursesEvent::cancel;
89 ret.detail = NCursesEvent::CONTINUE;
93 ret = NCPopup::wHandleInput( ch );
101 bool NCPopupMenu::postAgain()
105 int selection = ( postevent == NCursesEvent::button ) ? getCurrentItem()
107 yuiDebug() <<
"Index: " << selection << std::endl;
108 YTableItem * tableItem =
dynamic_cast<YTableItem *
>( getCurrentItemPointer() );
110 YMenuItem * item = itemsMap[ tableItem ];
115 yuiMilestone() <<
"Menu item: " << item->label() << std::endl;
117 if ( selection != -1 )
119 if ( item->hasChildren() )
122 wpos at( ScreenPos() +
wpos( selection, inparent.Sze.W - 1 ) );
124 item->childrenBegin(),
125 item->childrenEnd() );
126 YUI_CHECK_NEW( dialog );
128 again = ( dialog->post( &postevent ) == NCursesEvent::CONTINUE );
131 YDialog::deleteTopmostDialog();
137 postevent.detail = item->index();