mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
String meter supports now shadow and border effects.
This commit is contained in:
parent
1ec9e90265
commit
8563915b4b
@ -35,6 +35,8 @@ using namespace Gdiplus;
|
||||
CMeterString::CMeterString(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_Color = RGB(255, 255, 255);
|
||||
m_EffectColor = RGB(0, 0, 0);
|
||||
m_Effect = EFFECT_NONE;
|
||||
m_AutoScale = true;
|
||||
m_Align = ALIGN_LEFT;
|
||||
m_Font = NULL;
|
||||
@ -186,6 +188,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
} while(loop);
|
||||
|
||||
m_Color = parser.ReadColor(section, L"FontColor", Color::Black);
|
||||
m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black);
|
||||
|
||||
m_Prefix = parser.ReadString(section, L"Prefix", L"");
|
||||
m_Postfix = parser.ReadString(section, L"Postfix", L"");
|
||||
@ -259,6 +262,26 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
throw CError(std::wstring(L"No such StringStyle: ") + style, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
std::wstring effect;
|
||||
effect = parser.ReadString(section, L"StringEffect", L"NONE");
|
||||
|
||||
if(_wcsicmp(effect.c_str(), L"NONE") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_NONE;
|
||||
}
|
||||
else if(_wcsicmp(effect.c_str(), L"SHADOW") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_SHADOW;
|
||||
}
|
||||
else if(_wcsicmp(effect.c_str(), L"BORDER") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_BORDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw CError(std::wstring(L"No such StringEffect: ") + effect, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
if (-1 != parser.ReadInt(section, L"W", -1) && -1 != parser.ReadInt(section, L"H", -1))
|
||||
{
|
||||
m_DimensionsDefined = true;
|
||||
@ -398,7 +421,6 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
|
||||
else
|
||||
{
|
||||
RectF rc((REAL)x, (REAL)y, (REAL)m_W, (REAL)m_H);
|
||||
SolidBrush solidBrush(m_Color);
|
||||
|
||||
if (m_ClipString)
|
||||
{
|
||||
@ -415,6 +437,28 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
|
||||
graphics.RotateTransform(angle);
|
||||
graphics.TranslateTransform(-(Gdiplus::REAL)CMeter::GetX(), -y);
|
||||
|
||||
if (m_Effect == EFFECT_SHADOW)
|
||||
{
|
||||
SolidBrush solidBrush(m_EffectColor);
|
||||
RectF rcEffect(rc);
|
||||
rcEffect.Offset(1, 1);
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
}
|
||||
else if (m_Effect == EFFECT_BORDER)
|
||||
{
|
||||
SolidBrush solidBrush(m_EffectColor);
|
||||
RectF rcEffect(rc);
|
||||
rcEffect.Offset(0, 1);
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
rcEffect.Offset(1, -1);
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
rcEffect.Offset(-1, -1);
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
rcEffect.Offset(-1, 1);
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rcEffect, &stringFormat, &solidBrush);
|
||||
}
|
||||
|
||||
SolidBrush solidBrush(m_Color);
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rc, &stringFormat, &solidBrush);
|
||||
|
||||
graphics.ResetTransform();
|
||||
|
@ -49,9 +49,17 @@ private:
|
||||
BOLDITALIC
|
||||
};
|
||||
|
||||
enum TEXTEFFECT
|
||||
{
|
||||
EFFECT_NONE,
|
||||
EFFECT_SHADOW,
|
||||
EFFECT_BORDER
|
||||
};
|
||||
|
||||
bool DrawString(Gdiplus::Graphics& graphics, Gdiplus::RectF* rect);
|
||||
|
||||
Gdiplus::Color m_Color; // The color of the text
|
||||
Gdiplus::Color m_EffectColor; // The color of the text effect
|
||||
std::wstring m_Postfix; // The postfix of the text
|
||||
std::wstring m_Prefix; // The prefix of the text
|
||||
std::wstring m_Text; // The text
|
||||
@ -59,6 +67,7 @@ private:
|
||||
bool m_AutoScale; // true, if the value should be autoscaled
|
||||
METER_ALIGNMENT m_Align; // Alignment of the text
|
||||
TEXTSTYLE m_Style; // Style of the text
|
||||
TEXTEFFECT m_Effect; // Text effect
|
||||
int m_FontSize; // Size of the fonts
|
||||
double m_Scale; // Scaling if autoscale is not used
|
||||
bool m_NoDecimals; // Number of decimals to use
|
||||
|
Loading…
Reference in New Issue
Block a user