Relocated some context menu items to the resource file.

This commit is contained in:
spx 2011-08-19 03:12:01 +00:00
parent bf7fdad840
commit c0579e3b24
3 changed files with 146 additions and 124 deletions

View File

@ -73,8 +73,20 @@ BEGIN
POPUP "Context"
BEGIN
MENUITEM "About...", ID_CONTEXT_ABOUT
MENUITEM "Downloads", ID_CONTEXT_DOWNLOADS
MENUITEM "Help", ID_CONTEXT_SHOW_HELP
MENUITEM SEPARATOR
POPUP "Configs"
BEGIN
MENUITEM SEPARATOR
MENUITEM "Open Skins' Folder", ID_CONTEXT_OPENSKINSFOLDER
MENUITEM "Disable Dragging", ID_CONTEXT_DISABLEDRAG
MENUITEM "Manage Skins...", ID_CONTEXT_MANAGESKINS
END
POPUP "Themes"
BEGIN
MENUITEM "Manage Themes...", ID_CONTEXT_MANAGETHEMES
END
MENUITEM SEPARATOR
MENUITEM "Edit Settings...", ID_CONTEXT_EDITCONFIG
MENUITEM "Refresh All", ID_CONTEXT_REFRESH
@ -98,6 +110,13 @@ IDR_SKIN_MENU MENU DISCARDABLE
BEGIN
POPUP "Skin Menu"
BEGIN
MENUITEM " ", ID_CONTEXT_SKINMENU_OPENSKINSFOLDER
MENUITEM SEPARATOR
POPUP "Variants"
BEGIN
MENUITEM " ", 0, GRAYED // DUMMY
END
MENUITEM SEPARATOR
POPUP "Settings"
BEGIN
POPUP "Position"

View File

@ -3869,7 +3869,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
{
// Disable Quit/Logging if ran as a Litestep plugin
EnableMenuItem(subMenu, ID_CONTEXT_QUIT, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, 7, MF_BYPOSITION | MF_GRAYED); // "Logging" menu
EnableMenuItem(subMenu, 10, MF_BYPOSITION | MF_GRAYED); // "Logging" menu
}
else
{
@ -3890,26 +3890,24 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
}
}
HMENU configMenu = CreateConfigMenu(m_ConfigMenu);
if (!configMenu)
{
configMenu = CreatePopupMenu();
AppendMenu(configMenu, MF_GRAYED, 0, L"No configs available");
}
HMENU configMenu = GetSubMenu(subMenu, 4);
if (configMenu)
{
AppendMenu(configMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(configMenu, 0, ID_CONTEXT_OPENSKINSFOLDER, L"Open Skins\' Folder");
AppendMenu(configMenu, (m_DisableDragging) ? MF_CHECKED : MF_UNCHECKED, ID_CONTEXT_DISABLEDRAG, L"Disable Dragging");
AppendMenu(configMenu, 0, ID_CONTEXT_MANAGESKINS, L"Manage Skins...");
InsertMenu(subMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configMenu, L"Configs");
if (!CreateConfigMenu(configMenu, m_ConfigMenu))
{
InsertMenu(configMenu, 0, MF_BYPOSITION | MF_GRAYED, 0, L"No configs available");
}
HMENU themeMenu = CreateThemeMenu();
if (m_DisableDragging)
{
CheckMenuItem(configMenu, ID_CONTEXT_DISABLEDRAG, MF_BYCOMMAND | MF_CHECKED);
}
}
HMENU themeMenu = GetSubMenu(subMenu, 5);
if (themeMenu)
{
InsertMenu(subMenu, 4, MF_BYPOSITION | MF_POPUP, (UINT_PTR)themeMenu, L"Themes");
CreateThemeMenu(themeMenu);
}
if (meterWindow)
@ -3918,10 +3916,12 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
subMenu = CreateSkinMenu(meterWindow, 0, configMenu);
InsertMenu(subMenu, 9, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
InsertMenu(subMenu, 10, MF_BYPOSITION | MF_POPUP, (UINT_PTR)rainmeterMenu, L"Rainmeter Menu");
RemoveMenu(rainmeterMenu, ID_CONTEXT_DOWNLOADS, MF_BYCOMMAND);
}
else
{
InsertMenu(subMenu, 11, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
InsertMenu(subMenu, 12, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
// Create a menu for all active configs
std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
@ -3931,12 +3931,10 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
{
CMeterWindow* mw = ((*iter).second);
HMENU skinMenu = CreateSkinMenu(mw, index, configMenu);
InsertMenu(subMenu, 11, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, mw->GetSkinName().c_str());
InsertMenu(subMenu, 12, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, mw->GetSkinName().c_str());
++index;
}
InsertMenu(subMenu, 1, MF_BYPOSITION, ID_CONTEXT_DOWNLOADS, L"Downloads");
// Put Update notifications in the Tray menu
if (m_NewVersion)
{
@ -3994,15 +3992,16 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
}
HMENU CRainmeter::CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData)
HMENU CRainmeter::CreateConfigMenu(HMENU configMenu, std::vector<CONFIGMENU>& configMenuData)
{
HMENU configMenu = NULL;
if (!configMenuData.empty())
{
if (!configMenu)
{
configMenu = CreatePopupMenu();
bool item = false;
}
bool item = false;
for (int i = 0, j = 0, isize = (int)configMenuData.size(); i < isize; ++i)
{
if (configMenuData[i].index == -1)
@ -4015,7 +4014,7 @@ HMENU CRainmeter::CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData)
item = false;
}
HMENU submenu = CreateConfigMenu(configMenuData[i].children);
HMENU submenu = CreateConfigMenu(NULL, configMenuData[i].children);
if (submenu)
{
InsertMenu(configMenu, i + j, MF_BYPOSITION | MF_POPUP, (UINT_PTR)submenu, configMenuData[i].name.c_str());
@ -4028,27 +4027,24 @@ HMENU CRainmeter::CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData)
item = true;
}
}
}
return configMenu;
}
return NULL;
}
HMENU CRainmeter::CreateThemeMenu()
void CRainmeter::CreateThemeMenu(HMENU themeMenu)
{
HMENU themeMenu = CreatePopupMenu();
if (!m_Themes.empty())
{
InsertMenu(themeMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
for (size_t i = 0, isize = m_Themes.size(); i < isize; ++i)
{
AppendMenu(themeMenu, 0, ID_THEME_FIRST + i, m_Themes[i].c_str());
InsertMenu(themeMenu, i, MF_BYPOSITION, ID_THEME_FIRST + i, m_Themes[i].c_str());
}
if (!m_Themes.empty())
{
AppendMenu(themeMenu, MF_SEPARATOR, 0, NULL);
}
AppendMenu(themeMenu, 0, ID_CONTEXT_MANAGETHEMES, L"Manage Themes...");
return themeMenu;
}
HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu)
@ -4066,7 +4062,7 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
if (skinMenu)
{
// Tick the position
HMENU settingsMenu = GetSubMenu(skinMenu, 0);
HMENU settingsMenu = GetSubMenu(skinMenu, 4);
if (settingsMenu)
{
HMENU posMenu = GetSubMenu(settingsMenu, 0);
@ -4110,7 +4106,6 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
CreateMonitorMenu(monitorMenu, meterWindow);
}
}
}
// Tick the transparency
if (!meterWindow->GetNativeTransparency())
@ -4184,30 +4179,39 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_KEEPONSCREEN, MF_BYCOMMAND | MF_CHECKED);
}
}
// Add the name of the Skin to the menu and disable the item
// Add the name of the Skin to the menu
const std::wstring& skinName = meterWindow->GetSkinName();
InsertMenu(skinMenu, 0, MF_BYPOSITION, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str());
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
SetMenuDefaultItem(skinMenu, 0, MF_BYPOSITION);
ModifyMenu(skinMenu, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, MF_BYCOMMAND, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str());
SetMenuDefaultItem(skinMenu, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, FALSE);
// Remove dummy menuitem from the variants menu
HMENU variantsMenu = GetSubMenu(skinMenu, 2);
if (variantsMenu)
{
RemoveMenu(variantsMenu, 0, MF_BYPOSITION);
}
// Give the menuitem the unique id that depends on the skin
ChangeSkinIndex(skinMenu, index);
// Add the variants menu
if (variantsMenu)
{
for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i)
{
const CONFIG& config = m_ConfigStrings[i];
if (_wcsicmp(config.config.c_str(), skinName.c_str()) == 0)
{
HMENU variantsMenu = CreatePopupMenu();
for (int j = 0, jsize = (int)config.iniFiles.size(); j < jsize; ++j)
{
InsertMenu(variantsMenu, j, MF_BYPOSITION | ((config.active == j + 1) ? MF_CHECKED : MF_UNCHECKED), config.commands[j], config.iniFiles[j].c_str());
}
InsertMenu(skinMenu, 2, MF_BYPOSITION | MF_POPUP, (UINT_PTR)variantsMenu, L"Variants");
break;
}
}
}
// Add config's root menu
int itemCount = GetMenuItemCount(configMenu);
@ -4234,7 +4238,6 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
if (configRootMenu)
{
InsertMenu(skinMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configRootMenu, root.c_str());
InsertMenu(skinMenu, 4, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
}
break;
}

View File

@ -272,8 +272,8 @@ private:
HMENU CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu);
void ChangeSkinIndex(HMENU subMenu, int index);
int ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse);
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
HMENU CreateThemeMenu();
HMENU CreateConfigMenu(HMENU configMenu, std::vector<CONFIGMENU>& configMenuData);
void CreateThemeMenu(HMENU themeMenu);
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
void CreateDefaultConfigFile(const std::wstring& strFile);
void SetLogging(bool logging);