project64/Source/Project64/UserInterface/MenuItem.cpp

76 lines
2.0 KiB
C++
Raw Normal View History

2016-01-27 09:11:59 +00:00
#include "stdafx.h"
CBaseMenu::CBaseMenu() :
2022-09-26 02:31:54 +00:00
m_MenuHandle((HMENU)CreateMenu())
2016-01-27 09:11:59 +00:00
{
}
bool CBaseMenu::AddMenu(HMENU hMenu, MenuItemList Items)
{
2022-09-26 02:31:54 +00:00
if (Items.begin() == Items.end())
{
return false;
}
2016-01-27 09:11:59 +00:00
UINT ItemID, uFlags;
std::wstring Text, String;
for (MenuItemList::iterator MenuItem = Items.begin(); MenuItem != Items.end(); MenuItem++)
{
ItemID = MenuItem->ID();
uFlags = MF_STRING;
Text = wGS(MenuItem->Title());
if (MenuItem->Title() == EMPTY_STRING && MenuItem->ManualString().length() > 0)
{
Text = MenuItem->ManualString();
}
if (ItemID == SPLITER)
{
uFlags |= MF_SEPARATOR;
}
if (MenuItem->ItemTicked())
{
uFlags |= MFS_CHECKED;
}
if (MenuItem->ItemEnabled())
{
uFlags |= MFS_ENABLED;
}
else
{
uFlags |= MFS_DISABLED;
}
MenuItemList * SubMenu = (MenuItemList *)MenuItem->SubMenu();
if (ItemID == SUB_MENU && HIWORD(SubMenu) != 0 && (SubMenu->begin() != SubMenu->end()))
{
2023-02-27 23:39:08 +00:00
ItemID = (UINT)((LONG_PTR)CreatePopupMenu());
2016-01-27 09:11:59 +00:00
uFlags |= MF_POPUP;
2023-02-27 23:39:08 +00:00
AddMenu((HMENU)((LONG_PTR)ItemID), *SubMenu);
2016-01-27 09:11:59 +00:00
}
if (ItemID == ID_PLUGIN_MENU)
{
2023-02-27 23:39:08 +00:00
ItemID = (UINT)((LONG_PTR)MenuItem->SubMenu());
2016-01-27 09:11:59 +00:00
uFlags |= MF_POPUP;
MENUITEMINFO lpmii;
lpmii.cbSize = sizeof(MENUITEMINFO);
lpmii.fMask = MIIM_STATE;
lpmii.fState = 0;
2023-02-27 23:39:08 +00:00
SetMenuItemInfo((HMENU)((LONG_PTR)ItemID), (DWORD)((LONG_PTR)MenuItem->SubMenu()), FALSE, &lpmii);
2016-01-27 09:11:59 +00:00
}
if (MenuItem->ShortCut().empty() == false)
{
String = Text;
String += L"\t";
String += MenuItem->ShortCut();
Text = String;
}
AppendMenu(hMenu, uFlags, ItemID, Text.c_str());
2016-01-27 09:11:59 +00:00
}
return true;
2021-03-17 08:29:39 +00:00
}