void toggleRadio(MyGUI::MenuItem* current) {
		MyGUI::VectorWidgetPtr widgets;
		_menuBar->findWidgets(current->getName(), widgets);
		for (size_t i = 0; i < widgets.size(); i++) {
			MyGUI::MenuItem *item = widgets[i]->castType<MyGUI::MenuItem>();
			item->setItemChecked(item == current);
		}
	}
Beispiel #2
0
void HotkeyManager::setWidgetHotkey( const string name,const string key )
{
	MyGUI::Gui& gui = MyGUI::Gui::getInstance();
	MyGUI::Widget* p = gui.findWidget<MyGUI::Widget>( name,false );
	if( p && (p->isType<MyGUI::Button>() || p->isType<MyGUI::MenuItem>() ) )
	{
		MyGUI::MenuItem* menuitem = p->castType<MyGUI::MenuItem>(false);
		if( menuitem )
			menuitem->setUserString( "hotkey",key );
		else
			p->setUserString( "hotkey",key );
	}
}
	void MainMenuControlLE::updateMenuScale(size_t _scale)
	{
		MyGUI::MenuItem* scaleMenu = mBar->findItemById("Scale", true);
		if (scaleMenu != nullptr)
		{
			MyGUI::MenuControl* popup = scaleMenu->getItemChild();
			if (popup != nullptr)
			{
				std::string id = MyGUI::utility::toString("Command_ChangeScale.", (int)_scale);
				for (size_t index = 0; index < popup->getItemCount(); index ++)
				{
					MyGUI::MenuItem* item = popup->getItemAt(index);
					item->setItemChecked(item->getItemId() == id);
				}
			}
		}
	}
Beispiel #4
0
	void MainMenu::Init()
	{
		// scene
		{
			MyGUI::MenuItem* menuScene = mMainMenu->findItemById("Scene", true); d_assert (menuScene);

			MyGUI::MenuControl * ctrl = menuScene->getItemChild();

			if (ctrl == NULL)
				ctrl = menuScene->createItemChild();

			ctrl->addItem("Load ...",  MyGUI::MenuItemType::Normal, "CTRL_Menu_Load");
			ctrl->addItem("New",  MyGUI::MenuItemType::Normal, "CTRL_Menu_New");
			ctrl->addItem("Save",  MyGUI::MenuItemType::Normal, "CTRL_Menu_Save");
			ctrl->addItem("Import",  MyGUI::MenuItemType::Normal, "CTRL_Menu_Import");
			ctrl->addItem("Export",  MyGUI::MenuItemType::Normal, "CTRL_Menu_Export");
		}
	}
	void MainMenuControlLE::updateRecentProjectsMenu()
	{
		MyGUI::MenuItem* recentProjectsMenu = mBar->findItemById("RecentProjects", true);
		if (recentProjectsMenu != nullptr)
		{
			recentProjectsMenu->getItemChild()->removeAllItems();
			// список последних открытых проектов
			const RecentFilesManager::VectorUString& recentProjects = RecentFilesManager::getInstance().getRecentProjects();
			if (!recentProjects.empty())
			{
				size_t index = 1;
				for (RecentFilesManager::VectorUString::const_iterator iter = recentProjects.begin(); iter != recentProjects.end(); ++iter, ++index)
				{
					addUserTag("IndexRecentProject", MyGUI::utility::toString(index));
					addUserTag("RecentProject", *iter);
					recentProjectsMenu->getItemChild()->addItem(replaceTags("FormatRecentProject"), MyGUI::MenuItemType::Normal, "Command_OpenRecentProject", *iter);
				}
			}
		}
	}
Beispiel #6
0
void HotkeyManager::_linkWidget(MyGUI::Widget* _widget)
{
	if( _widget && 
		(_widget->isType<MyGUI::MenuItem>() || 
		_widget->isType<MyGUI::Button>() ) )
	{
		string name = _widget->getName();
		if( !name.empty() )
		{
			for( HotkeyTable::iterator it = mHotkeys.begin();it!=mHotkeys.end();++it )
			{
				if( it->mName == name )
				{
					MyGUI::MenuItem* menuitem = _widget->castType<MyGUI::MenuItem>(false);
					if( menuitem )
						menuitem->setUserString("hotkey",it->mHotkey );
					else
						_widget->setUserString( "hotkey",it->mHotkey );
					return;
				}
			}
		}
	}
}