rainmeter-studio/Library/MeterString.h

111 lines
3.0 KiB
C
Raw Normal View History

2009-02-10 18:37:48 +00:00
/*
Copyright (C) 2001 Kimmo Pekkola
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.
2009-02-10 18:37:48 +00:00
*/
#ifndef __METERSTRING_H__
#define __METERSTRING_H__
#include "Meter.h"
#include "Measure.h"
#include <unordered_map>
2010-09-21 22:47:53 +00:00
2009-02-10 18:37:48 +00:00
class CMeterString : public CMeter
{
public:
2011-02-15 16:26:54 +00:00
CMeterString(CMeterWindow* meterWindow, const WCHAR* name);
2009-02-10 18:37:48 +00:00
virtual ~CMeterString();
2012-04-09 16:45:54 +00:00
virtual UINT GetTypeID() { return TypeID<CMeterString>(); }
2009-02-10 18:37:48 +00:00
virtual int GetX(bool abs = false);
virtual int GetY(bool abs = false);
2009-02-10 18:37:48 +00:00
virtual void Initialize();
virtual bool Update();
void SetText(const WCHAR* text) { m_Text = text; }
virtual bool Draw(Gdiplus::Graphics& graphics);
virtual void BindMeasure(const std::list<CMeasure*>& measures);
Gdiplus::RectF GetRect() { return m_Rect; }
2009-02-10 18:37:48 +00:00
static void FreeFontCache(Gdiplus::PrivateFontCollection* collection = NULL);
static void EnumerateInstalledFontFamilies();
protected:
2012-05-30 18:53:44 +00:00
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
2009-02-10 18:37:48 +00:00
private:
enum TEXTSTYLE
{
NORMAL,
BOLD,
ITALIC,
BOLDITALIC
};
enum TEXTEFFECT
{
EFFECT_NONE,
EFFECT_SHADOW,
EFFECT_BORDER
};
enum TEXTCASE
{
TEXTCASE_NONE,
TEXTCASE_UPPER,
TEXTCASE_LOWER,
2011-01-24 10:15:05 +00:00
TEXTCASE_PROPER
};
bool DrawString(Gdiplus::Graphics& graphics, Gdiplus::RectF* rect);
2009-02-10 18:37:48 +00:00
2012-05-20 17:57:12 +00:00
Gdiplus::Color m_Color;
Gdiplus::Color m_EffectColor;
2012-07-03 13:57:46 +00:00
std::wstring m_Postfix;
std::wstring m_Prefix;
2012-05-20 17:57:12 +00:00
std::wstring m_Text;
std::wstring m_FontFace;
AUTOSCALE m_AutoScale;
METER_ALIGNMENT m_Align;
TEXTSTYLE m_Style;
TEXTEFFECT m_Effect;
TEXTCASE m_Case;
int m_FontSize;
double m_Scale;
bool m_NoDecimals;
bool m_Percentual;
bool m_ClipString;
Gdiplus::Font* m_Font;
Gdiplus::FontFamily* m_FontFamily;
int m_NumOfDecimals;
2009-02-10 18:37:48 +00:00
Gdiplus::REAL m_Angle;
Gdiplus::RectF m_Rect;
2009-02-10 18:37:48 +00:00
std::wstring m_String;
std::vector<std::wstring> m_MeasureNames;
std::vector<CMeasure*> m_Measures;
static std::wstring FontFaceToString(const std::wstring& fontFace, Gdiplus::PrivateFontCollection* collection);
static std::wstring FontPropertiesToString(Gdiplus::REAL size, Gdiplus::FontStyle style);
static std::unordered_map<std::wstring, Gdiplus::FontFamily*> c_FontFamilies; // Cache for the font families
static std::unordered_map<std::wstring, Gdiplus::Font*> c_Fonts; // Cache for the fonts
2009-02-10 18:37:48 +00:00
};
#endif