当前位置: 首页>>代码示例>>C++>>正文


C++ ContextMenuItem::addSubMenu方法代码示例

本文整理汇总了C++中ContextMenuItem::addSubMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextMenuItem::addSubMenu方法的具体用法?C++ ContextMenuItem::addSubMenu怎么用?C++ ContextMenuItem::addSubMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContextMenuItem的用法示例。


在下文中一共展示了ContextMenuItem::addSubMenu方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: insertItem

//! Insert a menu item at specified position.
ContextMenuItem* ContextMenu::insertItem(unsigned int idx, const std::string& text, int commandId, bool enabled,
    bool hasSubMenu, bool checked, bool autoChecking)
{
  ContextMenuItem* newItem = new ContextMenuItem( this, text );
  newItem->setEnabled( enabled );
  newItem->setSubElement( true );
  newItem->setChecked( checked );
  newItem->setAutoChecking( autoChecking );
  newItem->setText( text );
  newItem->setFlag( ContextMenuItem::drawSubmenuSprite );
  newItem->setIsSeparator( text.empty() );
  newItem->setCommandId( commandId );
  sendChildToBack( newItem );

  if (hasSubMenu)
  {
    ContextMenu* subMenu = newItem->addSubMenu( commandId );
    subMenu->setVisible( false );
  }

  if ( idx < _d->items.size() )
  {
    _d->items.insert( _d->items.begin() + idx, newItem );
  }
  else
  {
    _d->items.push_back( newItem );
  }

  return newItem;
}
开发者ID:andrelago13,项目名称:caesaria-game,代码行数:32,代码来源:contextmenu.cpp

示例2: MainMenu

TopMenu::TopMenu(Widget* parent, const int height , bool useIcon)
: MainMenu( parent, Rect( 0, 0, parent->width(), height ) ),
  _d( new Impl )
{
  setupUI( ":/gui/topmenu.gui" );
  setGeometry( Rect( 0, 0, parent->width(), height ) );

  _d->initBackground( size() );
  _d->useIcon = useIcon;

  GET_DWIDGET_FROM_UI( _d, lbPopulation )
  GET_DWIDGET_FROM_UI( _d, lbFunds )
  GET_DWIDGET_FROM_UI( _d, lbDate )

  if( _d->lbPopulation )
  {
    _d->lbPopulation->setPosition( Point( width() - populationLabelOffset, 0 ) );
    _d->lbPopulation->setIcon( useIcon ? Picture( "population", 1 ) : Picture() );
  }

  if( _d->lbFunds )
  {
    _d->lbFunds->setPosition(  Point( width() - fundLabelOffset, 0) );
    _d->lbFunds->setIcon( useIcon ? Picture( "paneling", 332 ) : Picture() );
  }

  if( _d->lbDate )
    _d->lbDate->setPosition( Point( width() - dateLabelOffset, 0) );

  ContextMenuItem* tmp = addItem( _("##gmenu_file##"), -1, true, true, false, false );
  ContextMenu* file = tmp->addSubMenu();

  ContextMenuItem* restart = file->addItem( _("##gmenu_file_restart##"), -1, true, false, false, false );
  ContextMenuItem* load = file->addItem( _("##mainmenu_loadgame##"), -1, true, false, false, false );
  ContextMenuItem* save = file->addItem( _("##gmenu_file_save##"), -1, true, false, false, false );
  ContextMenuItem* mainMenu = file->addItem( _("##gmenu_file_mainmenu##"), -1, true, false, false, false );
  ContextMenuItem* exit = file->addItem( _("##gmenu_exit_game##"), -1, true, false, false, false );

  CONNECT( restart, onClicked(), &_d->onRestartSignal, Signal0<>::_emit );
  CONNECT( exit, onClicked(), &_d->onExitSignal, Signal0<>::_emit );
  CONNECT( save, onClicked(), &_d->onSaveSignal, Signal0<>::_emit );
  CONNECT( load, onClicked(), &_d->onLoadSignal, Signal0<>::_emit );
  CONNECT( mainMenu, onClicked(), &_d->onEndSignal, Signal0<>::_emit );

  tmp = addItem( _("##gmenu_options##"), -1, true, true, false, false );
  ContextMenu* options = tmp->addSubMenu();
  ContextMenuItem* screen = options->addItem( _("##screen_settings##"), -1, true, false, false, false );
  ContextMenuItem* sound = options->addItem( _("##sound_settings##"), -1, true, false, false, false );
  ContextMenuItem* speed = options->addItem( _("##speed_settings##"), -1, true, false, false, false );
  ContextMenuItem* cityopts = options->addItem( _("##city_settings##"), -1, true, false, false, false );

  CONNECT( screen, onClicked(), &_d->onShowVideoOptionsSignal,     Signal0<>::_emit );
  CONNECT( speed,  onClicked(), &_d->onShowGameSpeedOptionsSignal, Signal0<>::_emit );
  CONNECT( sound,  onClicked(), &_d->onShowSoundOptionsSignal,     Signal0<>::_emit );
  CONNECT( cityopts,  onClicked(), &_d->onShowCityOptionsSignal,   Signal0<>::_emit );

  tmp = addItem( _("##gmenu_help##"), -1, true, true, false, false );
  ContextMenu* helpMenu = tmp->addSubMenu();
  ContextMenuItem* aboutItem = helpMenu->addItem( _("##gmenu_about##"), -1 );
  ContextMenuItem* shortkeysItem = helpMenu->addItem( _("##gmenu_shortkeys##"), -1 );
  CONNECT( aboutItem, onClicked(), _d.data(), Impl::showAboutInfo );
  CONNECT( shortkeysItem, onClicked(), _d.data(), Impl::showShortKeyInfo );

  tmp = addItem( _("##gmenu_advisors##"), -1, true, true, false, false );
  ContextMenu* advisersMenu = tmp->addSubMenu();
  advisersMenu->addItem( _("##visit_labor_advisor##"), advisor::employers );
  advisersMenu->addItem( _("##visit_military_advisor##"   ), advisor::military );
  advisersMenu->addItem( _("##visit_imperial_advisor##"     ), advisor::empire );
  advisersMenu->addItem( _("##visit_rating_advisor##"    ), advisor::ratings );
  advisersMenu->addItem( _("##visit_trade_advisor##"    ), advisor::trading );
  advisersMenu->addItem( _("##visit_population_advisor##" ), advisor::population );
  advisersMenu->addItem( _("##visit_health_advisor##"     ), advisor::health );
  advisersMenu->addItem( _("##visit_education_advisor##"  ), advisor::education );
  advisersMenu->addItem( _("##visit_religion_advisor##"   ), advisor::religion );
  advisersMenu->addItem( _("##visit_entertainment_advisor##"), advisor::entertainment );
  advisersMenu->addItem( _("##visit_financial_advisor##"    ), advisor::finance );
  advisersMenu->addItem( _("##visit_chief_advisor##"       ), advisor::main );

  CONNECT( advisersMenu, onItemAction(), _d.data(), Impl::resolveAdvisorShow );

  _d->updateDate();
}
开发者ID:b606,项目名称:caesaria-game,代码行数:82,代码来源:topmenu.cpp


注:本文中的ContextMenuItem::addSubMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。