Beispiel #1
0
void LayoutManager::addMenu(IMenu& menu)
{
	dynamicMenus_.push_back(&menu);

	auto window = getWindow(menu.windowId());
	if (window == nullptr)
	{
		return;
	}

	for (auto actionIt = actions_.begin(); actionIt != actions_.end(); ++actionIt)
	{
		auto action = actionIt->action_;
		if (getWindow(action->windowId()) != window)
		{
			continue;
		}

		for (auto& path : action->paths())
		{
			if (matchMenu(menu, path.c_str()))
			{
				menu.addAction(*action, path.c_str());
				actionIt->menus_.insert(&menu);
			}
		}
	}
}
bool PropertyRowPointer::onContextMenu(IMenu &menu, PropertyTree* tree)
{
	if(!menu.isEmpty())
		menu.addSeparator();
		if(!userReadOnly()){
			IMenu* createItem = menu.addMenu("Set");
			ClassMenuItemAdderRowPointer(this, tree).generateMenu(*createItem, tree->model()->typeStringList(baseType()));
		}
	return PropertyRow::onContextMenu(menu, tree);
}
Beispiel #3
0
fresult YNDialogForm::CreateMenu( IMenu** o_mnu )
{
	fresult fres;
	MenuFactory* mf = _Factories->GetMenuFactory();

	//ready factory
	mf->CurrentInterlaced = true;
	mf->CurrentTextFormatHandle = TF_MENU;
	mf->CurrentEvenTextFormatHandle = TF_MENUEVEN;
	mf->ClearSettings();

	//Set up menu
	MenuItemSettings* mis;
	//ItemOriginZ
	mis = &mf->Settings[ItemOriginZ];
	mis->ImgHandle = small_arrow_right_red;
	mis->OverrideTextFormat = TF_MENU_RED;
	mis->Text = "                     ";
	fres = _FormManager->GetCloseFormHandler(&mis->Handler, fsrOK);
	mis->Empty = FALSE;

	//ItemOriginE
	mis = &mf->Settings[ItemOriginE];
	mis->ImgHandle = small_arrow_bottom;
	mis->Text = "назад";
	fres = _FormManager->GetCloseFormHandler(&mis->Handler, fsrCancel);
	ENSURESUCCESS(fres);
	mis->Empty = FALSE;

	//create mnu
	IMenu* mnu = NULL;
	fres = mf->GetMenu(ABCXYZLER, &mnu);
	ENSURESUCCESS(fres);

	//Clean up
	mf->ClearSettings();
	mf->DefaultInterlaced=mf->CurrentInterlaced;
	mf->DefaultTextFormatHandle=mf->CurrentTextFormatHandle;
	mf->DefaultEvenTextFormatHandle=mf->CurrentEvenTextFormatHandle;

	//Get menu Items
	_miYes = (MenuItem*)mnu->GetItem(0);
	FAILIF(_miYes==NULL);
	_miCancel =(MenuItem*)mnu->GetItem(1);
	FAILIF(_miCancel==NULL);

	*o_mnu = mnu;
	return SUCCESS;
}
Beispiel #4
0
void LayoutManager::removeMenu(IMenu& menu)
{
	auto menuIt = std::find(dynamicMenus_.begin(), dynamicMenus_.end(), &menu);
	if (menuIt == dynamicMenus_.end())
	{
		return;
	}

	for (auto actionIt = actions_.begin(); actionIt != actions_.end(); ++actionIt)
	{
		for (auto menuIt = actionIt->menus_.begin(); menuIt != actionIt->menus_.end();)
		{
			if (*menuIt != &menu)
			{
				++menuIt;
				continue;
			}

			menu.removeAction(*actionIt->action_);
			menuIt = actionIt->menus_.erase(menuIt);
		}
	}

	dynamicMenus_.erase(menuIt);
}
Beispiel #5
0
bool LayoutManager::matchMenu(IMenu& menu, const char* path)
{
	auto menuPath = menu.path();
	auto menuPathLen = strlen(menuPath);

	auto chr = strchr(path, '|');
	auto minPathLen = chr != nullptr ? static_cast<size_t>(chr - path) : 0;
	auto optPath = chr != nullptr ? chr + 1 : path;

	if (menuPathLen < minPathLen)
	{
		return false;
	}

	if (minPathLen > 0 && strncmp(path, menuPath, minPathLen) != 0)
	{
		return false;
	}

	if (menuPathLen > 0 && strncmp(optPath, menuPath + minPathLen, menuPathLen - minPathLen) != 0)
	{
		return false;
	}

	if (menuPathLen > 0 && optPath[menuPathLen - minPathLen] != '.' && optPath[menuPathLen - minPathLen] != '\0')
	{
		return false;
	}

	return true;
}
Beispiel #6
0
void AddPlasmaExportMenu()
{
    IMenuManager* pMenuMan = GetCOREInterface()->GetMenuManager();
    IMenu* fileMenu = pMenuMan->FindMenu("&File");

    int i;

    bool plasmaExportFound = false;

    // Make sure our action isn't already in the menu
    TSTR ourName = GetString(IDS_PLASMA_EXPORT);
    for (i = 0; i < fileMenu->NumItems(); i++)
    {
        IMenuItem* fileMenuItem = fileMenu->GetItem(i);
        const TSTR& title = fileMenuItem->GetTitle();
        if (title == ourName)
            plasmaExportFound = true;

        // KLUDGE - MaxAss didn't define the file submenu with an accelerator.
        // This fixes it.
        if (title == (CStr)"MAX File Operations")
        {
            fileMenuItem->SetUseCustomTitle(true);
            bool custom = fileMenuItem->GetUseCustomTitle();
            fileMenuItem->SetTitle("MAX File Opera&tions");

            pMenuMan->UpdateMenuBar();
        }
    }

    if (!plasmaExportFound)
    {
        // Menu item isn't there, add it
        for (i = 0; i < fileMenu->NumItems(); i++)
        {
            IMenuItem* fileMenuItem = fileMenu->GetItem(i);
            const TSTR& title = fileMenuItem->GetTitle();
            // We want to add it after the "Export Selected" menu item
            if (title == (CStr)"Export Selected...")
            {
                ActionTable* pActionTable = GetCOREInterface()->GetActionManager()->FindTable(kActionId);
                if (!pActionTable)
                {
                    hsAssert(0, "Action table not found");
                    return;
                }

                IMenuItem* menuItem = GetIMenuItem();
                menuItem->SetActionItem(pActionTable->GetAction(kActionExport));
                fileMenu->AddItem(menuItem, i+1);

                pMenuMan->UpdateMenuBar();

                return;
            }
        }
    }
}
void ClassMenuItemAdder::generateMenu(IMenu& createItem, const StringList& comboStrings)
{
	StringList::const_iterator it;
	int index = 0;
	for (it = comboStrings.begin(); it != comboStrings.end(); ++it) {
		StringList path;
		splitStringList(&path, it->c_str(), '\\');
		int level = 0;
		IMenu* item = &createItem;

		for(int level = 0; level < int(path.size()); ++level){
			const char* leaf = path[level].c_str();
			if(level == path.size() - 1){
				addAction(*item, leaf, index++);
			}
			else{
				if (property_tree::IMenu* menu = item->findMenu(leaf))
					item = menu;
				else
					item = addMenu(*item, leaf);
			}
		}
	}
}
Beispiel #8
0
void plCreateMenu()
{
#if MAX_VERSION_MAJOR <= 11
    AddPlasmaExportMenu();
#endif

    IMenuManager* pMenuMan = GetCOREInterface()->GetMenuManager();
    bool newlyRegistered = pMenuMan->RegisterMenuBarContext(kMyMenuContextId, kMenuName);

    // Is the Max menu version the most recent?
    bool wrongVersion = GetPrivateProfileIntW(L"Menu", L"Version", 0, plMaxConfig::GetPluginIni().WideString().data()) < kMenuVersion;
    if (wrongVersion)
    {
        // Delete the old version of the menu
        IMenu *oldMenu = pMenuMan->FindMenu(kMenuName);
        if (oldMenu)
            pMenuMan->UnRegisterMenu(oldMenu);

        // Update the menu version
        wchar_t buf[12];
        snwprintf(buf, arrsize(buf), L"%d", kMenuVersion);
        WritePrivateProfileStringW(L"Menu", L"Version", buf, plMaxConfig::GetPluginIni().WideString().data());
    }
    
    if (wrongVersion || newlyRegistered)
    {
        IMenu *pMainMenu = pMenuMan->GetMainMenuBar();
        if (!pMainMenu)
        {
            hsAssert(0, "Main menu not found");
            return;
        }

        // Get our action table
        ActionTable* pActionTable = GetCOREInterface()->GetActionManager()->FindTable(kActionId);
        if (!pActionTable)
        {
            hsAssert(0, "Action table not found");
            return;
        }

        // Create the Plasma menu
        IMenu* pPlasmaMenu = GetIMenu();
        pPlasmaMenu->SetTitle(kMenuName);

        // Register the new menu with the system
        pMenuMan->RegisterMenu(pPlasmaMenu, 0);

        /////////////////////////////////////////////////
        // Add the menu items
        //
        IMenuItem* pMenuItem;
 
#if MAX_VERSION_MAJOR >= 12
        // Add the export action to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionExport));
        pPlasmaMenu->AddItem(pMenuItem);
#endif

        // Add the save selected action to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionSaveSel));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the merge action to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionMerge));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the component copy action to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionCompCopy));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add a separator
        pMenuItem = GetIMenuItem();
        pMenuItem->ActAsSeparator();
        pPlasmaMenu->AddItem(pMenuItem);
    
        // Add the component manager to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionComponent));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the resource collector to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionResCollect));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the texture search to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionTexSearch));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the age description to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionAgeDesc));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add a separator
        pMenuItem = GetIMenuItem();
        pMenuItem->ActAsSeparator();
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the Lock Selected to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionLock));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the Unlock Selected to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionUnlock));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the Reset Selected to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionReset));
        pPlasmaMenu->AddItem(pMenuItem);

        // Add the SelectNonRenderables to the menu
        pMenuItem = GetIMenuItem();
        pMenuItem->SetActionItem(pActionTable->GetAction(kActionSelectNonRenderables));
        pPlasmaMenu->AddItem(pMenuItem);

        // Create a new menu item to hold the sub-menu
        IMenuItem* pSubMenuItem1 = GetIMenuItem();   //menu in menu bar...
        pSubMenuItem1->SetSubMenu(pPlasmaMenu);
        pMainMenu->AddItem(pSubMenuItem1);

        pMenuMan->UpdateMenuBar();

        // Save the dang menu, in case Max crashes
        const char *uiDir = GetCOREInterface()->GetDir(APP_UI_DIR);
        char path[MAX_PATH];
        sprintf(path, "%s\\%s", uiDir, "MaxMenus.mnu");
        
        pMenuMan->SaveMenuFile(path);
    }

}
void ClassMenuItemAdder::addAction(IMenu& menu, const char* text, int index)
{
	menu.addAction(text, MENU_DISABLED);
}
Beispiel #10
0
fresult ItemsListFormBase::CreateMenu( IMenu** o_mnu )
{
	fresult fres;
	MenuFactory* mf = _Factories->GetMenuFactory();

	//ready factory
	mf->CurrentInterlaced = true;
	mf->CurrentTextFormatHandle = TF_MENU;
	mf->CurrentEvenTextFormatHandle = TF_MENUEVEN;
	mf->ClearSettings();

	//Set up menu
	MenuItemSettings* settings = mf->Settings;
	MenuItemSettings* mis;

	//ItemOriginX
	mis = &settings[ItemOriginX];
	mis->ImgHandle = scroll_up;
	mis->Handler = _AutoDispatchMenuHandler;
	mis->Empty = FALSE;

	//ItemOriginZ
	mis = &settings[ItemOriginZ];
	mis->ImgHandle = scroll_down;
	mis->Handler = _AutoDispatchMenuHandler;
	mis->Empty = FALSE;

	//ItemOriginL
	mis = &settings[ItemOriginL];
	mis->ImgHandle = small_arrow_bottom;
	mis->Text = _prevText;
	mis->Handler = _AutoDispatchMenuHandler;
	mis->Empty = FALSE;

	//ItemOriginE
	mis = &settings[ItemOriginE];
	mis->ImgHandle = small_arrow_bottom;
	mis->Text = "назад";
	fres = _FormManager->GetCloseFormHandler(&mis->Handler, fsrCancel);
	ENSURESUCCESS(fres);
	mis->Empty = FALSE;
	
	//ItemOriginR
	mis = &settings[ItemOriginR];
	mis->ImgHandle = small_arrow_bottom;
	mis->Text = _nextText;
	mis->Handler = _AutoDispatchMenuHandler;
	mis->Empty = FALSE;
	//call derived update settings
	UpdateMenuSettings(settings);

	//create mnu
	IMenu* mnu = NULL;
	fres = mf->GetMenu(ABCXYZLER, &mnu);
	ENSURESUCCESS(fres);

	for (ubyte_t i=0; i<mnu->GetItemsCount();i++)
	{
		MenuItem* mi = (MenuItem*)(mnu->GetItem(i));
		if (StringEquals(mi->GetName(), "L") == TRUE)
		{
			_mnuBack = mi;
		}
		if (StringEquals(mi->GetName(), "R") == TRUE)
		{
			_mnuNext = mi;
		}
	}

	//Clean up
	mf->ClearSettings();
	mf->DefaultInterlaced=mf->CurrentInterlaced;
	mf->DefaultTextFormatHandle=mf->CurrentTextFormatHandle;
	mf->DefaultEvenTextFormatHandle=mf->CurrentEvenTextFormatHandle;

	//Get menu Items

	*o_mnu = mnu;
	return SUCCESS;
}