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" POPUP "Context"
BEGIN BEGIN
MENUITEM "About...", ID_CONTEXT_ABOUT MENUITEM "About...", ID_CONTEXT_ABOUT
MENUITEM "Downloads", ID_CONTEXT_DOWNLOADS
MENUITEM "Help", ID_CONTEXT_SHOW_HELP MENUITEM "Help", ID_CONTEXT_SHOW_HELP
MENUITEM SEPARATOR 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 SEPARATOR
MENUITEM "Edit Settings...", ID_CONTEXT_EDITCONFIG MENUITEM "Edit Settings...", ID_CONTEXT_EDITCONFIG
MENUITEM "Refresh All", ID_CONTEXT_REFRESH MENUITEM "Refresh All", ID_CONTEXT_REFRESH
@ -98,14 +110,21 @@ IDR_SKIN_MENU MENU DISCARDABLE
BEGIN BEGIN
POPUP "Skin Menu" POPUP "Skin Menu"
BEGIN BEGIN
MENUITEM " ", ID_CONTEXT_SKINMENU_OPENSKINSFOLDER
MENUITEM SEPARATOR
POPUP "Variants"
BEGIN
MENUITEM " ", 0, GRAYED // DUMMY
END
MENUITEM SEPARATOR
POPUP "Settings" POPUP "Settings"
BEGIN BEGIN
POPUP "Position" POPUP "Position"
BEGIN BEGIN
POPUP "Display Monitor" POPUP "Display Monitor"
BEGIN BEGIN
MENUITEM "Use default: Primary monitor", ID_CONTEXT_SKINMENU_MONITOR_PRIMARY MENUITEM "Use default: Primary monitor", ID_CONTEXT_SKINMENU_MONITOR_PRIMARY
MENUITEM "@0: Virtual screen", ID_MONITOR_FIRST MENUITEM "@0: Virtual screen", ID_MONITOR_FIRST
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "Auto-select based on window position", ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT MENUITEM "Auto-select based on window position", ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT

View File

@ -3869,7 +3869,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
{ {
// Disable Quit/Logging if ran as a Litestep plugin // Disable Quit/Logging if ran as a Litestep plugin
EnableMenuItem(subMenu, ID_CONTEXT_QUIT, MF_BYCOMMAND | MF_GRAYED); 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 else
{ {
@ -3890,26 +3890,24 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
} }
} }
HMENU configMenu = CreateConfigMenu(m_ConfigMenu); HMENU configMenu = GetSubMenu(subMenu, 4);
if (!configMenu)
{
configMenu = CreatePopupMenu();
AppendMenu(configMenu, MF_GRAYED, 0, L"No configs available");
}
if (configMenu) if (configMenu)
{ {
AppendMenu(configMenu, MF_SEPARATOR, 0, NULL); if (!CreateConfigMenu(configMenu, m_ConfigMenu))
AppendMenu(configMenu, 0, ID_CONTEXT_OPENSKINSFOLDER, L"Open Skins\' Folder"); {
AppendMenu(configMenu, (m_DisableDragging) ? MF_CHECKED : MF_UNCHECKED, ID_CONTEXT_DISABLEDRAG, L"Disable Dragging"); InsertMenu(configMenu, 0, MF_BYPOSITION | MF_GRAYED, 0, L"No configs available");
AppendMenu(configMenu, 0, ID_CONTEXT_MANAGESKINS, L"Manage Skins..."); }
InsertMenu(subMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configMenu, L"Configs"); if (m_DisableDragging)
{
CheckMenuItem(configMenu, ID_CONTEXT_DISABLEDRAG, MF_BYCOMMAND | MF_CHECKED);
}
} }
HMENU themeMenu = CreateThemeMenu(); HMENU themeMenu = GetSubMenu(subMenu, 5);
if (themeMenu) if (themeMenu)
{ {
InsertMenu(subMenu, 4, MF_BYPOSITION | MF_POPUP, (UINT_PTR)themeMenu, L"Themes"); CreateThemeMenu(themeMenu);
} }
if (meterWindow) if (meterWindow)
@ -3918,10 +3916,12 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
subMenu = CreateSkinMenu(meterWindow, 0, configMenu); subMenu = CreateSkinMenu(meterWindow, 0, configMenu);
InsertMenu(subMenu, 9, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); InsertMenu(subMenu, 9, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
InsertMenu(subMenu, 10, MF_BYPOSITION | MF_POPUP, (UINT_PTR)rainmeterMenu, L"Rainmeter Menu"); InsertMenu(subMenu, 10, MF_BYPOSITION | MF_POPUP, (UINT_PTR)rainmeterMenu, L"Rainmeter Menu");
RemoveMenu(rainmeterMenu, ID_CONTEXT_DOWNLOADS, MF_BYCOMMAND);
} }
else 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 // Create a menu for all active configs
std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin(); 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); CMeterWindow* mw = ((*iter).second);
HMENU skinMenu = CreateSkinMenu(mw, index, configMenu); 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; ++index;
} }
InsertMenu(subMenu, 1, MF_BYPOSITION, ID_CONTEXT_DOWNLOADS, L"Downloads");
// Put Update notifications in the Tray menu // Put Update notifications in the Tray menu
if (m_NewVersion) 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 (!configMenuData.empty())
{ {
configMenu = CreatePopupMenu(); if (!configMenu)
bool item = false; {
configMenu = CreatePopupMenu();
}
bool item = false;
for (int i = 0, j = 0, isize = (int)configMenuData.size(); i < isize; ++i) for (int i = 0, j = 0, isize = (int)configMenuData.size(); i < isize; ++i)
{ {
if (configMenuData[i].index == -1) if (configMenuData[i].index == -1)
@ -4015,7 +4014,7 @@ HMENU CRainmeter::CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData)
item = false; item = false;
} }
HMENU submenu = CreateConfigMenu(configMenuData[i].children); HMENU submenu = CreateConfigMenu(NULL, configMenuData[i].children);
if (submenu) if (submenu)
{ {
InsertMenu(configMenu, i + j, MF_BYPOSITION | MF_POPUP, (UINT_PTR)submenu, configMenuData[i].name.c_str()); 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; item = true;
} }
} }
return configMenu;
} }
return configMenu;
return NULL;
} }
HMENU CRainmeter::CreateThemeMenu() void CRainmeter::CreateThemeMenu(HMENU themeMenu)
{ {
HMENU themeMenu = CreatePopupMenu();
for (size_t i = 0, isize = m_Themes.size(); i < isize; ++i)
{
AppendMenu(themeMenu, 0, ID_THEME_FIRST + i, m_Themes[i].c_str());
}
if (!m_Themes.empty()) if (!m_Themes.empty())
{ {
AppendMenu(themeMenu, MF_SEPARATOR, 0, NULL); InsertMenu(themeMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
for (size_t i = 0, isize = m_Themes.size(); i < isize; ++i)
{
InsertMenu(themeMenu, i, MF_BYPOSITION, ID_THEME_FIRST + i, m_Themes[i].c_str());
}
} }
AppendMenu(themeMenu, 0, ID_CONTEXT_MANAGETHEMES, L"Manage Themes...");
return themeMenu;
} }
HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu) HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu)
@ -4066,7 +4062,7 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
if (skinMenu) if (skinMenu)
{ {
// Tick the position // Tick the position
HMENU settingsMenu = GetSubMenu(skinMenu, 0); HMENU settingsMenu = GetSubMenu(skinMenu, 4);
if (settingsMenu) if (settingsMenu)
{ {
HMENU posMenu = GetSubMenu(settingsMenu, 0); HMENU posMenu = GetSubMenu(settingsMenu, 0);
@ -4110,102 +4106,110 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
CreateMonitorMenu(monitorMenu, meterWindow); CreateMonitorMenu(monitorMenu, meterWindow);
} }
} }
}
// Tick the transparency // Tick the transparency
if (!meterWindow->GetNativeTransparency()) if (!meterWindow->GetNativeTransparency())
{
EnableMenuItem(settingsMenu, 1, MF_BYPOSITION | MF_GRAYED); // "Transparency" menu
EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_GRAYED);
}
else
{
HMENU alphaMenu = GetSubMenu(settingsMenu, 1);
if (alphaMenu)
{ {
int value = (int)(10 - meterWindow->GetAlphaValue() / 25.5); EnableMenuItem(settingsMenu, 1, MF_BYPOSITION | MF_GRAYED); // "Transparency" menu
value = min(9, value); EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_GRAYED);
value = max(0, value); }
CheckMenuItem(alphaMenu, value, MF_BYPOSITION | MF_CHECKED); else
{
HMENU alphaMenu = GetSubMenu(settingsMenu, 1);
if (alphaMenu)
{
int value = (int)(10 - meterWindow->GetAlphaValue() / 25.5);
value = min(9, value);
value = max(0, value);
CheckMenuItem(alphaMenu, value, MF_BYPOSITION | MF_CHECKED);
if (meterWindow->GetWindowHide() == HIDEMODE_FADEIN) if (meterWindow->GetWindowHide() == HIDEMODE_FADEIN)
{ {
CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_CHECKED);
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED);
} }
else if (meterWindow->GetWindowHide() == HIDEMODE_FADEOUT) else if (meterWindow->GetWindowHide() == HIDEMODE_FADEOUT)
{ {
CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_CHECKED);
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED);
} }
else if (meterWindow->GetWindowHide() == HIDEMODE_HIDE) else if (meterWindow->GetWindowHide() == HIDEMODE_HIDE)
{ {
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(alphaMenu, ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT, MF_BYCOMMAND | MF_GRAYED);
}
} }
} }
// Tick the configs
if (meterWindow->GetWindowHide() == HIDEMODE_HIDE)
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_CHECKED);
}
else if (meterWindow->GetWindowHide() != HIDEMODE_NONE)
{
EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_GRAYED);
}
if (meterWindow->GetSnapEdges())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_SNAPTOEDGES, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetSavePosition())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_REMEMBERPOSITION, MF_BYCOMMAND | MF_CHECKED);
}
if (m_DisableDragging)
{
EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_DRAGGABLE, MF_BYCOMMAND | MF_GRAYED);
}
else if (meterWindow->GetWindowDraggable())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_DRAGGABLE, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetClickThrough())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetKeepOnScreen())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_KEEPONSCREEN, MF_BYCOMMAND | MF_CHECKED);
}
} }
// Tick the configs // Add the name of the Skin to the menu
if (meterWindow->GetWindowHide() == HIDEMODE_HIDE)
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_CHECKED);
}
else if (meterWindow->GetWindowHide() != HIDEMODE_NONE)
{
EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_HIDEONMOUSE, MF_BYCOMMAND | MF_GRAYED);
}
if (meterWindow->GetSnapEdges())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_SNAPTOEDGES, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetSavePosition())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_REMEMBERPOSITION, MF_BYCOMMAND | MF_CHECKED);
}
if (m_DisableDragging)
{
EnableMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_DRAGGABLE, MF_BYCOMMAND | MF_GRAYED);
}
else if (meterWindow->GetWindowDraggable())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_DRAGGABLE, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetClickThrough())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_CLICKTHROUGH, MF_BYCOMMAND | MF_CHECKED);
}
if (meterWindow->GetKeepOnScreen())
{
CheckMenuItem(settingsMenu, ID_CONTEXT_SKINMENU_KEEPONSCREEN, MF_BYCOMMAND | MF_CHECKED);
}
// Add the name of the Skin to the menu and disable the item
const std::wstring& skinName = meterWindow->GetSkinName(); const std::wstring& skinName = meterWindow->GetSkinName();
InsertMenu(skinMenu, 0, MF_BYPOSITION, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str()); ModifyMenu(skinMenu, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, MF_BYCOMMAND, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, skinName.c_str());
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); SetMenuDefaultItem(skinMenu, ID_CONTEXT_SKINMENU_OPENSKINSFOLDER, FALSE);
SetMenuDefaultItem(skinMenu, 0, MF_BYPOSITION);
// 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); ChangeSkinIndex(skinMenu, index);
// Add the variants menu // Add the variants menu
for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i) if (variantsMenu)
{ {
const CONFIG& config = m_ConfigStrings[i]; for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i)
if (_wcsicmp(config.config.c_str(), skinName.c_str()) == 0)
{ {
HMENU variantsMenu = CreatePopupMenu(); const CONFIG& config = m_ConfigStrings[i];
for (int j = 0, jsize = (int)config.iniFiles.size(); j < jsize; ++j) if (_wcsicmp(config.config.c_str(), skinName.c_str()) == 0)
{ {
InsertMenu(variantsMenu, j, MF_BYPOSITION | ((config.active == j + 1) ? MF_CHECKED : MF_UNCHECKED), config.commands[j], config.iniFiles[j].c_str()); 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());
}
break;
} }
InsertMenu(skinMenu, 2, MF_BYPOSITION | MF_POPUP, (UINT_PTR)variantsMenu, L"Variants");
break;
} }
} }
@ -4234,7 +4238,6 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
if (configRootMenu) if (configRootMenu)
{ {
InsertMenu(skinMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configRootMenu, root.c_str()); InsertMenu(skinMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configRootMenu, root.c_str());
InsertMenu(skinMenu, 4, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
} }
break; break;
} }

View File

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