[Project64] Clean up Menu Class.cpp

This commit is contained in:
zilmar 2015-11-14 08:15:20 +11:00
parent 9e744ef180
commit 003bcc9096
1 changed files with 56 additions and 56 deletions

View File

@ -1,72 +1,72 @@
#include "stdafx.h" #include "stdafx.h"
CBaseMenu::CBaseMenu () : CBaseMenu::CBaseMenu() :
m_MenuHandle((HMENU)CreateMenu()) m_MenuHandle((HMENU)CreateMenu())
{ {
} }
bool CBaseMenu::AddMenu(HMENU hMenu, MenuItemList Items ) { bool CBaseMenu::AddMenu(HMENU hMenu, MenuItemList Items)
if (Items.begin() == Items.end()) { return false; } {
if (Items.begin() == Items.end()) { return false; }
UINT ItemID, uFlags; UINT ItemID, uFlags;
std::wstring Text, String; std::wstring Text, String;
for (MenuItemList::iterator MenuItem = Items.begin(); MenuItem != Items.end(); MenuItem++) for (MenuItemList::iterator MenuItem = Items.begin(); MenuItem != Items.end(); MenuItem++)
{ {
ItemID = MenuItem->ID(); ItemID = MenuItem->ID();
uFlags = MF_STRING; uFlags = MF_STRING;
Text = g_Lang->GetString(MenuItem->Title()).c_str(); Text = g_Lang->GetString(MenuItem->Title()).c_str();
if (MenuItem->Title() == EMPTY_STRING && MenuItem->ManualString().length() > 0) if (MenuItem->Title() == EMPTY_STRING && MenuItem->ManualString().length() > 0)
{ {
Text = MenuItem->ManualString(); Text = MenuItem->ManualString();
} }
if (ItemID == SPLITER) if (ItemID == SPLITER)
{ {
uFlags |= MF_SEPARATOR; uFlags |= MF_SEPARATOR;
} }
if (MenuItem->ItemTicked()) if (MenuItem->ItemTicked())
{ {
uFlags |= MFS_CHECKED; uFlags |= MFS_CHECKED;
} }
if (MenuItem->ItemEnabled()) if (MenuItem->ItemEnabled())
{ {
uFlags |= MFS_ENABLED; uFlags |= MFS_ENABLED;
} }
else else
{ {
uFlags |= MFS_DISABLED; uFlags |= MFS_DISABLED;
} }
MenuItemList * SubMenu = (MenuItemList *)MenuItem->SubMenu();
if (ItemID == SUB_MENU && HIWORD(SubMenu) != 0 && (SubMenu->begin() != SubMenu->end()))
{
ItemID = (UINT)CreatePopupMenu();
uFlags |= MF_POPUP;
AddMenu((HMENU)ItemID,*SubMenu); MenuItemList * SubMenu = (MenuItemList *)MenuItem->SubMenu();
} if (ItemID == SUB_MENU && HIWORD(SubMenu) != 0 && (SubMenu->begin() != SubMenu->end()))
if (ItemID == ID_PLUGIN_MENU)
{
ItemID = (UINT)MenuItem->SubMenu();
uFlags |= MF_POPUP;
MENUITEMINFO lpmii;
lpmii.cbSize = sizeof(MENUITEMINFO);
lpmii.fMask = MIIM_STATE;
lpmii.fState = 0;
SetMenuItemInfo((HMENU)ItemID, (DWORD)MenuItem->SubMenu(), FALSE,&lpmii);
}
if (MenuItem->ShortCut().empty() == false)
{ {
String = Text; ItemID = (UINT)CreatePopupMenu();
String += L"\t"; uFlags |= MF_POPUP;
String += MenuItem->ShortCut();
Text = String;
}
AppendMenuW(hMenu,uFlags,ItemID,Text.c_str());
}
return true;
}
AddMenu((HMENU)ItemID, *SubMenu);
}
if (ItemID == ID_PLUGIN_MENU)
{
ItemID = (UINT)MenuItem->SubMenu();
uFlags |= MF_POPUP;
MENUITEMINFO lpmii;
lpmii.cbSize = sizeof(MENUITEMINFO);
lpmii.fMask = MIIM_STATE;
lpmii.fState = 0;
SetMenuItemInfo((HMENU)ItemID, (DWORD)MenuItem->SubMenu(), FALSE, &lpmii);
}
if (MenuItem->ShortCut().empty() == false)
{
String = Text;
String += L"\t";
String += MenuItem->ShortCut();
Text = String;
}
AppendMenuW(hMenu, uFlags, ItemID, Text.c_str());
}
return true;
}