mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code cleanup & cosmetics: Moved Measure/Meter shared part to Section.h
This commit is contained in:
parent
5103190129
commit
489f2c5a30
@ -44,12 +44,12 @@ void CGroup::InitializeGroup(const std::wstring& groups)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGroup::BelongsToGroup(const std::wstring& group)
|
bool CGroup::BelongsToGroup(const std::wstring& group) const
|
||||||
{
|
{
|
||||||
return (m_Groups.find(CreateGroup(group)) != m_Groups.end());
|
return (m_Groups.find(CreateGroup(group)) != m_Groups.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring CGroup::CreateGroup(const std::wstring& str)
|
std::wstring CGroup::CreateGroup(const std::wstring& str) const
|
||||||
{
|
{
|
||||||
std::wstring strTmp;
|
std::wstring strTmp;
|
||||||
|
|
||||||
|
@ -25,16 +25,17 @@
|
|||||||
class CGroup
|
class CGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool BelongsToGroup(const std::wstring& group);
|
virtual ~CGroup() {}
|
||||||
|
|
||||||
|
bool BelongsToGroup(const std::wstring& group) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CGroup() {}
|
CGroup() {}
|
||||||
virtual ~CGroup() {}
|
|
||||||
|
|
||||||
void InitializeGroup(const std::wstring& groups);
|
void InitializeGroup(const std::wstring& groups);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::wstring CreateGroup(const std::wstring& str);
|
std::wstring CreateGroup(const std::wstring& str) const;
|
||||||
|
|
||||||
std::unordered_set<std::wstring> m_Groups;
|
std::unordered_set<std::wstring> m_Groups;
|
||||||
std::wstring m_OldGroups;
|
std::wstring m_OldGroups;
|
||||||
|
@ -436,6 +436,7 @@
|
|||||||
<ClInclude Include="RainmeterQuery.h" />
|
<ClInclude Include="RainmeterQuery.h" />
|
||||||
<ClInclude Include="RawString.h" />
|
<ClInclude Include="RawString.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="Section.h" />
|
||||||
<ClInclude Include="StdAfx.h" />
|
<ClInclude Include="StdAfx.h" />
|
||||||
<ClInclude Include="System.h" />
|
<ClInclude Include="System.h" />
|
||||||
<ClInclude Include="TintedImage.h" />
|
<ClInclude Include="TintedImage.h" />
|
||||||
|
@ -551,6 +551,9 @@
|
|||||||
<ClInclude Include="Mouse.h">
|
<ClInclude Include="Mouse.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Section.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="Library.rc">
|
<ResourceCompile Include="Library.rc">
|
||||||
|
@ -69,8 +69,7 @@ extern CRainmeter* Rainmeter;
|
|||||||
** The constructor
|
** The constructor
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(meterWindow), m_Name(name),
|
CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : CSection(name), m_MeterWindow(meterWindow),
|
||||||
m_DynamicVariables(false),
|
|
||||||
m_Invert(false),
|
m_Invert(false),
|
||||||
m_LogMaxValue(false),
|
m_LogMaxValue(false),
|
||||||
m_MinValue(),
|
m_MinValue(),
|
||||||
@ -87,8 +86,6 @@ CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow
|
|||||||
m_IfAboveCommitted(false),
|
m_IfAboveCommitted(false),
|
||||||
m_IfBelowCommitted(false),
|
m_IfBelowCommitted(false),
|
||||||
m_Disabled(false),
|
m_Disabled(false),
|
||||||
m_UpdateDivider(1),
|
|
||||||
m_UpdateCounter(1),
|
|
||||||
m_Initialized(false)
|
m_Initialized(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Litestep.h"
|
#include "Litestep.h"
|
||||||
#include "Group.h"
|
#include "Section.h"
|
||||||
|
|
||||||
enum AUTOSCALE
|
enum AUTOSCALE
|
||||||
{
|
{
|
||||||
@ -41,29 +41,20 @@ class CMeter;
|
|||||||
class CMeterWindow;
|
class CMeterWindow;
|
||||||
class CConfigParser;
|
class CConfigParser;
|
||||||
|
|
||||||
class CMeasure : public CGroup
|
class CMeasure : public CSection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMeasure(CMeterWindow* meterWindow, const WCHAR* name);
|
|
||||||
virtual ~CMeasure();
|
virtual ~CMeasure();
|
||||||
|
|
||||||
virtual UINT GetTypeID() = 0;
|
|
||||||
|
|
||||||
void ReadOptions(CConfigParser& parser) { ReadOptions(parser, GetName()); }
|
void ReadOptions(CConfigParser& parser) { ReadOptions(parser, GetName()); }
|
||||||
|
|
||||||
virtual void Initialize();
|
virtual void Initialize();
|
||||||
bool Update();
|
bool Update();
|
||||||
|
|
||||||
const WCHAR* GetName() { return m_Name.c_str(); }
|
|
||||||
const std::wstring& GetOriginalName() { return m_Name; }
|
|
||||||
|
|
||||||
void Disable();
|
void Disable();
|
||||||
void Enable();
|
void Enable();
|
||||||
bool IsDisabled() { return m_Disabled; }
|
bool IsDisabled() { return m_Disabled; }
|
||||||
|
|
||||||
bool HasDynamicVariables() { return m_DynamicVariables; }
|
|
||||||
void SetDynamicVariables(bool b) { m_DynamicVariables = b; }
|
|
||||||
|
|
||||||
virtual void Command(const std::wstring& command);
|
virtual void Command(const std::wstring& command);
|
||||||
|
|
||||||
double GetValue();
|
double GetValue();
|
||||||
@ -72,10 +63,6 @@ public:
|
|||||||
double GetMinValue() { return m_MinValue; }
|
double GetMinValue() { return m_MinValue; }
|
||||||
double GetMaxValue() { return m_MaxValue; }
|
double GetMaxValue() { return m_MaxValue; }
|
||||||
|
|
||||||
void ResetUpdateCounter() { m_UpdateCounter = m_UpdateDivider; }
|
|
||||||
int GetUpdateCounter() { return m_UpdateCounter; }
|
|
||||||
int GetUpdateDivider() { return m_UpdateDivider; }
|
|
||||||
|
|
||||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
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 void GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue, WCHAR* buffer, size_t sizeInWords);
|
||||||
static void RemoveTrailingZero(WCHAR* str, int strLen);
|
static void RemoveTrailingZero(WCHAR* str, int strLen);
|
||||||
@ -85,6 +72,8 @@ public:
|
|||||||
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
|
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
CMeasure(CMeterWindow* meterWindow, const WCHAR* name);
|
||||||
|
|
||||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||||
virtual void UpdateValue() = 0;
|
virtual void UpdateValue() = 0;
|
||||||
|
|
||||||
@ -93,13 +82,11 @@ protected:
|
|||||||
const WCHAR* CheckSubstitute(const WCHAR* buffer);
|
const WCHAR* CheckSubstitute(const WCHAR* buffer);
|
||||||
bool MakePlainSubstitute(std::wstring& str, size_t index);
|
bool MakePlainSubstitute(std::wstring& str, size_t index);
|
||||||
|
|
||||||
bool m_DynamicVariables; // If true, the measure contains dynamic variables
|
|
||||||
bool m_Invert; // If true, the value should be inverted
|
bool m_Invert; // If true, the value should be inverted
|
||||||
bool m_LogMaxValue; // If true, The maximum & minimum values are logged
|
bool m_LogMaxValue; // If true, The maximum & minimum values are logged
|
||||||
double m_MinValue; // The minimum value (so far)
|
double m_MinValue; // The minimum value (so far)
|
||||||
double m_MaxValue; // The maximum value (so far)
|
double m_MaxValue; // The maximum value (so far)
|
||||||
double m_Value; // The current value
|
double m_Value; // The current value
|
||||||
const std::wstring m_Name; // Name of this Measure
|
|
||||||
|
|
||||||
std::vector<std::wstring> m_Substitute; // Vec of substitute strings
|
std::vector<std::wstring> m_Substitute; // Vec of substitute strings
|
||||||
bool m_RegExpSubstitute;
|
bool m_RegExpSubstitute;
|
||||||
@ -122,8 +109,6 @@ protected:
|
|||||||
bool m_IfAboveCommitted; // True when the IfAbove action is executed
|
bool m_IfAboveCommitted; // True when the IfAbove action is executed
|
||||||
bool m_IfBelowCommitted; // True when the IfBelow action is executed
|
bool m_IfBelowCommitted; // True when the IfBelow action is executed
|
||||||
bool m_Disabled; // Status of the measure
|
bool m_Disabled; // Status of the measure
|
||||||
int m_UpdateDivider; // Divider for the update
|
|
||||||
int m_UpdateCounter; // Current update counter
|
|
||||||
bool m_Initialized;
|
bool m_Initialized;
|
||||||
|
|
||||||
CMeterWindow* m_MeterWindow;
|
CMeterWindow* m_MeterWindow;
|
||||||
|
@ -39,7 +39,7 @@ extern CRainmeter* Rainmeter;
|
|||||||
** The constructor
|
** The constructor
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(meterWindow), m_Name(name),
|
CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : CSection(name), m_MeterWindow(meterWindow),
|
||||||
m_X(),
|
m_X(),
|
||||||
m_Y(),
|
m_Y(),
|
||||||
m_W(0),
|
m_W(0),
|
||||||
@ -48,7 +48,6 @@ CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(met
|
|||||||
m_WDefined(false),
|
m_WDefined(false),
|
||||||
m_HDefined(false),
|
m_HDefined(false),
|
||||||
m_RelativeMeter(),
|
m_RelativeMeter(),
|
||||||
m_DynamicVariables(false),
|
|
||||||
m_Transformation(),
|
m_Transformation(),
|
||||||
m_ToolTipWidth(),
|
m_ToolTipWidth(),
|
||||||
m_ToolTipType(false),
|
m_ToolTipType(false),
|
||||||
@ -58,8 +57,6 @@ CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(met
|
|||||||
m_MouseOver(false),
|
m_MouseOver(false),
|
||||||
m_RelativeX(POSITION_ABSOLUTE),
|
m_RelativeX(POSITION_ABSOLUTE),
|
||||||
m_RelativeY(POSITION_ABSOLUTE),
|
m_RelativeY(POSITION_ABSOLUTE),
|
||||||
m_UpdateDivider(1),
|
|
||||||
m_UpdateCounter(1),
|
|
||||||
m_SolidBevel(BEVELTYPE_NONE),
|
m_SolidBevel(BEVELTYPE_NONE),
|
||||||
m_SolidAngle(),
|
m_SolidAngle(),
|
||||||
m_AntiAlias(false),
|
m_AntiAlias(false),
|
||||||
|
@ -26,28 +26,22 @@
|
|||||||
#include "Litestep.h"
|
#include "Litestep.h"
|
||||||
#include "ConfigParser.h"
|
#include "ConfigParser.h"
|
||||||
#include "MeterWindow.h"
|
#include "MeterWindow.h"
|
||||||
|
#include "Section.h"
|
||||||
#include "Measure.h"
|
#include "Measure.h"
|
||||||
#include "Group.h"
|
|
||||||
|
|
||||||
class CMeasure;
|
class CMeasure;
|
||||||
|
|
||||||
class CMeter : public CGroup
|
class CMeter : public CSection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMeter(CMeterWindow* meterWindow, const WCHAR* name);
|
|
||||||
virtual ~CMeter();
|
virtual ~CMeter();
|
||||||
|
|
||||||
virtual UINT GetTypeID() = 0;
|
|
||||||
|
|
||||||
void ReadOptions(CConfigParser& parser) { ReadOptions(parser, GetName()); parser.ClearStyleTemplate(); }
|
void ReadOptions(CConfigParser& parser) { ReadOptions(parser, GetName()); parser.ClearStyleTemplate(); }
|
||||||
|
|
||||||
virtual void Initialize();
|
virtual void Initialize();
|
||||||
virtual bool Update();
|
virtual bool Update();
|
||||||
virtual bool Draw(Gdiplus::Graphics& graphics);
|
virtual bool Draw(Gdiplus::Graphics& graphics);
|
||||||
virtual bool HasActiveTransition() { return false; }
|
virtual bool HasActiveTransition() { return false; }
|
||||||
|
|
||||||
bool HasDynamicVariables() { return m_DynamicVariables; }
|
|
||||||
void SetDynamicVariables(bool b) { m_DynamicVariables = b; }
|
|
||||||
|
|
||||||
virtual int GetW() { return m_Hidden ? 0 : m_W; }
|
virtual int GetW() { return m_Hidden ? 0 : m_W; }
|
||||||
virtual int GetH() { return m_Hidden ? 0 : m_H; }
|
virtual int GetH() { return m_Hidden ? 0 : m_H; }
|
||||||
@ -82,13 +76,6 @@ public:
|
|||||||
void SetMouseOver(bool over) { m_MouseOver = over; }
|
void SetMouseOver(bool over) { m_MouseOver = over; }
|
||||||
bool IsMouseOver() { return m_MouseOver; }
|
bool IsMouseOver() { return m_MouseOver; }
|
||||||
|
|
||||||
const WCHAR* GetName() { return m_Name.c_str(); }
|
|
||||||
const std::wstring& GetOriginalName() { return m_Name; }
|
|
||||||
|
|
||||||
void ResetUpdateCounter() { m_UpdateCounter = m_UpdateDivider; }
|
|
||||||
int GetUpdateCounter() { return m_UpdateCounter; }
|
|
||||||
int GetUpdateDivider() { return m_UpdateDivider; }
|
|
||||||
|
|
||||||
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
|
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
|
||||||
|
|
||||||
static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name);
|
static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name);
|
||||||
@ -117,6 +104,8 @@ protected:
|
|||||||
POSITION_RELATIVE_BR
|
POSITION_RELATIVE_BR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CMeter(CMeterWindow* meterWindow, const WCHAR* name);
|
||||||
|
|
||||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||||
virtual void BindMeasures(CConfigParser& parser, const WCHAR* section);
|
virtual void BindMeasures(CConfigParser& parser, const WCHAR* section);
|
||||||
|
|
||||||
@ -127,7 +116,6 @@ protected:
|
|||||||
|
|
||||||
bool ReplaceMeasures(std::wstring& str, AUTOSCALE autoScale = AUTOSCALE_ON, double scale = 1.0, int decimals = 0, bool percentual = false);
|
bool ReplaceMeasures(std::wstring& str, AUTOSCALE autoScale = AUTOSCALE_ON, double scale = 1.0, int decimals = 0, bool percentual = false);
|
||||||
|
|
||||||
const std::wstring m_Name;
|
|
||||||
std::vector<CMeasure*> m_Measures;
|
std::vector<CMeasure*> m_Measures;
|
||||||
int m_X;
|
int m_X;
|
||||||
int m_Y;
|
int m_Y;
|
||||||
@ -137,7 +125,6 @@ protected:
|
|||||||
bool m_WDefined;
|
bool m_WDefined;
|
||||||
bool m_HDefined;
|
bool m_HDefined;
|
||||||
CMeter* m_RelativeMeter;
|
CMeter* m_RelativeMeter;
|
||||||
bool m_DynamicVariables;
|
|
||||||
|
|
||||||
Gdiplus::Matrix* m_Transformation;
|
Gdiplus::Matrix* m_Transformation;
|
||||||
|
|
||||||
@ -157,9 +144,6 @@ protected:
|
|||||||
METER_POSITION m_RelativeX;
|
METER_POSITION m_RelativeX;
|
||||||
METER_POSITION m_RelativeY;
|
METER_POSITION m_RelativeY;
|
||||||
|
|
||||||
int m_UpdateDivider;
|
|
||||||
int m_UpdateCounter;
|
|
||||||
|
|
||||||
BEVELTYPE m_SolidBevel;
|
BEVELTYPE m_SolidBevel;
|
||||||
Gdiplus::Color m_SolidColor;
|
Gdiplus::Color m_SolidColor;
|
||||||
Gdiplus::Color m_SolidColor2;
|
Gdiplus::Color m_SolidColor2;
|
||||||
|
@ -935,16 +935,6 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const std::vector<std::wstring>& ar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** This is a helper template that compares the given name to measure/meter's name.
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
bool CompareName(T* m, const WCHAR* name, bool group)
|
|
||||||
{
|
|
||||||
return (group) ? m->BelongsToGroup(name) : (_wcsicmp(m->GetName(), name) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Enables blurring of the window background (using Aero)
|
** Enables blurring of the window background (using Aero)
|
||||||
**
|
**
|
||||||
@ -1074,6 +1064,15 @@ void CMeterWindow::ResizeBlur(const std::wstring& arg, int mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Helper function that compares the given name to section's name.
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
bool CompareName(const CSection* section, const WCHAR* name, bool group)
|
||||||
|
{
|
||||||
|
return (group) ? section->BelongsToGroup(name) : (_wcsicmp(section->GetName(), name) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Shows the given meter
|
** Shows the given meter
|
||||||
**
|
**
|
||||||
|
53
Library/Section.h
Normal file
53
Library/Section.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2012 spx
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SECTION_H__
|
||||||
|
#define __SECTION_H__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <string>
|
||||||
|
#include "Group.h"
|
||||||
|
|
||||||
|
class CSection : public CGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~CSection() {};
|
||||||
|
|
||||||
|
virtual UINT GetTypeID() = 0;
|
||||||
|
|
||||||
|
const WCHAR* GetName() const { return m_Name.c_str(); }
|
||||||
|
const std::wstring& GetOriginalName() const { return m_Name; }
|
||||||
|
|
||||||
|
bool HasDynamicVariables() const { return m_DynamicVariables; }
|
||||||
|
void SetDynamicVariables(bool b) { m_DynamicVariables = b; }
|
||||||
|
|
||||||
|
void ResetUpdateCounter() { m_UpdateCounter = m_UpdateDivider; }
|
||||||
|
int GetUpdateCounter() const { return m_UpdateCounter; }
|
||||||
|
int GetUpdateDivider() const { return m_UpdateDivider; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CSection(const WCHAR* name) : m_Name(name), m_DynamicVariables(false), m_UpdateDivider(1), m_UpdateCounter(1) {}
|
||||||
|
|
||||||
|
const std::wstring m_Name; // Name of this Section
|
||||||
|
|
||||||
|
bool m_DynamicVariables; // If true, the section contains dynamic variables
|
||||||
|
int m_UpdateDivider; // Divider for the update
|
||||||
|
int m_UpdateCounter; // Current update counter
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user