mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code optimization and removed unused part for reducing core dll size.
This commit is contained in:
parent
2bf3299ded
commit
cab258a7e5
@ -201,12 +201,11 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
const WCHAR* name = (*i)->GetName();
|
||||
const WCHAR* val = (*i)->GetStats();
|
||||
|
||||
std::wstring range;
|
||||
WCHAR buffer[256];
|
||||
double minVal = (*i)->GetMinValue();
|
||||
double maxVal = (*i)->GetMaxValue();
|
||||
CMeasure::GetScaledValue(1, minVal, buffer);
|
||||
range = buffer;
|
||||
std::wstring range = buffer;
|
||||
range += L" - ";
|
||||
CMeasure::GetScaledValue(1, maxVal, buffer);
|
||||
range += buffer;
|
||||
|
@ -36,7 +36,7 @@ const WCHAR* CError::c_ErrorStrings[] =
|
||||
*/
|
||||
const std::wstring& CError::GetString()
|
||||
{
|
||||
static WCHAR Buffer[16];
|
||||
// static WCHAR Buffer[16];
|
||||
|
||||
if (m_Error != ERROR_USER)
|
||||
{
|
||||
|
@ -35,12 +35,12 @@ public:
|
||||
ERROR_CREATE_WINDOW
|
||||
};
|
||||
|
||||
CError(const std::wstring& String) { m_Error = ERROR_USER; m_String = String; m_File = NULL; };
|
||||
CError(const WCHAR* String ) { m_Error = ERROR_USER; m_String = String; m_File = NULL; };
|
||||
CError(const std::wstring& String, int Line, const char* File) { m_Error = ERROR_USER; m_String = String; m_Line = Line; m_File = File; };
|
||||
CError(const WCHAR* String, int Line, const char* File) { m_Error = ERROR_USER; m_String = String; m_Line = Line; m_File = File; };
|
||||
CError(RAINERROR Error) { m_Error = Error; m_File = NULL; };
|
||||
CError(RAINERROR Error, int Line, const char* File) { m_Error = Error; m_Line = Line; m_File = File; };
|
||||
CError(const std::wstring& String) : m_Error(ERROR_USER), m_String(String), m_File(NULL) {}
|
||||
CError(const WCHAR* String ) : m_Error(ERROR_USER), m_String(String), m_File(NULL) {}
|
||||
CError(const std::wstring& String, int Line, const char* File) : m_Error(ERROR_USER), m_String(String), m_Line(Line), m_File(File) {}
|
||||
CError(const WCHAR* String, int Line, const char* File) : m_Error(ERROR_USER), m_String(String), m_Line(Line), m_File(File) {}
|
||||
CError(RAINERROR Error) : m_Error(Error), m_File(NULL) {}
|
||||
CError(RAINERROR Error, int Line, const char* File) : m_Error(Error), m_Line(Line), m_File(File) {}
|
||||
|
||||
const std::wstring& GetString();
|
||||
|
||||
|
@ -47,7 +47,7 @@ extern CRainmeter* Rainmeter;
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasure::CMeasure(CMeterWindow* meterWindow)
|
||||
CMeasure::CMeasure(CMeterWindow* meterWindow) : m_MeterWindow(meterWindow)
|
||||
{
|
||||
m_Invert = false;
|
||||
m_LogMaxValue = false;
|
||||
@ -68,8 +68,6 @@ CMeasure::CMeasure(CMeterWindow* meterWindow)
|
||||
m_AverageSize = 0;
|
||||
m_DynamicVariables = false;
|
||||
m_Initialized = false;
|
||||
|
||||
m_MeterWindow = meterWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -147,8 +145,7 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0);
|
||||
|
||||
std::wstring subs;
|
||||
subs = parser.ReadString(section, L"Substitute", L"");
|
||||
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'\"'))
|
||||
@ -220,16 +217,12 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
|
||||
{
|
||||
if (buffer.empty()) return true;
|
||||
|
||||
std::wstring word1;
|
||||
std::wstring word2;
|
||||
std::wstring sep;
|
||||
|
||||
while (!buffer.empty())
|
||||
{
|
||||
word1 = ExtractWord(buffer);
|
||||
sep = ExtractWord(buffer);
|
||||
std::wstring word1 = ExtractWord(buffer);
|
||||
std::wstring sep = ExtractWord(buffer);
|
||||
if (sep != L":") return false;
|
||||
word2 = ExtractWord(buffer);
|
||||
std::wstring word2 = ExtractWord(buffer);
|
||||
|
||||
if (word1 != word2)
|
||||
{
|
||||
|
@ -27,7 +27,8 @@
|
||||
|
||||
#define SystemProcessorPerformanceInformation 8
|
||||
|
||||
#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
|
||||
//#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
|
||||
#define Li2Double(x) ((double)((x).QuadPart))
|
||||
#define Ft2Double(x) ((double)((x).dwHighDateTime) * 4.294967296E9 + (double)((x).dwLowDateTime))
|
||||
|
||||
// ntdll!NtQuerySystemInformation (NT specific!)
|
||||
@ -56,7 +57,6 @@
|
||||
*/
|
||||
CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_CPUFromRegistry = false;
|
||||
m_MaxValue = 100.0;
|
||||
m_MinValue = 0.0;
|
||||
m_FirstTime = true;
|
||||
@ -85,19 +85,6 @@ CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
*/
|
||||
CMeasureCPU::~CMeasureCPU()
|
||||
{
|
||||
if(m_CPUFromRegistry)
|
||||
{
|
||||
// Stop the counter if it was started
|
||||
HKEY hkey;
|
||||
DWORD dwDataSize;
|
||||
DWORD dwType;
|
||||
DWORD dwDummy;
|
||||
|
||||
RegOpenKeyEx(HKEY_DYN_DATA, L"PerfStats\\StopStat", 0, KEY_ALL_ACCESS, &hkey);
|
||||
dwDataSize = sizeof(dwDummy);
|
||||
RegQueryValueEx(hkey, L"KERNEL\\CPUUsage", NULL, &dwType, (LPBYTE)&dwDummy, &dwDataSize);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -141,16 +128,13 @@ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current CPU utilization value. On NT the value is taken
|
||||
** from the performance counters and on 9x we'll use the registry.
|
||||
** Updates the current CPU utilization value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureCPU::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
if (CSystem::IsNT())
|
||||
{
|
||||
if (m_Processor == 0 && m_GetSystemTimes)
|
||||
{
|
||||
BOOL status;
|
||||
@ -241,33 +225,6 @@ bool CMeasureCPU::Update()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's a wintendo!
|
||||
HKEY hkey;
|
||||
DWORD dwDataSize;
|
||||
DWORD dwType;
|
||||
DWORD dwCpuUsage;
|
||||
|
||||
if(m_FirstTime)
|
||||
{
|
||||
RegOpenKeyEx(HKEY_DYN_DATA, L"PerfStats\\StartStat", 0, KEY_ALL_ACCESS, &hkey);
|
||||
dwDataSize = sizeof(dwCpuUsage);
|
||||
RegQueryValueEx(hkey, L"KERNEL\\CPUUsage", NULL, &dwType, (LPBYTE)&dwCpuUsage, &dwDataSize);
|
||||
RegCloseKey(hkey);
|
||||
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
RegOpenKeyEx(HKEY_DYN_DATA, L"PerfStats\\StatData", 0, KEY_ALL_ACCESS, &hkey);
|
||||
dwDataSize = sizeof(dwCpuUsage);
|
||||
RegQueryValueEx(hkey, L"KERNEL\\CPUUsage", NULL, &dwType, (LPBYTE)&dwCpuUsage, &dwDataSize);
|
||||
RegCloseKey(hkey);
|
||||
|
||||
m_Value = dwCpuUsage;
|
||||
m_CPUFromRegistry = true;
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ protected:
|
||||
void CalcUsage(double idleTime, double systemTime);
|
||||
void CalcAverageUsage(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo);
|
||||
|
||||
bool m_CPUFromRegistry;
|
||||
bool m_FirstTime;
|
||||
|
||||
int m_Processor;
|
||||
|
@ -117,8 +117,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
std::wstring keyname;
|
||||
keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER");
|
||||
std::wstring keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER");
|
||||
|
||||
if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
|
@ -233,8 +233,7 @@ void CMeasureTime::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
m_Format = parser.ReadString(section, L"Format", L"");
|
||||
|
||||
std::wstring timezone;
|
||||
timezone = parser.ReadString(section, L"TimeZone", L"local");
|
||||
std::wstring timezone = parser.ReadString(section, L"TimeZone", L"local");
|
||||
bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1);
|
||||
|
||||
SYSTEMTIME sysLocalTime, sysUTCTime;
|
||||
|
@ -39,7 +39,7 @@ using namespace Gdiplus;
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeter::CMeter(CMeterWindow* meterWindow)
|
||||
CMeter::CMeter(CMeterWindow* meterWindow) : m_MeterWindow(meterWindow)
|
||||
{
|
||||
m_Measure = NULL;
|
||||
|
||||
@ -64,8 +64,6 @@ CMeter::CMeter(CMeterWindow* meterWindow)
|
||||
m_ToolTipHidden = false;
|
||||
|
||||
m_ToolTipHandle = NULL;
|
||||
|
||||
m_MeterWindow = meterWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -34,16 +34,12 @@ extern CRainmeter* Rainmeter;
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterBar::CMeterBar(CMeterWindow* meterWindow) : CMeterImage(meterWindow)
|
||||
CMeterBar::CMeterBar(CMeterWindow* meterWindow) : CMeterImage(meterWindow, L"ImageW", L"ImageH"),
|
||||
m_Color(Color::Green)
|
||||
{
|
||||
m_Color = 0;
|
||||
m_Bitmap = NULL;
|
||||
m_Value = 0.0;
|
||||
m_Border = 0;
|
||||
m_Flip = false;
|
||||
|
||||
m_ImageWidthString = L"ImageW";
|
||||
m_ImageHeightString = L"ImageH";
|
||||
}
|
||||
|
||||
/*
|
||||
@ -118,8 +114,7 @@ void CMeterBar::ReadConfig(const WCHAR* section)
|
||||
|
||||
m_Flip = parser.ReadInt(section, L"Flip", 0) == 1;
|
||||
|
||||
std::wstring orientation;
|
||||
orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL");
|
||||
std::wstring orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL");
|
||||
|
||||
if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0)
|
||||
{
|
||||
@ -182,8 +177,9 @@ bool CMeterBar::Draw(Graphics& graphics)
|
||||
|
||||
if(m_Orientation == VERTICAL)
|
||||
{
|
||||
int size = (int)((m_H - 2 * m_Border) * m_Value);
|
||||
size = min(m_H - 2 * m_Border, size);
|
||||
int barSize = m_H - 2 * m_Border;
|
||||
int size = (int)(barSize * m_Value);
|
||||
size = min(barSize, size);
|
||||
size = max(0, size);
|
||||
|
||||
if (drawBitmap)
|
||||
@ -234,8 +230,9 @@ bool CMeterBar::Draw(Graphics& graphics)
|
||||
}
|
||||
else
|
||||
{
|
||||
int size = (int)((m_W - 2 * m_Border) * m_Value);
|
||||
size = min(m_W - 2 * m_Border, size);
|
||||
int barSize = m_W - 2 * m_Border;
|
||||
int size = (int)(barSize * m_Value);
|
||||
size = min(barSize, size);
|
||||
size = max(0, size);
|
||||
|
||||
if (drawBitmap)
|
||||
|
@ -115,11 +115,6 @@ bool CMeterBitmap::HitTest(int x, int y)
|
||||
{
|
||||
if (m_Extend)
|
||||
{
|
||||
int value = (int)m_Value;
|
||||
value = max(0, value); // Only positive integers are supported
|
||||
|
||||
int tmpValue = value;
|
||||
|
||||
// Calc the number of numbers
|
||||
int numOfNums = 0;
|
||||
|
||||
@ -129,6 +124,9 @@ bool CMeterBitmap::HitTest(int x, int y)
|
||||
}
|
||||
else
|
||||
{
|
||||
int tmpValue = (int)m_Value;
|
||||
tmpValue = max(0, tmpValue); // Only positive integers are supported
|
||||
|
||||
int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
|
||||
do
|
||||
{
|
||||
@ -197,8 +195,7 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
|
||||
|
||||
m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0);
|
||||
|
||||
std::wstring align;
|
||||
align = parser.ReadString(section, L"BitmapAlign", L"LEFT");
|
||||
std::wstring align = parser.ReadString(section, L"BitmapAlign", L"LEFT");
|
||||
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
@ -242,15 +239,7 @@ bool CMeterBitmap::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
double value = 0.0;
|
||||
if (m_Extend)
|
||||
{
|
||||
value = m_Measure->GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = m_Measure->GetRelativeValue();
|
||||
}
|
||||
double value = (m_Extend) ? m_Measure->GetValue() : m_Measure->GetRelativeValue();
|
||||
|
||||
if (m_TransitionFrameCount > 0)
|
||||
{
|
||||
@ -314,7 +303,6 @@ bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
int transitionValue = (int)m_TransitionStartValue;
|
||||
transitionValue = max(0, transitionValue); // Only positive integers are supported
|
||||
|
||||
int tmpValue = value;
|
||||
// Calc the number of numbers
|
||||
int numOfNums = 0;
|
||||
|
||||
@ -324,6 +312,8 @@ bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
}
|
||||
else
|
||||
{
|
||||
int tmpValue = value;
|
||||
|
||||
do
|
||||
{
|
||||
++numOfNums;
|
||||
|
@ -32,12 +32,12 @@ extern CRainmeter* Rainmeter;
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterHistogram::CMeterHistogram(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
CMeterHistogram::CMeterHistogram(CMeterWindow* meterWindow) : CMeter(meterWindow),
|
||||
m_PrimaryColor(Color::Green),
|
||||
m_SecondaryColor(Color::Red),
|
||||
m_BothColor(Color::Yellow)
|
||||
{
|
||||
m_SecondaryMeasure = NULL;
|
||||
m_PrimaryColor = 0;
|
||||
m_SecondaryColor = 0;
|
||||
m_BothColor = 0;
|
||||
m_MeterPos = 0;
|
||||
m_PrimaryBitmap = NULL;
|
||||
m_SecondaryBitmap = NULL;
|
||||
@ -342,30 +342,44 @@ bool CMeterHistogram::Update()
|
||||
// Go through all values and find the max
|
||||
|
||||
double newValue = 0;
|
||||
for (int i = 0; i != m_W; ++i)
|
||||
for (int i = 0; i < m_W; ++i)
|
||||
{
|
||||
newValue = max(newValue, m_PrimaryValues[i]);
|
||||
}
|
||||
|
||||
// Scale the value up to nearest power of 2
|
||||
m_MaxPrimaryValue = 2;
|
||||
while(m_MaxPrimaryValue < newValue && m_MaxPrimaryValue != 0)
|
||||
if (newValue > DBL_MAX / 2.0)
|
||||
{
|
||||
m_MaxPrimaryValue *= 2;
|
||||
m_MaxPrimaryValue = DBL_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MaxPrimaryValue = 2.0;
|
||||
while (m_MaxPrimaryValue < newValue)
|
||||
{
|
||||
m_MaxPrimaryValue *= 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_SecondaryMeasure && m_SecondaryValues)
|
||||
{
|
||||
for (int i = 0; i != m_W; ++i)
|
||||
for (int i = 0; i < m_W; ++i)
|
||||
{
|
||||
newValue = max(newValue, m_SecondaryValues[i]);
|
||||
}
|
||||
|
||||
// Scale the value up to nearest power of 2
|
||||
m_MaxSecondaryValue = 2;
|
||||
while(m_MaxSecondaryValue < newValue && m_MaxSecondaryValue != 0)
|
||||
if (newValue > DBL_MAX / 2.0)
|
||||
{
|
||||
m_MaxSecondaryValue *= 2;
|
||||
m_MaxSecondaryValue = DBL_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MaxSecondaryValue = 2.0;
|
||||
while (m_MaxSecondaryValue < newValue)
|
||||
{
|
||||
m_MaxSecondaryValue *= 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -426,15 +440,7 @@ bool CMeterHistogram::Draw(Graphics& graphics)
|
||||
secondaryBarHeight = max(0, secondaryBarHeight);
|
||||
|
||||
// Check which measured value is higher
|
||||
int bothBarHeight;
|
||||
if (secondaryBarHeight > primaryBarHeight)
|
||||
{
|
||||
bothBarHeight = primaryBarHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
bothBarHeight = secondaryBarHeight;
|
||||
}
|
||||
int bothBarHeight = min(primaryBarHeight, secondaryBarHeight);
|
||||
|
||||
// Draw image/color for the both lines
|
||||
if (m_PrimaryBitmap)
|
||||
|
@ -51,7 +51,8 @@ const Gdiplus::ColorMatrix CMeterImage::c_IdentifyMatrix = {
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterImage::CMeterImage(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
CMeterImage::CMeterImage(CMeterWindow* meterWindow, WCHAR* wName, WCHAR* hName) : CMeter(meterWindow), m_ImageWidthString(wName), m_ImageHeightString(hName),
|
||||
m_ColorMatrix(c_IdentifyMatrix)
|
||||
{
|
||||
m_Bitmap = NULL;
|
||||
m_BitmapTint = NULL;
|
||||
@ -66,12 +67,8 @@ CMeterImage::CMeterImage(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
m_Modified.dwLowDateTime = 0;
|
||||
|
||||
m_GreyScale = false;
|
||||
m_ColorMatrix = c_IdentifyMatrix;
|
||||
m_Flip = RotateNoneFlipNone;
|
||||
m_Rotate = 0.0f;
|
||||
|
||||
m_ImageWidthString = L"W";
|
||||
m_ImageHeightString = L"H";
|
||||
}
|
||||
|
||||
/*
|
||||
@ -522,8 +519,7 @@ void CMeterImage::ReadConfig(const WCHAR* section)
|
||||
|
||||
m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(oldColorMatrix, m_ColorMatrix));
|
||||
|
||||
std::wstring flip;
|
||||
flip = parser.ReadString(section, L"ImageFlip", L"NONE");
|
||||
std::wstring flip = parser.ReadString(section, L"ImageFlip", L"NONE");
|
||||
|
||||
if(_wcsicmp(flip.c_str(), L"NONE") == 0)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace Gdiplus
|
||||
class CMeterImage : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterImage(CMeterWindow* meterWindow);
|
||||
CMeterImage(CMeterWindow* meterWindow, WCHAR* wName = L"W", WCHAR* hName = L"H");
|
||||
virtual ~CMeterImage();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
@ -40,14 +40,15 @@ public:
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
|
||||
protected:
|
||||
std::wstring m_ImageWidthString;
|
||||
std::wstring m_ImageHeightString;
|
||||
void LoadImage(bool bLoadAlways);
|
||||
bool CompareColorMatrix(const Gdiplus::ColorMatrix& a, const Gdiplus::ColorMatrix& b);
|
||||
void ApplyTint();
|
||||
Gdiplus::Bitmap* TurnGreyscale();
|
||||
void ApplyTransform();
|
||||
|
||||
const std::wstring m_ImageWidthString;
|
||||
const std::wstring m_ImageHeightString;
|
||||
|
||||
Gdiplus::Bitmap* m_Bitmap; // The bitmap
|
||||
Gdiplus::Bitmap* m_BitmapTint; // The bitmap
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
|
@ -29,11 +29,11 @@ using namespace Gdiplus;
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterLine::CMeterLine(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
CMeterLine::CMeterLine(CMeterWindow* meterWindow) : CMeter(meterWindow),
|
||||
m_HorizontalColor(Color::Black)
|
||||
{
|
||||
m_Autoscale = false;
|
||||
m_HorizontalLines = false;
|
||||
m_HorizontalColor = 0;
|
||||
m_CurrentPos = 0;
|
||||
m_Flip = false;
|
||||
m_LineWidth = 1.0;
|
||||
@ -224,19 +224,28 @@ bool CMeterLine::Draw(Graphics& graphics)
|
||||
counter = 0;
|
||||
for (; i != m_AllValues.end(); ++i)
|
||||
{
|
||||
double scale = m_ScaleValues[counter];
|
||||
std::vector<double>::const_iterator j = (*i).begin();
|
||||
for (; j != (*i).end(); ++j)
|
||||
{
|
||||
newValue = max(newValue, (*j) * m_ScaleValues[counter]);
|
||||
double val = (*j) * scale;
|
||||
newValue = max(newValue, val);
|
||||
}
|
||||
++counter;
|
||||
}
|
||||
|
||||
// Scale the value up to nearest power of 2
|
||||
maxValue = 2;
|
||||
while(maxValue < newValue && maxValue != 0)
|
||||
if (newValue > DBL_MAX / 2.0)
|
||||
{
|
||||
maxValue *= 2;
|
||||
maxValue = DBL_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxValue = 2.0;
|
||||
while (maxValue < newValue)
|
||||
{
|
||||
maxValue *= 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -248,8 +257,8 @@ bool CMeterLine::Draw(Graphics& graphics)
|
||||
std::vector<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for (; i != m_Measures.end(); ++i)
|
||||
{
|
||||
maxValue = max(maxValue, (*i)->GetMaxValue());
|
||||
}
|
||||
double val = (*i)->GetMaxValue();
|
||||
maxValue = max(maxValue, val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,6 +266,7 @@ bool CMeterLine::Draw(Graphics& graphics)
|
||||
{
|
||||
maxValue = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
@ -294,47 +304,41 @@ bool CMeterLine::Draw(Graphics& graphics)
|
||||
for (; i != m_AllValues.end(); ++i)
|
||||
{
|
||||
// Draw a line
|
||||
int X = x;
|
||||
REAL Y = 0;
|
||||
REAL oldY = 0;
|
||||
int pos = m_CurrentPos;
|
||||
if (pos >= m_W) pos = 0;
|
||||
REAL Y = 0.0f;
|
||||
REAL oldY = 0.0f;
|
||||
REAL H = m_H - 1.0f;
|
||||
|
||||
double scale = m_ScaleValues[counter] * H / maxValue;
|
||||
|
||||
int pos = m_CurrentPos;
|
||||
int size = (int)(*i).size();
|
||||
|
||||
Pen pen(m_Colors[counter], (REAL)m_LineWidth);
|
||||
|
||||
for (int j = 0; j < m_W; ++j)
|
||||
for (int j = x, R = x + m_W; j < R; ++j)
|
||||
{
|
||||
if (pos >= m_W) pos = 0;
|
||||
|
||||
if (pos < size)
|
||||
{
|
||||
Y = (REAL)((*i)[pos] * m_ScaleValues[counter] * (m_H - 1) / maxValue);
|
||||
Y = min(Y, m_H - 1);
|
||||
Y = max(Y, 0);
|
||||
Y = (REAL)((*i)[pos] * scale);
|
||||
Y = min(Y, H);
|
||||
Y = max(Y, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Y = 0;
|
||||
Y = 0.0f;
|
||||
}
|
||||
|
||||
if (m_Flip)
|
||||
{
|
||||
Y = y + Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
Y = y + m_H - Y - 1;
|
||||
}
|
||||
Y = (m_Flip) ? y + Y : y + H - Y;
|
||||
|
||||
if (j != 0)
|
||||
if (j != x)
|
||||
{
|
||||
graphics.DrawLine(&pen, (REAL)X - 1, oldY, (REAL)X, Y); // GDI+
|
||||
graphics.DrawLine(&pen, (REAL)(j - 1), oldY, (REAL)j, Y); // GDI+
|
||||
}
|
||||
oldY = Y;
|
||||
|
||||
++X;
|
||||
++pos;
|
||||
if (pos >= m_W) pos = 0;
|
||||
}
|
||||
|
||||
++counter;
|
||||
|
@ -33,13 +33,9 @@ extern CRainmeter* Rainmeter;
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterRotator::CMeterRotator(CMeterWindow* meterWindow) : CMeterImage(meterWindow)
|
||||
CMeterRotator::CMeterRotator(CMeterWindow* meterWindow) : CMeterImage(meterWindow, L"ImageW", L"ImageH")
|
||||
{
|
||||
m_Bitmap = NULL;
|
||||
m_Value = 0.0;
|
||||
|
||||
m_ImageWidthString = L"ImageW";
|
||||
m_ImageHeightString = L"ImageH";
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -30,7 +30,8 @@ using namespace Gdiplus;
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterRoundLine::CMeterRoundLine(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
CMeterRoundLine::CMeterRoundLine(CMeterWindow* meterWindow) : CMeter(meterWindow),
|
||||
m_LineColor(Color::Black)
|
||||
{
|
||||
m_LineWidth = 1.0;
|
||||
m_LineLength = 20;
|
||||
|
@ -66,10 +66,10 @@ void StringToProper(std::wstring& str)
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterString::CMeterString(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
CMeterString::CMeterString(CMeterWindow* meterWindow) : CMeter(meterWindow),
|
||||
m_Color(Color::White),
|
||||
m_EffectColor(Color::Black)
|
||||
{
|
||||
m_Color = RGB(255, 255, 255);
|
||||
m_EffectColor = RGB(0, 0, 0);
|
||||
m_Effect = EFFECT_NONE;
|
||||
m_AutoScale = true;
|
||||
m_Align = ALIGN_LEFT;
|
||||
@ -298,8 +298,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
|
||||
m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0);
|
||||
|
||||
std::wstring scale;
|
||||
scale = parser.ReadString(section, L"Scale", L"1");
|
||||
std::wstring scale = parser.ReadString(section, L"Scale", L"1");
|
||||
|
||||
if (scale.find(L'.') == std::wstring::npos)
|
||||
{
|
||||
@ -313,8 +312,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
|
||||
m_FontFace = parser.ReadString(section, L"FontFace", L"Arial");
|
||||
|
||||
std::wstring align;
|
||||
align = parser.ReadString(section, L"StringAlign", L"LEFT");
|
||||
std::wstring align = parser.ReadString(section, L"StringAlign", L"LEFT");
|
||||
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
@ -333,8 +331,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
throw CError(std::wstring(L"StringAlign=") + align + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
std::wstring stringCase;
|
||||
stringCase = parser.ReadString(section, L"StringCase", L"NONE");
|
||||
std::wstring stringCase = parser.ReadString(section, L"StringCase", L"NONE");
|
||||
|
||||
if(_wcsicmp(stringCase.c_str(), L"NONE") == 0)
|
||||
{
|
||||
@ -357,8 +354,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
throw CError(std::wstring(L"StringCase=") + stringCase + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
std::wstring style;
|
||||
style = parser.ReadString(section, L"StringStyle", L"NORMAL");
|
||||
std::wstring style = parser.ReadString(section, L"StringStyle", L"NORMAL");
|
||||
|
||||
if(_wcsicmp(style.c_str(), L"NORMAL") == 0)
|
||||
{
|
||||
@ -381,8 +377,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
throw CError(std::wstring(L"StringStyle=") + style + L" is not valid in meter [" + m_Name + L"].", __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
std::wstring effect;
|
||||
effect = parser.ReadString(section, L"StringEffect", L"NONE");
|
||||
std::wstring effect = parser.ReadString(section, L"StringEffect", L"NONE");
|
||||
|
||||
if(_wcsicmp(effect.c_str(), L"NONE") == 0)
|
||||
{
|
||||
@ -591,17 +586,14 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
|
||||
graphics.TranslateTransform(-(Gdiplus::REAL)CMeter::GetX(), -y);
|
||||
}
|
||||
|
||||
switch (m_Effect)
|
||||
{
|
||||
case EFFECT_SHADOW:
|
||||
if (m_Effect == EFFECT_SHADOW)
|
||||
{
|
||||
SolidBrush solidBrush(m_EffectColor);
|
||||
RectF rcEffect(rc);
|
||||
rcEffect.Offset(1, 1);
|
||||
graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
break;
|
||||
}
|
||||
case EFFECT_BORDER:
|
||||
else if (m_Effect == EFFECT_BORDER)
|
||||
{
|
||||
SolidBrush solidBrush(m_EffectColor);
|
||||
RectF rcEffect(rc);
|
||||
@ -613,8 +605,6 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
|
||||
graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
rcEffect.Offset(-1, 1);
|
||||
graphics.DrawString(m_String.c_str(), (int)m_String.length(), m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SolidBrush solidBrush(m_Color);
|
||||
|
@ -33,9 +33,6 @@
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
#define ULW_ALPHA 0x00000002
|
||||
#define WS_EX_LAYERED 0x00080000
|
||||
|
||||
#define METERTIMER 1
|
||||
#define MOUSETIMER 2
|
||||
#define FADETIMER 3
|
||||
@ -53,16 +50,18 @@ extern CRainmeter* Rainmeter;
|
||||
** Constructor
|
||||
**
|
||||
*/
|
||||
CMeterWindow::CMeterWindow(std::wstring& path, std::wstring& config, std::wstring& iniFile)
|
||||
CMeterWindow::CMeterWindow(const std::wstring& path, const std::wstring& config, const std::wstring& iniFile) : m_SkinPath(path), m_SkinName(config), m_SkinIniFile(iniFile),
|
||||
m_WindowX(L"0"),
|
||||
m_WindowY(L"0")
|
||||
{
|
||||
m_Rainmeter = NULL;
|
||||
|
||||
m_Background = NULL;
|
||||
m_Window = NULL;
|
||||
m_ChildWindow = false;
|
||||
|
||||
m_DoubleBuffer = NULL;
|
||||
|
||||
m_WindowX = L"0";
|
||||
m_WindowY = L"0";
|
||||
m_ScreenX = 0;
|
||||
m_ScreenY = 0;
|
||||
m_WindowW = 0;
|
||||
@ -91,7 +90,6 @@ CMeterWindow::CMeterWindow(std::wstring& path, std::wstring& config, std::wstrin
|
||||
m_WindowHide = HIDEMODE_NONE;
|
||||
m_WindowStartHidden = false;
|
||||
m_SnapEdges = true;
|
||||
m_Rainmeter = NULL;
|
||||
m_Hidden = false;
|
||||
m_ResetRegion = false;
|
||||
m_Refreshing = false;
|
||||
@ -120,10 +118,6 @@ CMeterWindow::CMeterWindow(std::wstring& path, std::wstring& config, std::wstrin
|
||||
m_BackgroundMode = BGMODE_IMAGE;
|
||||
m_SolidBevel = BEVELTYPE_NONE;
|
||||
|
||||
m_SkinPath = path;
|
||||
m_SkinName = config;
|
||||
m_SkinIniFile = iniFile;
|
||||
|
||||
m_UpdateCounter = 0;
|
||||
m_FontCollection = NULL;
|
||||
|
||||
@ -819,9 +813,9 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
case BANG_SETTRANSPARENCY:
|
||||
if (arg != NULL)
|
||||
{
|
||||
int alpha = (int)CConfigParser::ParseDouble(arg, 255, true);
|
||||
alpha = max(alpha, 0);
|
||||
m_AlphaValue = min(alpha, 255);
|
||||
m_AlphaValue = (int)CConfigParser::ParseDouble(arg, 255, true);
|
||||
m_AlphaValue = max(m_AlphaValue, 0);
|
||||
m_AlphaValue = min(m_AlphaValue, 255);
|
||||
UpdateTransparency(m_AlphaValue, false);
|
||||
}
|
||||
break;
|
||||
@ -1623,8 +1617,8 @@ void CMeterWindow::ReadConfig()
|
||||
m_AutoSelectScreen = 0!=parser.ReadInt(section, L"AutoSelectScreen", m_AutoSelectScreen);
|
||||
|
||||
m_AlphaValue = parser.ReadInt(section, L"AlphaValue", m_AlphaValue);
|
||||
m_AlphaValue = min(255, m_AlphaValue);
|
||||
m_AlphaValue = max(0, m_AlphaValue);
|
||||
m_AlphaValue = max(m_AlphaValue, 0);
|
||||
m_AlphaValue = min(m_AlphaValue, 255);
|
||||
|
||||
m_FadeDuration = parser.ReadInt(section, L"FadeDuration", m_FadeDuration);
|
||||
|
||||
@ -1729,7 +1723,6 @@ bool CMeterWindow::ReadSkin()
|
||||
if (appVersion > RAINMETER_VERSION)
|
||||
{
|
||||
WCHAR buffer[128];
|
||||
std::wstring text;
|
||||
if (appVersion % 1000 != 0)
|
||||
{
|
||||
wsprintf(buffer, L"%i.%i.%i", appVersion / 1000000, (appVersion / 1000) % 1000, appVersion % 1000);
|
||||
@ -1739,7 +1732,7 @@ bool CMeterWindow::ReadSkin()
|
||||
wsprintf(buffer, L"%i.%i", appVersion / 1000000, (appVersion / 1000) % 1000);
|
||||
}
|
||||
|
||||
text = L"The skin \"";
|
||||
std::wstring text = L"The skin \"";
|
||||
text += m_SkinName;
|
||||
text += L"\\";
|
||||
text += m_SkinIniFile;
|
||||
@ -1809,7 +1802,7 @@ bool CMeterWindow::ReadSkin()
|
||||
// We want to check the fonts folder first
|
||||
// !!!!!!! - We may want to fix the method in which I get the path to
|
||||
// Rainmeter/fonts
|
||||
std::wstring szFontFile = m_Rainmeter->GetPath().c_str();
|
||||
std::wstring szFontFile = m_Rainmeter->GetPath();
|
||||
|
||||
m_FontCollection = new Gdiplus::PrivateFontCollection();
|
||||
|
||||
@ -1828,7 +1821,7 @@ bool CMeterWindow::ReadSkin()
|
||||
// The font wasn't found, check full path.
|
||||
if(nResults != Ok)
|
||||
{
|
||||
szFontFile = localFont.c_str();
|
||||
szFontFile = localFont;
|
||||
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||
if(nResults != Ok)
|
||||
{
|
||||
@ -1854,7 +1847,7 @@ bool CMeterWindow::ReadSkin()
|
||||
// We want to check the fonts folder first
|
||||
// !!!!!!! - We may want to fix the method in which I get the path to
|
||||
// Rainmeter/fonts
|
||||
std::wstring szFontFile = m_Rainmeter->GetPath().c_str();
|
||||
std::wstring szFontFile = m_Rainmeter->GetPath();
|
||||
szFontFile += L"Fonts\\";
|
||||
szFontFile += localFont;
|
||||
|
||||
@ -1871,7 +1864,7 @@ bool CMeterWindow::ReadSkin()
|
||||
// The font wasn't found, check full path.
|
||||
if(nResults != Ok)
|
||||
{
|
||||
szFontFile = localFont.c_str();
|
||||
szFontFile = localFont;
|
||||
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||
// The font file wasn't found anywhere, log the error
|
||||
if(nResults != Ok)
|
||||
@ -1908,11 +1901,9 @@ bool CMeterWindow::ReadSkin()
|
||||
_wcsicmp(L"Variables", strSection.c_str()) != 0 &&
|
||||
_wcsicmp(L"Metadata", strSection.c_str()) != 0)
|
||||
{
|
||||
std::wstring meterName, measureName;
|
||||
|
||||
// Check if the item is a meter or a measure (or perhaps something else)
|
||||
measureName = m_Parser.ReadString(strSection.c_str(), L"Measure", L"");
|
||||
meterName = m_Parser.ReadString(strSection.c_str(), L"Meter", L"");
|
||||
std::wstring measureName = m_Parser.ReadString(strSection.c_str(), L"Measure", L"");
|
||||
std::wstring meterName = m_Parser.ReadString(strSection.c_str(), L"Meter", L"");
|
||||
if (measureName.length() > 0)
|
||||
{
|
||||
// It's a measure
|
||||
@ -1996,8 +1987,7 @@ bool CMeterWindow::ReadSkin()
|
||||
|
||||
if (m_Meters.empty())
|
||||
{
|
||||
std::wstring text;
|
||||
text = L"The skin \"";
|
||||
std::wstring text = L"The skin \"";
|
||||
text += m_SkinName;
|
||||
text += L"\\";
|
||||
text += m_SkinIniFile;
|
||||
@ -2104,8 +2094,10 @@ bool CMeterWindow::ResizeWindow(bool reset)
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
w = max(w, (*j)->GetX() + (*j)->GetW());
|
||||
h = max(h, (*j)->GetY() + (*j)->GetH());
|
||||
int mr = (*j)->GetX() + (*j)->GetW();
|
||||
w = max(w, mr);
|
||||
int mb = (*j)->GetY() + (*j)->GetH();
|
||||
h = max(h, mb);
|
||||
}
|
||||
|
||||
w += m_BackgroundMargins.GetRight();
|
||||
@ -3120,8 +3112,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
|
||||
{
|
||||
std::wstring command;
|
||||
command += L"\"";
|
||||
std::wstring command = L"\"";
|
||||
command += m_SkinPath + L"\\" + m_SkinName;
|
||||
command += L"\"";
|
||||
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
|
||||
@ -4570,7 +4561,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
** Converts the path to absolute by adding the skin's path to it (unless it already is absolute).
|
||||
**
|
||||
*/
|
||||
std::wstring CMeterWindow::MakePathAbsolute(std::wstring path)
|
||||
std::wstring CMeterWindow::MakePathAbsolute(const std::wstring& path)
|
||||
{
|
||||
if (path.empty() ||
|
||||
path.find(L":\\") != std::wstring::npos || path.find(L":/") != std::wstring::npos ||
|
||||
|
@ -139,7 +139,7 @@ class CMeter;
|
||||
class CMeterWindow : public CGroup
|
||||
{
|
||||
public:
|
||||
CMeterWindow(std::wstring& path, std::wstring& config, std::wstring& iniFile);
|
||||
CMeterWindow(const std::wstring& path, const std::wstring& config, const std::wstring& iniFile);
|
||||
~CMeterWindow();
|
||||
|
||||
int Initialize(CRainmeter& Rainmeter);
|
||||
@ -203,7 +203,7 @@ public:
|
||||
|
||||
LRESULT OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
std::wstring MakePathAbsolute(std::wstring path);
|
||||
std::wstring MakePathAbsolute(const std::wstring& path);
|
||||
|
||||
Gdiplus::PrivateFontCollection* GetPrivateFontCollection() { return m_FontCollection; }
|
||||
|
||||
|
@ -230,8 +230,7 @@ void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring dbg;
|
||||
dbg = L"Unknown config name: " + config;
|
||||
std::wstring dbg = L"Unknown config name: " + config;
|
||||
LSLog(LOG_DEBUG, APPNAME, dbg.c_str());
|
||||
}
|
||||
}
|
||||
@ -1174,7 +1173,7 @@ void RainmeterQuit(HWND, const char* arg)
|
||||
//
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
||||
GlobalConfig CRainmeter::c_GlobalConfig;
|
||||
GlobalConfig CRainmeter::c_GlobalConfig = {0};
|
||||
bool CRainmeter::c_Debug = false;
|
||||
|
||||
/*
|
||||
@ -1185,11 +1184,6 @@ bool CRainmeter::c_Debug = false;
|
||||
*/
|
||||
CRainmeter::CRainmeter()
|
||||
{
|
||||
c_GlobalConfig.netInSpeed = 0;
|
||||
c_GlobalConfig.netOutSpeed = 0;
|
||||
|
||||
c_Debug = false;
|
||||
|
||||
m_MenuActive = false;
|
||||
|
||||
m_Logging = false;
|
||||
@ -1736,7 +1730,7 @@ void CRainmeter::CheckSkinVersions()
|
||||
** Compares two version strings. Returns 0 if they are equal, 1 if A > B and -1 if A < B.
|
||||
**
|
||||
*/
|
||||
int CRainmeter::CompareVersions(std::wstring strA, std::wstring strB)
|
||||
int CRainmeter::CompareVersions(const std::wstring& strA, const std::wstring& strB)
|
||||
{
|
||||
if (strA.empty() && strB.empty()) return 0;
|
||||
if (strA.empty()) return -1;
|
||||
@ -1773,7 +1767,7 @@ int CRainmeter::CompareVersions(std::wstring strA, std::wstring strB)
|
||||
** illustro\System is enabled.
|
||||
**
|
||||
*/
|
||||
void CRainmeter::CreateDefaultConfigFile(std::wstring strFile)
|
||||
void CRainmeter::CreateDefaultConfigFile(const std::wstring& strFile)
|
||||
{
|
||||
size_t pos = strFile.find_last_of(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
@ -1839,9 +1833,9 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
|
||||
if (_waccess(skinIniPath.c_str(), 0) == -1)
|
||||
{
|
||||
std::wstring message = L"Unable to activate skin \"";
|
||||
message += skinConfig.c_str();
|
||||
message += skinConfig;
|
||||
message += L"\\";
|
||||
message += skinIniFile.c_str();
|
||||
message += skinIniFile;
|
||||
message += L"\": Ini-file not found.";
|
||||
LSLog(LOG_DEBUG, APPNAME, message.c_str());
|
||||
MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
@ -1899,7 +1893,7 @@ void CRainmeter::WriteActive(const std::wstring& config, int iniIndex)
|
||||
WritePrivateProfileString(config.c_str(), L"Active", buffer, m_IniFile.c_str());
|
||||
}
|
||||
|
||||
void CRainmeter::CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile)
|
||||
void CRainmeter::CreateMeterWindow(const std::wstring& path, const std::wstring& config, const std::wstring& iniFile)
|
||||
{
|
||||
CMeterWindow* mw = new CMeterWindow(path, config, iniFile);
|
||||
|
||||
@ -2164,7 +2158,7 @@ void CRainmeter::Quit(HINSTANCE dllInst)
|
||||
**
|
||||
** Scans all the subfolders and locates the ini-files.
|
||||
*/
|
||||
void CRainmeter::ScanForConfigs(std::wstring& path)
|
||||
void CRainmeter::ScanForConfigs(const std::wstring& path)
|
||||
{
|
||||
m_ConfigStrings.clear();
|
||||
m_ConfigMenu.clear();
|
||||
@ -2173,7 +2167,7 @@ void CRainmeter::ScanForConfigs(std::wstring& path)
|
||||
ScanForConfigsRecursive(path, L"", 0, m_ConfigMenu, false);
|
||||
}
|
||||
|
||||
int CRainmeter::ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse)
|
||||
int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse)
|
||||
{
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
WIN32_FIND_DATA fileDataIni; // Data structure describes the file found
|
||||
@ -2263,7 +2257,7 @@ int CRainmeter::ScanForConfigsRecursive(std::wstring& path, std::wstring base, i
|
||||
**
|
||||
** Scans the given folder for themes
|
||||
*/
|
||||
void CRainmeter::ScanForThemes(std::wstring& path)
|
||||
void CRainmeter::ScanForThemes(const std::wstring& path)
|
||||
{
|
||||
m_Themes.clear();
|
||||
|
||||
@ -2726,7 +2720,7 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
||||
** Reads the general settings from the Rainmeter.ini file
|
||||
**
|
||||
*/
|
||||
void CRainmeter::ReadGeneralSettings(std::wstring& iniFile)
|
||||
void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
||||
{
|
||||
// Clear old settings
|
||||
m_DesktopWorkAreas.clear();
|
||||
@ -2859,8 +2853,7 @@ void CRainmeter::ReadGeneralSettings(std::wstring& iniFile)
|
||||
{
|
||||
if (!SetActiveConfig(skinName, skinIni))
|
||||
{
|
||||
std::wstring error;
|
||||
error = L"The selected skin (L" + skinName + L"\\" + skinIni + L") cannot be found.";
|
||||
std::wstring error = L"The selected skin (L" + skinName + L"\\" + skinIni + L") cannot be found.";
|
||||
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
return;
|
||||
@ -2886,7 +2879,7 @@ void CRainmeter::ReadGeneralSettings(std::wstring& iniFile)
|
||||
**
|
||||
** Makes the given config active. If the config cannot be found this returns false.
|
||||
*/
|
||||
bool CRainmeter::SetActiveConfig(std::wstring& skinName, std::wstring& skinIni)
|
||||
bool CRainmeter::SetActiveConfig(const std::wstring& skinName, const std::wstring& skinIni)
|
||||
{
|
||||
for (size_t i = 0; i < m_ConfigStrings.size(); ++i)
|
||||
{
|
||||
@ -2969,9 +2962,9 @@ void CRainmeter::RefreshAll()
|
||||
DeactivateConfig(mw, i);
|
||||
|
||||
std::wstring message = L"Unable to refresh skin \"";
|
||||
message += skinConfig.c_str();
|
||||
message += skinConfig;
|
||||
message += L"\\";
|
||||
message += skinIniFile.c_str();
|
||||
message += skinIniFile;
|
||||
message += L"\": Ini-file not found.";
|
||||
LSLog(LOG_DEBUG, APPNAME, message.c_str());
|
||||
MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
@ -2987,7 +2980,7 @@ void CRainmeter::RefreshAll()
|
||||
DeactivateConfig(mw, -2); // -2 = Deactivate the config forcibly
|
||||
|
||||
std::wstring message = L"Unable to refresh config \"";
|
||||
message += skinConfig.c_str();
|
||||
message += skinConfig;
|
||||
message += L"\": Config not found.";
|
||||
LSLog(LOG_DEBUG, APPNAME, message.c_str());
|
||||
MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
@ -3770,8 +3763,7 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
|
||||
{
|
||||
LSLog(LOG_DEBUG, APPNAME, L"The Rainmeter.ini file is NOT writable.");
|
||||
|
||||
std::wstring error;
|
||||
error += L"The Rainmeter.ini file is not writable. This means that the\n";
|
||||
std::wstring error = L"The Rainmeter.ini file is not writable. This means that the\n";
|
||||
error += L"application will not be able to save any settings permanently.\n\n";
|
||||
|
||||
if (!bDefaultIniLocation)
|
||||
|
@ -204,12 +204,12 @@ public:
|
||||
bool IsMenuActive() { return m_MenuActive; }
|
||||
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; }
|
||||
const std::wstring& GetTrayExecuteL() { return m_TrayExecuteL; }
|
||||
const std::wstring& GetTrayExecuteR() { return m_TrayExecuteR; }
|
||||
const std::wstring& GetTrayExecuteM() { return m_TrayExecuteM; }
|
||||
const std::wstring& GetTrayExecuteDR() { return m_TrayExecuteDR; }
|
||||
const std::wstring& GetTrayExecuteDL() { return m_TrayExecuteDL; }
|
||||
const 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);
|
||||
@ -224,27 +224,27 @@ public:
|
||||
static void ExpandEnvironmentVariables(std::wstring& strPath);
|
||||
|
||||
private:
|
||||
void CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile);
|
||||
void CreateMeterWindow(const std::wstring& path, const std::wstring& config, const std::wstring& iniFile);
|
||||
bool DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater);
|
||||
void WriteActive(const std::wstring& config, int iniIndex);
|
||||
void ScanForConfigs(std::wstring& path);
|
||||
void ScanForThemes(std::wstring& path);
|
||||
void ReadGeneralSettings(std::wstring& path);
|
||||
void ScanForConfigs(const std::wstring& path);
|
||||
void ScanForThemes(const std::wstring& path);
|
||||
void ReadGeneralSettings(const std::wstring& iniFile);
|
||||
void SetConfigOrder(int configIndex);
|
||||
int GetLoadOrder(const std::wstring& config);
|
||||
bool SetActiveConfig(std::wstring& skinName, std::wstring& skinIni);
|
||||
bool SetActiveConfig(const std::wstring& skinName, const std::wstring& skinIni);
|
||||
void UpdateDesktopWorkArea(bool reset);
|
||||
HMENU CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu);
|
||||
void ChangeSkinIndex(HMENU subMenu, int index);
|
||||
int ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse);
|
||||
int ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse);
|
||||
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
|
||||
HMENU CreateThemeMenu();
|
||||
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
|
||||
void CreateDefaultConfigFile(std::wstring strFile);
|
||||
void CreateDefaultConfigFile(const std::wstring& strFile);
|
||||
void SetLogging(bool logging);
|
||||
void TestSettingsFile(bool bDefaultIniLocation);
|
||||
void CheckSkinVersions();
|
||||
int CompareVersions(std::wstring strA, std::wstring strB);
|
||||
int CompareVersions(const std::wstring& strA, const std::wstring& strB);
|
||||
|
||||
CTrayWindow* m_TrayWindow;
|
||||
|
||||
|
@ -69,5 +69,6 @@
|
||||
#include <io.h>
|
||||
#include <stdarg.h>
|
||||
#include <process.h>
|
||||
#include <float.h>
|
||||
|
||||
#endif
|
||||
|
@ -37,7 +37,9 @@ extern CRainmeter* Rainmeter;
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
CTrayWindow::CTrayWindow(HINSTANCE instance)
|
||||
CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance),
|
||||
m_TrayColor1(0, 100, 0),
|
||||
m_TrayColor2(0, 255, 0)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
|
||||
@ -68,13 +70,10 @@ CTrayWindow::CTrayWindow(HINSTANCE instance)
|
||||
instance,
|
||||
this);
|
||||
|
||||
m_Instance = instance;
|
||||
m_Measure = NULL;
|
||||
m_TrayIcon = NULL;
|
||||
|
||||
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
||||
m_TrayColor1 = Color(0, 100, 0);
|
||||
m_TrayColor2 = Color(0, 255, 0);
|
||||
|
||||
m_Bitmap = NULL;
|
||||
|
||||
@ -477,8 +476,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_OPENSKINSFOLDER)
|
||||
{
|
||||
std::wstring command;
|
||||
command += L"\"";
|
||||
std::wstring command = L"\"";
|
||||
command += Rainmeter->GetSkinPath();
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
|
Loading…
Reference in New Issue
Block a user