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"
|
|
|
|
|
|
|
|
using namespace Gdiplus;
|
|
|
|
|
2012-04-06 17:01:45 +00:00
|
|
|
extern CRainmeter* Rainmeter;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
** The constructor
|
|
|
|
**
|
|
|
|
*/
|
2011-02-15 16:26:54 +00:00
|
|
|
CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(meterWindow), m_Name(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(),
|
|
|
|
m_DynamicVariables(false),
|
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(),
|
|
|
|
m_HasMouseAction(false),
|
|
|
|
m_MouseOver(false),
|
|
|
|
m_RelativeX(POSITION_ABSOLUTE),
|
|
|
|
m_RelativeY(POSITION_ABSOLUTE),
|
|
|
|
m_UpdateDivider(1),
|
|
|
|
m_UpdateCounter(1),
|
|
|
|
m_SolidBevel(BEVELTYPE_NONE),
|
|
|
|
m_SolidAngle(),
|
|
|
|
m_AntiAlias(false),
|
|
|
|
m_Initialized(false)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The destructor
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CMeter::~CMeter()
|
|
|
|
{
|
2011-11-04 12:48:03 +00:00
|
|
|
delete m_Transformation;
|
|
|
|
|
2010-10-19 22:03:32 +00:00
|
|
|
if (m_ToolTipHandle != NULL)
|
|
|
|
{
|
|
|
|
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
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CMeter::Initialize()
|
|
|
|
{
|
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.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
int CMeter::GetX(bool abs)
|
|
|
|
{
|
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.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
int CMeter::GetY(bool abs)
|
|
|
|
{
|
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-07-17 14:47:34 +00:00
|
|
|
return m_RelativeMeter->GetY() + m_Y;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-17 14:47:34 +00:00
|
|
|
return m_RelativeMeter->GetY() + 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
|
|
|
}
|
|
|
|
|
2012-07-17 18:19:03 +00:00
|
|
|
void CMeter::SetX(int x)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMeter::SetY(int y)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
RECT CMeter::GetMeterRect()
|
|
|
|
{
|
|
|
|
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.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
bool CMeter::HitTest(int x, int y)
|
|
|
|
{
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
if (x >= GetX() && x < GetX() + GetW() && y >= GetY() && y < GetY() + GetH())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-19 22:03:32 +00:00
|
|
|
/*
|
|
|
|
** Shows the meter and tooltip.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CMeter::Show()
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
|
2010-10-19 22:03:32 +00:00
|
|
|
if (m_ToolTipHandle != NULL)
|
|
|
|
{
|
|
|
|
if (!m_ToolTipHidden)
|
|
|
|
{
|
|
|
|
SendMessage(m_ToolTipHandle, TTM_ACTIVATE, TRUE, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Hides the meter and tooltip.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CMeter::Hide()
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
|
2010-10-19 22:03:32 +00:00
|
|
|
if (m_ToolTipHandle != NULL)
|
|
|
|
{
|
|
|
|
SendMessage(m_ToolTipHandle, TTM_ACTIVATE, FALSE, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
**
|
|
|
|
*/
|
2012-05-30 18:53:44 +00:00
|
|
|
void CMeter::ReadOptions(CConfigParser& 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
|
|
|
|
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
|
|
|
|
2012-07-13 09:33:09 +00:00
|
|
|
m_Mouse.ReadOptions(parser, section, m_MeterWindow);
|
2009-09-25 22:20:07 +00:00
|
|
|
|
2009-09-26 07:16:55 +00:00
|
|
|
m_HasMouseAction =
|
2012-07-13 09:33:09 +00:00
|
|
|
!(m_Mouse.GetLeftUpAction().empty() && m_Mouse.GetLeftDownAction().empty() &&
|
|
|
|
m_Mouse.GetLeftDoubleClickAction().empty() && m_Mouse.GetMiddleUpAction().empty() &&
|
|
|
|
m_Mouse.GetMiddleDownAction().empty() && m_Mouse.GetMiddleDoubleClickAction().empty() &&
|
|
|
|
m_Mouse.GetRightUpAction().empty() && m_Mouse.GetRightDownAction().empty() &&
|
|
|
|
m_Mouse.GetRightDoubleClickAction().empty());
|
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"");
|
2012-04-06 12:16:54 +00:00
|
|
|
m_ToolTipWidth = (int)parser.ReadFloat(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
|
|
|
|
2010-12-28 13:31:17 +00:00
|
|
|
int updateDivider = parser.ReadInt(section, L"UpdateDivider", 1);
|
2010-11-13 19:53:28 +00:00
|
|
|
if (updateDivider != m_UpdateDivider)
|
|
|
|
{
|
|
|
|
m_UpdateCounter = m_UpdateDivider = updateDivider;
|
|
|
|
}
|
|
|
|
|
2009-09-04 16:37:51 +00:00
|
|
|
m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0);
|
|
|
|
m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 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;
|
|
|
|
m_Transformation = NULL;
|
|
|
|
|
2011-09-09 16:31:55 +00:00
|
|
|
LogWithArgs(LOG_ERROR, 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
|
|
|
}
|
|
|
|
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::wstring& group = parser.ReadString(section, L"Group", L"");
|
2010-07-07 23:46:44 +00:00
|
|
|
InitializeGroup(group);
|
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.
|
|
|
|
**
|
|
|
|
*/
|
2012-07-17 07:37:53 +00:00
|
|
|
void CMeter::BindMeasures(CConfigParser& 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.
|
|
|
|
**
|
|
|
|
*/
|
2011-02-15 16:26:54 +00:00
|
|
|
CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* 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
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
return new CMeterString(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
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
return new CMeterImage(meterWindow, name);
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"HISTOGRAM", meter) == 0)
|
|
|
|
{
|
|
|
|
return new CMeterHistogram(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
|
|
|
{
|
2011-02-15 16:26:54 +00:00
|
|
|
return new CMeterBar(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
|
|
|
{
|
2011-02-15 16:26:54 +00:00
|
|
|
return new CMeterBitmap(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
|
|
|
{
|
2011-02-15 16:26:54 +00:00
|
|
|
return new CMeterLine(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
|
|
|
{
|
2011-02-15 16:26:54 +00:00
|
|
|
return new CMeterRoundLine(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
|
|
|
{
|
2011-02-15 16:26:54 +00:00
|
|
|
return new CMeterRotator(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
|
|
|
{
|
2011-02-15 16:26:54 +00:00
|
|
|
return new CMeterButton(meterWindow, name);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-04-06 16:54:20 +00:00
|
|
|
LogWithArgs(LOG_ERROR, L"Meter=%s is not valid in [%s]", meter, name);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Updates the value(s) from the measures. Derived classes should
|
|
|
|
** only update if this returns true;
|
|
|
|
*/
|
|
|
|
bool CMeter::Update()
|
|
|
|
{
|
|
|
|
// Only update the meter's value when the divider is equal to the counter
|
2010-03-30 22:37:05 +00:00
|
|
|
++m_UpdateCounter;
|
2009-02-10 18:37:48 +00:00
|
|
|
if (m_UpdateCounter < m_UpdateDivider) return false;
|
|
|
|
m_UpdateCounter = 0;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2012-07-17 07:37:53 +00:00
|
|
|
bool CMeter::BindPrimaryMeasure(CConfigParser& 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
|
|
|
|
2012-07-17 07:37:53 +00:00
|
|
|
CMeasure* measure = parser.GetMeasure(measureName);
|
|
|
|
if (measure)
|
|
|
|
{
|
|
|
|
m_Measures.push_back(measure);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (!optional)
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
2012-07-17 07:37:53 +00:00
|
|
|
LogWithArgs(LOG_ERROR, L"MeasureName=%s is not valid in [%s]", measureName.c_str(), section);
|
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
|
|
|
*/
|
2012-07-17 07:37:53 +00:00
|
|
|
void CMeter::BindSecondaryMeasures(CConfigParser& 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"");
|
|
|
|
CMeasure* measure = parser.GetMeasure(measureName);
|
|
|
|
if (measure)
|
|
|
|
{
|
|
|
|
m_Measures.push_back(measure);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!measureName.empty())
|
|
|
|
{
|
|
|
|
LogWithArgs(LOG_ERROR, L"MeasureName%i=%s is not valid in [%s]", i, measureName.c_str(), section);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
2012-07-17 07:57:28 +00:00
|
|
|
bool CMeter::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
|
|
|
|
|
|
|
const WCHAR* measureValue = m_Measures[i - 1]->GetStringValue(autoScale, scale, decimals, percentual);
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
void CMeter::CreateToolTip(CMeterWindow* meterWindow)
|
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
HWND hMeterWindow = m_MeterWindow->GetWindow();
|
2012-04-06 17:01:45 +00:00
|
|
|
HINSTANCE hInstance = Rainmeter->GetInstance();
|
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,
|
2010-09-17 08:47:22 +00:00
|
|
|
NULL,
|
|
|
|
style,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
2011-11-08 10:32:57 +00:00
|
|
|
hMeterWindow,
|
2010-09-17 08:47:22 +00:00
|
|
|
NULL,
|
2011-11-08 10:32:57 +00:00
|
|
|
hInstance,
|
2010-09-17 08:47:22 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-09-17 08:47:22 +00:00
|
|
|
SendMessage(hwndTT, TTM_ADDTOOL, NULL, (LPARAM) (LPTOOLINFO) &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
|
|
|
|
*/
|
|
|
|
void CMeter::UpdateToolTip()
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
2011-11-08 19:11:31 +00:00
|
|
|
SendMessage(hwndTT, TTM_GETTOOLINFO, NULL, (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();
|
|
|
|
|
2011-11-08 19:11:31 +00:00
|
|
|
SendMessage(hwndTT, TTM_SETTOOLINFO, NULL, (LPARAM)&ti);
|
2010-09-17 08:47:22 +00:00
|
|
|
SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, NULL, m_ToolTipWidth);
|
2010-07-17 00:06:24 +00:00
|
|
|
|
|
|
|
if (!m_ToolTipTitle.empty())
|
|
|
|
{
|
|
|
|
HICON hIcon = NULL;
|
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
|
|
|
{
|
|
|
|
hIcon = LoadIcon(NULL, IDI_QUESTION);
|
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(tipIcon, L"SHIELD") == 0)
|
2010-07-17 00:06:24 +00:00
|
|
|
{
|
|
|
|
hIcon = LoadIcon(NULL, IDI_SHIELD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-16 16:47:20 +00:00
|
|
|
hIcon = (HICON)LoadImage(NULL, 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);
|
2011-11-08 19:11:31 +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)
|
|
|
|
{
|
2010-10-12 14:14:32 +00:00
|
|
|
SendMessage(hwndTT, TTM_ACTIVATE, FALSE, NULL);
|
2010-10-10 16:58:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendMessage(hwndTT, TTM_ACTIVATE, !IsHidden(), NULL);
|
|
|
|
}
|
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
|
|
|
|
*/
|
2009-07-27 11:48:57 +00:00
|
|
|
bool CMeter::Draw(Graphics& graphics)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (IsHidden()) return false;
|
|
|
|
|
2010-02-24 14:58:35 +00:00
|
|
|
graphics.SetInterpolationMode(InterpolationModeDefault);
|
|
|
|
graphics.SetCompositingQuality(CompositingQualityDefault);
|
|
|
|
|
2009-07-29 11:52:01 +00:00
|
|
|
if (m_AntiAlias)
|
|
|
|
{
|
2009-08-05 08:36:38 +00:00
|
|
|
graphics.SetSmoothingMode(SmoothingModeHighQuality);
|
|
|
|
graphics.SetPixelOffsetMode(PixelOffsetModeHighQuality);
|
2009-07-29 11:52:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
graphics.SetSmoothingMode(SmoothingModeNone);
|
2009-08-05 08:36:38 +00:00
|
|
|
graphics.SetPixelOffsetMode(PixelOffsetModeDefault);
|
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);
|
2010-12-08 09:04:36 +00:00
|
|
|
graphics.FillRectangle(&solid, r);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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);
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_SolidBevel != BEVELTYPE_NONE)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Draws a bevel inside the given area
|
|
|
|
*/
|
2010-12-08 09:04:36 +00:00
|
|
|
void CMeter::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);
|
|
|
|
}
|