2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2001 Kimmo Pekkola
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RAINMETER_H__
|
|
|
|
#define __RAINMETER_H__
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2011-02-07 08:02:12 +00:00
|
|
|
#include <list>
|
2009-02-10 18:37:48 +00:00
|
|
|
#include <string>
|
2013-05-30 16:51:05 +00:00
|
|
|
#include "CommandHandler.h"
|
2013-06-16 16:54:22 +00:00
|
|
|
#include "ContextMenu.h"
|
2013-05-29 19:05:41 +00:00
|
|
|
#include "Logger.h"
|
2010-09-21 22:47:53 +00:00
|
|
|
#include "MeterWindow.h"
|
2013-06-16 16:14:59 +00:00
|
|
|
#include "SkinRegistry.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
#define MAX_LINE_LENGTH 4096
|
|
|
|
|
|
|
|
#define APPNAME L"Rainmeter"
|
|
|
|
#ifdef _WIN64
|
2011-08-28 10:58:26 +00:00
|
|
|
#define APPBITS L"64-bit"
|
2009-02-10 18:37:48 +00:00
|
|
|
#else
|
2011-08-28 10:58:26 +00:00
|
|
|
#define APPBITS L"32-bit"
|
2009-02-10 18:37:48 +00:00
|
|
|
#endif
|
2011-08-28 10:58:26 +00:00
|
|
|
#define WIDEN2(x) L ## x
|
|
|
|
#define WIDEN(x) WIDEN2(x)
|
|
|
|
#define APPDATE WIDEN(__DATE__)
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-02-14 17:00:07 +00:00
|
|
|
#define RAINMETER_CLASS_NAME L"DummyRainWClass"
|
|
|
|
#define RAINMETER_WINDOW_NAME L"Rainmeter control window"
|
|
|
|
|
2012-02-14 17:58:03 +00:00
|
|
|
#define WM_RAINMETER_DELAYED_REFRESH_ALL WM_APP + 0
|
|
|
|
#define WM_RAINMETER_DELAYED_EXECUTE WM_APP + 1
|
2012-02-22 06:42:52 +00:00
|
|
|
#define WM_RAINMETER_EXECUTE WM_APP + 2
|
2012-02-14 17:58:03 +00:00
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
struct GlobalOptions
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
double netInSpeed;
|
|
|
|
double netOutSpeed;
|
|
|
|
};
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
class ConfigParser;
|
|
|
|
class TrayWindow;
|
2011-02-07 08:02:12 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
class Rainmeter
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-06-13 14:20:27 +00:00
|
|
|
static Rainmeter& GetInstance();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-10-06 17:12:40 +00:00
|
|
|
int Initialize(LPCWSTR iniPath, LPCWSTR layout);
|
2013-06-14 13:58:42 +00:00
|
|
|
void Finalize();
|
|
|
|
|
2012-05-24 11:15:03 +00:00
|
|
|
bool IsAlreadyRunning();
|
2012-02-14 17:00:07 +00:00
|
|
|
int MessagePump();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-02-15 02:51:27 +00:00
|
|
|
void SetNetworkStatisticsTimer();
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
ConfigParser* GetCurrentParser() { return m_CurrentParser; }
|
|
|
|
void SetCurrentParser(ConfigParser* parser) { m_CurrentParser = parser; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
TrayWindow* GetTrayWindow() { return m_TrayWindow; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
bool HasMeterWindow(const MeterWindow* meterWindow) const;
|
2013-03-21 12:29:59 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
MeterWindow* GetMeterWindow(const std::wstring& folderPath);
|
|
|
|
MeterWindow* GetMeterWindowByINI(const std::wstring& ini_searching);
|
2011-09-08 14:39:25 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
MeterWindow* GetMeterWindow(HWND hwnd);
|
|
|
|
void GetMeterWindowsByLoadOrder(std::multimap<int, MeterWindow*>& windows, const std::wstring& group = std::wstring());
|
|
|
|
std::map<std::wstring, MeterWindow*>& GetAllMeterWindows() { return m_MeterWindows; }
|
2012-06-01 10:05:25 +00:00
|
|
|
|
2012-10-02 14:44:47 +00:00
|
|
|
const std::vector<std::wstring>& GetAllLayouts() { return m_Layouts; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void RemoveMeterWindow(MeterWindow* meterWindow);
|
|
|
|
void AddUnmanagedMeterWindow(MeterWindow* meterWindow);
|
|
|
|
void RemoveUnmanagedMeterWindow(MeterWindow* meterWindow);
|
2012-02-02 12:05:14 +00:00
|
|
|
|
2013-06-16 16:14:59 +00:00
|
|
|
bool ActivateSkin(const std::wstring& folderPath);
|
|
|
|
bool ActivateSkin(const std::wstring& folderPath, const std::wstring& file);
|
2012-06-01 13:06:36 +00:00
|
|
|
void ActivateSkin(int folderIndex, int fileIndex);
|
2013-05-31 14:18:52 +00:00
|
|
|
void DeactivateSkin(MeterWindow* meterWindow, int folderIndex, bool save = true);
|
2012-06-01 13:06:36 +00:00
|
|
|
void ToggleSkin(int folderIndex, int fileIndex);
|
2013-06-16 16:14:59 +00:00
|
|
|
void ToggleSkinWithID(UINT id);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-10-19 22:03:32 +00:00
|
|
|
const std::wstring& GetPath() { return m_Path; }
|
|
|
|
const std::wstring& GetIniFile() { return m_IniFile; }
|
2012-05-05 11:45:34 +00:00
|
|
|
const std::wstring& GetDataFile() { return m_DataFile; }
|
2012-06-09 15:38:45 +00:00
|
|
|
const std::wstring& GetSettingsPath() { return m_SettingsPath; }
|
2010-10-19 22:03:32 +00:00
|
|
|
const std::wstring& GetSkinPath() { return m_SkinPath; }
|
2012-11-13 14:11:43 +00:00
|
|
|
void SetSkinPath(const std::wstring& skinPath);
|
2012-10-02 14:44:47 +00:00
|
|
|
std::wstring GetLayoutPath() { return m_SettingsPath + L"Layouts\\"; }
|
2012-05-30 05:33:32 +00:00
|
|
|
std::wstring GetPluginPath() { return m_Path + L"Plugins\\"; }
|
2012-06-09 15:38:45 +00:00
|
|
|
std::wstring GetUserPluginPath() { return m_SettingsPath + L"Plugins\\"; }
|
|
|
|
std::wstring GetAddonPath() { return m_SettingsPath + L"Addons\\"; }
|
2012-05-30 05:33:32 +00:00
|
|
|
|
2012-06-21 09:06:17 +00:00
|
|
|
bool HasUserPluginPath() { return (_wcsicmp(m_Path.c_str(), m_SettingsPath.c_str()) != 0); }
|
|
|
|
|
2012-05-30 05:33:32 +00:00
|
|
|
std::wstring GetDefaultSkinPath() { return m_Path + L"Defaults\\Skins\\"; }
|
2012-10-02 14:44:47 +00:00
|
|
|
std::wstring GetDefaultLayoutPath() { return m_Path + L"Defaults\\Layouts\\"; }
|
2012-06-09 15:38:45 +00:00
|
|
|
std::wstring GetDefaultPluginPath() { return m_Path + L"Defaults\\Plugins\\"; }
|
|
|
|
std::wstring GetDefaultAddonPath() { return m_Path + L"Defaults\\Addons\\"; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& GetDrive() { return m_Drive; }
|
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
const std::wstring& GetSkinEditor() { return m_SkinEditor; }
|
2012-11-13 15:54:32 +00:00
|
|
|
void SetSkinEditor(const std::wstring& path);
|
2010-10-19 22:03:32 +00:00
|
|
|
const std::wstring& GetStatsDate() { return m_StatsDate; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-02-14 17:00:07 +00:00
|
|
|
HWND GetWindow() { return m_Window; }
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
HINSTANCE GetModuleInstance() { return m_Instance; }
|
2011-09-23 16:28:38 +00:00
|
|
|
HINSTANCE GetResourceInstance() { return m_ResourceInstance; }
|
2011-10-01 17:39:09 +00:00
|
|
|
LCID GetResourceLCID() { return m_ResourceLCID; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-07-25 22:44:06 +00:00
|
|
|
bool GetUseD2D() const { return m_UseD2D; }
|
|
|
|
void SetUseD2D(bool enabled);
|
2013-03-25 16:00:53 +00:00
|
|
|
|
2011-09-28 18:28:35 +00:00
|
|
|
bool GetDebug() { return m_Debug; }
|
2010-07-07 23:46:44 +00:00
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
GlobalOptions& GetGlobalOptions() { return m_GlobalOptions; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
void ReloadSettings();
|
2012-02-21 19:15:10 +00:00
|
|
|
void EditSettings();
|
|
|
|
void EditSkinFile(const std::wstring& name, const std::wstring& iniFile);
|
|
|
|
void OpenSkinFolder(const std::wstring& name = std::wstring());
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
void UpdateStats();
|
|
|
|
void ReadStats();
|
2009-07-27 12:30:28 +00:00
|
|
|
void WriteStats(bool bForce);
|
2009-02-10 18:37:48 +00:00
|
|
|
void ResetStats();
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
bool GetDisableVersionCheck() { return m_DisableVersionCheck; }
|
|
|
|
void SetDisableVersionCheck(bool check);
|
|
|
|
bool GetNewVersion() { return m_NewVersion; }
|
2012-04-06 17:54:45 +00:00
|
|
|
void SetNewVersion() { m_NewVersion = true; }
|
2010-07-07 23:46:44 +00:00
|
|
|
|
2012-02-21 19:15:10 +00:00
|
|
|
void ShowLogFile();
|
2010-09-19 09:21:25 +00:00
|
|
|
|
2010-11-24 15:34:07 +00:00
|
|
|
bool GetDisableRDP() { return m_DisableRDP; }
|
2012-02-20 15:33:13 +00:00
|
|
|
bool IsRedrawable() { return (!GetDisableRDP() || !GetSystemMetrics(SM_REMOTESESSION)); }
|
2010-11-24 15:34:07 +00:00
|
|
|
|
2010-11-27 10:57:59 +00:00
|
|
|
bool GetDisableDragging() { return m_DisableDragging; }
|
|
|
|
void SetDisableDragging(bool dragging);
|
2010-11-24 15:34:07 +00:00
|
|
|
|
2011-11-10 11:50:47 +00:00
|
|
|
bool IsNormalStayDesktop() { return m_NormalStayDesktop; }
|
|
|
|
|
2010-07-07 23:46:44 +00:00
|
|
|
void SetDebug(bool debug);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-06-19 11:31:08 +00:00
|
|
|
int ShowMessage(HWND parent, const WCHAR* text, UINT type);
|
|
|
|
|
2013-06-16 16:54:22 +00:00
|
|
|
bool IsMenuActive() { return m_ContextMenu.IsMenuActive(); }
|
|
|
|
void ShowContextMenu(POINT pos, MeterWindow* mw) { return m_ContextMenu.ShowMenu(pos, mw); }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-11-11 20:24:59 +00:00
|
|
|
const std::wstring& GetTrayExecuteR() { return m_TrayExecuteR; }
|
|
|
|
const std::wstring& GetTrayExecuteM() { return m_TrayExecuteM; }
|
|
|
|
const std::wstring& GetTrayExecuteDR() { return m_TrayExecuteDR; }
|
|
|
|
const std::wstring& GetTrayExecuteDM() { return m_TrayExecuteDM; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ExecuteBang(const WCHAR* bang, std::vector<std::wstring>& args, MeterWindow* meterWindow);
|
|
|
|
void ExecuteCommand(const WCHAR* command, MeterWindow* meterWindow, bool multi = true);
|
2012-02-14 17:00:07 +00:00
|
|
|
void DelayedExecuteCommand(const WCHAR* command);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-03-29 21:50:05 +00:00
|
|
|
void RefreshAll();
|
|
|
|
|
2012-10-06 17:12:40 +00:00
|
|
|
bool LoadLayout(const std::wstring& name);
|
2011-09-04 07:40:12 +00:00
|
|
|
void PreserveSetting(const std::wstring& from, LPCTSTR key, bool replace = true);
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
friend class CommandHandler;
|
2013-06-16 16:54:22 +00:00
|
|
|
friend class ContextMenu;
|
2013-05-31 14:18:52 +00:00
|
|
|
friend class DialogManage;
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
private:
|
2013-06-13 14:20:27 +00:00
|
|
|
Rainmeter();
|
|
|
|
~Rainmeter();
|
|
|
|
|
2014-01-05 10:07:22 +00:00
|
|
|
Rainmeter(const Rainmeter& other) = delete;
|
|
|
|
Rainmeter& operator=(Rainmeter other) = delete;
|
|
|
|
|
2012-02-14 17:00:07 +00:00
|
|
|
static LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
void ActivateActiveSkins();
|
|
|
|
void CreateMeterWindow(const std::wstring& folderPath, const std::wstring& file);
|
2013-03-10 21:06:02 +00:00
|
|
|
void DeleteAllMeterWindows();
|
|
|
|
void DeleteAllUnmanagedMeterWindows();
|
2012-06-01 13:06:36 +00:00
|
|
|
void WriteActive(const std::wstring& folderPath, int fileIndex);
|
2012-06-10 09:17:47 +00:00
|
|
|
void ScanForSkins();
|
2012-10-02 14:44:47 +00:00
|
|
|
void ScanForLayouts();
|
2010-11-11 20:24:59 +00:00
|
|
|
void ReadGeneralSettings(const std::wstring& iniFile);
|
2012-06-01 10:05:25 +00:00
|
|
|
void SetLoadOrder(int folderIndex, int order);
|
2012-06-01 13:06:36 +00:00
|
|
|
int GetLoadOrder(const std::wstring& folderPath);
|
2010-07-10 12:56:37 +00:00
|
|
|
void UpdateDesktopWorkArea(bool reset);
|
2013-06-16 16:54:22 +00:00
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
void CreateOptionsFile();
|
2012-05-05 11:45:34 +00:00
|
|
|
void CreateDataFile();
|
2012-06-09 16:45:27 +00:00
|
|
|
void CreateComponentFolders(bool defaultIniLocation);
|
2011-05-02 11:58:02 +00:00
|
|
|
void TestSettingsFile(bool bDefaultIniLocation);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
TrayWindow* m_TrayWindow;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
std::multimap<int, int> m_SkinOrders;
|
2013-05-31 14:18:52 +00:00
|
|
|
std::map<std::wstring, MeterWindow*> m_MeterWindows;
|
|
|
|
std::list<MeterWindow*> m_UnmanagedMeterWindows;
|
2012-10-02 14:44:47 +00:00
|
|
|
std::vector<std::wstring> m_Layouts;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-05-05 11:45:34 +00:00
|
|
|
std::wstring m_Path;
|
|
|
|
std::wstring m_IniFile;
|
|
|
|
std::wstring m_DataFile;
|
|
|
|
std::wstring m_StatsFile;
|
2012-06-09 15:38:45 +00:00
|
|
|
std::wstring m_SettingsPath;
|
2012-05-05 11:45:34 +00:00
|
|
|
std::wstring m_SkinPath;
|
2010-11-25 22:00:34 +00:00
|
|
|
|
|
|
|
std::wstring m_Drive;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-05-20 17:57:12 +00:00
|
|
|
std::wstring m_StatsDate;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
std::wstring m_TrayExecuteR;
|
|
|
|
std::wstring m_TrayExecuteM;
|
|
|
|
std::wstring m_TrayExecuteDR;
|
|
|
|
std::wstring m_TrayExecuteDM;
|
|
|
|
|
2013-03-25 16:00:53 +00:00
|
|
|
bool m_UseD2D;
|
|
|
|
|
2011-09-28 18:28:35 +00:00
|
|
|
bool m_Debug;
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
bool m_DisableVersionCheck;
|
|
|
|
bool m_NewVersion;
|
2011-12-09 08:40:19 +00:00
|
|
|
|
2010-07-17 13:02:34 +00:00
|
|
|
bool m_DesktopWorkAreaChanged;
|
2012-05-20 17:57:12 +00:00
|
|
|
bool m_DesktopWorkAreaType;
|
2010-07-10 12:56:37 +00:00
|
|
|
std::map<UINT, RECT> m_DesktopWorkAreas;
|
|
|
|
std::vector<RECT> m_OldDesktopWorkAreas;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-11-10 11:50:47 +00:00
|
|
|
bool m_NormalStayDesktop;
|
|
|
|
|
2010-11-24 15:34:07 +00:00
|
|
|
bool m_DisableRDP;
|
|
|
|
|
2010-11-27 10:57:59 +00:00
|
|
|
bool m_DisableDragging;
|
2010-11-24 15:34:07 +00:00
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
std::wstring m_SkinEditor;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
CommandHandler m_CommandHandler;
|
2013-06-16 16:54:22 +00:00
|
|
|
ContextMenu m_ContextMenu;
|
2013-06-16 16:14:59 +00:00
|
|
|
SkinRegistry m_SkinRegistry;
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
ConfigParser* m_CurrentParser;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-02-14 17:00:07 +00:00
|
|
|
HWND m_Window;
|
|
|
|
|
2012-05-24 11:15:03 +00:00
|
|
|
HANDLE m_Mutex;
|
2009-02-10 18:37:48 +00:00
|
|
|
HINSTANCE m_Instance;
|
2011-09-23 16:28:38 +00:00
|
|
|
HMODULE m_ResourceInstance;
|
2011-10-01 17:39:09 +00:00
|
|
|
LCID m_ResourceLCID;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
ULONG_PTR m_GDIplusToken;
|
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
GlobalOptions m_GlobalOptions;
|
2009-02-10 18:37:48 +00:00
|
|
|
};
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
// Convenience function.
|
|
|
|
inline Rainmeter& GetRainmeter() { return Rainmeter::GetInstance(); }
|
|
|
|
|
2012-02-04 16:13:04 +00:00
|
|
|
#ifdef LIBRARY_EXPORTS
|
|
|
|
#define EXPORT_PLUGIN EXTERN_C
|
|
|
|
#else
|
|
|
|
#define EXPORT_PLUGIN EXTERN_C __declspec(dllimport)
|
|
|
|
#endif
|
|
|
|
|
2012-02-16 17:38:45 +00:00
|
|
|
EXPORT_PLUGIN int RainmeterMain(LPWSTR cmdLine);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
#endif
|