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
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RAINMETER_H__
|
|
|
|
#define __RAINMETER_H__
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include "Litestep.h"
|
|
|
|
#include "MeterWindow.h"
|
|
|
|
#include "TrayWindow.h"
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#define MAX_LINE_LENGTH 4096
|
|
|
|
|
2009-08-02 11:32:12 +00:00
|
|
|
#define MAKE_VER(major, minor1, minor2) major * 1000000 + minor1 * 1000 + minor2
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
#define APPNAME L"Rainmeter"
|
2010-01-24 17:31:15 +00:00
|
|
|
#define APPVERSION L"1.2"
|
2009-02-10 18:37:48 +00:00
|
|
|
#ifdef _WIN64
|
2009-07-24 07:56:37 +00:00
|
|
|
#define APPBITS L"(64-bit)"
|
2009-02-10 18:37:48 +00:00
|
|
|
#else
|
2009-07-24 07:56:37 +00:00
|
|
|
#define APPBITS L"(32-bit)"
|
2009-02-10 18:37:48 +00:00
|
|
|
#endif
|
2010-01-24 17:31:15 +00:00
|
|
|
#define RAINMETER_VERSION MAKE_VER(1, 2, 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
enum PLATFORM
|
|
|
|
{
|
|
|
|
PLATFORM_9X,
|
|
|
|
PLATFORM_NT4,
|
|
|
|
PLATFORM_2K,
|
|
|
|
PLATFORM_XP
|
|
|
|
};
|
|
|
|
|
|
|
|
void RainmeterActivateConfig(HWND, const char* arg);
|
|
|
|
void RainmeterDeactivateConfig(HWND, const char* arg);
|
|
|
|
void RainmeterToggleConfig(HWND, const char* arg);
|
|
|
|
void RainmeterRefresh(HWND, const char* arg);
|
2010-03-29 21:50:05 +00:00
|
|
|
void RainmeterRefreshApp(HWND, const char* arg);
|
2009-02-10 18:37:48 +00:00
|
|
|
void RainmeterRedraw(HWND, const char* arg);
|
|
|
|
void RainmeterToggleMeasure(HWND, const char* arg);
|
|
|
|
void RainmeterEnableMeasure(HWND, const char* arg);
|
|
|
|
void RainmeterDisableMeasure(HWND, const char* arg);
|
|
|
|
void RainmeterToggleMeter(HWND, const char* arg);
|
|
|
|
void RainmeterShowMeter(HWND, const char* arg);
|
|
|
|
void RainmeterHideMeter(HWND, const char* arg);
|
|
|
|
void RainmeterShow(HWND, const char* arg);
|
|
|
|
void RainmeterHide(HWND, const char* arg);
|
|
|
|
void RainmeterToggle(HWND, const char* arg);
|
|
|
|
void RainmeterMove(HWND, const char* arg);
|
|
|
|
void RainmeterZPos(HWND, const char* arg);
|
|
|
|
void RainmeterLsHook(HWND, const char* arg);
|
|
|
|
void RainmeterAbout(HWND, const char* arg);
|
|
|
|
void RainmeterResetStats(HWND, const char* arg);
|
|
|
|
void RainmeterMoveMeter(HWND, const char* arg);
|
|
|
|
void RainmeterPluginBang(HWND, const char* arg);
|
2009-08-04 09:48:03 +00:00
|
|
|
void RainmeterQuit(HWND, const char* arg);
|
2009-08-26 17:37:15 +00:00
|
|
|
void RainmeterSetVariable(HWND, const char* arg);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-02-14 10:11:28 +00:00
|
|
|
void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
struct GlobalConfig
|
|
|
|
{
|
|
|
|
double netInSpeed;
|
|
|
|
double netOutSpeed;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CRainmeter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct CONFIG
|
|
|
|
{
|
2009-07-24 07:56:37 +00:00
|
|
|
std::wstring path;
|
2009-02-10 18:37:48 +00:00
|
|
|
std::wstring config;
|
|
|
|
std::vector<std::wstring> iniFiles;
|
|
|
|
std::vector<UINT> commands;
|
|
|
|
int active;
|
|
|
|
};
|
|
|
|
|
2010-03-29 21:50:05 +00:00
|
|
|
struct CONFIGORDER
|
|
|
|
{
|
|
|
|
std::wstring config;
|
|
|
|
int id;
|
|
|
|
int active;
|
|
|
|
};
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
struct CONFIGMENU
|
|
|
|
{
|
|
|
|
std::wstring name;
|
|
|
|
size_t index;
|
|
|
|
std::vector<CONFIGMENU> children;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CRainmeter();
|
|
|
|
~CRainmeter();
|
|
|
|
|
|
|
|
int Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath);
|
|
|
|
void Quit(HINSTANCE dllInst);
|
|
|
|
|
|
|
|
CConfigParser* GetCurrentParser() { return m_CurrentParser; };
|
|
|
|
void SetCurrentParser(CConfigParser* parser) { m_CurrentParser = parser; };
|
|
|
|
|
|
|
|
CTrayWindow* GetTrayWindow() { return m_TrayWindow; };
|
|
|
|
|
|
|
|
CMeterWindow* GetMeterWindow(const std::wstring& config);
|
2010-03-23 16:15:07 +00:00
|
|
|
CMeterWindow* GetMeterWindow(HWND hwnd);
|
2009-02-10 18:37:48 +00:00
|
|
|
std::map<std::wstring, CMeterWindow*>& GetAllMeterWindows() { return m_Meters; };
|
|
|
|
const std::vector<CONFIG>& GetAllConfigs() { return m_ConfigStrings; };
|
2010-03-29 21:50:05 +00:00
|
|
|
const std::multimap<int, CONFIGORDER>& GetAllConfigOrders() { return m_ConfigOrders; }
|
2009-08-12 17:11:52 +00:00
|
|
|
const std::vector<std::wstring>& GetAllThemes() { return m_Themes; };
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
void ActivateConfig(int configIndex, int iniIndex);
|
|
|
|
bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex);
|
|
|
|
|
|
|
|
const std::wstring& GetPath() { return m_Path; };
|
|
|
|
const std::wstring& GetIniFile() { return m_IniFile; };
|
2009-07-21 12:26:50 +00:00
|
|
|
const std::wstring& GetLogFile() { return m_LogFile; };
|
2009-02-10 18:37:48 +00:00
|
|
|
const std::wstring& GetSkinPath() { return m_SkinPath; };
|
|
|
|
const std::wstring& GetPluginPath() { return m_PluginPath; };
|
2009-07-26 21:08:46 +00:00
|
|
|
std::wstring GetSettingsPath() { return ExtractPath(m_IniFile); };
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
const std::wstring& GetConfigEditor() { return m_ConfigEditor; };
|
|
|
|
const std::wstring& GetStatsDate() { return m_StatsDate; };
|
|
|
|
|
|
|
|
HINSTANCE GetInstance() { return m_Instance; };
|
|
|
|
|
|
|
|
static void SetDummyLitestep(bool Dummy) { c_DummyLitestep = Dummy; };
|
|
|
|
static bool GetDummyLitestep() { return c_DummyLitestep; };
|
|
|
|
static void SetCommandLine(LPCTSTR CmdLine) { c_CmdLine = CmdLine;};
|
|
|
|
static LPCTSTR GetCommandLine() { return c_CmdLine.c_str(); };
|
|
|
|
static GlobalConfig& GetGlobalConfig() { return c_GlobalConfig; };
|
2010-02-13 03:07:34 +00:00
|
|
|
static bool GetDebug() { return c_Debug; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
void ReloadSettings();
|
|
|
|
void SaveSettings();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
BOOL GetCheckUpdate() { return m_CheckUpdate; };
|
|
|
|
void SetCheckUpdate(BOOL check) { m_CheckUpdate = check; };
|
|
|
|
|
|
|
|
void ShowContextMenu(POINT pos, CMeterWindow* meterWindow);
|
|
|
|
|
|
|
|
std::wstring GetTrayExecuteL() { return m_TrayExecuteL; };
|
|
|
|
std::wstring GetTrayExecuteR() { return m_TrayExecuteR; };
|
|
|
|
std::wstring GetTrayExecuteM() { return m_TrayExecuteM; };
|
|
|
|
std::wstring GetTrayExecuteDR() { return m_TrayExecuteDR; };
|
|
|
|
std::wstring GetTrayExecuteDL() { return m_TrayExecuteDL; };
|
|
|
|
std::wstring GetTrayExecuteDM() { return m_TrayExecuteDM; };
|
|
|
|
|
|
|
|
BOOL ExecuteBang(const std::wstring& bang, const std::wstring& arg, CMeterWindow* meterWindow);
|
|
|
|
std::wstring ParseCommand(const WCHAR* command, CMeterWindow* meterWindow);
|
|
|
|
void ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow);
|
|
|
|
|
2010-03-29 21:50:05 +00:00
|
|
|
void RefreshAll();
|
|
|
|
|
2009-10-17 06:43:18 +00:00
|
|
|
void ClearDeleteLaterList();
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
static PLATFORM IsNT();
|
2009-07-26 21:08:46 +00:00
|
|
|
static std::wstring ExtractPath(const std::wstring& strFilePath);
|
2009-08-26 17:37:15 +00:00
|
|
|
static void ExpandEnvironmentVariables(std::wstring& strPath);
|
2010-04-02 01:35:53 +00:00
|
|
|
static bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
private:
|
2009-07-24 07:56:37 +00:00
|
|
|
void CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile);
|
2009-10-17 06:43:18 +00:00
|
|
|
bool DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater);
|
2009-02-10 18:37:48 +00:00
|
|
|
void ScanForConfigs(std::wstring& path);
|
2009-08-12 17:11:52 +00:00
|
|
|
void ScanForThemes(std::wstring& path);
|
2009-02-10 18:37:48 +00:00
|
|
|
void ReadGeneralSettings(std::wstring& path);
|
2010-03-29 21:50:05 +00:00
|
|
|
void SetConfigOrder(const std::wstring& config, int index, int active);
|
|
|
|
int GetLoadOrder(const std::wstring& config);
|
2009-02-10 18:37:48 +00:00
|
|
|
bool SetActiveConfig(std::wstring& skinName, std::wstring& skinIni);
|
|
|
|
HMENU CreateSkinMenu(CMeterWindow* meterWindow, int index);
|
|
|
|
void ChangeSkinIndex(HMENU subMenu, int index);
|
2009-09-18 18:42:50 +00:00
|
|
|
int ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse);
|
2009-02-10 18:37:48 +00:00
|
|
|
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
|
2009-08-12 17:11:52 +00:00
|
|
|
HMENU CreateThemeMenu();
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
HMENU CreateMonitorMenu(CMeterWindow* meterWindow);
|
2009-07-21 12:26:50 +00:00
|
|
|
void CreateDefaultConfigFile(std::wstring strFile);
|
2009-07-24 07:56:37 +00:00
|
|
|
void TestSettingsFile(bool bDefaultIniLocation);
|
2009-09-18 18:42:50 +00:00
|
|
|
void CheckSkinVersions();
|
|
|
|
int CompareVersions(std::wstring strA, std::wstring strB);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
CTrayWindow* m_TrayWindow;
|
|
|
|
|
|
|
|
std::vector<CONFIG> m_ConfigStrings; // All configs found in the given folder
|
|
|
|
std::vector<CONFIGMENU> m_ConfigMenu;
|
2010-03-29 21:50:05 +00:00
|
|
|
std::multimap<int, CONFIGORDER> m_ConfigOrders;
|
2009-02-10 18:37:48 +00:00
|
|
|
std::map<std::wstring, CMeterWindow*> m_Meters; // The meter windows
|
2009-08-12 17:11:52 +00:00
|
|
|
std::vector<std::wstring> m_Themes;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
std::wstring m_Path; // Path to the main folder
|
|
|
|
std::wstring m_IniFile; // The main ini file
|
2009-07-21 12:26:50 +00:00
|
|
|
std::wstring m_LogFile; // The log file
|
2009-02-10 18:37:48 +00:00
|
|
|
std::wstring m_SkinPath; // Path to the folder where the skins are
|
|
|
|
std::wstring m_PluginPath; // Path to the folder where the plugins are
|
|
|
|
|
|
|
|
std::wstring m_StatsDate; // The date when stats gathering started
|
|
|
|
|
|
|
|
std::wstring m_TrayExecuteL;
|
|
|
|
std::wstring m_TrayExecuteR;
|
|
|
|
std::wstring m_TrayExecuteM;
|
|
|
|
std::wstring m_TrayExecuteDL;
|
|
|
|
std::wstring m_TrayExecuteDR;
|
|
|
|
std::wstring m_TrayExecuteDM;
|
|
|
|
|
|
|
|
BOOL m_CheckUpdate;
|
|
|
|
|
|
|
|
BOOL m_DesktopWorkAreaChanged;
|
|
|
|
RECT m_DesktopWorkArea;
|
|
|
|
|
|
|
|
std::wstring m_ConfigEditor;
|
|
|
|
|
|
|
|
CConfigParser* m_CurrentParser;
|
|
|
|
|
|
|
|
HINSTANCE m_Instance;
|
|
|
|
|
|
|
|
ULONG_PTR m_GDIplusToken;
|
|
|
|
|
2009-10-17 06:43:18 +00:00
|
|
|
std::list<CMeterWindow*> m_DelayDeleteList;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
static bool c_DummyLitestep; // true, if not a Litestep plugin
|
|
|
|
static std::wstring c_CmdLine; // The command line arguments
|
|
|
|
static GlobalConfig c_GlobalConfig;
|
2010-02-13 03:07:34 +00:00
|
|
|
static bool c_Debug;
|
2009-02-10 18:37:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef LIBRARY_EXPORTS
|
|
|
|
#define EXPORT_PLUGIN __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define EXPORT_PLUGIN __declspec(dllimport)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
EXPORT_PLUGIN int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath);
|
|
|
|
EXPORT_PLUGIN void quitModule(HINSTANCE dllInst);
|
|
|
|
EXPORT_PLUGIN void Initialize(bool DummyLS, LPCTSTR CmdLine);
|
2009-10-10 08:20:28 +00:00
|
|
|
EXPORT_PLUGIN void ExecuteBang(LPCTSTR szBang);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|