本文整理汇总了C++中ContextMenuItem::getSubMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextMenuItem::getSubMenu方法的具体用法?C++ ContextMenuItem::getSubMenu怎么用?C++ ContextMenuItem::getSubMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextMenuItem
的用法示例。
在下文中一共展示了ContextMenuItem::getSubMenu方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recalculateSize_
void MainMenu::recalculateSize_()
{
Rect parentRect = getParent()->getClientRect(); // client rect of parent
//AbstractSkin* skin = getEnvironment()->getSkin();
Font font = Font::create( FONT_2_WHITE );
int height = std::max<int>( DEFAULT_MENU_HEIGHT, getHeight() );
setGeometry( Rect( parentRect.UpperLeftCorner.getX(), parentRect.UpperLeftCorner.getY(),
parentRect.LowerRightCorner.getX(), parentRect.UpperLeftCorner.getY() + height ) );
Rect rect;
rect.UpperLeftCorner = parentRect.UpperLeftCorner;
height = std::max<int>( font.getSize("A").getHeight(), height );
//if (skin && height < skin->getSize ( EGDS_MENU_HEIGHT ))
// height = skin->getSize(EGDS_MENU_HEIGHT);
int width = rect.UpperLeftCorner.getX();
int i;
for( i=0; i<(int)getItemCount(); ++i)
{
ContextMenuItem* refItem = getItem( i );
if ( refItem->isSeparator() )
{
refItem->setDim( Size( 16, getHeight() ) );
}
else
{
Size itemSize = font.getSize( refItem->getText() ) + Size( 20, 0 );
itemSize.setHeight( getHeight() );
refItem->setDim( itemSize );
}
refItem->setOffset( width );
width += refItem->getDim().getWidth();
}
// recalculate submenus
for (i=0; i<(int)getItemCount(); ++i)
{
ContextMenuItem* refItem = getItem( i );
Rect rectangle( refItem->getOffset(), 0, refItem->getOffset() + refItem->getDim().getWidth(), height );
refItem->setGeometry( rectangle );
if (refItem->getSubMenu())
{
// move submenu
Size itemSize = refItem->getSubMenu()->getAbsoluteRect().getSize();
refItem->getSubMenu()->setGeometry( Rect( refItem->getOffset(), height,
refItem->getOffset() + itemSize.getWidth()-5, height+itemSize.getHeight() ));
}
}
}
示例2: addItem
ContextMenuItem* MainMenu::addItem(const std::string& text, int commandId, bool enabled, bool hasSubMenu, bool checked, bool autoChecking)
{
ContextMenuItem* ret = ContextMenu::addItem( text, commandId, enabled, hasSubMenu, checked, autoChecking );
if( ret && ret->getSubMenu() )
{
//ret->getSubMenu()->setStyle( getStyle().getSubStyle( NES_SUBMENU ).getName() );
ret->setFlag( ContextMenuItem::drawSubmenuSprite, false );
ret->setBackgroundMode( Label::bgNone );
}
//refItem.alignEnabled = true;
//refItem.horizontal = EGUIA_CENTER;
//refItem.vertical = EGUIA_CENTER;
return ret;
}