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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __METERSTRING_H__
|
|
|
|
#define __METERSTRING_H__
|
|
|
|
|
|
|
|
#include "Meter.h"
|
2011-01-19 15:31:45 +00:00
|
|
|
#include "Measure.h"
|
2011-02-18 16:26:58 +00:00
|
|
|
#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();
|
|
|
|
|
|
|
|
virtual int GetX(bool abs = false);
|
|
|
|
|
|
|
|
virtual void Initialize();
|
|
|
|
virtual bool Update();
|
2010-12-12 17:08:36 +00:00
|
|
|
void SetText(const WCHAR* text) { m_Text = text; }
|
2009-07-27 11:48:57 +00:00
|
|
|
virtual bool Draw(Gdiplus::Graphics& graphics);
|
2010-11-19 07:33:58 +00:00
|
|
|
virtual void BindMeasure(const std::list<CMeasure*>& measures);
|
2010-12-12 17:08:36 +00:00
|
|
|
Gdiplus::RectF GetRect() { return m_Rect; }
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-01-17 22:39:40 +00:00
|
|
|
static void FreeFontCache(Gdiplus::PrivateFontCollection* collection = NULL);
|
2010-03-20 19:40:30 +00:00
|
|
|
static void EnumerateInstalledFontFamilies();
|
2009-10-07 16:45:14 +00:00
|
|
|
|
2011-11-26 02:49:52 +00:00
|
|
|
protected:
|
|
|
|
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
private:
|
|
|
|
enum TEXTSTYLE
|
|
|
|
{
|
|
|
|
NORMAL,
|
|
|
|
BOLD,
|
|
|
|
ITALIC,
|
|
|
|
BOLDITALIC
|
|
|
|
};
|
|
|
|
|
2009-07-29 12:54:05 +00:00
|
|
|
enum TEXTEFFECT
|
|
|
|
{
|
|
|
|
EFFECT_NONE,
|
|
|
|
EFFECT_SHADOW,
|
|
|
|
EFFECT_BORDER
|
|
|
|
};
|
|
|
|
|
2010-03-18 19:48:14 +00:00
|
|
|
enum TEXTCASE
|
|
|
|
{
|
|
|
|
TEXTCASE_NONE,
|
|
|
|
TEXTCASE_UPPER,
|
|
|
|
TEXTCASE_LOWER,
|
2011-01-24 10:15:05 +00:00
|
|
|
TEXTCASE_PROPER
|
2010-03-18 19:48:14 +00:00
|
|
|
};
|
|
|
|
|
2009-07-27 11:48:57 +00:00
|
|
|
bool DrawString(Gdiplus::Graphics& graphics, Gdiplus::RectF* rect);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-03-18 19:48:14 +00:00
|
|
|
Gdiplus::Color m_Color; // The color of the text
|
2009-07-29 12:54:05 +00:00
|
|
|
Gdiplus::Color m_EffectColor; // The color of the text effect
|
2010-03-18 19:48:14 +00:00
|
|
|
std::wstring m_Postfix; // The postfix of the text
|
|
|
|
std::wstring m_Prefix; // The prefix of the text
|
|
|
|
std::wstring m_Text; // The text
|
|
|
|
std::wstring m_FontFace; // name of the font face
|
2011-01-19 15:31:45 +00:00
|
|
|
AUTOSCALE m_AutoScale; // true, if the value should be autoscaled
|
2010-03-18 19:48:14 +00:00
|
|
|
METER_ALIGNMENT m_Align; // Alignment of the text
|
|
|
|
TEXTSTYLE m_Style; // Style of the text
|
|
|
|
TEXTEFFECT m_Effect; // Text effect
|
|
|
|
TEXTCASE m_textCase; // Case of the text
|
|
|
|
int m_FontSize; // Size of the fonts
|
|
|
|
double m_Scale; // Scaling if autoscale is not used
|
|
|
|
bool m_NoDecimals; // Number of decimals to use
|
|
|
|
bool m_Percentual; // True, if the value should be given as %
|
|
|
|
bool m_ClipString; // True, the text is clipped in borders (adds ellipsis to the end of the string)
|
|
|
|
Gdiplus::Font* m_Font; // The font
|
|
|
|
Gdiplus::FontFamily* m_FontFamily; // The font family
|
|
|
|
int m_NumOfDecimals; // Number of decimals to be displayed
|
2009-02-10 18:37:48 +00:00
|
|
|
Gdiplus::REAL m_Angle;
|
2010-12-12 17:08:36 +00:00
|
|
|
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;
|
2009-10-07 16:45:14 +00:00
|
|
|
|
2011-01-17 22:39:40 +00:00
|
|
|
static std::wstring FontFaceToString(const std::wstring& fontFace, Gdiplus::PrivateFontCollection* collection);
|
|
|
|
static std::wstring FontPropertiesToString(Gdiplus::REAL size, Gdiplus::FontStyle style);
|
|
|
|
|
2011-02-18 16:26:58 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
/*
|
|
|
|
E eksa 10^18
|
|
|
|
P peta 10^15
|
|
|
|
T tera 10^12
|
|
|
|
G giga 10^9
|
|
|
|
M mega 10^6
|
|
|
|
k kilo 10^3
|
|
|
|
*/
|