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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
2009-10-07 16:45:14 +00:00
|
|
|
#include "StdAfx.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "Error.h"
|
|
|
|
#include "Meter.h"
|
|
|
|
#include "MeterBitmap.h"
|
|
|
|
#include "MeterBar.h"
|
|
|
|
#include "MeterHistogram.h"
|
|
|
|
#include "MeterString.h"
|
|
|
|
#include "MeterImage.h"
|
|
|
|
#include "MeterLine.h"
|
|
|
|
#include "MeterRoundLine.h"
|
|
|
|
#include "MeterRotator.h"
|
|
|
|
#include "MeterButton.h"
|
|
|
|
#include "Measure.h"
|
|
|
|
#include "Rainmeter.h"
|
2013-03-25 15:42:18 +00:00
|
|
|
#include "../Common/Gfx/Canvas.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
using namespace Gdiplus;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The constructor
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
Meter::Meter(MeterWindow* meterWindow, const WCHAR* name) : Section(meterWindow, name),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_X(),
|
|
|
|
m_Y(),
|
2012-08-01 17:52:50 +00:00
|
|
|
m_W(0),
|
|
|
|
m_H(0),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_Hidden(false),
|
2011-11-01 04:56:46 +00:00
|
|
|
m_WDefined(false),
|
|
|
|
m_HDefined(false),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_RelativeMeter(),
|
2011-11-04 12:48:03 +00:00
|
|
|
m_Transformation(),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_ToolTipWidth(),
|
|
|
|
m_ToolTipType(false),
|
2011-11-08 10:32:57 +00:00
|
|
|
m_ToolTipHidden(meterWindow->GetMeterToolTipHidden()),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_ToolTipHandle(),
|
2013-01-16 10:23:42 +00:00
|
|
|
m_Mouse(meterWindow, this),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_HasMouseAction(false),
|
|
|
|
m_MouseOver(false),
|
|
|
|
m_RelativeX(POSITION_ABSOLUTE),
|
|
|
|
m_RelativeY(POSITION_ABSOLUTE),
|
|
|
|
m_SolidBevel(BEVELTYPE_NONE),
|
|
|
|
m_SolidAngle(),
|
|
|
|
m_AntiAlias(false),
|
|
|
|
m_Initialized(false)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The destructor
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
Meter::~Meter()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-04 12:48:03 +00:00
|
|
|
delete m_Transformation;
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
if (m_ToolTipHandle != nullptr)
|
2010-10-19 22:03:32 +00:00
|
|
|
{
|
|
|
|
DestroyWindow(m_ToolTipHandle);
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-17 14:47:34 +00:00
|
|
|
** Initializes the meter. Usually this method is overwritten by the inherited
|
|
|
|
** classes, which load bitmaps and such things during initialization.
|
2009-02-10 18:37:48 +00:00
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::Initialize()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2009-08-27 17:05:10 +00:00
|
|
|
m_Initialized = true;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Returns the X-position of the meter.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
int Meter::GetX(bool abs)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 14:47:34 +00:00
|
|
|
if (m_RelativeX != POSITION_ABSOLUTE && m_RelativeMeter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 14:47:34 +00:00
|
|
|
if (m_RelativeX == POSITION_RELATIVE_TL)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 14:47:34 +00:00
|
|
|
return m_RelativeMeter->GetX(true) + m_X;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-17 14:47:34 +00:00
|
|
|
return m_RelativeMeter->GetX(true) + m_RelativeMeter->GetW() + m_X;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
return m_X;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Returns the Y-position of the meter.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
int Meter::GetY(bool abs)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 14:47:34 +00:00
|
|
|
if (m_RelativeY != POSITION_ABSOLUTE && m_RelativeMeter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 14:47:34 +00:00
|
|
|
if (m_RelativeY == POSITION_RELATIVE_TL)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-08-13 05:42:50 +00:00
|
|
|
return m_RelativeMeter->GetY(true) + m_Y;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-13 05:42:50 +00:00
|
|
|
return m_RelativeMeter->GetY(true) + m_RelativeMeter->GetH() + m_Y;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
return m_Y;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::SetX(int x)
|
2012-07-17 18:19:03 +00:00
|
|
|
{
|
|
|
|
m_X = x;
|
|
|
|
m_RelativeX = POSITION_ABSOLUTE;
|
|
|
|
|
|
|
|
// Change the option as well to avoid reset in ReadOptions().
|
|
|
|
WCHAR buffer[32];
|
|
|
|
_itow_s(x, buffer, 10);
|
|
|
|
m_MeterWindow->GetParser().SetValue(m_Name, L"X", buffer);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::SetY(int y)
|
2012-07-17 18:19:03 +00:00
|
|
|
{
|
|
|
|
m_Y = y;
|
|
|
|
m_RelativeY = POSITION_ABSOLUTE;
|
|
|
|
|
|
|
|
// Change the option as well to avoid reset in ReadOptions().
|
|
|
|
WCHAR buffer[32];
|
|
|
|
_itow_s(y, buffer, 10);
|
|
|
|
m_MeterWindow->GetParser().SetValue(m_Name, L"Y", buffer);
|
|
|
|
}
|
|
|
|
|
2010-07-17 00:06:24 +00:00
|
|
|
/*
|
|
|
|
** Returns a RECT containing the dimensions of the meter within the MeterWindow
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
RECT Meter::GetMeterRect()
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
|
|
|
RECT meterRect;
|
|
|
|
|
|
|
|
meterRect.left = GetX();
|
|
|
|
meterRect.top = GetY();
|
2010-10-19 22:03:32 +00:00
|
|
|
meterRect.right = meterRect.left + m_W;
|
|
|
|
meterRect.bottom = meterRect.top + m_H;
|
2010-07-17 00:06:24 +00:00
|
|
|
|
|
|
|
return meterRect;
|
|
|
|
}
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
** Checks if the given point is inside the meter.
|
2013-02-06 10:12:16 +00:00
|
|
|
** This function doesn't check Hidden state, so check it before calling this function if needed.
|
2009-02-10 18:37:48 +00:00
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool Meter::HitTest(int x, int y)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-02-06 10:12:16 +00:00
|
|
|
int p;
|
|
|
|
return (x >= (p = GetX()) && x < p + m_W && y >= (p = GetY()) && y < p + m_H);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 22:03:32 +00:00
|
|
|
/*
|
|
|
|
** Shows the meter and tooltip.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::Show()
|
2010-10-19 22:03:32 +00:00
|
|
|
{
|
|
|
|
m_Hidden = false;
|
|
|
|
|
2012-07-17 18:19:03 +00:00
|
|
|
// Change the option as well to avoid reset in ReadOptions().
|
|
|
|
m_MeterWindow->GetParser().SetValue(m_Name, L"Hidden", L"0");
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
if (m_ToolTipHandle != nullptr)
|
2010-10-19 22:03:32 +00:00
|
|
|
{
|
|
|
|
if (!m_ToolTipHidden)
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(m_ToolTipHandle, TTM_ACTIVATE, TRUE, 0);
|
2010-10-19 22:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Hides the meter and tooltip.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::Hide()
|
2010-10-19 22:03:32 +00:00
|
|
|
{
|
|
|
|
m_Hidden = true;
|
|
|
|
|
2012-07-17 18:19:03 +00:00
|
|
|
// Change the option as well to avoid reset in ReadOptions().
|
|
|
|
m_MeterWindow->GetParser().SetValue(m_Name, L"Hidden", L"1");
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
if (m_ToolTipHandle != nullptr)
|
2010-10-19 22:03:32 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(m_ToolTipHandle, TTM_ACTIVATE, FALSE, 0);
|
2010-10-19 22:03:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
/*
|
2012-06-01 13:06:36 +00:00
|
|
|
** Read the common options specified in the ini file. The inherited classes must
|
|
|
|
** call this base implementation if they overwrite this method.
|
2009-02-10 18:37:48 +00:00
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::ReadOptions(ConfigParser& parser, const WCHAR* section)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2009-09-04 17:40:02 +00:00
|
|
|
// The MeterStyle defines a template where the values are read if the meter doesn't have it itself
|
|
|
|
const std::wstring& style = parser.ReadString(section, L"MeterStyle", L"");
|
2010-05-31 21:02:04 +00:00
|
|
|
if (!style.empty())
|
|
|
|
{
|
|
|
|
parser.SetStyleTemplate(style);
|
|
|
|
}
|
2009-09-04 17:40:02 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Section::ReadOptions(parser, section);
|
2013-02-06 10:12:16 +00:00
|
|
|
|
2012-07-18 14:55:32 +00:00
|
|
|
BindMeasures(parser, section);
|
2012-07-18 05:19:01 +00:00
|
|
|
|
2012-07-17 19:15:06 +00:00
|
|
|
int oldX = m_X;
|
2012-07-17 18:19:03 +00:00
|
|
|
std::wstring& x = (std::wstring&)parser.ReadString(section, L"X", L"0");
|
|
|
|
if (!x.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 18:19:03 +00:00
|
|
|
WCHAR lastChar = x[x.size() - 1];
|
|
|
|
if (lastChar == L'r')
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 18:19:03 +00:00
|
|
|
m_RelativeX = POSITION_RELATIVE_TL;
|
|
|
|
x.pop_back();
|
|
|
|
}
|
|
|
|
else if (lastChar == L'R')
|
|
|
|
{
|
|
|
|
m_RelativeX = POSITION_RELATIVE_BR;
|
|
|
|
x.pop_back();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2009-07-30 15:19:47 +00:00
|
|
|
else
|
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
m_RelativeX = POSITION_ABSOLUTE;
|
2009-07-30 15:19:47 +00:00
|
|
|
}
|
2012-07-17 18:19:03 +00:00
|
|
|
|
|
|
|
m_X = parser.ParseInt(x.c_str(), 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_X = 0;
|
|
|
|
m_RelativeX = POSITION_ABSOLUTE;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 19:15:06 +00:00
|
|
|
int oldY = m_Y;
|
2012-07-17 18:19:03 +00:00
|
|
|
std::wstring& y = (std::wstring&)parser.ReadString(section, L"Y", L"0");
|
|
|
|
if (!y.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 18:19:03 +00:00
|
|
|
WCHAR lastChar = y[y.size() - 1];
|
|
|
|
if (lastChar == L'r')
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 18:19:03 +00:00
|
|
|
m_RelativeY = POSITION_RELATIVE_TL;
|
|
|
|
y.pop_back();
|
|
|
|
}
|
|
|
|
else if (lastChar == L'R')
|
|
|
|
{
|
|
|
|
m_RelativeY = POSITION_RELATIVE_BR;
|
|
|
|
y.pop_back();
|
2010-04-10 02:29:52 +00:00
|
|
|
}
|
2010-05-31 21:02:04 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_RelativeY = POSITION_ABSOLUTE;
|
|
|
|
}
|
2012-07-17 18:19:03 +00:00
|
|
|
|
|
|
|
m_Y = parser.ParseInt(y.c_str(), 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Y = 0;
|
|
|
|
m_RelativeY = POSITION_ABSOLUTE;
|
2010-06-01 14:55:52 +00:00
|
|
|
}
|
2010-04-10 02:29:52 +00:00
|
|
|
|
2012-08-01 17:52:50 +00:00
|
|
|
bool oldWDefined = m_WDefined;
|
2012-08-05 00:29:25 +00:00
|
|
|
int w = parser.ReadInt(section, L"W", m_W);
|
2012-08-01 17:52:50 +00:00
|
|
|
m_WDefined = parser.GetLastValueDefined();
|
2012-08-05 00:29:25 +00:00
|
|
|
if (IsFixedSize(true)) m_W = w;
|
2012-08-03 23:18:12 +00:00
|
|
|
if (!m_WDefined && oldWDefined && IsFixedSize())
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
|
|
|
m_W = 0;
|
|
|
|
}
|
|
|
|
|
2012-08-01 21:47:10 +00:00
|
|
|
bool oldHDefined = m_HDefined;
|
2012-08-05 00:29:25 +00:00
|
|
|
int h = parser.ReadInt(section, L"H", m_H);
|
2011-11-01 04:56:46 +00:00
|
|
|
m_HDefined = parser.GetLastValueDefined();
|
2012-08-05 00:29:25 +00:00
|
|
|
if (IsFixedSize(true)) m_H = h;
|
2012-08-03 23:18:12 +00:00
|
|
|
if (!m_HDefined && oldHDefined && IsFixedSize())
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
|
|
|
m_H = 0;
|
|
|
|
}
|
2010-06-01 14:55:52 +00:00
|
|
|
|
2012-07-17 19:15:06 +00:00
|
|
|
bool oldHidden = m_Hidden;
|
2012-07-17 18:19:03 +00:00
|
|
|
m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0);
|
2011-11-27 08:30:39 +00:00
|
|
|
|
2012-07-17 19:15:06 +00:00
|
|
|
if (oldX != m_X || oldY != m_Y || oldHidden != m_Hidden)
|
|
|
|
{
|
|
|
|
m_MeterWindow->SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
|
|
|
|
}
|
|
|
|
|
2010-05-31 21:02:04 +00:00
|
|
|
m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", BEVELTYPE_NONE);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-11-28 14:13:20 +00:00
|
|
|
m_SolidColor = parser.ReadColor(section, L"SolidColor", Color::MakeARGB(0, 0, 0, 0));
|
|
|
|
m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor.GetValue());
|
2009-09-04 16:37:51 +00:00
|
|
|
m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-01-16 10:23:42 +00:00
|
|
|
m_Mouse.ReadOptions(parser, section);
|
|
|
|
m_HasMouseAction = m_Mouse.HasButtonAction() || m_Mouse.HasScrollAction();
|
2009-09-25 22:20:07 +00:00
|
|
|
|
2011-11-03 00:13:42 +00:00
|
|
|
m_ToolTipText = parser.ReadString(section, L"ToolTipText", L"");
|
|
|
|
m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L"");
|
|
|
|
m_ToolTipIcon = parser.ReadString(section, L"ToolTipIcon", L"");
|
2013-02-06 10:12:16 +00:00
|
|
|
m_ToolTipWidth = parser.ReadInt(section, L"ToolTipWidth", 1000);
|
2010-07-17 00:06:24 +00:00
|
|
|
m_ToolTipType = 0!=parser.ReadInt(section, L"ToolTipType", 0);
|
2011-11-08 10:32:57 +00:00
|
|
|
m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden());
|
2010-07-17 00:06:24 +00:00
|
|
|
|
2009-09-04 16:37:51 +00:00
|
|
|
m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-07-27 11:48:57 +00:00
|
|
|
std::vector<Gdiplus::REAL> matrix = parser.ReadFloats(section, L"TransformationMatrix");
|
|
|
|
if (matrix.size() == 6)
|
|
|
|
{
|
2011-11-04 12:48:03 +00:00
|
|
|
if (m_Transformation)
|
|
|
|
{
|
|
|
|
m_Transformation->SetElements(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Transformation = new Matrix(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
|
|
}
|
2009-07-27 11:48:57 +00:00
|
|
|
}
|
|
|
|
else if (!matrix.empty())
|
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
delete m_Transformation;
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Transformation = nullptr;
|
2011-11-08 10:32:57 +00:00
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(this, L"Meter: Incorrect number of values in TransformationMatrix=%s", parser.ReadString(section, L"TransformationMatrix", L"").c_str());
|
2009-07-27 11:48:57 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Binds this meter to the given measure. The same measure can be bound to
|
|
|
|
** several meters but one meter and only be bound to one measure.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::BindMeasures(ConfigParser& parser, const WCHAR* section)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-07-17 07:37:53 +00:00
|
|
|
BindPrimaryMeasure(parser, section, false);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Creates the given meter. This is the factory method for the meters.
|
|
|
|
** If new meters are implemented this method needs to be updated.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
Meter* Meter::Create(const WCHAR* meter, MeterWindow* meterWindow, const WCHAR* name)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
if (_wcsicmp(L"STRING", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterString(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
else if (_wcsicmp(L"IMAGE", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterImage(meterWindow, name);
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"HISTOGRAM", meter) == 0)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterHistogram(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"BAR", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterBar(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"BITMAP", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterBitmap(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"LINE", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterLine(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"ROUNDLINE", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterRoundLine(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"ROTATOR", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterRotator(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"BUTTON", meter) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return new MeterButton(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(meterWindow, L"Meter=%s is not valid in [%s]", meter, name);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
return nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Updates the value(s) from the measures. Derived classes should
|
|
|
|
** only update if this returns true;
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool Meter::Update()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
// Only update the meter's value when the divider is equal to the counter
|
2013-02-06 10:12:16 +00:00
|
|
|
return UpdateCounter();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2010-09-10 17:29:30 +00:00
|
|
|
/*
|
2012-07-18 14:55:32 +00:00
|
|
|
** Reads and binds the primary MeasureName. This must always be called in overridden
|
|
|
|
** BindMeasures() implementations.
|
2012-07-17 07:37:53 +00:00
|
|
|
**
|
2010-09-17 08:47:22 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool Meter::BindPrimaryMeasure(ConfigParser& parser, const WCHAR* section, bool optional)
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
2012-07-18 14:55:32 +00:00
|
|
|
m_Measures.clear();
|
|
|
|
|
2012-07-17 07:37:53 +00:00
|
|
|
const std::wstring& measureName = parser.ReadString(section, L"MeasureName", L"");
|
2010-09-10 17:29:30 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure* measure = parser.GetMeasure(measureName);
|
2012-07-17 07:37:53 +00:00
|
|
|
if (measure)
|
|
|
|
{
|
|
|
|
m_Measures.push_back(measure);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (!optional)
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(this, L"MeasureName=%s is not valid", measureName.c_str());
|
2010-09-10 17:29:30 +00:00
|
|
|
}
|
2012-07-17 07:37:53 +00:00
|
|
|
|
|
|
|
return false;
|
2010-09-10 17:29:30 +00:00
|
|
|
}
|
|
|
|
|
2010-12-05 15:34:37 +00:00
|
|
|
/*
|
2012-07-17 07:37:53 +00:00
|
|
|
** Reads and binds secondary measures (MeasureName2 - MeasureNameN).
|
|
|
|
**
|
2010-12-05 15:34:37 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::BindSecondaryMeasures(ConfigParser& parser, const WCHAR* section)
|
2010-12-05 15:34:37 +00:00
|
|
|
{
|
2012-07-17 07:37:53 +00:00
|
|
|
if (!m_Measures.empty())
|
2010-12-05 15:34:37 +00:00
|
|
|
{
|
2012-07-17 07:37:53 +00:00
|
|
|
WCHAR tmpName[64];
|
|
|
|
|
|
|
|
int i = 2;
|
|
|
|
do
|
2010-12-05 15:34:37 +00:00
|
|
|
{
|
2012-07-17 07:37:53 +00:00
|
|
|
_snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i);
|
|
|
|
const std::wstring& measureName = parser.ReadString(section, tmpName, L"");
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure* measure = parser.GetMeasure(measureName);
|
2012-07-17 07:37:53 +00:00
|
|
|
if (measure)
|
|
|
|
{
|
|
|
|
m_Measures.push_back(measure);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!measureName.empty())
|
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(this, L"MeasureName%i=%s is not valid", i, measureName.c_str());
|
2012-07-17 07:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++i;
|
2010-12-05 15:34:37 +00:00
|
|
|
}
|
2012-07-17 07:37:53 +00:00
|
|
|
while (true);
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
2010-12-05 15:34:37 +00:00
|
|
|
}
|
|
|
|
|
2010-09-10 17:29:30 +00:00
|
|
|
/*
|
2012-07-17 07:57:28 +00:00
|
|
|
** Replaces %1, %2, ... with the corresponding measure value.
|
|
|
|
**
|
2010-09-10 17:29:30 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool Meter::ReplaceMeasures(std::wstring& str, AUTOSCALE autoScale, double scale, int decimals, bool percentual)
|
2010-11-19 07:33:58 +00:00
|
|
|
{
|
2010-12-05 15:34:37 +00:00
|
|
|
bool replaced = false;
|
|
|
|
|
2010-12-04 15:07:28 +00:00
|
|
|
if (str.find(L'%') != std::wstring::npos)
|
2010-11-19 07:33:58 +00:00
|
|
|
{
|
2010-12-04 15:07:28 +00:00
|
|
|
WCHAR buffer[64];
|
2010-11-19 07:33:58 +00:00
|
|
|
|
2012-07-17 07:57:28 +00:00
|
|
|
for (size_t i = m_Measures.size(); i > 0; --i)
|
2010-11-19 07:33:58 +00:00
|
|
|
{
|
2011-12-09 08:40:19 +00:00
|
|
|
size_t len = _snwprintf_s(buffer, _TRUNCATE, L"%%%i", (int)i);
|
2011-12-09 03:28:19 +00:00
|
|
|
size_t start = 0, pos;
|
2012-07-17 07:57:28 +00:00
|
|
|
|
2013-04-10 15:59:41 +00:00
|
|
|
const WCHAR* measureValue = m_Measures[i - 1]->GetStringOrFormattedValue(
|
|
|
|
autoScale, scale, decimals, percentual);
|
2012-07-17 07:57:28 +00:00
|
|
|
int measureValueLen = wcslen(measureValue);
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
do
|
2010-11-19 07:33:58 +00:00
|
|
|
{
|
2011-12-09 03:28:19 +00:00
|
|
|
pos = str.find(buffer, start, len);
|
2010-12-04 15:07:28 +00:00
|
|
|
if (pos != std::wstring::npos)
|
|
|
|
{
|
2012-07-17 07:57:28 +00:00
|
|
|
str.replace(pos, len, measureValue, measureValueLen);
|
|
|
|
start = pos + measureValueLen;
|
2010-12-05 15:34:37 +00:00
|
|
|
replaced = true;
|
2010-12-04 15:07:28 +00:00
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
|
|
|
while (pos != std::wstring::npos);
|
2010-12-04 15:07:28 +00:00
|
|
|
}
|
2010-11-19 07:33:58 +00:00
|
|
|
}
|
2010-12-05 15:34:37 +00:00
|
|
|
|
|
|
|
return replaced;
|
2010-11-19 07:33:58 +00:00
|
|
|
}
|
|
|
|
|
2010-07-17 00:06:24 +00:00
|
|
|
/*
|
|
|
|
** Does the initial construction of the ToolTip for the meter
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::CreateToolTip(MeterWindow* meterWindow)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
HWND hMeterWindow = m_MeterWindow->GetWindow();
|
2013-06-13 14:20:27 +00:00
|
|
|
HINSTANCE hInstance = GetRainmeter().GetModuleInstance();
|
2010-09-17 08:47:22 +00:00
|
|
|
DWORD style = WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP;
|
|
|
|
|
|
|
|
if (m_ToolTipType)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2010-09-17 08:47:22 +00:00
|
|
|
style |= TTS_BALLOON;
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
2010-09-17 08:47:22 +00:00
|
|
|
|
|
|
|
HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
|
2011-03-29 19:21:57 +00:00
|
|
|
TOOLTIPS_CLASS,
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr,
|
2010-09-17 08:47:22 +00:00
|
|
|
style,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
2011-11-08 10:32:57 +00:00
|
|
|
hMeterWindow,
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr,
|
2011-11-08 10:32:57 +00:00
|
|
|
hInstance,
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr);
|
2010-09-17 08:47:22 +00:00
|
|
|
|
|
|
|
if (hwndTT)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2010-09-17 08:47:22 +00:00
|
|
|
SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
2010-07-17 00:06:24 +00:00
|
|
|
|
2011-11-08 10:32:57 +00:00
|
|
|
TOOLINFO ti = {sizeof(TOOLINFO), TTF_SUBCLASS, hMeterWindow, 0, GetMeterRect(), hInstance};
|
2010-07-17 00:06:24 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM)&ti);
|
2010-07-17 00:06:24 +00:00
|
|
|
|
2010-09-17 08:47:22 +00:00
|
|
|
m_ToolTipHandle = hwndTT;
|
|
|
|
UpdateToolTip();
|
2010-07-17 19:11:05 +00:00
|
|
|
}
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Updates the ToolTip to match new values
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::UpdateToolTip()
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
|
|
|
HWND hwndTT = m_ToolTipHandle;
|
|
|
|
|
2010-09-17 08:47:22 +00:00
|
|
|
TOOLINFO ti = {sizeof(TOOLINFO)};
|
2010-07-17 00:06:24 +00:00
|
|
|
ti.hwnd = m_MeterWindow->GetWindow();
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(hwndTT, TTM_GETTOOLINFO, 0, (LPARAM)&ti);
|
2010-07-17 00:06:24 +00:00
|
|
|
|
2010-11-19 07:33:58 +00:00
|
|
|
std::wstring text = m_ToolTipText;
|
2012-07-17 07:57:28 +00:00
|
|
|
ReplaceMeasures(text);
|
2011-11-08 19:11:31 +00:00
|
|
|
ti.lpszText = (LPTSTR)text.c_str();
|
2010-07-17 00:06:24 +00:00
|
|
|
ti.rect = GetMeterRect();
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(hwndTT, TTM_SETTOOLINFO, 0, (LPARAM)&ti);
|
|
|
|
SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, m_ToolTipWidth);
|
2010-07-17 00:06:24 +00:00
|
|
|
|
|
|
|
if (!m_ToolTipTitle.empty())
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
HICON hIcon = nullptr;
|
2010-09-17 08:47:22 +00:00
|
|
|
bool destroy = false;
|
|
|
|
|
2010-07-17 00:06:24 +00:00
|
|
|
if (!m_ToolTipIcon.empty())
|
|
|
|
{
|
2011-11-16 16:47:20 +00:00
|
|
|
const WCHAR* tipIcon = m_ToolTipIcon.c_str();
|
|
|
|
if (_wcsicmp(tipIcon, L"INFO") == 0)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2011-11-08 19:11:31 +00:00
|
|
|
hIcon = (HICON)TTI_INFO;
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(tipIcon, L"WARNING") == 0)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2011-11-08 19:11:31 +00:00
|
|
|
hIcon = (HICON)TTI_WARNING;
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(tipIcon, L"ERROR") == 0)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2011-11-08 19:11:31 +00:00
|
|
|
hIcon = (HICON)TTI_ERROR;
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(tipIcon, L"QUESTION") == 0)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
hIcon = LoadIcon(nullptr, IDI_QUESTION);
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(tipIcon, L"SHIELD") == 0)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
hIcon = LoadIcon(nullptr, IDI_SHIELD);
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
hIcon = (HICON)LoadImage(nullptr, tipIcon, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
2010-09-17 08:47:22 +00:00
|
|
|
destroy = true;
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-09-17 08:47:22 +00:00
|
|
|
|
2010-11-19 07:33:58 +00:00
|
|
|
text = m_ToolTipTitle;
|
2012-07-17 07:57:28 +00:00
|
|
|
ReplaceMeasures(text);
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(hwndTT, TTM_SETTITLE, (WPARAM)hIcon, (LPARAM)text.c_str());
|
2010-09-17 08:47:22 +00:00
|
|
|
|
|
|
|
if (destroy)
|
|
|
|
{
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
}
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
2010-10-12 14:14:32 +00:00
|
|
|
|
2010-10-10 16:58:55 +00:00
|
|
|
if (m_ToolTipHidden)
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(hwndTT, TTM_ACTIVATE, FALSE, 0);
|
2010-10-10 16:58:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(hwndTT, TTM_ACTIVATE, !IsHidden(), 0);
|
2010-10-10 16:58:55 +00:00
|
|
|
}
|
2010-07-17 00:06:24 +00:00
|
|
|
}
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
** Draws the solid background & bevel if such are defined
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool Meter::Draw(Gfx::Canvas& canvas)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (IsHidden()) return false;
|
|
|
|
|
2013-03-25 15:42:18 +00:00
|
|
|
canvas.SetAntiAliasing(m_AntiAlias);
|
2009-07-29 11:52:01 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
if (m_SolidColor.GetA() != 0 || m_SolidColor2.GetA() != 0)
|
|
|
|
{
|
|
|
|
int x = GetX();
|
|
|
|
int y = GetY();
|
|
|
|
|
2010-12-08 09:04:36 +00:00
|
|
|
Rect r(x, y, m_W, m_H);
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
if (m_SolidColor.GetValue() == m_SolidColor2.GetValue())
|
|
|
|
{
|
|
|
|
SolidBrush solid(m_SolidColor);
|
2013-03-25 15:42:18 +00:00
|
|
|
canvas.FillRectangle(r, solid);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-25 15:42:18 +00:00
|
|
|
Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();
|
|
|
|
|
2011-01-30 11:28:20 +00:00
|
|
|
if (!m_AntiAlias)
|
|
|
|
{
|
|
|
|
// Fix the tiling issue in some GradientAngle values
|
|
|
|
graphics.SetPixelOffsetMode(PixelOffsetModeHalf);
|
|
|
|
}
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
LinearGradientBrush gradient(r, m_SolidColor, m_SolidColor2, m_SolidAngle, TRUE);
|
|
|
|
graphics.FillRectangle(&gradient, r);
|
2011-01-30 11:28:20 +00:00
|
|
|
|
|
|
|
if (!m_AntiAlias)
|
|
|
|
{
|
|
|
|
graphics.SetPixelOffsetMode(PixelOffsetModeDefault);
|
|
|
|
}
|
2013-03-25 15:42:18 +00:00
|
|
|
|
|
|
|
canvas.EndGdiplusContext();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_SolidBevel != BEVELTYPE_NONE)
|
|
|
|
{
|
2013-03-25 15:42:18 +00:00
|
|
|
Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
int x = GetX();
|
|
|
|
int y = GetY();
|
|
|
|
|
2010-12-08 09:04:36 +00:00
|
|
|
Color lightColor(255, 255, 255, 255);
|
|
|
|
Color darkColor(255, 0, 0, 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
if (m_SolidBevel == BEVELTYPE_DOWN)
|
|
|
|
{
|
2010-12-08 09:04:36 +00:00
|
|
|
lightColor.SetValue(Color::MakeARGB(255, 0, 0, 0));
|
|
|
|
darkColor.SetValue(Color::MakeARGB(255, 255, 255, 255));
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 09:04:36 +00:00
|
|
|
Pen light(lightColor);
|
|
|
|
Pen dark(darkColor);
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
// The bevel is drawn outside the meter
|
2011-03-29 19:21:57 +00:00
|
|
|
Rect rect(x - 2, y - 2, m_W + 4, m_H + 4);
|
2009-02-10 18:37:48 +00:00
|
|
|
DrawBevel(graphics, rect, light, dark);
|
2013-03-25 15:42:18 +00:00
|
|
|
|
|
|
|
canvas.EndGdiplusContext();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Draws a bevel inside the given area
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void Meter::DrawBevel(Graphics& graphics, const Rect& rect, const Pen& light, const Pen& dark)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
int l = rect.GetLeft();
|
|
|
|
int r = rect.GetRight() - 1;
|
|
|
|
int t = rect.GetTop();
|
|
|
|
int b = rect.GetBottom() - 1;
|
|
|
|
|
|
|
|
graphics.DrawLine(&light, l, t, l, b);
|
|
|
|
graphics.DrawLine(&light, l, t, r, t);
|
|
|
|
graphics.DrawLine(&light, l + 1, t + 1, l + 1, b - 1);
|
2011-01-18 13:01:04 +00:00
|
|
|
graphics.DrawLine(&light, l + 1, t + 1, r - 1, t + 1);
|
2009-02-10 18:37:48 +00:00
|
|
|
graphics.DrawLine(&dark, l, b, r, b);
|
|
|
|
graphics.DrawLine(&dark, r, t, r, b);
|
|
|
|
graphics.DrawLine(&dark, l + 1, b - 1, r - 1, b - 1);
|
|
|
|
graphics.DrawLine(&dark, r - 1, t + 1, r - 1, b - 1);
|
|
|
|
}
|