Work on exporting stuff, revert some changes for better diff

This commit is contained in:
Tiberiu Chibici 2014-08-01 22:54:35 +03:00
parent 473f23378f
commit 69913fa251
31 changed files with 21016 additions and 20755 deletions

View File

@ -165,7 +165,7 @@ void DoBang(const BangInfo& bangInfo, std::vector<std::wstring>& args, MeterWind
const std::wstring& folderPath = args[bangInfo.argCount];
if (!folderPath.empty() && (folderPath.length() != 1 || folderPath[0] != L'*'))
{
MeterWindow* meterWindow = Rainmeter::GetInstance().GetMeterWindow(folderPath);
MeterWindow* meterWindow = GetRainmeter().GetMeterWindow(folderPath);
if (meterWindow)
{
meterWindow->DoBang(bangInfo.bang, args);
@ -179,7 +179,7 @@ void DoBang(const BangInfo& bangInfo, std::vector<std::wstring>& args, MeterWind
}
// No skin defined -> apply to all.
for (const auto& ip : Rainmeter::GetInstance().GetAllMeterWindows())
for (const auto& ip : GetRainmeter().GetAllMeterWindows())
{
ip.second->DoBang(bangInfo.bang, args);
}
@ -213,7 +213,7 @@ void DoGroupBang(const BangInfo& bangInfo, std::vector<std::wstring>& args, Mete
if (args.size() > bangInfo.argCount)
{
std::multimap<int, MeterWindow*> windows;
Rainmeter::GetInstance().GetMeterWindowsByLoadOrder(windows, args[bangInfo.argCount]);
GetRainmeter().GetMeterWindowsByLoadOrder(windows, args[bangInfo.argCount]);
// Remove extra parameters (including group).
args.resize(bangInfo.argCount);
@ -584,11 +584,11 @@ void CommandHandler::DoActivateSkinBang(std::vector<std::wstring>& args, MeterWi
{
if (args.size() == 1)
{
if (Rainmeter::GetInstance().ActivateSkin(args[0])) return;
if (GetRainmeter().ActivateSkin(args[0])) return;
}
else if (args.size() > 1)
{
if (Rainmeter::GetInstance().ActivateSkin(args[0], args[1])) return;
if (GetRainmeter().ActivateSkin(args[0], args[1])) return;
}
LogErrorF(skin, L"!ActivateConfig: Invalid parameters");
@ -598,7 +598,7 @@ void CommandHandler::DoDeactivateSkinBang(std::vector<std::wstring>& args, Meter
{
if (!args.empty())
{
skin = Rainmeter::GetInstance().GetMeterWindow(args[0]);
skin = GetRainmeter().GetMeterWindow(args[0]);
if (!skin)
{
LogWarningF(L"!DeactivateConfig: \"%s\" not active", args[0].c_str());
@ -608,7 +608,7 @@ void CommandHandler::DoDeactivateSkinBang(std::vector<std::wstring>& args, Meter
if (skin)
{
Rainmeter::GetInstance().DeactivateSkin(skin, -1);
GetRainmeter().DeactivateSkin(skin, -1);
}
else
{
@ -620,10 +620,10 @@ void CommandHandler::DoToggleSkinBang(std::vector<std::wstring>& args, MeterWind
{
if (args.size() >= 2)
{
MeterWindow* meterWindow = Rainmeter::GetInstance().GetMeterWindow(args[0]);
MeterWindow* meterWindow = GetRainmeter().GetMeterWindow(args[0]);
if (meterWindow)
{
Rainmeter::GetInstance().DeactivateSkin(meterWindow, -1);
GetRainmeter().DeactivateSkin(meterWindow, -1);
return;
}
@ -641,10 +641,10 @@ void CommandHandler::DoDeactivateSkinGroupBang(std::vector<std::wstring>& args,
if (!args.empty())
{
std::multimap<int, MeterWindow*> windows;
Rainmeter::GetInstance().GetMeterWindowsByLoadOrder(windows, args[0]);
GetRainmeter().GetMeterWindowsByLoadOrder(windows, args[0]);
for (const auto& ip : windows)
{
Rainmeter::GetInstance().DeactivateSkin(ip.second, -1);
GetRainmeter().DeactivateSkin(ip.second, -1);
}
}
else
@ -663,12 +663,12 @@ void CommandHandler::DoLoadLayoutBang(std::vector<std::wstring>& args, MeterWind
std::wstring command = L"!LoadLayout \"";
command += args[0];
command += L'"';
Rainmeter::GetInstance().DelayedExecuteCommand(command.c_str());
GetRainmeter().DelayedExecuteCommand(command.c_str());
}
else
{
// Not called from a skin (or called with delay).
Rainmeter::GetInstance().LoadLayout(args[0]);
GetRainmeter().LoadLayout(args[0]);
}
}
}
@ -734,7 +734,7 @@ void CommandHandler::DoSkinMenuBang(std::vector<std::wstring>& args, MeterWindow
{
if (!args.empty())
{
skin = Rainmeter::GetInstance().GetMeterWindow(args[0]);
skin = GetRainmeter().GetMeterWindow(args[0]);
if (!skin)
{
LogWarningF(L"!SkinMenu: \"%s\" not active", args[0].c_str());
@ -745,7 +745,7 @@ void CommandHandler::DoSkinMenuBang(std::vector<std::wstring>& args, MeterWindow
if (skin)
{
POINT pos = System::GetCursorPosition();
Rainmeter::GetInstance().ShowContextMenu(pos, skin);
GetRainmeter().ShowContextMenu(pos, skin);
}
else
{
@ -756,12 +756,12 @@ void CommandHandler::DoSkinMenuBang(std::vector<std::wstring>& args, MeterWindow
void CommandHandler::DoTrayMenuBang(std::vector<std::wstring>& args, MeterWindow* skin)
{
POINT pos = System::GetCursorPosition();
Rainmeter::GetInstance().ShowContextMenu(pos, nullptr);
GetRainmeter().ShowContextMenu(pos, nullptr);
}
void CommandHandler::DoResetStatsBang(std::vector<std::wstring>& args, MeterWindow* meterWindow)
{
Rainmeter::GetInstance().ResetStats();
GetRainmeter().ResetStats();
}
void CommandHandler::DoWriteKeyValueBang(std::vector<std::wstring>& args, MeterWindow* skin)
@ -791,8 +791,8 @@ void CommandHandler::DoWriteKeyValueBang(std::vector<std::wstring>& args, MeterW
return;
}
if (_wcsnicmp(iniFile, Rainmeter::GetInstance().m_SkinPath.c_str(), Rainmeter::GetInstance().m_SkinPath.size()) != 0 &&
_wcsnicmp(iniFile, Rainmeter::GetInstance().m_SettingsPath.c_str(), Rainmeter::GetInstance().m_SettingsPath.size()) != 0)
if (_wcsnicmp(iniFile, GetRainmeter().m_SkinPath.c_str(), GetRainmeter().m_SkinPath.size()) != 0 &&
_wcsnicmp(iniFile, GetRainmeter().m_SettingsPath.c_str(), GetRainmeter().m_SettingsPath.size()) != 0)
{
LogErrorF(skin, L"!WriteKeyValue: Illegal path: %s", iniFile);
return;
@ -825,14 +825,14 @@ void CommandHandler::DoWriteKeyValueBang(std::vector<std::wstring>& args, MeterW
if (temporary)
{
if (Rainmeter::GetInstance().GetDebug())
if (GetRainmeter().GetDebug())
{
LogDebugF(skin, L"!WriteKeyValue: Writing to: %s (Temp: %s)", iniFile, strIniWrite.c_str());
}
}
else
{
if (Rainmeter::GetInstance().GetDebug())
if (GetRainmeter().GetDebug())
{
LogDebugF(skin, L"!WriteKeyValue: Writing to: %s", iniFile);
}
@ -935,13 +935,13 @@ void CommandHandler::DoLogBang(std::vector<std::wstring>& args, MeterWindow* ski
void CommandHandler::DoRefreshApp(std::vector<std::wstring>& args, MeterWindow* meterWindow)
{
// Refresh needs to be delayed since it crashes if done during Update().
PostMessage(Rainmeter::GetInstance().m_Window, WM_RAINMETER_DELAYED_REFRESH_ALL, 0, 0);
PostMessage(GetRainmeter().m_Window, WM_RAINMETER_DELAYED_REFRESH_ALL, 0, 0);
}
void CommandHandler::DoQuitBang(std::vector<std::wstring>& args, MeterWindow* meterWindow)
{
// Quit needs to be delayed since it crashes if done during Update().
PostMessage(Rainmeter::GetInstance().GetTrayWindow()->GetWindow(), WM_COMMAND, MAKEWPARAM(IDM_QUIT, 0), 0);
PostMessage(GetRainmeter().GetTrayWindow()->GetWindow(), WM_COMMAND, MAKEWPARAM(IDM_QUIT, 0), 0);
}
void CommandHandler::DoLsBoxHookBang(std::vector<std::wstring>& args, MeterWindow* meterWindow)

View File

@ -92,13 +92,13 @@ void ConfigParser::SetBuiltInVariables(const std::wstring& filename, const std::
return m_BuiltInVariables.insert(std::make_pair(name, value));
};
insertVariable(L"PROGRAMPATH", Rainmeter::GetInstance().GetPath());
insertVariable(L"PROGRAMDRIVE", Rainmeter::GetInstance().GetDrive());
insertVariable(L"SETTINGSPATH", Rainmeter::GetInstance().GetSettingsPath());
insertVariable(L"SKINSPATH", Rainmeter::GetInstance().GetSkinPath());
insertVariable(L"PLUGINSPATH", Rainmeter::GetInstance().GetPluginPath());
insertVariable(L"PROGRAMPATH", GetRainmeter().GetPath());
insertVariable(L"PROGRAMDRIVE", GetRainmeter().GetDrive());
insertVariable(L"SETTINGSPATH", GetRainmeter().GetSettingsPath());
insertVariable(L"SKINSPATH", GetRainmeter().GetSkinPath());
insertVariable(L"PLUGINSPATH", GetRainmeter().GetPluginPath());
insertVariable(L"CURRENTPATH", PathUtil::GetFolderFromFilePath(filename));
insertVariable(L"ADDONSPATH", Rainmeter::GetInstance().GetAddonPath());
insertVariable(L"ADDONSPATH", GetRainmeter().GetAddonPath());
if (meterWindow)
{
@ -1314,7 +1314,7 @@ void ConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR skinSection,
{
if (depth > 100) // Is 100 enough to assume the include loop never ends?
{
Rainmeter::GetInstance().ShowMessage(nullptr, GetString(ID_STR_INCLUDEINFINITELOOP), MB_OK | MB_ICONERROR);
GetRainmeter().ShowMessage(nullptr, GetString(ID_STR_INCLUDEINFINITELOOP), MB_OK | MB_ICONERROR);
return;
}
@ -1331,11 +1331,11 @@ void ConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR skinSection,
if (temporary)
{
if (Rainmeter::GetInstance().GetDebug()) LogDebugF(m_MeterWindow, L"Reading file: %s (Temp: %s)", iniFile.c_str(), iniRead.c_str());
if (GetRainmeter().GetDebug()) LogDebugF(m_MeterWindow, L"Reading file: %s (Temp: %s)", iniFile.c_str(), iniRead.c_str());
}
else
{
if (Rainmeter::GetInstance().GetDebug()) LogDebugF(m_MeterWindow, L"Reading file: %s", iniFile.c_str());
if (GetRainmeter().GetDebug()) LogDebugF(m_MeterWindow, L"Reading file: %s", iniFile.c_str());
iniRead = iniFile;
}

View File

@ -73,7 +73,7 @@ void ContextMenu::ShowMenu(POINT pos, MeterWindow* meterWindow)
if (!menu) return;
m_MenuActive = true;
Rainmeter& rainmeter = Rainmeter::GetInstance();
Rainmeter& rainmeter = GetRainmeter();
SetMenuDefaultItem(menu, IDM_MANAGE, MF_BYCOMMAND);
@ -343,7 +343,7 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
CheckMenuItem(settingsMenu, IDM_SKIN_REMEMBERPOSITION, MF_BYCOMMAND | MF_CHECKED);
}
if (Rainmeter::GetInstance().m_DisableDragging)
if (GetRainmeter().m_DisableDragging)
{
EnableMenuItem(settingsMenu, IDM_SKIN_DRAGGABLE, MF_BYCOMMAND | MF_GRAYED);
}
@ -364,7 +364,7 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
if (Gfx::CanvasD2D::Initialize())
{
if (!Rainmeter::GetInstance().GetUseD2D())
if (!GetRainmeter().GetUseD2D())
{
EnableMenuItem(settingsMenu, IDM_SKIN_USED2D, MF_BYCOMMAND | MF_GRAYED);
}
@ -398,7 +398,7 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
// Add the variants menu
if (variantsMenu)
{
const SkinRegistry::Folder& skinFolder = *Rainmeter::GetInstance().m_SkinRegistry.FindFolder(skinName);
const SkinRegistry::Folder& skinFolder = *GetRainmeter().m_SkinRegistry.FindFolder(skinName);
for (int i = 0, isize = (int)skinFolder.files.size(); i < isize; ++i)
{
InsertMenu(variantsMenu, i, MF_BYPOSITION, skinFolder.baseID + i, skinFolder.files[i].c_str());
@ -549,7 +549,7 @@ void ContextMenu::AppendSkinCustomMenu(
int ContextMenu::CreateAllSkinsMenuRecursive(HMENU skinMenu, int index)
{
SkinRegistry& skinRegistry = Rainmeter::GetInstance().m_SkinRegistry;
SkinRegistry& skinRegistry = GetRainmeter().m_SkinRegistry;
const int initialLevel = skinRegistry.GetFolder(index).level;
int menuIndex = 0;
@ -604,7 +604,7 @@ int ContextMenu::CreateAllSkinsMenuRecursive(HMENU skinMenu, int index)
void ContextMenu::CreateLayoutMenu(HMENU layoutMenu)
{
const auto& layouts = Rainmeter::GetInstance().m_Layouts;
const auto& layouts = GetRainmeter().m_Layouts;
for (size_t i = 0, isize = layouts.size(); i < isize; ++i)
{
InsertMenu(layoutMenu, (UINT)i, MF_BYPOSITION, ID_THEME_FIRST + i, layouts[i].c_str());

View File

@ -62,7 +62,7 @@ void DialogAbout::Open(int tab)
0, 0, 400, 210,
DS_CENTER | WS_POPUP | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
WS_EX_APPWINDOW | WS_EX_CONTROLPARENT | ((*GetString(ID_STR_ISRTL) == L'1') ? WS_EX_LAYOUTRTL : 0),
Rainmeter::GetInstance().GetWindow());
GetRainmeter().GetWindow());
// Fake WM_NOTIFY to change tab
NMHDR nm;
@ -752,7 +752,7 @@ void DialogAbout::TabSkins::UpdateSkinList()
// Add entries for each skin
std::wstring::size_type maxLength = 0;
const std::map<std::wstring, MeterWindow*>& windows = Rainmeter::GetInstance().GetAllMeterWindows();
const std::map<std::wstring, MeterWindow*>& windows = GetRainmeter().GetAllMeterWindows();
std::map<std::wstring, MeterWindow*>::const_iterator iter = windows.begin();
bool found = false;
for ( ; iter != windows.end(); ++iter)
@ -806,7 +806,7 @@ void DialogAbout::TabSkins::UpdateMeasureList(MeterWindow* meterWindow)
HWND item = GetControl(Id_SkinsListBox);
int selected = (int)SendMessage(item, LB_GETCURSEL, 0, 0);
const std::map<std::wstring, MeterWindow*>& windows = Rainmeter::GetInstance().GetAllMeterWindows();
const std::map<std::wstring, MeterWindow*>& windows = GetRainmeter().GetAllMeterWindows();
std::map<std::wstring, MeterWindow*>::const_iterator iter = windows.begin();
while (selected && iter != windows.end())
{
@ -1143,10 +1143,10 @@ void DialogAbout::TabPlugins::Initialize()
FindClose(hSearch);
};
findPlugins(Rainmeter::GetInstance().GetPluginPath());
if (Rainmeter::GetInstance().HasUserPluginPath())
findPlugins(GetRainmeter().GetPluginPath());
if (GetRainmeter().HasUserPluginPath())
{
findPlugins(Rainmeter::GetInstance().GetUserPluginPath());
findPlugins(GetRainmeter().GetUserPluginPath());
}
m_Initialized = true;
@ -1242,15 +1242,15 @@ void DialogAbout::TabVersion::Initialize()
SetWindowText(item, Platform::GetPlatformFriendlyName().c_str());
item = GetControl(Id_PathLabel);
std::wstring text = L"Path: " + Rainmeter::GetInstance().GetPath();
std::wstring text = L"Path: " + GetRainmeter().GetPath();
SetWindowText(item, text.c_str());
item = GetControl(Id_IniFileLabel);
text = L"IniFile: " + Rainmeter::GetInstance().GetIniFile();
text = L"IniFile: " + GetRainmeter().GetIniFile();
SetWindowText(item, text.c_str());
item = GetControl(Id_SkinPathLabel);
text = L"SkinPath: " + Rainmeter::GetInstance().GetSkinPath();
text = L"SkinPath: " + GetRainmeter().GetSkinPath();
SetWindowText(item, text.c_str());
m_Initialized = true;
@ -1291,11 +1291,11 @@ INT_PTR DialogAbout::TabVersion::OnCommand(WPARAM wParam, LPARAM lParam)
text += L'\n';
text += Platform::GetPlatformFriendlyName();
text += L"\nPath: ";
text += Rainmeter::GetInstance().GetPath();
text += GetRainmeter().GetPath();
text += L"\nIniFile: ";
text += Rainmeter::GetInstance().GetIniFile();
text += GetRainmeter().GetIniFile();
text += L"\nSkinPath: ";
text += Rainmeter::GetInstance().GetSkinPath();
text += GetRainmeter().GetSkinPath();
System::SetClipboardText(text);
}
break;

View File

@ -88,7 +88,7 @@ void DialogManage::Open(int tab)
0, 0, 500, 322,
DS_CENTER | WS_POPUP | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU,
WS_EX_APPWINDOW | WS_EX_CONTROLPARENT | ((*GetString(ID_STR_ISRTL) == L'1') ? WS_EX_LAYOUTRTL : 0),
Rainmeter::GetInstance().GetWindow());
GetRainmeter().GetWindow());
// Fake WM_NOTIFY to change tab
NMHDR nm;
@ -290,11 +290,11 @@ INT_PTR DialogManage::OnCommand(WPARAM wParam, LPARAM lParam)
switch (LOWORD(wParam))
{
case Id_RefreshAllButton:
Rainmeter::GetInstance().RefreshAll();
GetRainmeter().RefreshAll();
break;
case Id_EditSettingsButton:
Rainmeter::GetInstance().EditSettings();
GetRainmeter().EditSettings();
break;
case Id_OpenLogButton:
@ -606,7 +606,7 @@ void DialogManage::TabSkins::Update(MeterWindow* meterWindow, bool deleted)
tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.item.iImage = tvi.item.iSelectedImage = 0;
if (!Rainmeter::GetInstance().m_SkinRegistry.IsEmpty())
if (!GetRainmeter().m_SkinRegistry.IsEmpty())
{
PopulateTree(item, tvi);
}
@ -644,7 +644,7 @@ void DialogManage::TabSkins::SetControls()
EnableWindow(item, TRUE);
item = GetControl(Id_DraggableCheckBox);
if (Rainmeter::GetInstance().GetDisableDragging())
if (GetRainmeter().GetDisableDragging())
{
EnableWindow(item, FALSE);
Button_SetCheck(item, BST_UNCHECKED);
@ -684,7 +684,7 @@ void DialogManage::TabSkins::SetControls()
item = GetControl(Id_LoadOrderEdit);
EnableWindow(item, TRUE);
_itow_s(Rainmeter::GetInstance().GetLoadOrder(m_SkinFolderPath), buffer, 10);
_itow_s(GetRainmeter().GetLoadOrder(m_SkinFolderPath), buffer, 10);
SetWindowText(item, buffer);
item = GetControl(Id_OnHoverDropDownList);
@ -797,10 +797,10 @@ void DialogManage::TabSkins::ReadSkin()
item = GetControl(Id_EditButton);
EnableWindow(item, TRUE);
std::wstring file = Rainmeter::GetInstance().GetSkinPath() + m_SkinFolderPath;
std::wstring file = GetRainmeter().GetSkinPath() + m_SkinFolderPath;
file += L'\\';
file += m_SkinFileName;
m_SkinWindow = Rainmeter::GetInstance().GetMeterWindowByINI(file);
m_SkinWindow = GetRainmeter().GetMeterWindowByINI(file);
if (!m_SkinWindow)
{
DisableControls();
@ -917,12 +917,12 @@ std::wstring DialogManage::TabSkins::GetTreeSelectionPath(HWND tree)
*/
int DialogManage::TabSkins::PopulateTree(HWND tree, TVINSERTSTRUCT& tvi, int index)
{
int initialLevel = Rainmeter::GetInstance().m_SkinRegistry.GetFolder(index).level;
int initialLevel = GetRainmeter().m_SkinRegistry.GetFolder(index).level;
const size_t max = Rainmeter::GetInstance().m_SkinRegistry.GetFolderCount();
const size_t max = GetRainmeter().m_SkinRegistry.GetFolderCount();
while (index < max)
{
const auto& skinFolder = Rainmeter::GetInstance().m_SkinRegistry.GetFolder(index);
const auto& skinFolder = GetRainmeter().m_SkinRegistry.GetFolder(index);
if (skinFolder.level != initialLevel)
{
return index - 1;
@ -937,7 +937,7 @@ int DialogManage::TabSkins::PopulateTree(HWND tree, TVINSERTSTRUCT& tvi, int ind
// Add subfolders
if ((index + 1) < max &&
Rainmeter::GetInstance().m_SkinRegistry.GetFolder(index + 1).level == initialLevel + 1)
GetRainmeter().m_SkinRegistry.GetFolder(index + 1).level == initialLevel + 1)
{
index = PopulateTree(tree, tvi, index + 1);
}
@ -1042,9 +1042,9 @@ INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
HMENU menu = CreatePopupMenu();
// Add active skins to menu
std::map<std::wstring, MeterWindow*>::const_iterator iter = Rainmeter::GetInstance().GetAllMeterWindows().begin();
std::map<std::wstring, MeterWindow*>::const_iterator iter = GetRainmeter().GetAllMeterWindows().begin();
int index = 0;
for ( ; iter != Rainmeter::GetInstance().GetAllMeterWindows().end(); ++iter)
for ( ; iter != GetRainmeter().GetAllMeterWindows().end(); ++iter)
{
std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
name += ((*iter).second)->GetFileName();
@ -1075,7 +1075,7 @@ INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
case Id_CreateSkinPackageButton:
{
std::wstring file = Rainmeter::GetInstance().GetPath() + L"SkinInstaller.exe";
std::wstring file = GetRainmeter().GetPath() + L"SkinInstaller.exe";
CommandHandler::RunFile(file.c_str(), L"/Packager");
}
break;
@ -1086,11 +1086,11 @@ INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{
// Skin not active, load
const SkinRegistry::Indexes indexes =
Rainmeter::GetInstance().m_SkinRegistry.FindIndexes(m_SkinFolderPath, m_SkinFileName);
GetRainmeter().m_SkinRegistry.FindIndexes(m_SkinFolderPath, m_SkinFileName);
if (indexes.IsValid())
{
m_HandleCommands = false;
Rainmeter::GetInstance().ActivateSkin(indexes.folder, indexes.file);
GetRainmeter().ActivateSkin(indexes.folder, indexes.file);
m_HandleCommands = true;
// Fake selection change to update controls
@ -1104,7 +1104,7 @@ INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
else
{
m_HandleCommands = false;
Rainmeter::GetInstance().DeactivateSkin(m_SkinWindow, -1);
GetRainmeter().DeactivateSkin(m_SkinWindow, -1);
}
}
break;
@ -1117,7 +1117,7 @@ INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
break;
case Id_EditButton:
Rainmeter::GetInstance().EditSkinFile(m_SkinFolderPath, m_SkinFileName);
GetRainmeter().EditSkinFile(m_SkinFolderPath, m_SkinFileName);
break;
case Id_XPositionEdit:
@ -1184,15 +1184,15 @@ INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
// Reset selection
Edit_SetSel((HWND)lParam, LOWORD(sel), HIWORD(sel));
WritePrivateProfileString(m_SkinFolderPath.c_str(), L"LoadOrder", buffer, Rainmeter::GetInstance().GetIniFile().c_str());
const SkinRegistry::Indexes indexes = Rainmeter::GetInstance().m_SkinRegistry.FindIndexes(
WritePrivateProfileString(m_SkinFolderPath.c_str(), L"LoadOrder", buffer, GetRainmeter().GetIniFile().c_str());
const SkinRegistry::Indexes indexes = GetRainmeter().m_SkinRegistry.FindIndexes(
m_SkinWindow->GetFolderPath(), m_SkinWindow->GetFileName());
if (indexes.IsValid())
{
Rainmeter::GetInstance().SetLoadOrder(indexes.folder, value);
GetRainmeter().SetLoadOrder(indexes.folder, value);
std::multimap<int, MeterWindow*> windows;
Rainmeter::GetInstance().GetMeterWindowsByLoadOrder(windows);
GetRainmeter().GetMeterWindowsByLoadOrder(windows);
System::PrepareHelperWindow();
@ -1306,17 +1306,17 @@ INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
case IDM_MANAGESKINSMENU_OPENFOLDER:
{
HWND tree = GetControl(Id_SkinsTreeView);
Rainmeter::GetInstance().OpenSkinFolder(GetTreeSelectionPath(tree));
GetRainmeter().OpenSkinFolder(GetTreeSelectionPath(tree));
}
break;
default:
if (wParam >= ID_CONFIG_FIRST && wParam <= ID_CONFIG_LAST)
{
std::map<std::wstring, MeterWindow*>::const_iterator iter = Rainmeter::GetInstance().GetAllMeterWindows().begin();
std::map<std::wstring, MeterWindow*>::const_iterator iter = GetRainmeter().GetAllMeterWindows().begin();
int index = (int)wParam - ID_CONFIG_FIRST;
int i = 0;
for ( ; iter != Rainmeter::GetInstance().GetAllMeterWindows().end(); ++iter)
for ( ; iter != GetRainmeter().GetAllMeterWindows().end(); ++iter)
{
if (i == index)
{
@ -1356,7 +1356,7 @@ INT_PTR DialogManage::TabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
case NM_CLICK:
if (nm->idFrom == Id_AddMetadataLink)
{
std::wstring file = Rainmeter::GetInstance().GetSkinPath() + m_SkinFolderPath;
std::wstring file = GetRainmeter().GetSkinPath() + m_SkinFolderPath;
file += L'\\';
file += m_SkinFileName;
const WCHAR* str = L"\r\n" // Hack to add below [Rainmeter].
@ -1586,7 +1586,7 @@ void DialogManage::TabLayouts::Initialize()
{
HWND item = GetControl(Id_List);
ListBox_ResetContent(item);
const std::vector<std::wstring>& layouts = Rainmeter::GetInstance().GetAllLayouts();
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
for (size_t i = 0, isize = layouts.size(); i < isize; ++i)
{
ListBox_AddString(item, layouts[i].c_str());
@ -1654,7 +1654,7 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
item = GetControl(Id_EditButton);
EnableWindow(item, TRUE);
const std::vector<std::wstring>& layouts = Rainmeter::GetInstance().GetAllLayouts();
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item);
@ -1671,7 +1671,7 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
Edit_GetText(item, buffer, MAX_PATH);
std::wstring layout = buffer;
std::wstring path = Rainmeter::GetInstance().GetLayoutPath();
std::wstring path = GetRainmeter().GetLayoutPath();
CreateDirectory(path.c_str(), 0);
path += layout;
@ -1679,7 +1679,7 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
if (alreadyExists)
{
std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, layout.c_str());
if (Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES)
if (GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES)
{
// Cancel
break;
@ -1696,10 +1696,10 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
item = GetControl(Id_SaveEmptyThemeCheckBox);
if (Button_GetCheck(item) != BST_CHECKED)
{
if (!System::CopyFiles(Rainmeter::GetInstance().GetIniFile(), path))
if (!System::CopyFiles(GetRainmeter().GetIniFile(), path))
{
std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
break;
}
@ -1741,7 +1741,7 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
if (file == INVALID_HANDLE_VALUE)
{
std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
break;
}
@ -1753,7 +1753,7 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
item = GetControl(Id_List);
ListBox_AddString(item, layout.c_str());
Rainmeter::GetInstance().ScanForLayouts();
GetRainmeter().ScanForLayouts();
}
}
break;
@ -1762,7 +1762,7 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
{
HWND item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item);
Rainmeter::GetInstance().LoadLayout(Rainmeter::GetInstance().m_Layouts[sel]);
GetRainmeter().LoadLayout(GetRainmeter().m_Layouts[sel]);
}
break;
@ -1770,13 +1770,13 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
{
HWND item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item);
const std::vector<std::wstring>& layouts = Rainmeter::GetInstance().GetAllLayouts();
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
std::wstring args = L"\"" + Rainmeter::GetInstance().GetLayoutPath();
std::wstring args = L"\"" + GetRainmeter().GetLayoutPath();
args += layouts[sel];
args += L"\\Rainmeter.ini";
args += L'"';
CommandHandler::RunFile(Rainmeter::GetInstance().GetSkinEditor().c_str(), args.c_str());
CommandHandler::RunFile(GetRainmeter().GetSkinEditor().c_str(), args.c_str());
}
break;
@ -1784,16 +1784,16 @@ INT_PTR DialogManage::TabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
{
HWND item = GetControl(Id_List);
int sel = ListBox_GetCurSel(item);
std::vector<std::wstring>& layouts = const_cast<std::vector<std::wstring>&>(Rainmeter::GetInstance().GetAllLayouts());
std::vector<std::wstring>& layouts = const_cast<std::vector<std::wstring>&>(GetRainmeter().GetAllLayouts());
std::wstring text = GetFormattedString(ID_STR_THEMEDELETE, layouts[sel].c_str());
if (Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_ICONQUESTION | MB_YESNO) != IDYES)
if (GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_ICONQUESTION | MB_YESNO) != IDYES)
{
// Cancel
break;
}
std::wstring folder = Rainmeter::GetInstance().GetLayoutPath();
std::wstring folder = GetRainmeter().GetLayoutPath();
folder += layouts[sel];
if (System::RemoveFolder(folder))
@ -1907,7 +1907,7 @@ void DialogManage::TabSettings::Initialize()
// Scan for languages
HWND item = GetControl(Id_LanguageDropDownList);
std::wstring files = Rainmeter::GetInstance().GetPath() + L"Languages\\*.dll";
std::wstring files = GetRainmeter().GetPath() + L"Languages\\*.dll";
WIN32_FIND_DATA fd;
HANDLE hSearch = FindFirstFile(files.c_str(), &fd);
if (hSearch != INVALID_HANDLE_VALUE)
@ -1932,7 +1932,7 @@ void DialogManage::TabSettings::Initialize()
int index = ComboBox_AddString(item, text.c_str());
ComboBox_SetItemData(item, index, (LPARAM)lcid);
if (lcid == Rainmeter::GetInstance().GetResourceLCID())
if (lcid == GetRainmeter().GetResourceLCID())
{
ComboBox_SetCurSel(item, index);
}
@ -1944,23 +1944,23 @@ void DialogManage::TabSettings::Initialize()
FindClose(hSearch);
}
Button_SetCheck(GetControl(Id_CheckForUpdatesCheckBox), !Rainmeter::GetInstance().GetDisableVersionCheck());
Button_SetCheck(GetControl(Id_LockSkinsCheckBox), Rainmeter::GetInstance().GetDisableDragging());
Button_SetCheck(GetControl(Id_CheckForUpdatesCheckBox), !GetRainmeter().GetDisableVersionCheck());
Button_SetCheck(GetControl(Id_LockSkinsCheckBox), GetRainmeter().GetDisableDragging());
Button_SetCheck(GetControl(Id_LogToFileCheckBox), GetLogger().IsLogToFile());
Button_SetCheck(GetControl(Id_VerboseLoggingCheckbox), Rainmeter::GetInstance().GetDebug());
Button_SetCheck(GetControl(Id_VerboseLoggingCheckbox), GetRainmeter().GetDebug());
BOOL isLogFile = (_waccess(GetLogger().GetLogFilePath().c_str(), 0) != -1);
EnableWindow(GetControl(Id_ShowLogFileButton), isLogFile);
EnableWindow(GetControl(Id_DeleteLogFileButton), isLogFile);
Edit_SetText(GetControl(Id_EditorEdit), Rainmeter::GetInstance().GetSkinEditor().c_str());
Edit_SetText(GetControl(Id_EditorEdit), GetRainmeter().GetSkinEditor().c_str());
bool iconEnabled = Rainmeter::GetInstance().GetTrayWindow()->IsTrayIconEnabled();
bool iconEnabled = GetRainmeter().GetTrayWindow()->IsTrayIconEnabled();
Button_SetCheck(GetControl(Id_ShowTrayIconCheckBox), iconEnabled);
if (IsWindowsVistaOrGreater())
{
Button_SetCheck(GetControl(Id_UseD2DCheckBox), Rainmeter::GetInstance().GetUseD2D());
Button_SetCheck(GetControl(Id_UseD2DCheckBox), GetRainmeter().GetUseD2D());
}
else
{
@ -1995,18 +1995,18 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
{
int sel = ComboBox_GetCurSel((HWND)lParam);
LCID lcid = (LCID)ComboBox_GetItemData((HWND)lParam, sel);
if (lcid != Rainmeter::GetInstance().m_ResourceLCID)
if (lcid != GetRainmeter().m_ResourceLCID)
{
WCHAR buffer[16];
_ultow(lcid, buffer, 10);
WritePrivateProfileString(L"Rainmeter", L"Language", buffer, Rainmeter::GetInstance().GetIniFile().c_str());
WritePrivateProfileString(L"Rainmeter", L"Language", buffer, GetRainmeter().GetIniFile().c_str());
std::wstring resource = Rainmeter::GetInstance().GetPath() + L"Languages\\";
std::wstring resource = GetRainmeter().GetPath() + L"Languages\\";
resource += buffer;
resource += L".dll";
FreeLibrary(Rainmeter::GetInstance().m_ResourceInstance);
Rainmeter::GetInstance().m_ResourceInstance = LoadLibraryEx(resource.c_str(), nullptr, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
Rainmeter::GetInstance().m_ResourceLCID = lcid;
FreeLibrary(GetRainmeter().m_ResourceInstance);
GetRainmeter().m_ResourceInstance = LoadLibraryEx(resource.c_str(), nullptr, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
GetRainmeter().m_ResourceLCID = lcid;
if (DialogAbout::GetDialog())
{
@ -2014,42 +2014,42 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
SendMessage(DialogAbout::GetDialog()->GetWindow(), WM_CLOSE, 0, 0);
if (sel == 0)
{
Rainmeter::GetInstance().DelayedExecuteCommand(L"!About");
GetRainmeter().DelayedExecuteCommand(L"!About");
}
else if (sel == 1)
{
Rainmeter::GetInstance().DelayedExecuteCommand(L"!About Skins");
GetRainmeter().DelayedExecuteCommand(L"!About Skins");
}
else if (sel == 2)
{
Rainmeter::GetInstance().DelayedExecuteCommand(L"!About Plugins");
GetRainmeter().DelayedExecuteCommand(L"!About Plugins");
}
else //if (sel == 3)
{
Rainmeter::GetInstance().DelayedExecuteCommand(L"!About Version");
GetRainmeter().DelayedExecuteCommand(L"!About Version");
}
}
SendMessage(c_Dialog->GetWindow(), WM_CLOSE, 0, 0);
Rainmeter::GetInstance().DelayedExecuteCommand(L"!Manage Settings");
GetRainmeter().DelayedExecuteCommand(L"!Manage Settings");
}
}
break;
case Id_CheckForUpdatesCheckBox:
Rainmeter::GetInstance().SetDisableVersionCheck(!Rainmeter::GetInstance().GetDisableVersionCheck());
GetRainmeter().SetDisableVersionCheck(!GetRainmeter().GetDisableVersionCheck());
break;
case Id_LockSkinsCheckBox:
Rainmeter::GetInstance().SetDisableDragging(!Rainmeter::GetInstance().GetDisableDragging());
GetRainmeter().SetDisableDragging(!GetRainmeter().GetDisableDragging());
break;
case Id_ResetStatisticsButton:
Rainmeter::GetInstance().ResetStats();
GetRainmeter().ResetStats();
break;
case Id_ShowLogFileButton:
Rainmeter::GetInstance().ShowLogFile();
GetRainmeter().ShowLogFile();
break;
case Id_DeleteLogFileButton:
@ -2079,7 +2079,7 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
break;
case Id_VerboseLoggingCheckbox:
Rainmeter::GetInstance().SetDebug(!Rainmeter::GetInstance().GetDebug());
GetRainmeter().SetDebug(!GetRainmeter().GetDebug());
break;
case Id_EditorEdit:
@ -2088,7 +2088,7 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
WCHAR buffer[MAX_PATH];
if (GetWindowText((HWND)lParam, buffer, _countof(buffer)) > 0)
{
Rainmeter::GetInstance().SetSkinEditor(buffer);
GetRainmeter().SetSkinEditor(buffer);
}
}
break;
@ -2098,7 +2098,7 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
WCHAR buffer[MAX_PATH];
buffer[0] = L'\0';
std::wstring editor = Rainmeter::GetInstance().GetSkinEditor();
std::wstring editor = GetRainmeter().GetSkinEditor();
editor = editor.substr(0, editor.find_last_of(L"/\\")).c_str();
OPENFILENAME ofn = { sizeof(OPENFILENAME) };
@ -2122,11 +2122,11 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
break;
case Id_ShowTrayIconCheckBox:
Rainmeter::GetInstance().GetTrayWindow()->SetTrayIcon(!Rainmeter::GetInstance().GetTrayWindow()->IsTrayIconEnabled());
GetRainmeter().GetTrayWindow()->SetTrayIcon(!GetRainmeter().GetTrayWindow()->IsTrayIconEnabled());
break;
case Id_UseD2DCheckBox:
Rainmeter::GetInstance().SetUseD2D(!Rainmeter::GetInstance().GetUseD2D());
GetRainmeter().SetUseD2D(!GetRainmeter().GetUseD2D());
break;
default:

View File

@ -86,7 +86,7 @@ void* __stdcall RmGet(void* rm, int type)
case RMG_SETTINGSFILE:
{
return (void*)Rainmeter::GetInstance().GetDataFile().c_str();
return (void*)GetRainmeter().GetDataFile().c_str();
}
case RMG_SKINNAME:
@ -113,7 +113,7 @@ void __stdcall RmExecute(void* skin, LPCWSTR command)
if (command)
{
// WM_RAINMETER_EXECUTE used instead of ExecuteCommand for thread-safety
SendMessage(Rainmeter::GetInstance().GetWindow(), WM_RAINMETER_EXECUTE, (WPARAM)mw, (LPARAM)command);
SendMessage(GetRainmeter().GetWindow(), WM_RAINMETER_EXECUTE, (WPARAM)mw, (LPARAM)command);
}
}
@ -122,7 +122,7 @@ BOOL LSLog(int level, LPCWSTR unused, LPCWSTR message)
NULLCHECK(message);
// Ignore Debug messages from plugins unless in debug mode.
if (level != (int)Logger::Level::Debug || Rainmeter::GetInstance().GetDebug())
if (level != (int)Logger::Level::Debug || GetRainmeter().GetDebug())
{
GetLogger().Log((Logger::Level)level, L"", message);
}
@ -137,7 +137,7 @@ void __stdcall RmLog(void* rm, int level, LPCWSTR message)
MeasurePlugin* measure = (MeasurePlugin*)rm;
// Ignore Debug messages from plugins unless in debug mode.
if (level != (int)Logger::Level::Debug || Rainmeter::GetInstance().GetDebug())
if (level != (int)Logger::Level::Debug || GetRainmeter().GetDebug())
{
GetLogger().LogSection((Logger::Level)level, measure, message);
}
@ -150,7 +150,7 @@ void RmLogF(void* rm, int level, LPCWSTR format, ...)
MeasurePlugin* measure = (MeasurePlugin*)rm;
// Ignore Debug messages from plugins unless in debug mode.
if (level != (int)Logger::Level::Debug || Rainmeter::GetInstance().GetDebug())
if (level != (int)Logger::Level::Debug || GetRainmeter().GetDebug())
{
va_list args;
va_start(args, format);
@ -166,7 +166,7 @@ LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue)
NULLCHECK(option);
NULLCHECK(defValue);
ConfigParser* parser = Rainmeter::GetInstance().GetCurrentParser();
ConfigParser* parser = GetRainmeter().GetCurrentParser();
if (parser)
{
return parser->ReadString(section, option, defValue, false).c_str();
@ -187,7 +187,7 @@ LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data)
if (_wcsicmp(command, L"GetConfig") == 0)
{
MeterWindow* meterWindow = Rainmeter::GetInstance().GetMeterWindowByINI(data);
MeterWindow* meterWindow = GetRainmeter().GetMeterWindowByINI(data);
if (meterWindow)
{
g_Buffer = L"\"";
@ -206,7 +206,7 @@ LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data)
{
const std::wstring& config = subStrings[0];
MeterWindow* meterWindow = Rainmeter::GetInstance().GetMeterWindow(config);
MeterWindow* meterWindow = GetRainmeter().GetMeterWindow(config);
if (meterWindow)
{
WCHAR buf1[64];
@ -226,7 +226,7 @@ LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data)
{
const std::wstring& config = subStrings[0];
MeterWindow* meterWindow = Rainmeter::GetInstance().GetMeterWindow(config);
MeterWindow* meterWindow = GetRainmeter().GetMeterWindow(config);
if (meterWindow)
{
const std::wstring& variable = subStrings[1];
@ -247,7 +247,7 @@ LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data)
if (subStrings.size() == 3)
{
MeterWindow* meterWindow = Rainmeter::GetInstance().GetMeterWindow(subStrings[0]);
MeterWindow* meterWindow = GetRainmeter().GetMeterWindow(subStrings[0]);
if (meterWindow)
{
meterWindow->SetVariable(subStrings[1], subStrings[2]);

3
Library/Exports_Common.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
#define EXPORT extern "C" _declspec(dllexport)

32
Library/Exports_Group.cpp Normal file
View File

@ -0,0 +1,32 @@
#include "StdAfx.h"
#include <cstdint>
#include "Group.h"
#include "HandleManager.h"
#include "Exports_Common.h"
EXPORT bool Group_BelongsToGroup (bool* result, int32_t handle, LPWSTR str)
{
Group* group = (Group*)handle_get_resource (handle);
if (group != nullptr)
{
*result = group->BelongsToGroup (str);
return true;
}
return false;
}
EXPORT bool Group_Destroy (int32_t handle)
{
Group* group = (Group*)handle_get_resource (handle);
if (group != nullptr)
{
handle_free (handle);
delete group;
return true;
}
return false;
}

21
Library/Exports_Meter.cpp Normal file
View File

@ -0,0 +1,21 @@
#include "StdAfx.h"
#include <cstdint>
#include "Meter.h"
#include "HandleManager.h"
#include "Exports_Common.h"
EXPORT bool Meter_Destroy (int handle)
{
Meter* meter = (Meter*)handle_get_resource (handle);
if (meter != nullptr)
{
handle_free (handle);
delete meter;
return true;
}
return false;
}

View File

@ -0,0 +1,35 @@
#include "StdAfx.h"
#include <cstdint>
#include "MeterString.h"
#include "HandleManager.h"
#include "Exports_Common.h"
EXPORT bool MeterString_Init (int* handle_result, int meterCanvasHandle, LPCWSTR name)
{
MeterWindow* w = (MeterWindow*) handle_get_resource (meterCanvasHandle);
if (w != nullptr)
{
MeterString* result = new MeterString (w, name);
*handle_result = handle_allocate (result);
return true;
}
return false;
}
EXPORT bool MeterString_Destroy (int handle)
{
MeterString* ms = (MeterString*) handle_get_resource (handle);
if (ms != nullptr)
{
handle_free (handle);
delete ms;
return true;
}
return false;
}

View File

@ -0,0 +1,27 @@
#include "Rainmeter.h"
#include "HandleManager.h"
/*
** Initializes Rainmeter.
**
*/
bool Rainmeter_Initialize()
{
int res = GetRainmeter().Initialize(nullptr, nullptr);
// Success?
if (res == 0)
return &GetRainmeter();
return nullptr;
}
/*
** Finalizes Rainmeter.
**
*/
void Rainmeter_Finalize(void* ptr)
{
Rainmeter* rainmeter = (Rainmeter*)ptr;
rainmeter->Finalize();
}

131
Library/Exports_Section.cpp Normal file
View File

@ -0,0 +1,131 @@
#include "HandleManager.h"
#include "Exports_Common.h"
#include "Section.h"
EXPORT bool Section_GetName (LPCWCHAR* result, int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
*result = section->GetName();
return true;
}
return false;
}
EXPORT bool Section_GetOriginalName (LPCWCHAR* result, int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
*result = section->GetOriginalName().c_str();
return true;
}
return false;
}
EXPORT bool Section_HasDynamicVariables (bool* result, int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
*result = section->HasDynamicVariables();
return true;
}
return false;
}
EXPORT bool Section_SetDynamicVariables (int32_t handle, bool value)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
section->SetDynamicVariables(value);
return true;
}
return false;
}
EXPORT bool Section_ResetUpdateCounter (int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
section->ResetUpdateCounter();
return true;
}
return false;
}
EXPORT bool Section_GetUpdateCounter (int* result, int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
*result = section->GetUpdateCounter();
return true;
}
return false;
}
EXPORT bool Section_GetUpdateDivider (int* result, int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
*result = section->GetUpdateDivider();
return true;
}
return false;
}
EXPORT bool Section_GetOnUpdateAction (LPCWCHAR* result, int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
*result = section->GetOnUpdateAction().c_str();
return true;
}
return false;
}
EXPORT bool Section_DoUpdateAction (int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
section->DoUpdateAction ();
return true;
}
return false;
}
EXPORT bool Section_Destroy (int32_t handle)
{
Section* section = (Section*) handle_get_resource (handle);
if (section != nullptr)
{
handle_free (handle);
delete section;
return true;
}
return false;
}

28
Library/HandleManager.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <map>
#include <cstdint>
#include "HandleManager.h"
std::map<int32_t, void*> handles;
int32_t handle_allocate (void* resource)
{
static int32_t handle = 1;
handles.insert (std::make_pair(handle, resource));
return handle++;
}
void* handle_get_resource (int32_t handle)
{
if (handles.count (handle) != 0)
return handles.at (handle);
return nullptr;
}
void handle_free (int32_t handle)
{
handles.erase (handle);
}
void

7
Library/HandleManager.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include <cstdint>
int32_t handle_allocate (void* resource);
void* handle_get_resource (int32_t handle);
void handle_free (int32_t handle);

View File

@ -161,7 +161,7 @@ void IfActions::DoIfActions(Measure& measure, double value)
if (!m_EqualCommitted)
{
m_EqualCommitted = true; // To avoid infinite loop from !Update
Rainmeter::GetInstance().ExecuteCommand(m_EqualAction.c_str(), measure.GetMeterWindow());
GetRainmeter().ExecuteCommand(m_EqualAction.c_str(), measure.GetMeterWindow());
}
}
else
@ -178,7 +178,7 @@ void IfActions::DoIfActions(Measure& measure, double value)
if (!m_AboveCommitted)
{
m_AboveCommitted = true; // To avoid infinite loop from !Update
Rainmeter::GetInstance().ExecuteCommand(m_AboveAction.c_str(), measure.GetMeterWindow());
GetRainmeter().ExecuteCommand(m_AboveAction.c_str(), measure.GetMeterWindow());
}
}
else
@ -195,7 +195,7 @@ void IfActions::DoIfActions(Measure& measure, double value)
if (!m_BelowCommitted)
{
m_BelowCommitted = true; // To avoid infinite loop from !Update
Rainmeter::GetInstance().ExecuteCommand(m_BelowAction.c_str(), measure.GetMeterWindow());
GetRainmeter().ExecuteCommand(m_BelowAction.c_str(), measure.GetMeterWindow());
}
}
else
@ -240,7 +240,7 @@ void IfActions::DoIfActions(Measure& measure, double value)
if (m_ConditionMode || !item.tCommitted)
{
item.tCommitted = true;
Rainmeter::GetInstance().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow());
GetRainmeter().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow());
}
}
else if (result == 0.0f) // "False"
@ -250,7 +250,7 @@ void IfActions::DoIfActions(Measure& measure, double value)
if (m_ConditionMode || !item.fCommitted)
{
item.fCommitted = true;
Rainmeter::GetInstance().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow());
GetRainmeter().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow());
}
}
}
@ -314,7 +314,7 @@ void IfActions::DoIfActions(Measure& measure, double value)
if (m_MatchMode || !item.tCommitted)
{
item.tCommitted = true;
Rainmeter::GetInstance().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow());
GetRainmeter().ExecuteCommand(item.tAction.c_str(), measure.GetMeterWindow());
}
}
else // Not Match
@ -324,7 +324,7 @@ void IfActions::DoIfActions(Measure& measure, double value)
if (m_MatchMode || !item.fCommitted)
{
item.fCommitted = true;
Rainmeter::GetInstance().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow());
GetRainmeter().ExecuteCommand(item.fAction.c_str(), measure.GetMeterWindow());
}
}
}

View File

@ -31,7 +31,7 @@ UINT GetUniqueID()
WCHAR* GetString(UINT id)
{
LPWSTR pData;
int len = LoadString(Rainmeter::GetInstance().GetResourceInstance(), id, (LPWSTR)&pData, 0);
int len = LoadString(GetRainmeter().GetResourceInstance(), id, (LPWSTR)&pData, 0);
return len ? pData : L"";
}

View File

@ -65,7 +65,7 @@ void Logger::StartLogFile()
else
{
const std::wstring text = GetFormattedString(ID_STR_LOGFILECREATEFAIL, filePath);
Rainmeter::GetInstance().ShowMessage(nullptr, text.c_str(), MB_OK | MB_ICONERROR);
GetRainmeter().ShowMessage(nullptr, text.c_str(), MB_OK | MB_ICONERROR);
SetLogToFile(false);
return;
}
@ -85,7 +85,7 @@ void Logger::DeleteLogFile()
if (_waccess(filePath, 0) != -1)
{
const std::wstring text = GetFormattedString(ID_STR_LOGFILEDELETE, filePath);
const int res = Rainmeter::GetInstance().ShowMessage(nullptr, text.c_str(), MB_YESNO | MB_ICONQUESTION);
const int res = GetRainmeter().ShowMessage(nullptr, text.c_str(), MB_YESNO | MB_ICONQUESTION);
if (res == IDYES)
{
SetLogToFile(false);
@ -98,7 +98,7 @@ void Logger::SetLogToFile(bool logToFile)
{
m_LogToFile = logToFile;
WritePrivateProfileString(
L"Rainmeter", L"Logging", logToFile ? L"1" : L"0", Rainmeter::GetInstance().GetIniFile().c_str());
L"Rainmeter", L"Logging", logToFile ? L"1" : L"0", GetRainmeter().GetIniFile().c_str());
}
void Logger::LogInternal(Level level, ULONGLONG timestamp, const WCHAR* source, const WCHAR* msg)

View File

@ -721,7 +721,7 @@ void Measure::DoChangeAction(bool execute)
{
if (m_OldValue->IsChanged(newValue, newStringValue))
{
Rainmeter::GetInstance().ExecuteCommand(m_OnChangeAction.c_str(), m_MeterWindow);
GetRainmeter().ExecuteCommand(m_OnChangeAction.c_str(), m_MeterWindow);
}
}
else

View File

@ -76,7 +76,7 @@ void MeasureNet::UpdateIFTable()
logging = true;
}
if (Rainmeter::GetInstance().GetDebug() && logging)
if (GetRainmeter().GetDebug() && logging)
{
LogDebug(L"------------------------------");
LogDebugF(L"* NETWORK-INTERFACE: Count=%i", c_NumOfTables);
@ -169,7 +169,7 @@ void MeasureNet::UpdateIFTable()
logging = true;
}
if (Rainmeter::GetInstance().GetDebug() && logging)
if (GetRainmeter().GetDebug() && logging)
{
LogDebug(L"------------------------------");
LogDebugF(L"* NETWORK-INTERFACE: Count=%i", c_NumOfTables);
@ -463,17 +463,17 @@ void MeasureNet::ReadOptions(ConfigParser& parser, const WCHAR* section)
if (m_Net == NET_IN)
{
netName = L"NetInSpeed";
value = Rainmeter::GetInstance().GetGlobalOptions().netInSpeed;
value = GetRainmeter().GetGlobalOptions().netInSpeed;
}
else if (m_Net == NET_OUT)
{
netName = L"NetOutSpeed";
value = Rainmeter::GetInstance().GetGlobalOptions().netOutSpeed;
value = GetRainmeter().GetGlobalOptions().netOutSpeed;
}
else // if (m_Net == NET_TOTAL)
{
netName = L"NetTotalSpeed";
value = Rainmeter::GetInstance().GetGlobalOptions().netInSpeed + Rainmeter::GetInstance().GetGlobalOptions().netOutSpeed;
value = GetRainmeter().GetGlobalOptions().netInSpeed + GetRainmeter().GetGlobalOptions().netOutSpeed;
}
double maxValue = parser.ReadFloat(section, L"MaxValue", -1);
@ -491,7 +491,7 @@ void MeasureNet::ReadOptions(ConfigParser& parser, const WCHAR* section)
m_Cumulative = parser.ReadBool(section, L"Cumulative", false);
if (m_Cumulative)
{
Rainmeter::GetInstance().SetNetworkStatisticsTimer();
GetRainmeter().SetNetworkStatisticsTimer();
}
if (maxValue == 0.0)
@ -705,7 +705,7 @@ void MeasureNet::InitializeStatic()
}
}
if (Rainmeter::GetInstance().GetDebug())
if (GetRainmeter().GetDebug())
{
UpdateIFTable();
}

View File

@ -127,15 +127,15 @@ void MeasurePlugin::ReadOptions(ConfigParser& parser, const WCHAR* section)
}
// First try from program path
std::wstring pluginFile = Rainmeter::GetInstance().GetPluginPath();
std::wstring pluginFile = GetRainmeter().GetPluginPath();
pluginFile += pluginName;
m_Plugin = System::RmLoadLibrary(pluginFile.c_str());
if (!m_Plugin)
{
if (Rainmeter::GetInstance().HasUserPluginPath())
if (GetRainmeter().HasUserPluginPath())
{
// Try from settings path
pluginFile = Rainmeter::GetInstance().GetUserPluginPath();
pluginFile = GetRainmeter().GetUserPluginPath();
pluginFile += pluginName;
m_Plugin = System::RmLoadLibrary(pluginFile.c_str());
}

View File

@ -556,7 +556,7 @@ bool Meter::ReplaceMeasures(std::wstring& str, AUTOSCALE autoScale, double scale
void Meter::CreateToolTip(MeterWindow* meterWindow)
{
HWND hMeterWindow = m_MeterWindow->GetWindow();
HINSTANCE hInstance = Rainmeter::GetInstance().GetModuleInstance();
HINSTANCE hInstance = GetRainmeter().GetModuleInstance();
DWORD style = WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP;
if (m_ToolTipType)

View File

@ -258,7 +258,7 @@ bool MeterButton::MouseUp(POINT pos, bool execute)
{
if (execute && m_Clicked && m_Focus && HitTest2(pos.x, pos.y))
{
Rainmeter::GetInstance().ExecuteCommand(m_Command.c_str(), m_MeterWindow);
GetRainmeter().ExecuteCommand(m_Command.c_str(), m_MeterWindow);
}
m_State = BUTTON_STATE_NORMAL;
m_Clicked = false;

View File

@ -668,7 +668,7 @@ void MeterString::EnumerateInstalledFontFamilies()
void MeterString::InitializeStatic()
{
if (Rainmeter::GetInstance().GetDebug())
if (GetRainmeter().GetDebug())
{
LogDebug(L"------------------------------");
LogDebug(L"* Font families:");

View File

@ -160,7 +160,7 @@ MeterWindow::MeterWindow(const std::wstring& folderPath, const std::wstring& fil
WNDCLASSEX wc = {sizeof(WNDCLASSEX)};
wc.style = CS_NOCLOSE | CS_DBLCLKS;
wc.lpfnWndProc = InitialWndProc;
wc.hInstance = Rainmeter::GetInstance().GetModuleInstance();
wc.hInstance = GetRainmeter().GetModuleInstance();
wc.hCursor = nullptr; // The cursor should be controlled by using SetCursor() when needed.
wc.lpszClassName = METERWINDOW_CLASS_NAME;
RegisterClassEx(&wc);
@ -179,7 +179,7 @@ MeterWindow::~MeterWindow()
if (!m_OnCloseAction.empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_OnCloseAction.c_str(), this);
GetRainmeter().ExecuteCommand(m_OnCloseAction.c_str(), this);
}
Dispose(false);
@ -188,7 +188,7 @@ MeterWindow::~MeterWindow()
if (c_InstanceCount == 0)
{
UnregisterClass(METERWINDOW_CLASS_NAME, Rainmeter::GetInstance().GetModuleInstance());
UnregisterClass(METERWINDOW_CLASS_NAME, GetRainmeter().GetModuleInstance());
if (c_DwmInstance)
{
@ -287,7 +287,7 @@ void MeterWindow::Initialize()
CW_USEDEFAULT,
nullptr,
nullptr,
Rainmeter::GetInstance().GetModuleInstance(),
GetRainmeter().GetModuleInstance(),
this);
setlocale(LC_NUMERIC, "C");
@ -383,8 +383,8 @@ void MeterWindow::Deactivate()
if (m_State == STATE_CLOSING) return;
m_State = STATE_CLOSING;
Rainmeter::GetInstance().RemoveMeterWindow(this);
Rainmeter::GetInstance().AddUnmanagedMeterWindow(this);
GetRainmeter().RemoveMeterWindow(this);
GetRainmeter().AddUnmanagedMeterWindow(this);
HideFade();
SetTimer(m_Window, TIMER_DEACTIVATE, m_FadeDuration + 50, nullptr);
@ -399,7 +399,7 @@ void MeterWindow::Refresh(bool init, bool all)
if (m_State == STATE_CLOSING) return;
m_State = STATE_REFRESHING;
Rainmeter::GetInstance().SetCurrentParser(&m_Parser);
GetRainmeter().SetCurrentParser(&m_Parser);
LogNoticeF(this, L"Refreshing skin");
@ -414,7 +414,7 @@ void MeterWindow::Refresh(bool init, bool all)
if (!ReadSkin())
{
Rainmeter::GetInstance().DeactivateSkin(this, -1);
GetRainmeter().DeactivateSkin(this, -1);
return;
}
@ -461,13 +461,13 @@ void MeterWindow::Refresh(bool init, bool all)
SetTimer(m_Window, TIMER_MOUSE, INTERVAL_MOUSE, nullptr);
Rainmeter::GetInstance().SetCurrentParser(nullptr);
GetRainmeter().SetCurrentParser(nullptr);
m_State = STATE_RUNNING;
if (!m_OnRefreshAction.empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_OnRefreshAction.c_str(), this);
GetRainmeter().ExecuteCommand(m_OnRefreshAction.c_str(), this);
}
}
@ -625,7 +625,7 @@ void MeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
break;
case ZPOSITION_NORMAL:
if (all || !Rainmeter::GetInstance().IsNormalStayDesktop()) break;
if (all || !GetRainmeter().IsNormalStayDesktop()) break;
case ZPOSITION_ONDESKTOP:
if (System::GetShowDesktop())
{
@ -676,7 +676,7 @@ void MeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
*/
void MeterWindow::ChangeSingleZPos(ZPOSITION zPos, bool all)
{
if (zPos == ZPOSITION_NORMAL && Rainmeter::GetInstance().IsNormalStayDesktop() && (!all || System::GetShowDesktop()))
if (zPos == ZPOSITION_NORMAL && GetRainmeter().IsNormalStayDesktop() && (!all || System::GetShowDesktop()))
{
m_WindowZPosition = zPos;
@ -983,7 +983,7 @@ void MeterWindow::DoBang(Bang bang, const std::vector<std::wstring>& args)
break;
case Bang::SkinCustomMenu:
Rainmeter::GetInstance().ShowSkinCustomContextMenu(System::GetCursorPosition(), this);
GetRainmeter().ShowSkinCustomContextMenu(System::GetCursorPosition(), this);
break;
}
}
@ -1884,7 +1884,7 @@ void MeterWindow::ReadOptions()
const WCHAR* section = m_FolderPath.c_str();
ConfigParser parser;
parser.Initialize(Rainmeter::GetInstance().GetIniFile(), nullptr, section);
parser.Initialize(GetRainmeter().GetIniFile(), nullptr, section);
INT writeFlags = 0;
auto addWriteFlag = [&](INT flag)
@ -1962,7 +1962,7 @@ void MeterWindow::ReadOptions()
*/
void MeterWindow::WriteOptions(INT setting)
{
const WCHAR* iniFile = Rainmeter::GetInstance().GetIniFile().c_str();
const WCHAR* iniFile = GetRainmeter().GetIniFile().c_str();
if (*iniFile)
{
@ -2063,7 +2063,7 @@ bool MeterWindow::ReadSkin()
if (_waccess(iniFile.c_str(), 0) == -1)
{
std::wstring message = GetFormattedString(ID_STR_UNABLETOREFRESHSKIN, m_FolderPath.c_str(), m_FileName.c_str());
Rainmeter::GetInstance().ShowMessage(m_Window, message.c_str(), MB_OK | MB_ICONEXCLAMATION);
GetRainmeter().ShowMessage(m_Window, message.c_str(), MB_OK | MB_ICONEXCLAMATION);
return false;
}
@ -2076,7 +2076,7 @@ bool MeterWindow::ReadSkin()
m_Parser.Initialize(iniFile, this, nullptr, &resourcePath);
m_Canvas = Gfx::Canvas::Create(
m_UseD2D && Rainmeter::GetInstance().GetUseD2D() ? Gfx::Renderer::PreferD2D : Gfx::Renderer::GDIP);
m_UseD2D && GetRainmeter().GetUseD2D() ? Gfx::Renderer::PreferD2D : Gfx::Renderer::GDIP);
m_Canvas->SetAccurateText(m_Parser.ReadBool(L"Rainmeter", L"AccurateText", false));
// Gotta have some kind of buffer during initialization
@ -2096,7 +2096,7 @@ bool MeterWindow::ReadSkin()
}
std::wstring text = GetFormattedString(ID_STR_NEWVERSIONREQUIRED, m_FolderPath.c_str(), m_FileName.c_str(), buffer);
Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
return false;
}
@ -2234,7 +2234,7 @@ bool MeterWindow::ReadSkin()
do
{
// Try program folder first
std::wstring szFontFile = Rainmeter::GetInstance().GetPath() + L"Fonts\\";
std::wstring szFontFile = GetRainmeter().GetPath() + L"Fonts\\";
szFontFile += localFont;
if (!m_FontCollection->AddFile(szFontFile.c_str()))
{
@ -2310,7 +2310,7 @@ bool MeterWindow::ReadSkin()
if (m_Meters.empty())
{
std::wstring text = GetFormattedString(ID_STR_NOMETERSINSKIN, m_FolderPath.c_str(), m_FileName.c_str());
Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
return false;
}
@ -2794,7 +2794,7 @@ void MeterWindow::Update(bool refresh)
// If our option is to disable when in an RDP session, then check if in an RDP session.
// Only redraw if we are not in a remote session
if (Rainmeter::GetInstance().IsRedrawable())
if (GetRainmeter().IsRedrawable())
{
Redraw();
}
@ -2805,7 +2805,7 @@ void MeterWindow::Update(bool refresh)
if (!m_OnUpdateAction.empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_OnUpdateAction.c_str(), this);
GetRainmeter().ExecuteCommand(m_OnUpdateAction.c_str(), this);
}
}
@ -2862,7 +2862,7 @@ LRESULT MeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case TIMER_MOUSE:
if (!Rainmeter::GetInstance().IsMenuActive() && !m_Dragging)
if (!GetRainmeter().IsMenuActive() && !m_Dragging)
{
ShowWindowIfAppropriate();
@ -2967,7 +2967,7 @@ LRESULT MeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (m_FadeStartTime == 0)
{
KillTimer(m_Window, TIMER_DEACTIVATE);
Rainmeter::GetInstance().RemoveUnmanagedMeterWindow(this);
GetRainmeter().RemoveUnmanagedMeterWindow(this);
delete this;
}
break;
@ -3392,7 +3392,7 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
switch (wParam)
{
case IDM_SKIN_EDITSKIN:
Rainmeter::GetInstance().EditSkinFile(m_FolderPath, m_FileName);
GetRainmeter().EditSkinFile(m_FolderPath, m_FileName);
break;
case IDM_SKIN_REFRESH:
@ -3400,7 +3400,7 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case IDM_SKIN_OPENSKINSFOLDER:
Rainmeter::GetInstance().OpenSkinFolder(m_FolderPath);
GetRainmeter().OpenSkinFolder(m_FolderPath);
break;
case IDM_SKIN_MANAGESKIN:
@ -3466,7 +3466,7 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDM_CLOSESKIN:
if (m_State != STATE_CLOSING)
{
Rainmeter::GetInstance().DeactivateSkin(this, -1);
GetRainmeter().DeactivateSkin(this, -1);
}
break;
@ -3556,13 +3556,13 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (!action.empty())
{
Rainmeter::GetInstance().ExecuteCommand(action.c_str(), this);
GetRainmeter().ExecuteCommand(action.c_str(), this);
}
}
else
{
// Forward to tray window, which handles all the other commands
HWND tray = Rainmeter::GetInstance().GetTrayWindow()->GetWindow();
HWND tray = GetRainmeter().GetTrayWindow()->GetWindow();
if (wParam == IDM_QUIT)
{
@ -3780,7 +3780,7 @@ LRESULT MeterWindow::OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
*/
LRESULT MeterWindow::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (m_WindowDraggable && !Rainmeter::GetInstance().GetDisableDragging())
if (m_WindowDraggable && !GetRainmeter().GetDisableDragging())
{
POINT pos;
pos.x = GET_X_LPARAM(lParam);
@ -3820,7 +3820,7 @@ LRESULT MeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam
if (m_State != STATE_REFRESHING)
{
if (m_WindowZPosition == ZPOSITION_NORMAL && Rainmeter::GetInstance().IsNormalStayDesktop() && System::GetShowDesktop())
if (m_WindowZPosition == ZPOSITION_NORMAL && GetRainmeter().IsNormalStayDesktop() && System::GetShowDesktop())
{
if (!(wp->flags & (SWP_NOOWNERZORDER | SWP_NOACTIVATE)))
{
@ -3865,7 +3865,7 @@ LRESULT MeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam
}
// Snap to other windows
for (auto iter = Rainmeter::GetInstance().GetAllMeterWindows().cbegin(); iter != Rainmeter::GetInstance().GetAllMeterWindows().cend(); ++iter)
for (auto iter = GetRainmeter().GetAllMeterWindows().cbegin(); iter != GetRainmeter().GetAllMeterWindows().cend(); ++iter)
{
if ((*iter).second != this)
{
@ -4348,14 +4348,14 @@ LRESULT MeterWindow::OnSetWindowFocus(UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_SETFOCUS:
if (!m_OnFocusAction.empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_OnFocusAction.c_str(), this);
GetRainmeter().ExecuteCommand(m_OnFocusAction.c_str(), this);
}
break;
case WM_KILLFOCUS:
if (!m_OnUnfocusAction.empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_OnUnfocusAction.c_str(), this);
GetRainmeter().ExecuteCommand(m_OnUnfocusAction.c_str(), this);
}
break;
}
@ -4398,7 +4398,7 @@ LRESULT MeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
}
Rainmeter::GetInstance().ShowContextMenu(pos, this);
GetRainmeter().ShowContextMenu(pos, this);
return 0;
}
@ -4439,7 +4439,7 @@ bool MeterWindow::DoAction(int x, int y, MOUSEACTION action, bool test)
{
if (!test)
{
Rainmeter::GetInstance().ExecuteCommand(command.c_str(), this);
GetRainmeter().ExecuteCommand(command.c_str(), this);
}
return true;
@ -4475,7 +4475,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!m_Mouse.GetOverAction().empty())
{
UINT currCounter = m_MouseMoveCounter;
Rainmeter::GetInstance().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
GetRainmeter().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
return (currCounter == m_MouseMoveCounter);
}
}
@ -4512,7 +4512,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!mouse.GetOverAction().empty())
{
UINT currCounter = m_MouseMoveCounter;
Rainmeter::GetInstance().ExecuteCommand(mouse.GetOverAction().c_str(), this);
GetRainmeter().ExecuteCommand(mouse.GetOverAction().c_str(), this);
return (currCounter == m_MouseMoveCounter);
}
}
@ -4538,7 +4538,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
const Mouse& mouse = (*j)->GetMouse();
if (!mouse.GetLeaveAction().empty())
{
Rainmeter::GetInstance().ExecuteCommand(mouse.GetLeaveAction().c_str(), this);
GetRainmeter().ExecuteCommand(mouse.GetLeaveAction().c_str(), this);
return true;
}
}
@ -4561,7 +4561,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!m_Mouse.GetOverAction().empty())
{
UINT currCounter = m_MouseMoveCounter;
Rainmeter::GetInstance().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
GetRainmeter().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
return (currCounter == m_MouseMoveCounter);
}
}
@ -4581,7 +4581,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!m_Mouse.GetLeaveAction().empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_Mouse.GetLeaveAction().c_str(), this);
GetRainmeter().ExecuteCommand(m_Mouse.GetLeaveAction().c_str(), this);
return true;
}
}
@ -4658,7 +4658,7 @@ LRESULT MeterWindow::OnWake(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (wParam == PBT_APMRESUMEAUTOMATIC && !m_OnWakeAction.empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_OnWakeAction.c_str(), this);
GetRainmeter().ExecuteCommand(m_OnWakeAction.c_str(), this);
}
return 0;
@ -4783,10 +4783,10 @@ LRESULT MeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (pCopyDataStruct && (pCopyDataStruct->dwData == 1) && (pCopyDataStruct->cbData > 0))
{
if (Rainmeter::GetInstance().HasMeterWindow(this))
if (GetRainmeter().HasMeterWindow(this))
{
const WCHAR* command = (const WCHAR*)pCopyDataStruct->lpData;
Rainmeter::GetInstance().ExecuteCommand(command, this);
GetRainmeter().ExecuteCommand(command, this);
}
else
{
@ -4841,8 +4841,8 @@ void MeterWindow::MakePathAbsolute(std::wstring& path)
else
{
std::wstring absolute;
absolute.reserve(Rainmeter::GetInstance().GetSkinPath().size() + m_FolderPath.size() + 1 + path.size());
absolute = Rainmeter::GetInstance().GetSkinPath();
absolute.reserve(GetRainmeter().GetSkinPath().size() + m_FolderPath.size() + 1 + path.size());
absolute = GetRainmeter().GetSkinPath();
absolute += m_FolderPath;
absolute += L'\\';
absolute += path;
@ -4852,7 +4852,7 @@ void MeterWindow::MakePathAbsolute(std::wstring& path)
std::wstring MeterWindow::GetFilePath()
{
std::wstring file = Rainmeter::GetInstance().GetSkinPath() + m_FolderPath;
std::wstring file = GetRainmeter().GetSkinPath() + m_FolderPath;
file += L'\\';
file += m_FileName;
return file;
@ -4871,7 +4871,7 @@ std::wstring MeterWindow::GetRootName()
std::wstring MeterWindow::GetRootPath()
{
std::wstring path = Rainmeter::GetInstance().GetSkinPath();
std::wstring path = GetRainmeter().GetSkinPath();
std::wstring::size_type loc;
if ((loc = m_FolderPath.find_first_of(L'\\')) != std::wstring::npos)

View File

@ -47,7 +47,7 @@ enum INTERVAL
*/
int RainmeterMain(LPWSTR cmdLine)
{
auto& rainmeter = Rainmeter::GetInstance();
auto& rainmeter = GetRainmeter();
int ret = rainmeter.Initialize(nullptr, nullptr);
if (ret == 0)
{
@ -58,30 +58,6 @@ int RainmeterMain(LPWSTR cmdLine)
return ret;
}
/*
** Initializes Rainmeter.
**
*/
void* Rainmeter_Initialize()
{
int res = Rainmeter::GetInstance().Initialize(nullptr, nullptr);
// Success?
if (res == 0)
return &Rainmeter::GetInstance();
return nullptr;
}
/*
** Finalizes Rainmeter.
**
*/
void Rainmeter_Finalize(void* ptr)
{
Rainmeter* rainmeter = (Rainmeter*)ptr;
rainmeter->Finalize();
}
/*
** Constructor
@ -127,7 +103,7 @@ Rainmeter::~Rainmeter()
GdiplusShutdown(m_GDIplusToken);
}
Rainmeter& Rainmeter::GetInstance()
Rainmeter& GetRainmeter()
{
static Rainmeter s_Rainmeter;
return s_Rainmeter;
@ -457,7 +433,7 @@ LRESULT CALLBACK Rainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
const WCHAR* data = (const WCHAR*)cds->lpData;
if (cds->dwData == 1 && (cds->cbData > 0))
{
Rainmeter::GetInstance().DelayedExecuteCommand(data);
GetRainmeter().DelayedExecuteCommand(data);
}
}
}
@ -468,12 +444,12 @@ LRESULT CALLBACK Rainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
{
MeasureNet::UpdateIFTable();
MeasureNet::UpdateStats();
Rainmeter::GetInstance().WriteStats(false);
GetRainmeter().WriteStats(false);
}
break;
case WM_RAINMETER_DELAYED_REFRESH_ALL:
Rainmeter::GetInstance().RefreshAll();
GetRainmeter().RefreshAll();
break;
case WM_RAINMETER_DELAYED_EXECUTE:
@ -481,15 +457,15 @@ LRESULT CALLBACK Rainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
{
// Execute bang
WCHAR* bang = (WCHAR*)lParam;
Rainmeter::GetInstance().ExecuteCommand(bang, nullptr);
GetRainmeter().ExecuteCommand(bang, nullptr);
free(bang); // _wcsdup()
}
break;
case WM_RAINMETER_EXECUTE:
if (Rainmeter::GetInstance().HasMeterWindow((MeterWindow*)wParam))
if (GetRainmeter().HasMeterWindow((MeterWindow*)wParam))
{
Rainmeter::GetInstance().ExecuteCommand((const WCHAR*)lParam, (MeterWindow*)wParam);
GetRainmeter().ExecuteCommand((const WCHAR*)lParam, (MeterWindow*)wParam);
}
break;

View File

@ -272,14 +272,15 @@ private:
GlobalOptions m_GlobalOptions;
};
// Convenience function.
inline Rainmeter& GetRainmeter() { return Rainmeter::GetInstance(); }
#ifdef LIBRARY_EXPORTS
#define EXPORT_PLUGIN EXTERN_C __declspec(dllexport)
#define EXPORT_PLUGIN EXTERN_C
#else
#define EXPORT_PLUGIN EXTERN_C __declspec(dllimport)
#endif
EXPORT_PLUGIN int RainmeterMain(LPWSTR cmdLine);
EXPORT_PLUGIN void* Rainmeter_Initialize();
EXPORT_PLUGIN void Rainmeter_Finalize(void* ptr);
#endif

View File

@ -82,6 +82,6 @@ void Section::DoUpdateAction()
{
if (!m_OnUpdateAction.empty())
{
Rainmeter::GetInstance().ExecuteCommand(m_OnUpdateAction.c_str(), m_MeterWindow);
GetRainmeter().ExecuteCommand(m_OnUpdateAction.c_str(), m_MeterWindow);
}
}

View File

@ -158,7 +158,7 @@ BOOL CALLBACK MyInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonit
info.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(hMonitor, &info);
if (Rainmeter::GetInstance().GetDebug())
if (GetRainmeter().GetDebug())
{
LogDebug(info.szDevice);
LogDebugF(L" Flags : %s(0x%08X)", (info.dwFlags & MONITORINFOF_PRIMARY) ? L"PRIMARY " : L"", info.dwFlags);
@ -240,7 +240,7 @@ size_t System::GetMonitorCount()
void System::SetMultiMonitorInfo()
{
std::vector<MonitorInfo>& monitors = c_Monitors.monitors;
bool logging = Rainmeter::GetInstance().GetDebug();
bool logging = GetRainmeter().GetDebug();
c_Monitors.vsT = GetSystemMetrics(SM_YVIRTUALSCREEN);
c_Monitors.vsL = GetSystemMetrics(SM_XVIRTUALSCREEN);
@ -528,7 +528,7 @@ void System::UpdateWorkareaInfo()
(*iter).work = info.rcWork;
if (Rainmeter::GetInstance().GetDebug())
if (GetRainmeter().GetDebug())
{
LogDebugF(L"WorkArea@%i : L=%i, T=%i, R=%i, B=%i (W=%i, H=%i)",
i,
@ -633,7 +633,7 @@ HWND System::GetBackmostTopWindow()
// Skip all ZPOSITION_ONDESKTOP, ZPOSITION_BOTTOM, and ZPOSITION_NORMAL windows
while (winPos = ::GetNextWindow(winPos, GW_HWNDPREV))
{
MeterWindow* wnd = Rainmeter::GetInstance().GetMeterWindow(winPos);
MeterWindow* wnd = GetRainmeter().GetMeterWindow(winPos);
if (!wnd ||
(wnd->GetWindowZPosition() != ZPOSITION_NORMAL &&
wnd->GetWindowZPosition() != ZPOSITION_ONDESKTOP &&
@ -666,7 +666,7 @@ bool System::BelongToSameProcess(HWND hwndA, HWND hwndB)
*/
BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam)
{
bool logging = Rainmeter::GetInstance().GetDebug() && DEBUG_VERBOSE;
bool logging = GetRainmeter().GetDebug() && DEBUG_VERBOSE;
const int classLen = _countof(METERWINDOW_CLASS_NAME) + (DEBUG_VERBOSE ? 32 : 1);
WCHAR className[classLen];
MeterWindow* Window;
@ -674,11 +674,11 @@ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam)
if (GetClassName(hwnd, className, classLen) > 0 &&
wcscmp(className, METERWINDOW_CLASS_NAME) == 0 &&
(Window = Rainmeter::GetInstance().GetMeterWindow(hwnd)))
(Window = GetRainmeter().GetMeterWindow(hwnd)))
{
ZPOSITION zPos = Window->GetWindowZPosition();
if (zPos == ZPOSITION_ONDESKTOP ||
(zPos == ZPOSITION_NORMAL && Rainmeter::GetInstance().IsNormalStayDesktop()) ||
(zPos == ZPOSITION_NORMAL && GetRainmeter().IsNormalStayDesktop()) ||
zPos == ZPOSITION_ONBOTTOM)
{
if (lParam)
@ -717,7 +717,7 @@ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam)
*/
void System::ChangeZPosInOrder()
{
bool logging = Rainmeter::GetInstance().GetDebug() && DEBUG_VERBOSE;
bool logging = GetRainmeter().GetDebug() && DEBUG_VERBOSE;
std::vector<MeterWindow*> windowsInZOrder;
if (logging) LogDebug(L"1: ----- BEFORE -----");
@ -738,7 +738,7 @@ void System::ChangeZPosInOrder()
}
};
if (Rainmeter::GetInstance().IsNormalStayDesktop())
if (GetRainmeter().IsNormalStayDesktop())
{
resetZPos(ZPOSITION_NORMAL);
}
@ -765,7 +765,7 @@ void System::ChangeZPosInOrder()
*/
void System::PrepareHelperWindow(HWND WorkerW)
{
bool logging = Rainmeter::GetInstance().GetDebug() && DEBUG_VERBOSE;
bool logging = GetRainmeter().GetDebug() && DEBUG_VERBOSE;
SetWindowPos(c_Window, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS); // always on bottom
@ -848,7 +848,7 @@ bool System::CheckDesktopState(HWND WorkerW)
{
c_ShowDesktop = !c_ShowDesktop;
if (Rainmeter::GetInstance().GetDebug())
if (GetRainmeter().GetDebug())
{
LogDebugF(L"System: \"Show %s\" has been detected.",
c_ShowDesktop ? L"desktop" : L"open windows");
@ -943,10 +943,10 @@ LRESULT CALLBACK System::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
case TIMER_RESUME:
KillTimer(hWnd, TIMER_RESUME);
if (Rainmeter::GetInstance().IsRedrawable())
if (GetRainmeter().IsRedrawable())
{
std::map<std::wstring, MeterWindow*>::const_iterator iter = Rainmeter::GetInstance().GetAllMeterWindows().begin();
for ( ; iter != Rainmeter::GetInstance().GetAllMeterWindows().end(); ++iter)
std::map<std::wstring, MeterWindow*>::const_iterator iter = GetRainmeter().GetAllMeterWindows().begin();
for ( ; iter != GetRainmeter().GetAllMeterWindows().end(); ++iter)
{
(*iter).second->RedrawWindow();
}
@ -970,8 +970,8 @@ LRESULT CALLBACK System::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
// Deliver WM_DISPLAYCHANGE / WM_SETTINGCHANGE message to all meter windows
std::map<std::wstring, MeterWindow*>::const_iterator iter = Rainmeter::GetInstance().GetAllMeterWindows().begin();
for ( ; iter != Rainmeter::GetInstance().GetAllMeterWindows().end(); ++iter)
std::map<std::wstring, MeterWindow*>::const_iterator iter = GetRainmeter().GetAllMeterWindows().begin();
for ( ; iter != GetRainmeter().GetAllMeterWindows().end(); ++iter)
{
PostMessage((*iter).second->GetWindow(), WM_METERWINDOW_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
}
@ -1147,7 +1147,7 @@ void System::SetWallpaper(const std::wstring& wallpaper, const std::wstring& sty
Bitmap bitmap(wallpaper.c_str());
if (bitmap.GetLastStatus() == Ok)
{
std::wstring file = Rainmeter::GetInstance().GetSettingsPath() + L"Wallpaper.bmp";
std::wstring file = GetRainmeter().GetSettingsPath() + L"Wallpaper.bmp";
const CLSID bmpClsid = { 0x557cf400, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } };
if (bitmap.Save(file.c_str(), &bmpClsid) == Ok)

View File

@ -87,7 +87,7 @@ void TrayWindow::Initialize()
{
WNDCLASS wc = {0};
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.hInstance = Rainmeter::GetInstance().GetModuleInstance();
wc.hInstance = GetRainmeter().GetModuleInstance();
wc.lpszClassName = L"RainmeterTrayClass";
wc.hIcon = GetIcon(IDI_RAINMETER);
@ -337,7 +337,7 @@ void TrayWindow::SetTrayIcon(bool enabled)
m_IconEnabled = enabled;
// Save to Rainmeter.ini.
const std::wstring& iniFile = Rainmeter::GetInstance().GetIniFile();
const std::wstring& iniFile = GetRainmeter().GetIniFile();
WritePrivateProfileString(L"Rainmeter", L"TrayIcon", enabled ? nullptr : L"0", iniFile.c_str());
}
@ -370,8 +370,8 @@ void TrayWindow::ReadOptions(ConfigParser& parser)
if (!measureName.empty())
{
ConfigParser* oldParser = Rainmeter::GetInstance().GetCurrentParser();
Rainmeter::GetInstance().SetCurrentParser(&parser);
ConfigParser* oldParser = GetRainmeter().GetCurrentParser();
GetRainmeter().SetCurrentParser(&parser);
m_Measure = Measure::Create(measureName.c_str(), nullptr, L"TrayMeasure");
if (m_Measure)
@ -379,7 +379,7 @@ void TrayWindow::ReadOptions(ConfigParser& parser)
m_Measure->ReadOptions(parser);
}
Rainmeter::GetInstance().SetCurrentParser(oldParser);
GetRainmeter().SetCurrentParser(oldParser);
}
const WCHAR* type = parser.ReadString(L"TrayMeasure", L"TrayMeter", m_Measure ? L"HISTOGRAM" : L"NONE").c_str();
@ -402,7 +402,7 @@ void TrayWindow::ReadOptions(ConfigParser& parser)
// Load the bitmaps if defined
if (!imageName.empty())
{
imageName.insert(0, Rainmeter::GetInstance().GetSkinPath());
imageName.insert(0, GetRainmeter().GetSkinPath());
const WCHAR* imagePath = imageName.c_str();
if (_wcsicmp(imagePath + (imageName.size() - 4), L".ico") == 0)
{
@ -457,7 +457,7 @@ void TrayWindow::ReadOptions(ConfigParser& parser)
LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
TrayWindow* tray = Rainmeter::GetInstance().GetTrayWindow();
TrayWindow* tray = GetRainmeter().GetTrayWindow();
switch (uMsg)
{
@ -481,11 +481,11 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
break;
case IDM_REFRESH:
PostMessage(Rainmeter::GetInstance().GetWindow(), WM_RAINMETER_DELAYED_REFRESH_ALL, (WPARAM)nullptr, (LPARAM)nullptr);
PostMessage(GetRainmeter().GetWindow(), WM_RAINMETER_DELAYED_REFRESH_ALL, (WPARAM)nullptr, (LPARAM)nullptr);
break;
case IDM_SHOWLOGFILE:
Rainmeter::GetInstance().ShowLogFile();
GetRainmeter().ShowLogFile();
break;
case IDM_STARTLOG:
@ -501,15 +501,15 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
break;
case IDM_DEBUGLOG:
Rainmeter::GetInstance().SetDebug(!Rainmeter::GetInstance().GetDebug());
GetRainmeter().SetDebug(!GetRainmeter().GetDebug());
break;
case IDM_DISABLEDRAG:
Rainmeter::GetInstance().SetDisableDragging(!Rainmeter::GetInstance().GetDisableDragging());
GetRainmeter().SetDisableDragging(!GetRainmeter().GetDisableDragging());
break;
case IDM_EDITCONFIG:
Rainmeter::GetInstance().EditSettings();
GetRainmeter().EditSettings();
break;
case IDM_QUIT:
@ -517,7 +517,7 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
break;
case IDM_OPENSKINSFOLDER:
Rainmeter::GetInstance().OpenSkinFolder();
GetRainmeter().OpenSkinFolder();
break;
default:
@ -528,21 +528,21 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
{
int pos = mID - ID_THEME_FIRST;
const std::vector<std::wstring>& layouts = Rainmeter::GetInstance().GetAllLayouts();
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
if (pos >= 0 && pos < (int)layouts.size())
{
Rainmeter::GetInstance().LoadLayout(layouts[pos]);
GetRainmeter().LoadLayout(layouts[pos]);
}
}
else if (mID >= ID_CONFIG_FIRST && mID <= ID_CONFIG_LAST)
{
Rainmeter::GetInstance().ToggleSkinWithID(mID);
GetRainmeter().ToggleSkinWithID(mID);
}
else
{
// Forward the message to correct window
int index = (int)(wParam >> 16);
const std::map<std::wstring, MeterWindow*>& windows = Rainmeter::GetInstance().GetAllMeterWindows();
const std::map<std::wstring, MeterWindow*>& windows = GetRainmeter().GetAllMeterWindows();
if (index < (int)windows.size())
{
@ -573,19 +573,19 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
switch (uMouseMsg)
{
case WM_MBUTTONDOWN:
bang = Rainmeter::GetInstance().GetTrayExecuteM().c_str();
bang = GetRainmeter().GetTrayExecuteM().c_str();
break;
case WM_RBUTTONDOWN:
bang = Rainmeter::GetInstance().GetTrayExecuteR().c_str();
bang = GetRainmeter().GetTrayExecuteR().c_str();
break;
case WM_MBUTTONDBLCLK:
bang = Rainmeter::GetInstance().GetTrayExecuteDM().c_str();
bang = GetRainmeter().GetTrayExecuteDM().c_str();
break;
case WM_RBUTTONDBLCLK:
bang = Rainmeter::GetInstance().GetTrayExecuteDR().c_str();
bang = GetRainmeter().GetTrayExecuteDR().c_str();
break;
default:
@ -596,7 +596,7 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (*bang &&
!IsCtrlKeyDown()) // Ctrl is pressed, so only run default action
{
Rainmeter::GetInstance().ExecuteCommand(bang, nullptr);
GetRainmeter().ExecuteCommand(bang, nullptr);
tray->m_TrayContextMenuEnabled = (uMouseMsg != WM_RBUTTONDOWN);
break;
}
@ -612,7 +612,7 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (tray->m_TrayContextMenuEnabled)
{
POINT pos = System::GetCursorPosition();
Rainmeter::GetInstance().ShowContextMenu(pos, nullptr);
GetRainmeter().ShowContextMenu(pos, nullptr);
}
break;
@ -656,19 +656,19 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
switch (wParam)
{
case RAINMETER_QUERY_ID_SKINS_PATH:
sendCopyData(Rainmeter::GetInstance().GetSkinPath());
sendCopyData(GetRainmeter().GetSkinPath());
return 0;
case RAINMETER_QUERY_ID_SETTINGS_PATH:
sendCopyData(Rainmeter::GetInstance().GetSettingsPath());
sendCopyData(GetRainmeter().GetSettingsPath());
return 0;
case RAINMETER_QUERY_ID_PLUGINS_PATH:
sendCopyData(Rainmeter::GetInstance().GetPluginPath());
sendCopyData(GetRainmeter().GetPluginPath());
return 0;
case RAINMETER_QUERY_ID_PROGRAM_PATH:
sendCopyData(Rainmeter::GetInstance().GetPath());
sendCopyData(GetRainmeter().GetPath());
return 0;
case RAINMETER_QUERY_ID_LOG_PATH:
@ -676,12 +676,12 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
return 0;
case RAINMETER_QUERY_ID_CONFIG_EDITOR:
sendCopyData(Rainmeter::GetInstance().GetSkinEditor());
sendCopyData(GetRainmeter().GetSkinEditor());
return 0;
case RAINMETER_QUERY_ID_IS_DEBUGGING:
{
BOOL debug = Rainmeter::GetInstance().GetDebug();
BOOL debug = GetRainmeter().GetDebug();
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)debug);
}
return 0;
@ -695,7 +695,7 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
{
LPCWSTR folderPath = (LPCWSTR)cds->lpData;
MeterWindow* mw = Rainmeter::GetInstance().GetMeterWindow(folderPath);
MeterWindow* mw = GetRainmeter().GetMeterWindow(folderPath);
return (mw) ? (LRESULT)mw->GetWindow() : 0;
}
}

View File

@ -70,17 +70,17 @@ void CheckVersion(void* dummy)
if (availableVersion > RAINMETER_VERSION ||
(revision_beta && availableVersion == RAINMETER_VERSION))
{
Rainmeter::GetInstance().SetNewVersion();
GetRainmeter().SetNewVersion();
WCHAR buffer[32];
const WCHAR* dataFile = Rainmeter::GetInstance().GetDataFile().c_str();
const WCHAR* dataFile = GetRainmeter().GetDataFile().c_str();
GetPrivateProfileString(L"Rainmeter", L"LastCheck", L"0", buffer, _countof(buffer), dataFile);
// Show tray notification only once per new version
int lastVersion = parseVersion(buffer);
if (availableVersion > lastVersion)
{
Rainmeter::GetInstance().GetTrayWindow()->ShowUpdateNotification(version);
GetRainmeter().GetTrayWindow()->ShowUpdateNotification(version);
WritePrivateProfileString(L"Rainmeter", L"LastCheck", version, dataFile);
}
}

View File

@ -38,7 +38,7 @@ static int Bang(lua_State* L)
if (top == 2) // 1 argument
{
parser.ReplaceVariables(bang);
Rainmeter::GetInstance().ExecuteCommand(bang.c_str(), self);
GetRainmeter().ExecuteCommand(bang.c_str(), self);
}
else
{
@ -54,7 +54,7 @@ static int Bang(lua_State* L)
args.push_back(tmpSz);
}
Rainmeter::GetInstance().ExecuteBang(bangSz, args, self);
GetRainmeter().ExecuteBang(bangSz, args, self);
}
}