mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Renamed bool ReadFormula() to ParseFormula.
- Changed ReadConfig() in Measure/Meter to protected. - Other code tweaks and cleanups.
This commit is contained in:
parent
b26dafc46f
commit
3c1338b4c5
@ -40,7 +40,8 @@ CConfigParser::CConfigParser() :
|
||||
m_Parser(MathParser_Create(NULL)),
|
||||
m_LastReplaced(false),
|
||||
m_LastDefaultUsed(false),
|
||||
m_LastValueDefined(false)
|
||||
m_LastValueDefined(false),
|
||||
m_CurrentSection()
|
||||
{
|
||||
}
|
||||
|
||||
@ -76,6 +77,8 @@ void CConfigParser::Initialize(LPCTSTR filename, CRainmeter* pRainmeter, CMeterW
|
||||
m_LastDefaultUsed = false;
|
||||
m_LastValueDefined = false;
|
||||
|
||||
m_CurrentSection = NULL;
|
||||
|
||||
// Set the built-in variables. Do this before the ini file is read so that the paths can be used with @include
|
||||
SetBuiltInVariables(pRainmeter, meterWindow);
|
||||
ResetMonitorVariables(meterWindow);
|
||||
@ -106,7 +109,6 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
|
||||
SetBuiltInVariable(L"PLUGINSPATH", pRainmeter->GetPluginPath());
|
||||
SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(m_Filename));
|
||||
SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetAddonPath());
|
||||
SetBuiltInVariable(L"CRLF", L"\n");
|
||||
}
|
||||
if (meterWindow)
|
||||
{
|
||||
@ -114,6 +116,12 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
|
||||
SetBuiltInVariable(L"CURRENTCONFIG", meterWindow->GetSkinName());
|
||||
SetBuiltInVariable(L"ROOTCONFIGPATH", meterWindow->GetSkinRootPath());
|
||||
}
|
||||
|
||||
SetBuiltInVariable(L"CRLF", L"\n");
|
||||
|
||||
static const std::wstring CURRENTSECTION = L"CURRENTSECTION";
|
||||
SetBuiltInVariable(CURRENTSECTION, L"");
|
||||
m_CurrentSection = &((*m_BuiltInVariables.find(StrToLower(CURRENTSECTION))).second); // shortcut
|
||||
}
|
||||
|
||||
/*
|
||||
@ -461,7 +469,7 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
|
||||
if (end != std::wstring::npos)
|
||||
{
|
||||
size_t ei = end - 1;
|
||||
if (result[si] == L'*' && result[ei] == L'*')
|
||||
if (si != ei && result[si] == L'*' && result[ei] == L'*')
|
||||
{
|
||||
result.erase(ei, 1);
|
||||
result.erase(si, 1);
|
||||
@ -528,7 +536,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
|
||||
if (next == std::wstring::npos || end < next)
|
||||
{
|
||||
size_t ei = end - 1;
|
||||
if (result[si] == L'*' && result[ei] == L'*')
|
||||
if (si != ei && result[si] == L'*' && result[ei] == L'*')
|
||||
{
|
||||
result.erase(ei, 1);
|
||||
result.erase(si, 1);
|
||||
@ -633,26 +641,28 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT
|
||||
{
|
||||
m_LastValueDefined = true;
|
||||
|
||||
if (result.find(L'#') != std::wstring::npos)
|
||||
if (result.size() >= 3)
|
||||
{
|
||||
static const std::wstring CURRENTSECTION = L"CURRENTSECTION";
|
||||
SetBuiltInVariable(CURRENTSECTION, strSection); // Set temporarily
|
||||
if (result.find(L'#') != std::wstring::npos)
|
||||
{
|
||||
m_CurrentSection->assign(strSection); // Set temporarily
|
||||
|
||||
if (ReplaceVariables(result))
|
||||
if (ReplaceVariables(result))
|
||||
{
|
||||
m_LastReplaced = true;
|
||||
}
|
||||
|
||||
m_CurrentSection->clear(); // Reset
|
||||
}
|
||||
else
|
||||
{
|
||||
CRainmeter::ExpandEnvironmentVariables(result);
|
||||
}
|
||||
|
||||
if (bReplaceMeasures && ReplaceMeasures(result))
|
||||
{
|
||||
m_LastReplaced = true;
|
||||
}
|
||||
|
||||
SetBuiltInVariable(CURRENTSECTION, L""); // Reset
|
||||
}
|
||||
else
|
||||
{
|
||||
CRainmeter::ExpandEnvironmentVariables(result);
|
||||
}
|
||||
|
||||
if (bReplaceMeasures && ReplaceMeasures(result))
|
||||
{
|
||||
m_LastReplaced = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -667,8 +677,8 @@ bool CConfigParser::IsKeyDefined(LPCTSTR section, LPCTSTR key)
|
||||
|
||||
bool CConfigParser::IsValueDefined(LPCTSTR section, LPCTSTR key)
|
||||
{
|
||||
const std::wstring& result = ReadString(section, key, L"", false);
|
||||
return (!m_LastDefaultUsed && !result.empty());
|
||||
ReadString(section, key, L"", false);
|
||||
return m_LastValueDefined;
|
||||
}
|
||||
|
||||
void CConfigParser::AddMeasure(CMeasure* pMeasure)
|
||||
@ -694,7 +704,7 @@ double CConfigParser::ReadFloat(LPCTSTR section, LPCTSTR key, double defValue)
|
||||
{
|
||||
const std::wstring& result = ReadString(section, key, L"");
|
||||
|
||||
return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue);
|
||||
return (m_LastDefaultUsed) ? defValue : ParseDouble(result.c_str(), defValue);
|
||||
}
|
||||
|
||||
std::vector<Gdiplus::REAL> CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR key)
|
||||
@ -708,7 +718,7 @@ std::vector<Gdiplus::REAL> CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR ke
|
||||
std::vector<std::wstring>::const_iterator iter = tokens.begin();
|
||||
for ( ; iter != tokens.end(); ++iter)
|
||||
{
|
||||
result.push_back((Gdiplus::REAL)ParseDouble((*iter), 0));
|
||||
result.push_back((Gdiplus::REAL)ParseDouble((*iter).c_str(), 0.0));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -718,14 +728,14 @@ int CConfigParser::ReadInt(LPCTSTR section, LPCTSTR key, int defValue)
|
||||
{
|
||||
const std::wstring& result = ReadString(section, key, L"");
|
||||
|
||||
return (m_LastDefaultUsed) ? defValue : (int)ParseDouble(result, defValue, true);
|
||||
return (m_LastDefaultUsed) ? defValue : ParseInt(result.c_str(), defValue);
|
||||
}
|
||||
|
||||
unsigned int CConfigParser::ReadUInt(LPCTSTR section, LPCTSTR key, unsigned int defValue)
|
||||
{
|
||||
const std::wstring& result = ReadString(section, key, L"");
|
||||
|
||||
return (m_LastDefaultUsed) ? defValue : (unsigned int)ParseDouble(result, defValue, true);
|
||||
return (m_LastDefaultUsed) ? defValue : ParseUInt(result.c_str(), defValue);
|
||||
}
|
||||
|
||||
// Works as ReadFloat except if the value is surrounded by parenthesis in which case it tries to evaluate the formula
|
||||
@ -743,9 +753,9 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
|
||||
std::wstring error = L"ReadFormula: ";
|
||||
error += ConvertToWide(errMsg);
|
||||
error += L" in key \"";
|
||||
error += key ? key : L"";
|
||||
error += key;
|
||||
error += L"\" in [";
|
||||
error += section ? section : L"";
|
||||
error += section;
|
||||
error += L"]";
|
||||
Log(LOG_ERROR, error.c_str());
|
||||
}
|
||||
@ -753,12 +763,12 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
|
||||
return resultValue;
|
||||
}
|
||||
|
||||
return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue);
|
||||
return (m_LastDefaultUsed) ? defValue : ParseDouble(result.c_str(), defValue);
|
||||
}
|
||||
|
||||
// Returns true if the formula was read successfully, false for failure.
|
||||
// Pass a pointer to a double.
|
||||
bool CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
|
||||
bool CConfigParser::ParseFormula(const std::wstring& result, double* resultValue)
|
||||
{
|
||||
// Formulas must be surrounded by parenthesis
|
||||
if (!result.empty() && result[0] == L'(' && result[result.size() - 1] == L')')
|
||||
@ -766,7 +776,7 @@ bool CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
|
||||
char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(result.c_str()).c_str(), resultValue);
|
||||
if (errMsg != NULL)
|
||||
{
|
||||
std::wstring error = L"ReadFormula: ";
|
||||
std::wstring error = L"ParseFormula: ";
|
||||
error += ConvertToWide(errMsg);
|
||||
error += L": ";
|
||||
error += result;
|
||||
@ -874,40 +884,59 @@ void CConfigParser::Shrink(std::vector<std::wstring>& vec)
|
||||
** If the given string is invalid format or causes overflow/underflow, returns given default value.
|
||||
**
|
||||
*/
|
||||
double CConfigParser::ParseDouble(const std::wstring& string, double defValue, bool rejectExp)
|
||||
double CConfigParser::ParseDouble(LPCTSTR string, double defValue)
|
||||
{
|
||||
std::wstring::size_type pos;
|
||||
|
||||
// Ignore inline comments which start with ';'
|
||||
if ((pos = string.find_first_of(L';')) != std::wstring::npos)
|
||||
if (string && *string)
|
||||
{
|
||||
std::wstring temp(string, 0, pos);
|
||||
return ParseDouble(temp, defValue, rejectExp);
|
||||
}
|
||||
|
||||
if (rejectExp)
|
||||
{
|
||||
// Reject if the given string includes the exponential part
|
||||
if (string.find_last_of(L"dDeE") != std::wstring::npos)
|
||||
{
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pos = string.find_first_not_of(L" \t\r\n")) != std::wstring::npos)
|
||||
{
|
||||
// Trim white-space
|
||||
std::wstring temp(string, pos, string.find_last_not_of(L" \t\r\n") - pos + 1);
|
||||
|
||||
WCHAR* end = NULL;
|
||||
errno = 0;
|
||||
double resultValue = wcstod(temp.c_str(), &end);
|
||||
if (end && *end == L'\0' && errno != ERANGE)
|
||||
double resultValue = wcstod(string, NULL);
|
||||
if (errno != ERANGE)
|
||||
{
|
||||
return resultValue;
|
||||
}
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
/*
|
||||
** ParseInt
|
||||
**
|
||||
** This is a helper method that parses the integer value from the given string.
|
||||
** If the given string is invalid format or causes overflow/underflow, returns given default value.
|
||||
**
|
||||
*/
|
||||
int CConfigParser::ParseInt(LPCTSTR string, int defValue)
|
||||
{
|
||||
if (string && *string)
|
||||
{
|
||||
errno = 0;
|
||||
int resultValue = wcstol(string, NULL, 10);
|
||||
if (errno != ERANGE)
|
||||
{
|
||||
return resultValue;
|
||||
}
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
/*
|
||||
** ParseUInt
|
||||
**
|
||||
** This is a helper method that parses the unsigned integer value from the given string.
|
||||
** If the given string is invalid format or causes overflow/underflow, returns given default value.
|
||||
**
|
||||
*/
|
||||
unsigned int CConfigParser::ParseUInt(LPCTSTR string, unsigned int defValue)
|
||||
{
|
||||
if (string && *string)
|
||||
{
|
||||
errno = 0;
|
||||
unsigned int resultValue = wcstoul(string, NULL, 10);
|
||||
if (errno != ERANGE)
|
||||
{
|
||||
return resultValue;
|
||||
}
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
|
||||
@ -1198,9 +1227,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR config, int
|
||||
clen = len - (clen + 1); // value's length
|
||||
|
||||
// Trim surrounded quotes from value
|
||||
if (clen >= 2 && (
|
||||
(sep[0] == L'\"' && sep[clen - 1] == L'\"') ||
|
||||
(sep[0] == L'\'' && sep[clen - 1] == L'\'')))
|
||||
if (clen >= 2 && (sep[0] == L'\"' || sep[0] == L'\'') && sep[clen - 1] == sep[0])
|
||||
{
|
||||
clen -= 2;
|
||||
++sep;
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
RECT ReadRECT(LPCTSTR section, LPCTSTR key, const RECT& defValue);
|
||||
std::vector<Gdiplus::REAL> ReadFloats(LPCTSTR section, LPCTSTR key);
|
||||
|
||||
bool ReadFormula(const std::wstring& result, double* resultValue);
|
||||
bool ParseFormula(const std::wstring& result, double* resultValue);
|
||||
|
||||
const std::wstring& GetFilename() { return m_Filename; }
|
||||
const std::list<std::wstring>& GetSections() { return m_Sections; }
|
||||
@ -84,7 +84,9 @@ public:
|
||||
|
||||
static std::vector<std::wstring> Tokenize(const std::wstring& str, const std::wstring& delimiters);
|
||||
static void Shrink(std::vector<std::wstring>& vec);
|
||||
static double ParseDouble(const std::wstring& string, double defValue, bool rejectExp = false);
|
||||
static double ParseDouble(LPCTSTR string, double defValue);
|
||||
static int ParseInt(LPCTSTR string, int defValue);
|
||||
static unsigned int ParseUInt(LPCTSTR string, unsigned int defValue);
|
||||
static Gdiplus::ARGB ParseColor(LPCTSTR string);
|
||||
static Gdiplus::Rect ParseRect(LPCTSTR string);
|
||||
static RECT ParseRECT(LPCTSTR string);
|
||||
@ -107,6 +109,7 @@ private:
|
||||
|
||||
static void SetMultiMonitorVariables(bool reset);
|
||||
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
||||
static void SetMonitorVariable(const WCHAR* strVariable, const WCHAR* strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
||||
|
||||
static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; }
|
||||
static std::wstring StrToLower(const WCHAR* str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; }
|
||||
@ -124,6 +127,8 @@ private:
|
||||
bool m_LastDefaultUsed;
|
||||
bool m_LastValueDefined;
|
||||
|
||||
std::wstring* m_CurrentSection;
|
||||
|
||||
std::list<std::wstring> m_Sections; // The sections must be an ordered array
|
||||
std::unordered_map<std::wstring, std::wstring> m_Values;
|
||||
|
||||
|
@ -142,7 +142,7 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
const std::wstring& result = parser.ReadString(section, L"Disabled", L"0");
|
||||
if (parser.GetLastReplaced())
|
||||
{
|
||||
m_Disabled = 0!=(int)parser.ParseDouble(result, 0.0, true);
|
||||
m_Disabled = 0!=parser.ParseInt(result.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,17 +172,19 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
m_RegExpSubstitute = 0!=parser.ReadInt(section, L"RegExpSubstitute", 0);
|
||||
std::wstring subs = parser.ReadString(section, L"Substitute", L"");
|
||||
if (!subs.empty() &&
|
||||
(subs[0] != L'\"' || subs[subs.length() - 1] != L'\'') &&
|
||||
(subs[0] != L'\'' || subs[subs.length() - 1] != L'\"'))
|
||||
if (!subs.empty())
|
||||
{
|
||||
// Add quotes since they are removed by the GetProfileString
|
||||
subs.insert(0, L"\"");
|
||||
subs.append(L"\"");
|
||||
}
|
||||
if (!ParseSubstitute(subs))
|
||||
{
|
||||
LogWithArgs(LOG_ERROR, L"Measure: Invalid Substitute=%s", subs.c_str());
|
||||
if ((subs[0] != L'\"' || subs[subs.length() - 1] != L'\'') &&
|
||||
(subs[0] != L'\'' || subs[subs.length() - 1] != L'\"'))
|
||||
{
|
||||
// Add quotes since they are removed by the GetProfileString
|
||||
subs.insert(0, L"\"");
|
||||
subs.append(L"\"");
|
||||
}
|
||||
if (!ParseSubstitute(subs))
|
||||
{
|
||||
LogWithArgs(LOG_ERROR, L"Measure: Invalid Substitute=%s", subs.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring& group = parser.ReadString(section, L"Group", L"");
|
||||
|
@ -49,7 +49,6 @@ public:
|
||||
|
||||
void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); }
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update() = 0;
|
||||
|
||||
@ -87,6 +86,8 @@ public:
|
||||
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
virtual bool PreUpdate();
|
||||
virtual bool PostUpdate();
|
||||
|
||||
|
@ -37,10 +37,12 @@ public:
|
||||
CMeasureCPU(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureCPU();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
void CalcUsage(double idleTime, double systemTime);
|
||||
void CalcAverageUsage(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo);
|
||||
|
||||
|
@ -28,11 +28,13 @@ public:
|
||||
CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureCalc();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
static void UpdateVariableMap(CMeterWindow& meterWindow);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
void FormulaReplace();
|
||||
bool IsDelimiter(WCHAR ch);
|
||||
|
@ -27,10 +27,12 @@ public:
|
||||
CMeasureDiskSpace(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureDiskSpace();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
std::wstring m_Drive;
|
||||
std::wstring m_LabelName;
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
virtual ~CMeasureMemory();
|
||||
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
|
@ -27,9 +27,11 @@ public:
|
||||
CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureNetIn();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
ULONG64 m_InOctets;
|
||||
|
@ -27,9 +27,11 @@ public:
|
||||
CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureNetOut();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
ULONG64 m_OutOctets;
|
||||
|
@ -27,9 +27,11 @@ public:
|
||||
CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureNetTotal();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
ULONG64 m_TotalOctets;
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
virtual ~CMeasurePhysicalMemory();
|
||||
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
|
@ -34,11 +34,13 @@ public:
|
||||
CMeasurePlugin(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasurePlugin();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||
virtual void ExecuteBang(const WCHAR* args);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
std::wstring m_PluginName;
|
||||
HMODULE m_Plugin;
|
||||
|
@ -27,10 +27,12 @@ public:
|
||||
CMeasureRegistry(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureRegistry();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
std::wstring m_RegKeyName;
|
||||
std::wstring m_RegValueName;
|
||||
|
@ -27,7 +27,6 @@ public:
|
||||
CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureScript();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||
@ -36,6 +35,9 @@ public:
|
||||
void DeleteLuaScript();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
LuaScript* m_LuaScript;
|
||||
|
||||
bool m_HasInitializeFunction;
|
||||
|
@ -27,10 +27,12 @@ public:
|
||||
CMeasureTime(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureTime();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
void TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, const struct tm* time);
|
||||
|
||||
|
@ -29,6 +29,8 @@ public:
|
||||
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
virtual ~CMeasureVirtualMemory();
|
||||
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
|
@ -307,13 +307,13 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
double val;
|
||||
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && parser.ReadFormula(coord, &val))
|
||||
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && parser.ParseFormula(coord, &val))
|
||||
{
|
||||
m_X = (int)val;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_X = (int)parser.ParseDouble(coord, 0.0);
|
||||
m_X = (int)parser.ParseDouble(coord.c_str(), 0.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -346,13 +346,13 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
double val;
|
||||
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && parser.ReadFormula(coord, &val))
|
||||
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && parser.ParseFormula(coord, &val))
|
||||
{
|
||||
m_Y = (int)val;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Y = (int)parser.ParseDouble(coord, 0.0);
|
||||
m_Y = (int)parser.ParseDouble(coord.c_str(), 0.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -380,7 +380,7 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_StyleHidden = parser.GetLastUsedStyle();
|
||||
if (parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && m_StyleHidden != oldStyleHidden)
|
||||
{
|
||||
m_Hidden = 0!=(int)parser.ParseDouble(result, 0.0, true);
|
||||
m_Hidden = 0!=parser.ParseInt(result.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
|
||||
void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); parser.ClearStyleTemplate(); }
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
@ -120,6 +119,8 @@ protected:
|
||||
POSITION_RELATIVE_BR
|
||||
};
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
void SetAllMeasures(CMeasure* measure);
|
||||
void SetAllMeasures(const std::vector<CMeasure*>& measures);
|
||||
void ReplaceToolTipMeasures(std::wstring& str);
|
||||
|
@ -28,11 +28,13 @@ public:
|
||||
CMeterBar(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeterBar();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
enum ORIENTATION
|
||||
{
|
||||
|
@ -30,12 +30,14 @@ public:
|
||||
|
||||
virtual bool HitTest(int x, int y);
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
virtual bool HasActiveTransition();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
CTintedImage m_Image;
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
|
@ -30,7 +30,6 @@ public:
|
||||
CMeterButton(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeterButton();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
@ -42,6 +41,9 @@ public:
|
||||
|
||||
void SetFocus(bool f) { m_Focus = f; }
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool HitTest2(int px, int py, bool checkAlpha);
|
||||
|
||||
|
@ -28,12 +28,14 @@ public:
|
||||
CMeterHistogram(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeterHistogram();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
virtual void BindMeasure(const std::list<CMeasure*>& measures);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
void DisposeBuffer();
|
||||
|
||||
|
@ -28,13 +28,15 @@ public:
|
||||
CMeterImage(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeterImage();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
virtual void BindMeasure(const std::list<CMeasure*>& measures);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
void LoadImage(const std::wstring& imageName, bool bLoadAlways);
|
||||
|
||||
CTintedImage m_Image;
|
||||
|
@ -27,12 +27,14 @@ public:
|
||||
CMeterLine(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeterLine();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
virtual void BindMeasure(const std::list<CMeasure*>& measures);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
std::vector<std::wstring> m_MeasureNames; // Name of the other measures
|
||||
std::vector<CMeasure*> m_Measures; // Pointer ot the other measures
|
||||
|
@ -28,11 +28,13 @@ public:
|
||||
CMeterRotator(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeterRotator();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
CTintedImage m_Image;
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
|
@ -27,10 +27,12 @@ public:
|
||||
CMeterRoundLine(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeterRoundLine();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool m_Solid;
|
||||
double m_LineWidth;
|
||||
|
@ -23,11 +23,6 @@
|
||||
#include "Measure.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Gdiplus
|
||||
{
|
||||
class Font;
|
||||
}
|
||||
|
||||
class CMeterString : public CMeter
|
||||
{
|
||||
public:
|
||||
@ -36,7 +31,6 @@ public:
|
||||
|
||||
virtual int GetX(bool abs = false);
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
void SetText(const WCHAR* text) { m_Text = text; }
|
||||
@ -47,6 +41,9 @@ public:
|
||||
static void FreeFontCache(Gdiplus::PrivateFontCollection* collection = NULL);
|
||||
static void EnumerateInstalledFontFamilies();
|
||||
|
||||
protected:
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
enum TEXTSTYLE
|
||||
{
|
||||
|
@ -900,7 +900,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
case BANG_SETTRANSPARENCY:
|
||||
if (arg != NULL)
|
||||
{
|
||||
m_AlphaValue = (int)CConfigParser::ParseDouble(arg, 255, true);
|
||||
m_AlphaValue = CConfigParser::ParseInt(arg, 255);
|
||||
m_AlphaValue = max(m_AlphaValue, 0);
|
||||
m_AlphaValue = min(m_AlphaValue, 255);
|
||||
UpdateTransparency(m_AlphaValue, false);
|
||||
@ -1003,7 +1003,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
double value;
|
||||
|
||||
// Formula read fine
|
||||
if (m_Parser.ReadFormula(strValue, &value))
|
||||
if (m_Parser.ParseFormula(strValue, &value))
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
int len = _snwprintf_s(buffer, _TRUNCATE, L"%.5f", value);
|
||||
@ -1115,31 +1115,31 @@ void CMeterWindow::ResizeBlur(const WCHAR* arg, int mode)
|
||||
if (token)
|
||||
{
|
||||
while (token[0] == L' ') ++token;
|
||||
type = (m_Parser.ReadFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
type = (m_Parser.ParseFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
|
||||
token = wcstok(NULL, L",");
|
||||
if (token)
|
||||
{
|
||||
while (token[0] == L' ') ++token;
|
||||
x = (m_Parser.ReadFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
x = (m_Parser.ParseFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
|
||||
token = wcstok(NULL, L",");
|
||||
if (token)
|
||||
{
|
||||
while (token[0] == L' ') ++token;
|
||||
y = (m_Parser.ReadFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
y = (m_Parser.ParseFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
|
||||
token = wcstok(NULL, L",");
|
||||
if (token)
|
||||
{
|
||||
while (token[0] == L' ') ++token;
|
||||
w = (m_Parser.ReadFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
w = (m_Parser.ParseFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
|
||||
token = wcstok(NULL, L",");
|
||||
if (token)
|
||||
{
|
||||
while (token[0] == L' ') ++token;
|
||||
h = (m_Parser.ReadFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
h = (m_Parser.ParseFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1161,7 +1161,7 @@ void CMeterWindow::ResizeBlur(const WCHAR* arg, int mode)
|
||||
if (token)
|
||||
{
|
||||
while (token[0] == L' ') ++token;
|
||||
int r = (m_Parser.ReadFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
int r = (m_Parser.ParseFormula(token, &val)) ? (int)val : _wtoi(token);
|
||||
tempRegion = CreateRoundRectRgn(x, y, w, h, r, r);
|
||||
}
|
||||
break;
|
||||
@ -1924,7 +1924,7 @@ void CMeterWindow::ReadConfig()
|
||||
double value;
|
||||
if (!m_WindowX.empty() && m_WindowX[0] == L'(' && m_WindowX[m_WindowX.size() - 1] == L')')
|
||||
{
|
||||
if (!parser.ReadFormula(m_WindowX, &value))
|
||||
if (!parser.ParseFormula(m_WindowX, &value))
|
||||
{
|
||||
value = 0.0;
|
||||
}
|
||||
@ -1933,7 +1933,7 @@ void CMeterWindow::ReadConfig()
|
||||
}
|
||||
if (!m_WindowY.empty() && m_WindowY[0] == L'(' && m_WindowY[m_WindowY.size() - 1] == L')')
|
||||
{
|
||||
if (!parser.ReadFormula(m_WindowY, &value))
|
||||
if (!parser.ParseFormula(m_WindowY, &value))
|
||||
{
|
||||
value = 0.0;
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ void CRainmeter::RainmeterWriteKeyValue(const WCHAR* arg)
|
||||
if (mw)
|
||||
{
|
||||
double value;
|
||||
formula = mw->GetParser().ReadFormula(strValue, &value);
|
||||
formula = mw->GetParser().ParseFormula(strValue, &value);
|
||||
|
||||
// Formula read fine
|
||||
if (formula)
|
||||
@ -3170,13 +3170,16 @@ std::wstring CRainmeter::ExtractPath(const std::wstring& strFilePath)
|
||||
|
||||
void CRainmeter::ExpandEnvironmentVariables(std::wstring& strPath)
|
||||
{
|
||||
if (strPath.find(L'%') != std::wstring::npos)
|
||||
std::wstring::size_type pos;
|
||||
|
||||
if ((pos = strPath.find(L'%')) != std::wstring::npos &&
|
||||
strPath.find(L'%', pos + 2) != std::wstring::npos)
|
||||
{
|
||||
DWORD bufSize = 4096;
|
||||
WCHAR* buffer = new WCHAR[bufSize]; // lets hope the buffer is large enough...
|
||||
|
||||
// %APPDATA% is a special case
|
||||
std::wstring::size_type pos = strPath.find(L"%APPDATA%");
|
||||
pos = strPath.find(L"%APPDATA%", pos);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user