本文整理汇总了C++中MenuItem::_setGUIManager方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItem::_setGUIManager方法的具体用法?C++ MenuItem::_setGUIManager怎么用?C++ MenuItem::_setGUIManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::_setGUIManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
void Menu::addChild(Widget* w)
{
if(!w->isMenuItem())
throw Exception(Exception::ERR_INVALID_CHILD,"Cannot add non-MenuItem to a menu!","Menu::addChild");
// Set link to parent Menu
MenuItem* i = dynamic_cast<MenuItem*>(w);
i->notifyMenuParent(this);
// Set link to parent ToolBar
i->notifyToolBarParent(mDesc->toolBar);
// Set link to parent ContextMenu
i->notifyContextMenuParent(mDesc->contextMenu);
i->_setGUIManager(mDesc->guiManager);
i->_setSheet(mDesc->sheet);
i->setHeight(mDesc->menu_itemHeight);
// We cannot add the widget as a child, the texture position and drawing will be incorrect.
int itemIndex = i->getIndex();
// Adding Item to End of List
if((itemIndex < 0) || (itemIndex >= static_cast<int>(mItems.size())))
{
// Update Index
i->setIndex(static_cast<int>(mItems.size()));
// Update Position
if(!mItems.empty())
{
Point p = mItems.back()->getPosition();
p.y += i->getSize().height;
i->setPosition(p);
}
mItems.push_back(i);
}
// Inserting Item into the List
else
{
int count = 0;
for(std::list<MenuItem*>::iterator it = mItems.begin(); it != mItems.end(); ++it)
{
if(count == itemIndex)
{
// Insert Item into List. All items after this will need to have
// index and position updated.
Point p = (*it)->getPosition();
mItems.insert(it,i);
i->setPosition(p);
break;
}
++count;
}
count = 0;
Point p;
for(std::list<MenuItem*>::iterator it = mItems.begin(); it != mItems.end(); ++it)
{
// Update Index
(*it)->setIndex(count);
// Update Position
(*it)->setPosition(p);
p.y += (*it)->getHeight();
++count;
}
}
// Add to the windows list of MenuItems
mMenuPanel->addWidget(i);
if(i->getClass() == "Menu")
mSubMenus.push_back(dynamic_cast<Menu*>(i));
}