Code cleanup.

This commit is contained in:
spx 2011-02-15 16:26:54 +00:00
parent 1ba57f2adf
commit fe9fd9f476
55 changed files with 156 additions and 190 deletions

View File

@ -67,7 +67,7 @@ extern CRainmeter* Rainmeter;
** The constructor
**
*/
CMeasure::CMeasure(CMeterWindow* meterWindow) : m_MeterWindow(meterWindow),
CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(meterWindow), m_Name(name), m_ANSIName(ConvertToAscii(name)),
m_DynamicVariables(false),
m_Invert(false),
m_LogMaxValue(false),
@ -651,75 +651,77 @@ const WCHAR* CMeasure::GetStats()
** If new measures are implemented this method needs to be updated.
**
*/
CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow)
CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name)
{
// Comparson is caseinsensitive
// Comparison is caseinsensitive
if(_wcsicmp(L"", measure) == 0)
if(*measure == L'\0')
{
return NULL;
}
else if(_wcsicmp(L"CPU", measure) == 0)
{
return new CMeasureCPU(meterWindow);
return new CMeasureCPU(meterWindow, name);
}
else if(_wcsicmp(L"Memory", measure) == 0)
{
return new CMeasureMemory(meterWindow);
return new CMeasureMemory(meterWindow, name);
}
else if(_wcsicmp(L"NetIn", measure) == 0)
{
return new CMeasureNetIn(meterWindow);
return new CMeasureNetIn(meterWindow, name);
}
else if(_wcsicmp(L"NetOut", measure) == 0)
{
return new CMeasureNetOut(meterWindow);
return new CMeasureNetOut(meterWindow, name);
}
else if(_wcsicmp(L"NetTotal", measure) == 0)
{
return new CMeasureNetTotal(meterWindow);
return new CMeasureNetTotal(meterWindow, name);
}
else if(_wcsicmp(L"PhysicalMemory", measure) == 0)
{
return new CMeasurePhysicalMemory(meterWindow);
return new CMeasurePhysicalMemory(meterWindow, name);
}
else if(_wcsicmp(L"SwapMemory", measure) == 0)
{
return new CMeasureVirtualMemory(meterWindow);
return new CMeasureVirtualMemory(meterWindow, name);
}
else if(_wcsicmp(L"FreeDiskSpace", measure) == 0)
{
return new CMeasureDiskSpace(meterWindow);
return new CMeasureDiskSpace(meterWindow, name);
}
else if(_wcsicmp(L"Uptime", measure) == 0)
{
return new CMeasureUptime(meterWindow);
return new CMeasureUptime(meterWindow, name);
}
else if(_wcsicmp(L"Time", measure) == 0)
{
return new CMeasureTime(meterWindow);
return new CMeasureTime(meterWindow, name);
}
else if(_wcsicmp(L"Plugin", measure) == 0)
{
return new CMeasurePlugin(meterWindow);
return new CMeasurePlugin(meterWindow, name);
}
else if(_wcsicmp(L"Registry", measure) == 0)
{
return new CMeasureRegistry(meterWindow);
return new CMeasureRegistry(meterWindow, name);
}
else if(_wcsicmp(L"Calc", measure) == 0)
{
return new CMeasureCalc(meterWindow);
return new CMeasureCalc(meterWindow, name);
}
else if(_wcsicmp(L"script", measure) == 0)
{
return new CMeasureScript(meterWindow);
return new CMeasureScript(meterWindow, name);
}
// Error
std::wstring error = L"Measure=";
error += measure;
error += L" is not valid.";
error += L" is not valid in section [";
error += name;
error += L"].";
throw CError(error, __LINE__, __FILE__);
return NULL;

View File

@ -44,16 +44,17 @@ class CConfigParser;
class CMeasure : public CGroup
{
public:
CMeasure(CMeterWindow* meterWindow);
CMeasure(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasure();
void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); }
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update() = 0;
virtual const WCHAR* GetStats();
void SetName(const WCHAR* name) { m_Name = name; m_ANSIName = ConvertToAscii(name); }
const WCHAR* GetName() { return m_Name.c_str(); }
const char* GetANSIName() { return m_ANSIName.c_str(); }
@ -78,7 +79,7 @@ public:
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
static void GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue, WCHAR* buffer, size_t sizeInWords);
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow);
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
protected:
virtual bool PreUpdate();
@ -94,8 +95,8 @@ protected:
double m_MinValue; // The minimum value (so far)
double m_MaxValue; // The maximum value (so far)
double m_Value; // The current value
std::wstring m_Name; // Name of this Measure
std::string m_ANSIName; // Name of this Measure in ANSI
const std::wstring m_Name; // Name of this Measure
const std::string m_ANSIName; // Name of this Measure in ANSI
std::vector<std::wstring> m_Substitute; // Vec of substitute strings

View File

@ -60,7 +60,7 @@ ULONG CMeasureCPU::c_BufferSize = 0;
** The constructor
**
*/
CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_FirstTime(true),
m_Processor()
{

View File

@ -35,7 +35,7 @@ typedef BOOL (WINAPI *PROCGST)(LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, L
class CMeasureCPU : public CMeasure
{
public:
CMeasureCPU(CMeterWindow* meterWindow);
CMeasureCPU(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureCPU();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -31,7 +31,7 @@ bool CMeasureCalc::c_RandSeeded = false;
** The constructor
**
*/
CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_Parser(MathParser_Create(NULL)),
m_LowBound(),
m_HighBound(100),

View File

@ -25,7 +25,7 @@
class CMeasureCalc : public CMeasure
{
public:
CMeasureCalc(CMeterWindow* meterWindow);
CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureCalc();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -26,7 +26,7 @@
** The constructor
**
*/
CMeasureDiskSpace::CMeasureDiskSpace(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureDiskSpace::CMeasureDiskSpace(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_Total(false),
m_Label(false),
m_IgnoreRemovable(true),

View File

@ -24,7 +24,7 @@
class CMeasureDiskSpace : public CMeasure
{
public:
CMeasureDiskSpace(CMeterWindow* meterWindow);
CMeasureDiskSpace(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureDiskSpace();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -26,7 +26,7 @@
** The constructor
**
*/
CMeasureMemory::CMeasureMemory(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureMemory::CMeasureMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_Total(false)
{
}

View File

@ -24,7 +24,7 @@
class CMeasureMemory : public CMeasure
{
public:
CMeasureMemory(CMeterWindow* meterWindow);
CMeasureMemory(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureMemory();
virtual bool Update();

View File

@ -38,7 +38,7 @@ extern CRainmeter* Rainmeter;
** The constructor. This is the base class for the net-meters.
**
*/
CMeasureNet::CMeasureNet(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureNet::CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_CurrentTraffic(),
m_TrafficValue(),
m_Interface(),

View File

@ -167,7 +167,7 @@ public:
NET_TOTAL
};
CMeasureNet(CMeterWindow* meterWindow);
CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureNet();
virtual bool Update();

View File

@ -25,7 +25,7 @@
** The constructor
**
*/
CMeasureNetIn::CMeasureNetIn(CMeterWindow* meterWindow) : CMeasureNet(meterWindow),
CMeasureNetIn::CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name),
m_FirstTime(true),
m_InOctets()
{

View File

@ -24,7 +24,7 @@
class CMeasureNetIn : public CMeasureNet
{
public:
CMeasureNetIn(CMeterWindow* meterWindow);
CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureNetIn();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -25,7 +25,7 @@
** The constructor
**
*/
CMeasureNetOut::CMeasureNetOut(CMeterWindow* meterWindow) : CMeasureNet(meterWindow),
CMeasureNetOut::CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name),
m_FirstTime(true),
m_OutOctets()
{

View File

@ -24,7 +24,7 @@
class CMeasureNetOut : public CMeasureNet
{
public:
CMeasureNetOut(CMeterWindow* meterWindow);
CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureNetOut();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -25,7 +25,7 @@
** The constructor
**
*/
CMeasureNetTotal::CMeasureNetTotal(CMeterWindow* meterWindow) : CMeasureNet(meterWindow),
CMeasureNetTotal::CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name),
m_FirstTime(true),
m_TotalOctets()
{

View File

@ -24,7 +24,7 @@
class CMeasureNetTotal : public CMeasureNet
{
public:
CMeasureNetTotal(CMeterWindow* meterWindow);
CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureNetTotal();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -26,7 +26,7 @@
** The constructor
**
*/
CMeasurePhysicalMemory::CMeasurePhysicalMemory(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasurePhysicalMemory::CMeasurePhysicalMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_Total(false)
{
}

View File

@ -24,7 +24,7 @@
class CMeasurePhysicalMemory : public CMeasure
{
public:
CMeasurePhysicalMemory(CMeterWindow* meterWindow);
CMeasurePhysicalMemory(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasurePhysicalMemory();
virtual bool Update();

View File

@ -30,7 +30,7 @@ extern CRainmeter* Rainmeter;
** The constructor
**
*/
CMeasurePlugin::CMeasurePlugin(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasurePlugin::CMeasurePlugin(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_Plugin(),
m_ID(),
InitializeFunc(),

View File

@ -31,7 +31,7 @@ typedef void (*EXECUTEBANG)(LPCTSTR, UINT);
class CMeasurePlugin : public CMeasure
{
public:
CMeasurePlugin(CMeterWindow* meterWindow);
CMeasurePlugin(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasurePlugin();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -27,7 +27,7 @@
** The constructor
**
*/
CMeasureRegistry::CMeasureRegistry(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureRegistry::CMeasureRegistry(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_RegKey(),
m_HKey()
{

View File

@ -24,7 +24,7 @@
class CMeasureRegistry : public CMeasure
{
public:
CMeasureRegistry(CMeterWindow* meterWindow);
CMeasureRegistry(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureRegistry();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -9,7 +9,7 @@ const char* g_strUpdateFunction = "Update";
const char* g_strGetValueFunction = "GetValue";
const char* g_strGetStringValueFunction = "GetStringValue";
CMeasureScript::CMeasureScript(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_pLuaScript(),
m_bUpdateDefined(false),
m_bGetValueDefined(false),

View File

@ -8,7 +8,7 @@
class CMeasureScript : public CMeasure
{
public:
CMeasureScript(CMeterWindow* meterWindow);
CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureScript();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -46,7 +46,7 @@ int GetYearDay(int year, int month, int day)
** The constructor
**
*/
CMeasureTime::CMeasureTime(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureTime::CMeasureTime(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_DeltaTime(),
m_Time()
{

View File

@ -24,7 +24,7 @@
class CMeasureTime : public CMeasure
{
public:
CMeasureTime(CMeterWindow* meterWindow);
CMeasureTime(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureTime();
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);

View File

@ -26,7 +26,7 @@
** The constructor
**
*/
CMeasureUptime::CMeasureUptime(CMeterWindow* meterWindow) : CMeasure(meterWindow)
CMeasureUptime::CMeasureUptime(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name)
{
}

View File

@ -24,7 +24,7 @@
class CMeasureUptime : public CMeasure
{
public:
CMeasureUptime(CMeterWindow* meterWindow);
CMeasureUptime(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureUptime();
virtual bool Update();

View File

@ -26,7 +26,7 @@
** The constructor
**
*/
CMeasureVirtualMemory::CMeasureVirtualMemory(CMeterWindow* meterWindow) : CMeasure(meterWindow),
CMeasureVirtualMemory::CMeasureVirtualMemory(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_Total(false)
{
}

View File

@ -24,7 +24,7 @@
class CMeasureVirtualMemory : public CMeasure
{
public:
CMeasureVirtualMemory(CMeterWindow* meterWindow);
CMeasureVirtualMemory(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeasureVirtualMemory();
virtual bool Update();

View File

@ -39,7 +39,7 @@ using namespace Gdiplus;
** The constructor
**
*/
CMeter::CMeter(CMeterWindow* meterWindow) : m_MeterWindow(meterWindow),
CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(meterWindow), m_Name(name),
m_Measure(),
m_X(),
m_Y(),
@ -266,10 +266,8 @@ void CMeter::Hide()
** the base implementation if they overwrite this method.
**
*/
void CMeter::ReadConfig(const WCHAR* section)
void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
CConfigParser& parser = m_MeterWindow->GetParser();
// The MeterStyle defines a template where the values are read if the meter doesn't have it itself
const std::wstring& style = parser.ReadString(section, L"MeterStyle", L"");
if (!style.empty())
@ -479,49 +477,51 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
** If new meters are implemented this method needs to be updated.
**
*/
CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow)
CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name)
{
if(_wcsicmp(L"HISTOGRAM", meter) == 0)
{
return new CMeterHistogram(meterWindow);
return new CMeterHistogram(meterWindow, name);
}
else if(_wcsicmp(L"STRING", meter) == 0)
{
return new CMeterString(meterWindow);
return new CMeterString(meterWindow, name);
}
else if(_wcsicmp(L"BAR", meter) == 0)
{
return new CMeterBar(meterWindow);
return new CMeterBar(meterWindow, name);
}
else if(_wcsicmp(L"BITMAP", meter) == 0)
{
return new CMeterBitmap(meterWindow);
return new CMeterBitmap(meterWindow, name);
}
else if(_wcsicmp(L"IMAGE", meter) == 0)
{
return new CMeterImage(meterWindow);
return new CMeterImage(meterWindow, name);
}
else if(_wcsicmp(L"LINE", meter) == 0)
{
return new CMeterLine(meterWindow);
return new CMeterLine(meterWindow, name);
}
else if(_wcsicmp(L"ROUNDLINE", meter) == 0)
{
return new CMeterRoundLine(meterWindow);
return new CMeterRoundLine(meterWindow, name);
}
else if(_wcsicmp(L"ROTATOR", meter) == 0)
{
return new CMeterRotator(meterWindow);
return new CMeterRotator(meterWindow, name);
}
else if(_wcsicmp(L"BUTTON", meter) == 0)
{
return new CMeterButton(meterWindow);
return new CMeterButton(meterWindow, name);
}
// Error
std::wstring error = L"Meter=";
error += meter;
error += L" is not valid.";
error += L" is not valid in section [";
error += name;
error += L"].";
throw CError(error, __LINE__, __FILE__);
return NULL;

View File

@ -22,6 +22,7 @@
#include <windows.h>
#include <gdiplus.h>
#include <vector>
#include <string>
#include "Litestep.h"
#include "MeterWindow.h"
#include "Group.h"
@ -32,10 +33,12 @@ class CConfigParser;
class CMeter : public CGroup
{
public:
CMeter(CMeterWindow* meterWindow);
CMeter(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeter();
virtual void ReadConfig(const WCHAR* section);
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);
@ -89,14 +92,13 @@ public:
void SetMouseOver(bool over) { m_MouseOver = over; }
bool IsMouseOver() { return m_MouseOver; }
void SetName(const WCHAR* name) { m_Name = name; }
const WCHAR* GetName() { return m_Name.c_str(); }
void ResetUpdateCounter() { m_UpdateCounter = m_UpdateDivider; }
int GetUpdateCounter() { return m_UpdateCounter; }
int GetUpdateDivider() { return m_UpdateDivider; }
static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow);
static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name);
static void DrawBevel(Gdiplus::Graphics& graphics, const Gdiplus::Rect& rect, const Gdiplus::Pen& light, const Gdiplus::Pen& dark);
@ -124,7 +126,7 @@ protected:
static bool ReplaceMeasures(const std::vector<std::wstring>& stringValues, std::wstring& str);
Gdiplus::Matrix m_Transformation; // The transformation matrix
std::wstring m_Name; // Name of the meter
const std::wstring m_Name; // Name of the meter
std::wstring m_MeasureName; // Name of the measure this is bound to
CMeasure* m_Measure; // Pointer to the measure this meter is bound to
std::vector<CMeasure*> m_AllMeasures;

View File

@ -33,7 +33,7 @@ extern CRainmeter* Rainmeter;
** The constructor
**
*/
CMeterBar::CMeterBar(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterBar::CMeterBar(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_Image(L"BarImage"),
m_NeedsReload(false),
m_Color(Color::Green),
@ -90,7 +90,7 @@ void CMeterBar::Initialize()
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterBar::ReadConfig(const WCHAR* section)
void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Store the current values so we know if the image needs to be updated
std::wstring oldImageName = m_ImageName;
@ -98,9 +98,7 @@ void CMeterBar::ReadConfig(const WCHAR* section)
int oldH = m_H;
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
m_Color = parser.ReadColor(section, L"BarColor", Color::Green);

View File

@ -25,10 +25,10 @@
class CMeterBar : public CMeter
{
public:
CMeterBar(CMeterWindow* meterWindow);
CMeterBar(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterBar();
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -32,7 +32,7 @@ extern CRainmeter* Rainmeter;
** The constructor
**
*/
CMeterBitmap::CMeterBitmap(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterBitmap::CMeterBitmap(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_Image(L"BitmapImage", NULL, true),
m_NeedsReload(false),
m_ZeroFrame(false),
@ -162,7 +162,7 @@ bool CMeterBitmap::HitTest(int x, int y)
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterBitmap::ReadConfig(const WCHAR* section)
void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Store the current values so we know if the image needs to be updated
std::wstring oldImageName = m_ImageName;
@ -170,9 +170,7 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
int oldH = m_H;
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
m_ImageName = parser.ReadString(section, L"BitmapImage", L"");
if (!m_ImageName.empty())

View File

@ -25,12 +25,12 @@
class CMeterBitmap : public CMeter
{
public:
CMeterBitmap(CMeterWindow* meterWindow);
CMeterBitmap(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterBitmap();
virtual bool HitTest(int x, int y);
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -39,7 +39,7 @@ enum BUTTON_STATE
** The constructor
**
*/
CMeterButton::CMeterButton(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterButton::CMeterButton(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_Image(L"ButtonImage", NULL, true),
m_NeedsReload(false),
m_Bitmaps(),
@ -136,7 +136,7 @@ void CMeterButton::Initialize()
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterButton::ReadConfig(const WCHAR* section)
void CMeterButton::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Store the current values so we know if the image needs to be updated
std::wstring oldImageName = m_ImageName;
@ -144,9 +144,7 @@ void CMeterButton::ReadConfig(const WCHAR* section)
int oldH = m_H;
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
m_ImageName = parser.ReadString(section, L"ButtonImage", L"");
if (!m_ImageName.empty())

View File

@ -27,10 +27,10 @@
class CMeterButton : public CMeter
{
public:
CMeterButton(CMeterWindow* meterWindow);
CMeterButton(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterButton();
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -36,7 +36,7 @@ CTintedImageHelper_DefineConfigArray(CMeterHistogram::c_BothConfigArray, L"Both"
** The constructor
**
*/
CMeterHistogram::CMeterHistogram(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterHistogram::CMeterHistogram(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_SecondaryMeasure(),
m_PrimaryColor(Color::Green),
m_SecondaryColor(Color::Red),
@ -195,7 +195,7 @@ void CMeterHistogram::Initialize()
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterHistogram::ReadConfig(const WCHAR* section)
void CMeterHistogram::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Store the current values so we know if the image needs to be updated
std::wstring oldPrimaryImageName = m_PrimaryImageName;
@ -205,9 +205,7 @@ void CMeterHistogram::ReadConfig(const WCHAR* section)
int oldH = m_H;
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
m_PrimaryColor = parser.ReadColor(section, L"PrimaryColor", Color::Green);
m_SecondaryColor = parser.ReadColor(section, L"SecondaryColor", Color::Red);

View File

@ -25,10 +25,10 @@
class CMeterHistogram : public CMeter
{
public:
CMeterHistogram(CMeterWindow* meterWindow);
CMeterHistogram(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterHistogram();
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -32,7 +32,7 @@ using namespace Gdiplus;
** The constructor
**
*/
CMeterImage::CMeterImage(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterImage::CMeterImage(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_NeedsReload(false),
m_WidthDefined(false),
m_HeightDefined(false),
@ -117,12 +117,10 @@ void CMeterImage::LoadImage(const std::wstring& imageName, bool bLoadAlways)
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterImage::ReadConfig(const WCHAR* section)
void CMeterImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
// Check for extra measures
if (!m_Initialized && !m_MeasureName.empty())

View File

@ -25,10 +25,10 @@
class CMeterImage : public CMeter
{
public:
CMeterImage(CMeterWindow* meterWindow);
CMeterImage(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterImage();
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -29,7 +29,7 @@ using namespace Gdiplus;
** The constructor
**
*/
CMeterLine::CMeterLine(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterLine::CMeterLine(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_Autoscale(false),
m_HorizontalLines(false),
m_Flip(false),
@ -93,7 +93,7 @@ void CMeterLine::Initialize()
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterLine::ReadConfig(const WCHAR* section)
void CMeterLine::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
WCHAR tmpName[64];
@ -101,9 +101,7 @@ void CMeterLine::ReadConfig(const WCHAR* section)
int oldLineCount = (int)m_Colors.size();
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
int lineCount = parser.ReadInt(section, L"LineCount", 1);

View File

@ -24,10 +24,10 @@
class CMeterLine : public CMeter
{
public:
CMeterLine(CMeterWindow* meterWindow);
CMeterLine(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterLine();
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -33,7 +33,7 @@ extern CRainmeter* Rainmeter;
** The constructor
**
*/
CMeterRotator::CMeterRotator(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterRotator::CMeterRotator(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_NeedsReload(false),
m_OffsetX(),
m_OffsetY(),
@ -81,15 +81,13 @@ void CMeterRotator::Initialize()
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterRotator::ReadConfig(const WCHAR* section)
void CMeterRotator::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Store the current values so we know if the image needs to be updated
std::wstring oldImageName = m_ImageName;
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
m_ImageName = parser.ReadString(section, L"ImageName", L"");
if (!m_ImageName.empty())

View File

@ -25,10 +25,10 @@
class CMeterRotator : public CMeter
{
public:
CMeterRotator(CMeterWindow* meterWindow);
CMeterRotator(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterRotator();
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -32,7 +32,7 @@ using namespace Gdiplus;
** The constructor
**
*/
CMeterRoundLine::CMeterRoundLine(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterRoundLine::CMeterRoundLine(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_Solid(false),
m_LineWidth(1.0),
m_LineLength(20.0),
@ -66,12 +66,10 @@ CMeterRoundLine::~CMeterRoundLine()
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterRoundLine::ReadConfig(const WCHAR* section)
void CMeterRoundLine::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0);
m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0);

View File

@ -24,10 +24,10 @@
class CMeterRoundLine : public CMeter
{
public:
CMeterRoundLine(CMeterWindow* meterWindow);
CMeterRoundLine(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterRoundLine();
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual bool Update();
virtual bool Draw(Gdiplus::Graphics& graphics);

View File

@ -66,7 +66,7 @@ void StringToProper(std::wstring& str)
** The constructor
**
*/
CMeterString::CMeterString(CMeterWindow* meterWindow) : CMeter(meterWindow),
CMeterString::CMeterString(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_Color(Color::White),
m_EffectColor(Color::Black),
m_AutoScale(AUTOSCALE_OFF),
@ -289,7 +289,7 @@ void CMeterString::Initialize()
** Read the meter-specific configs from the ini-file.
**
*/
void CMeterString::ReadConfig(const WCHAR* section)
void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
// Store the current font values so we know if the font needs to be updated
std::wstring oldFontFace = m_FontFace;
@ -297,9 +297,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
TEXTSTYLE oldStyle = m_Style;
// Read common configs
CMeter::ReadConfig(section);
CConfigParser& parser = m_MeterWindow->GetParser();
CMeter::ReadConfig(parser, section);
// Check for extra measures
if (!m_Initialized && !m_MeasureName.empty())

View File

@ -30,12 +30,12 @@ class Font;
class CMeterString : public CMeter
{
public:
CMeterString(CMeterWindow* meterWindow);
CMeterString(CMeterWindow* meterWindow, const WCHAR* name);
virtual ~CMeterString();
virtual int GetX(bool abs = false);
virtual void ReadConfig(const WCHAR* section);
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
virtual void Initialize();
virtual bool Update();
void SetText(const WCHAR* text) { m_Text = text; }

View File

@ -1908,11 +1908,24 @@ bool CMeterWindow::ReadSkin()
try
{
measure = CMeasure::Create(measureName.c_str(), this);
measure = CMeasure::Create(measureName.c_str(), this, strSection.c_str());
if (measure)
{
measure->SetName(strSection.c_str());
measure->ReadConfig(m_Parser, strSection.c_str());
measure->ReadConfig(m_Parser);
m_Measures.push_back(measure);
m_Parser.AddMeasure(measure);
if (!m_HasNetMeasures && dynamic_cast<CMeasureNet*>(measure))
{
m_HasNetMeasures = true;
}
CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure);
if(measureScript)
{
m_ScriptMeasures.push_back(measureScript);
}
}
}
catch (CError& error)
@ -1921,24 +1934,6 @@ bool CMeterWindow::ReadSkin()
measure = NULL;
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
if (measure)
{
m_Measures.push_back(measure);
m_Parser.AddMeasure(measure);
if (!m_HasNetMeasures && dynamic_cast<CMeasureNet*>(measure))
{
m_HasNetMeasures = true;
}
CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure);
if(measureScript)
{
m_ScriptMeasures.push_back(measureScript);
}
}
}
else if (meterName.length() > 0)
{
@ -1947,22 +1942,20 @@ bool CMeterWindow::ReadSkin()
try
{
meter = CMeter::Create(meterName.c_str(), this);
meter = CMeter::Create(meterName.c_str(), this, strSection.c_str());
if (meter)
{
meter->SetName(strSection.c_str());
if (m_MouseActionCursor == false)
{
meter->SetMouseActionCursor(false);
}
meter->SetMouseActionCursor(m_MouseActionCursor);
meter->SetToolTipHidden(m_ToolTipHidden);
if (m_ToolTipHidden == true)
{
meter->SetToolTipHidden(true);
}
meter->ReadConfig(m_Parser);
meter->ReadConfig(strSection.c_str());
m_Meters.push_back(meter);
if (!m_HasButtons && dynamic_cast<CMeterButton*>(meter))
{
m_HasButtons = true;
}
}
}
catch (CError& error)
@ -1971,18 +1964,6 @@ bool CMeterWindow::ReadSkin()
meter = NULL;
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
if (meter)
{
m_Meters.push_back(meter);
m_Parser.ClearStyleTemplate();
if (!m_HasButtons && dynamic_cast<CMeterButton*>(meter))
{
m_HasButtons = true;
}
}
}
// If it's not a meter or measure it will be ignored
}
@ -2494,7 +2475,7 @@ bool CMeterWindow::UpdateMeasure(CMeasure* measure, bool force)
{
try
{
measure->ReadConfig(m_Parser, measure->GetName());
measure->ReadConfig(m_Parser);
}
catch (CError& error)
{
@ -2534,8 +2515,7 @@ bool CMeterWindow::UpdateMeter(CMeter* meter, bool& bActiveTransition, bool forc
{
try
{
meter->ReadConfig(meter->GetName());
m_Parser.ClearStyleTemplate();
meter->ReadConfig(m_Parser);
}
catch (CError& error)
{

View File

@ -4292,7 +4292,7 @@ void CRainmeter::ExpandEnvironmentVariables(std::wstring& strPath)
{
if (strPath.find(L'%') != std::wstring::npos)
{
WCHAR bufSize = 4096;
DWORD bufSize = 4096;
WCHAR* buffer = new WCHAR[bufSize]; // lets hope the buffer is large enough...
// %APPDATA% is a special case

View File

@ -289,11 +289,10 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
try
{
m_Measure = CMeasure::Create(measureName.c_str(), NULL);
m_Measure = CMeasure::Create(measureName.c_str(), NULL, L"TrayMeasure");
if (m_Measure)
{
m_Measure->SetName(L"TrayMeasure");
m_Measure->ReadConfig(parser, L"TrayMeasure");
m_Measure->ReadConfig(parser);
}
}
catch (CError& error)