rainmeter-studio/Library/MeterHistogram.cpp

666 lines
18 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
*/
#include "StdAfx.h"
2009-02-10 18:37:48 +00:00
#include "MeterHistogram.h"
#include "Measure.h"
#include "Error.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;
extern CRainmeter* Rainmeter;
2012-05-30 18:51:06 +00:00
CTintedImageHelper_DefineOptionArray(CMeterHistogram::c_PrimaryOptionArray, L"Primary");
CTintedImageHelper_DefineOptionArray(CMeterHistogram::c_SecondaryOptionArray, L"Secondary");
CTintedImageHelper_DefineOptionArray(CMeterHistogram::c_BothOptionArray, L"Both");
2011-02-07 09:38:27 +00:00
2009-02-10 18:37:48 +00:00
/*
** The constructor
**
*/
2011-02-15 16:26:54 +00:00
CMeterHistogram::CMeterHistogram(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
m_PrimaryColor(Color::Green),
m_SecondaryColor(Color::Red),
2012-05-20 17:57:12 +00:00
m_OverlapColor(Color::Yellow),
m_MeterPos(),
m_Autoscale(false),
m_Flip(false),
2012-05-30 18:51:06 +00:00
m_PrimaryImage(L"PrimaryImage", c_PrimaryOptionArray),
m_SecondaryImage(L"SecondaryImage", c_SecondaryOptionArray),
m_OverlapImage(L"BothImage", c_BothOptionArray),
m_PrimaryNeedsReload(false),
m_SecondaryNeedsReload(false),
2012-05-20 17:57:12 +00:00
m_OverlapNeedsReload(false),
m_PrimaryValues(),
m_SecondaryValues(),
m_MaxPrimaryValue(1.0),
m_MinPrimaryValue(),
m_MaxSecondaryValue(1.0),
m_MinSecondaryValue(),
m_SizeChanged(true),
m_GraphStartLeft(false),
m_GraphHorizontalOrientation(false)
2009-02-10 18:37:48 +00:00
{
}
/*
** The destructor
**
*/
CMeterHistogram::~CMeterHistogram()
{
DisposeBuffer();
}
/*
** Disposes the buffers.
**
*/
void CMeterHistogram::DisposeBuffer()
{
// Reset current position
m_MeterPos = 0;
// Delete buffers
delete [] m_PrimaryValues;
m_PrimaryValues = NULL;
delete [] m_SecondaryValues;
m_SecondaryValues = NULL;
2009-02-10 18:37:48 +00:00
}
2012-12-22 22:05:46 +00:00
/*
** Creates the buffers.
**
*/
void CMeterHistogram::CreateBuffer()
{
DisposeBuffer();
// Create buffers for values
int maxSize = m_GraphHorizontalOrientation ? m_H : m_W;
if (maxSize > 0)
{
m_PrimaryValues = new double[maxSize]();
if (m_Measures.size() >= 2)
{
m_SecondaryValues = new double[maxSize]();
}
}
}
2009-02-10 18:37:48 +00:00
/*
** Load the images and calculate the dimensions of the meter from them.
** Or create the brushes if solid color histogram is used.
**
*/
void CMeterHistogram::Initialize()
{
CMeter::Initialize();
2012-07-17 07:37:53 +00:00
CMeasure* secondaryMeasure = (m_Measures.size() >= 2) ? m_Measures[1] : NULL;
// A sanity check
2012-07-17 07:37:53 +00:00
if (secondaryMeasure && !m_PrimaryImageName.empty() && (m_OverlapImageName.empty() || m_SecondaryImageName.empty()))
2009-02-10 18:37:48 +00:00
{
Log(LOG_WARNING, L"Histogram: SecondaryImage and BothImage not defined");
2009-02-10 18:37:48 +00:00
m_PrimaryImage.DisposeImage();
m_SecondaryImage.DisposeImage();
2012-05-20 17:57:12 +00:00
m_OverlapImage.DisposeImage();
}
else
{
// Load the bitmaps if defined
if (!m_PrimaryImageName.empty())
{
m_PrimaryImage.LoadImage(m_PrimaryImageName, m_PrimaryNeedsReload);
2009-02-10 18:37:48 +00:00
if (m_PrimaryImage.IsLoaded())
{
2012-12-22 22:05:46 +00:00
int oldSize = m_GraphHorizontalOrientation ? m_H : m_W;
Bitmap* bitmap = m_PrimaryImage.GetImage();
m_W = bitmap->GetWidth();
m_H = bitmap->GetHeight();
2012-12-22 22:05:46 +00:00
int maxSize = m_GraphHorizontalOrientation ? m_H : m_W;
if (oldSize != maxSize)
{
m_SizeChanged = true;
}
}
}
else if (m_PrimaryImage.IsLoaded())
{
m_PrimaryImage.DisposeImage();
2009-02-10 18:37:48 +00:00
}
if (!m_SecondaryImageName.empty())
2009-02-10 18:37:48 +00:00
{
m_SecondaryImage.LoadImage(m_SecondaryImageName, m_SecondaryNeedsReload);
}
else if (m_SecondaryImage.IsLoaded())
{
m_SecondaryImage.DisposeImage();
2009-02-10 18:37:48 +00:00
}
2012-05-20 17:57:12 +00:00
if (!m_OverlapImageName.empty())
{
2012-05-20 17:57:12 +00:00
m_OverlapImage.LoadImage(m_OverlapImageName, m_OverlapNeedsReload);
}
2012-05-20 17:57:12 +00:00
else if (m_OverlapImage.IsLoaded())
{
2012-05-20 17:57:12 +00:00
m_OverlapImage.DisposeImage();
}
2009-02-10 18:37:48 +00:00
}
if ((!m_PrimaryImageName.empty() && !m_PrimaryImage.IsLoaded()) ||
(!m_SecondaryImageName.empty() && !m_SecondaryImage.IsLoaded()) ||
2012-05-20 17:57:12 +00:00
(!m_OverlapImageName.empty() && !m_OverlapImage.IsLoaded()))
2009-02-10 18:37:48 +00:00
{
DisposeBuffer();
m_SizeChanged = false;
}
else if (m_SizeChanged)
{
2012-12-22 22:05:46 +00:00
CreateBuffer();
m_SizeChanged = false;
2009-02-10 18:37:48 +00:00
}
}
/*
** Read the options specified in the ini file.
2009-02-10 18:37:48 +00:00
**
*/
2012-05-30 18:53:44 +00:00
void CMeterHistogram::ReadOptions(CConfigParser& parser, const WCHAR* section)
2009-02-10 18:37:48 +00:00
{
// Store the current values so we know if the image needs to be updated
std::wstring oldPrimaryImageName = m_PrimaryImageName;
std::wstring oldSecondaryImageName = m_SecondaryImageName;
2012-05-20 17:57:12 +00:00
std::wstring oldBothImageName = m_OverlapImageName;
int oldW = m_W;
int oldH = m_H;
2012-12-22 22:05:46 +00:00
bool oldGraphHorizontalOrientation = m_GraphHorizontalOrientation;
2012-05-30 18:53:44 +00:00
CMeter::ReadOptions(parser, section);
2009-02-10 18:37:48 +00:00
2009-09-04 16:37:51 +00:00
m_PrimaryColor = parser.ReadColor(section, L"PrimaryColor", Color::Green);
m_SecondaryColor = parser.ReadColor(section, L"SecondaryColor", Color::Red);
2012-05-20 17:57:12 +00:00
m_OverlapColor = parser.ReadColor(section, L"BothColor", Color::Yellow);
2009-02-10 18:37:48 +00:00
2009-09-04 16:37:51 +00:00
m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", L"");
2010-11-25 22:00:34 +00:00
if (!m_PrimaryImageName.empty())
{
2011-11-28 14:13:20 +00:00
m_MeterWindow->MakePathAbsolute(m_PrimaryImageName);
// Read tinting options
2012-05-30 18:53:44 +00:00
m_PrimaryImage.ReadOptions(parser, section);
}
else
{
2012-05-30 18:51:06 +00:00
m_PrimaryImage.ClearOptionFlags();
2010-11-25 22:00:34 +00:00
}
2009-02-10 18:37:48 +00:00
2009-09-04 16:37:51 +00:00
m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L"");
2010-11-25 22:00:34 +00:00
if (!m_SecondaryImageName.empty())
{
2011-11-28 14:13:20 +00:00
m_MeterWindow->MakePathAbsolute(m_SecondaryImageName);
// Read tinting options
2012-05-30 18:53:44 +00:00
m_SecondaryImage.ReadOptions(parser, section);
}
else
{
2012-05-30 18:51:06 +00:00
m_SecondaryImage.ClearOptionFlags();
2010-11-25 22:00:34 +00:00
}
2009-02-10 18:37:48 +00:00
2012-05-20 17:57:12 +00:00
m_OverlapImageName = parser.ReadString(section, L"BothImage", L"");
if (!m_OverlapImageName.empty())
2010-11-25 22:00:34 +00:00
{
2012-05-20 17:57:12 +00:00
m_MeterWindow->MakePathAbsolute(m_OverlapImageName);
// Read tinting options
2012-05-30 18:53:44 +00:00
m_OverlapImage.ReadOptions(parser, section);
}
else
{
2012-05-30 18:51:06 +00:00
m_OverlapImage.ClearOptionFlags();
2010-11-25 22:00:34 +00:00
}
2009-02-10 18:37:48 +00:00
2009-09-04 16:37:51 +00:00
m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0);
2009-02-10 18:37:48 +00:00
m_Flip = 0!=parser.ReadInt(section, L"Flip", 0);
2012-12-22 22:05:46 +00:00
const WCHAR* graph = parser.ReadString(section, L"GraphStart", L"RIGHT").c_str();
if (_wcsicmp(graph, L"RIGHT") == 0)
{
m_GraphStartLeft = false;
}
else if (_wcsicmp(graph, L"LEFT") == 0)
{
m_GraphStartLeft = true;
}
else
{
LogWithArgs(LOG_ERROR, L"GraphStart=%s is not valid in [%s]", graph, m_Name.c_str());
}
graph = parser.ReadString(section, L"GraphOrientation", L"VERTICAL").c_str();
if (_wcsicmp(graph, L"VERTICAL") == 0)
{
m_GraphHorizontalOrientation = false;
}
else if (_wcsicmp(graph, L"HORIZONTAL") == 0)
{
m_GraphHorizontalOrientation = true;
}
else
{
LogWithArgs(LOG_ERROR, L"GraphOrientation=%s is not valid in [%s]", graph, m_Name.c_str());
}
if (m_Initialized)
{
if (m_PrimaryImageName.empty())
{
2012-12-22 22:05:46 +00:00
int oldSize = oldGraphHorizontalOrientation ? oldH : oldW;
int maxSize = m_GraphHorizontalOrientation ? m_H : m_W;
if (oldSize != maxSize || oldGraphHorizontalOrientation != m_GraphHorizontalOrientation)
{
m_SizeChanged = true;
Initialize(); // Reload the image
}
}
else
{
// Reset to old dimensions
m_W = oldW;
m_H = oldH;
m_PrimaryNeedsReload = (wcscmp(oldPrimaryImageName.c_str(), m_PrimaryImageName.c_str()) != 0);
m_SecondaryNeedsReload = (wcscmp(oldSecondaryImageName.c_str(), m_SecondaryImageName.c_str()) != 0);
2012-05-20 17:57:12 +00:00
m_OverlapNeedsReload = (wcscmp(oldBothImageName.c_str(), m_OverlapImageName.c_str()) != 0);
2012-12-22 22:05:46 +00:00
m_SizeChanged = (oldGraphHorizontalOrientation != m_GraphHorizontalOrientation);
if (m_PrimaryNeedsReload ||
m_SecondaryNeedsReload ||
2012-05-20 17:57:12 +00:00
m_OverlapNeedsReload ||
2012-05-30 18:51:06 +00:00
m_PrimaryImage.IsOptionsChanged() ||
m_SecondaryImage.IsOptionsChanged() ||
m_OverlapImage.IsOptionsChanged())
{
Initialize(); // Reload the image
}
2012-12-22 22:05:46 +00:00
else if (m_SizeChanged)
{
2012-12-22 22:05:46 +00:00
CreateBuffer();
}
}
}
2009-02-10 18:37:48 +00:00
}
/*
** Updates the value(s) from the measures.
**
*/
bool CMeterHistogram::Update()
{
2012-12-22 22:05:46 +00:00
if (CMeter::Update() && !m_Measures.empty())
2009-02-10 18:37:48 +00:00
{
int maxSize = m_GraphHorizontalOrientation ? m_H : m_W;
2009-02-10 18:37:48 +00:00
2012-12-22 22:05:46 +00:00
if (maxSize > 0) // m_PrimaryValues is not NULL
2009-02-10 18:37:48 +00:00
{
2012-12-22 22:05:46 +00:00
CMeasure* measure = m_Measures[0];
CMeasure* secondaryMeasure = (m_Measures.size() >= 2) ? m_Measures[1] : NULL;
// Gather values
m_PrimaryValues[m_MeterPos] = measure->GetValue();
2009-02-10 18:37:48 +00:00
2012-12-22 22:05:46 +00:00
if (secondaryMeasure && m_SecondaryValues)
2009-02-10 18:37:48 +00:00
{
2012-12-22 22:05:46 +00:00
m_SecondaryValues[m_MeterPos] = secondaryMeasure->GetValue();
2009-02-10 18:37:48 +00:00
}
2012-12-22 22:05:46 +00:00
++m_MeterPos;
m_MeterPos %= maxSize;
m_MaxPrimaryValue = measure->GetMaxValue();
m_MinPrimaryValue = measure->GetMinValue();
m_MaxSecondaryValue = 0.0;
m_MinSecondaryValue = 0.0;
if (secondaryMeasure)
2009-02-10 18:37:48 +00:00
{
2012-12-22 22:05:46 +00:00
m_MaxSecondaryValue = secondaryMeasure->GetMaxValue();
m_MinSecondaryValue = secondaryMeasure->GetMinValue();
2009-02-10 18:37:48 +00:00
}
2012-12-22 22:05:46 +00:00
if (m_Autoscale)
2009-02-10 18:37:48 +00:00
{
2012-12-22 22:05:46 +00:00
// Go through all values and find the max
double newValue = 0.0;
for (int i = 0; i < maxSize; ++i)
2009-02-10 18:37:48 +00:00
{
2012-12-22 22:05:46 +00:00
newValue = max(newValue, m_PrimaryValues[i]);
2009-02-10 18:37:48 +00:00
}
// Scale the value up to nearest power of 2
if (newValue > DBL_MAX / 2.0)
2009-02-10 18:37:48 +00:00
{
2012-12-22 22:05:46 +00:00
m_MaxPrimaryValue = DBL_MAX;
}
else
{
2012-12-22 22:05:46 +00:00
m_MaxPrimaryValue = 2.0;
while (m_MaxPrimaryValue < newValue)
{
m_MaxPrimaryValue *= 2.0;
}
}
if (secondaryMeasure && m_SecondaryValues)
{
for (int i = 0; i < maxSize; ++i)
{
newValue = max(newValue, m_SecondaryValues[i]);
}
// Scale the value up to nearest power of 2
if (newValue > DBL_MAX / 2.0)
{
m_MaxSecondaryValue = DBL_MAX;
}
else
{
2012-12-22 22:05:46 +00:00
m_MaxSecondaryValue = 2.0;
while (m_MaxSecondaryValue < newValue)
{
m_MaxSecondaryValue *= 2.0;
}
}
2009-02-10 18:37:48 +00:00
}
}
}
return true;
}
return false;
}
/*
** Draws the meter on the double buffer
**
*/
2013-03-25 15:42:18 +00:00
bool CMeterHistogram::Draw(Gfx::Canvas& canvas)
2009-02-10 18:37:48 +00:00
{
2013-03-25 15:42:18 +00:00
if (!CMeter::Draw(canvas) ||
2012-07-17 07:37:53 +00:00
(m_Measures.size() >= 1 && !m_PrimaryValues) ||
(m_Measures.size() >= 2 && !m_SecondaryValues)) return false;
2013-03-25 15:42:18 +00:00
Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();
CMeasure* secondaryMeasure = (m_Measures.size() >= 2) ? m_Measures[1] : NULL;
2009-02-10 18:37:48 +00:00
GraphicsPath primaryPath;
GraphicsPath secondaryPath;
GraphicsPath bothPath;
Bitmap* primaryBitmap = m_PrimaryImage.GetImage();
Bitmap* secondaryBitmap = m_SecondaryImage.GetImage();
2012-05-20 17:57:12 +00:00
Bitmap* bothBitmap = m_OverlapImage.GetImage();
2009-02-10 18:37:48 +00:00
int x = GetX();
int y = GetY();
// Default values (GraphStart=Right, GraphOrientation=Vertical)
int i;
int startValue = 0;
int* endValueLHS = &i;
int* endValueRHS = &m_W;
int step = 1;
int endValue = -1; //(should be 0, but need to simulate <=)
// GraphStart=Left, GraphOrientation=Vertical
2012-12-27 07:47:44 +00:00
if (!m_GraphHorizontalOrientation)
{
2012-12-27 07:47:44 +00:00
if (m_GraphStartLeft)
{
startValue = m_W - 1;
endValueLHS = &endValue;
endValueRHS = &i;
step = -1;
}
}
2012-12-27 07:47:44 +00:00
else
{
2012-12-27 07:47:44 +00:00
if (!m_Flip)
{
endValueRHS = &m_H;
}
else
{
startValue = m_H - 1;
endValueLHS = &endValue;
endValueRHS = &i;
step = -1;
}
}
2009-02-10 18:37:48 +00:00
// Horizontal or Vertical graph
if (m_GraphHorizontalOrientation)
{
for (i = startValue; *endValueLHS < *endValueRHS; i += step)
2009-02-10 18:37:48 +00:00
{
double value = (m_MaxPrimaryValue == 0.0) ?
0.0
: m_PrimaryValues[(i + (m_MeterPos % m_H)) % m_H] / m_MaxPrimaryValue;
value -= m_MinPrimaryValue;
int primaryBarHeight = (int)(m_W * value);
primaryBarHeight = min(m_W, primaryBarHeight);
primaryBarHeight = max(0, primaryBarHeight);
2009-02-10 18:37:48 +00:00
2012-07-17 07:37:53 +00:00
if (secondaryMeasure)
2009-02-10 18:37:48 +00:00
{
value = (m_MaxSecondaryValue == 0.0) ?
0.0
: m_SecondaryValues[(i + m_MeterPos) % m_H] / m_MaxSecondaryValue;
value -= m_MinSecondaryValue;
int secondaryBarHeight = (int)(m_W * value);
secondaryBarHeight = min(m_W, secondaryBarHeight);
secondaryBarHeight = max(0, secondaryBarHeight);
// Check which measured value is higher
int bothBarHeight = min(primaryBarHeight, secondaryBarHeight);
// Cache image/color rectangle for the both lines
{
Rect& r = m_GraphStartLeft ?
Rect(x, y + startValue + (step * i), bothBarHeight, 1)
: Rect(x + m_W - bothBarHeight, y + startValue + (step * i), bothBarHeight, 1);
bothPath.AddRectangle(r); // cache
}
2009-02-10 18:37:48 +00:00
// Cache the image/color rectangle for the rest
if (secondaryBarHeight > primaryBarHeight)
{
Rect& r = m_GraphStartLeft ?
Rect(x + bothBarHeight, y + startValue + (step * i), secondaryBarHeight - bothBarHeight, 1)
: Rect(x + m_W - secondaryBarHeight, y + startValue + (step * i), secondaryBarHeight - bothBarHeight, 1);
secondaryPath.AddRectangle(r); // cache
}
else
{
Rect& r = m_GraphStartLeft ?
Rect(x + bothBarHeight, y + startValue + (step * i), primaryBarHeight - bothBarHeight, 1)
: Rect(x + m_W - primaryBarHeight, y + startValue + (step * i), primaryBarHeight - bothBarHeight, 1);
primaryPath.AddRectangle(r); // cache
}
2009-02-10 18:37:48 +00:00
}
else
{
Rect& r = m_GraphStartLeft ?
Rect(x, y + startValue + (step * i), primaryBarHeight, 1)
: Rect(x + m_W - primaryBarHeight, y + startValue + (step * i), primaryBarHeight, 1);
primaryPath.AddRectangle(r); // cache
2009-02-10 18:37:48 +00:00
}
}
}
else // GraphOrientation=Vertical
{
for (i = startValue; *endValueLHS < *endValueRHS; i += step)
2009-02-10 18:37:48 +00:00
{
double value = (m_MaxPrimaryValue == 0.0) ?
0.0
: m_PrimaryValues[(i + m_MeterPos) % m_W] / m_MaxPrimaryValue;
value -= m_MinPrimaryValue;
int primaryBarHeight = (int)(m_H * value);
primaryBarHeight = min(m_H, primaryBarHeight);
primaryBarHeight = max(0, primaryBarHeight);
2012-07-17 07:37:53 +00:00
if (secondaryMeasure)
{
value = (m_MaxSecondaryValue == 0.0) ?
0.0
: m_SecondaryValues[(i + m_MeterPos) % m_W] / m_MaxSecondaryValue;
value -= m_MinSecondaryValue;
int secondaryBarHeight = (int)(m_H * value);
secondaryBarHeight = min(m_H, secondaryBarHeight);
secondaryBarHeight = max(0, secondaryBarHeight);
// Check which measured value is higher
int bothBarHeight = min(primaryBarHeight, secondaryBarHeight);
// Cache image/color rectangle for the both lines
{
Rect& r = m_Flip ?
Rect(x + startValue + (step * i), y, 1, bothBarHeight)
: Rect(x + startValue + (step * i), y + m_H - bothBarHeight, 1, bothBarHeight);
bothPath.AddRectangle(r); // cache
}
// Cache the image/color rectangle for the rest
if (secondaryBarHeight > primaryBarHeight)
{
Rect& r = m_Flip ?
Rect(x + startValue + (step * i), y + bothBarHeight, 1, secondaryBarHeight - bothBarHeight)
: Rect(x + startValue + (step * i), y + m_H - secondaryBarHeight, 1, secondaryBarHeight - bothBarHeight);
secondaryPath.AddRectangle(r); // cache
}
else
{
Rect& r = m_Flip ?
Rect(x + startValue + (step * i), y + bothBarHeight, 1, primaryBarHeight - bothBarHeight)
: Rect(x + startValue + (step * i), y + m_H - primaryBarHeight, 1, primaryBarHeight - bothBarHeight);
primaryPath.AddRectangle(r); // cache
}
}
else
{
Rect& r = m_Flip ?
Rect(x + startValue + (step * i), y, 1, primaryBarHeight)
: Rect(x + startValue + (step * i), y + m_H - primaryBarHeight, 1, primaryBarHeight);
primaryPath.AddRectangle(r); // cache
}
2009-02-10 18:37:48 +00:00
}
}
// Draw cached rectangles
if (primaryBitmap)
{
Rect r(x, y, primaryBitmap->GetWidth(), primaryBitmap->GetHeight());
graphics.SetClip(&primaryPath);
graphics.DrawImage(primaryBitmap, r, 0, 0, r.Width, r.Height, UnitPixel);
graphics.ResetClip();
}
else
{
SolidBrush brush(m_PrimaryColor);
graphics.FillPath(&brush, &primaryPath);
}
2012-07-17 07:37:53 +00:00
if (secondaryMeasure)
{
if (secondaryBitmap)
{
Rect r(x, y, secondaryBitmap->GetWidth(), secondaryBitmap->GetHeight());
graphics.SetClip(&secondaryPath);
graphics.DrawImage(secondaryBitmap, r, 0, 0, r.Width, r.Height, UnitPixel);
graphics.ResetClip();
}
else
{
SolidBrush brush(m_SecondaryColor);
graphics.FillPath(&brush, &secondaryPath);
}
if (bothBitmap)
{
Rect r(x, y, bothBitmap->GetWidth(), bothBitmap->GetHeight());
graphics.SetClip(&bothPath);
graphics.DrawImage(bothBitmap, r, 0, 0, r.Width, r.Height, UnitPixel);
graphics.ResetClip();
}
else
{
2012-05-20 17:57:12 +00:00
SolidBrush brush(m_OverlapColor);
graphics.FillPath(&brush, &bothPath);
}
}
2013-03-25 15:42:18 +00:00
canvas.EndGdiplusContext();
2009-02-10 18:37:48 +00:00
return true;
}
/*
** Overwritten method to handle the secondary measure binding.
**
*/
2012-07-17 07:37:53 +00:00
void CMeterHistogram::BindMeasures(CConfigParser& parser, const WCHAR* section)
2009-02-10 18:37:48 +00:00
{
2012-07-17 19:07:57 +00:00
if (BindPrimaryMeasure(parser, section, false))
2009-02-10 18:37:48 +00:00
{
2012-07-17 07:37:53 +00:00
const std::wstring* secondaryMeasure = &parser.ReadString(section, L"MeasureName2", L"");
if (secondaryMeasure->empty())
2009-02-10 18:37:48 +00:00
{
2012-07-17 07:37:53 +00:00
// For backwards compatibility.
secondaryMeasure = &parser.ReadString(section, L"SecondaryMeasureName", L"");
2009-02-10 18:37:48 +00:00
}
2012-07-17 07:37:53 +00:00
CMeasure* measure = parser.GetMeasure(*secondaryMeasure);
if (measure)
{
m_Measures.push_back(measure);
}
2009-02-10 18:37:48 +00:00
}
}