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;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 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_Measure(),
|
|
|
|
m_X(),
|
|
|
|
m_Y(),
|
|
|
|
m_W(),
|
|
|
|
m_H(),
|
|
|
|
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_ToolTipDelay(),
|
|
|
|
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),
|
2011-11-08 10:32:57 +00:00
|
|
|
m_MouseActionCursor(meterWindow->GetMeterMouseActionCursor()),
|
2011-01-29 00:11:01 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Initializes the meter. The base implementation just stores the pointer.
|
|
|
|
** Usually this method is overwritten by the inherited classes, which load
|
|
|
|
** bitmaps and such things during initialization.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
if (m_RelativeX != POSITION_ABSOLUTE)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (m_RelativeMeter == NULL)
|
|
|
|
{
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::list<CMeter*>& meters = m_MeterWindow->GetMeters();
|
2010-03-30 22:37:05 +00:00
|
|
|
std::list<CMeter*>::const_iterator iter = meters.begin();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
// Find this meter
|
2010-03-30 22:37:05 +00:00
|
|
|
for ( ; iter != meters.end(); ++iter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (*iter == this && iter != meters.begin())
|
|
|
|
{
|
2010-03-30 22:37:05 +00:00
|
|
|
--iter;
|
2009-02-10 18:37:48 +00:00
|
|
|
m_RelativeMeter = (*iter);
|
|
|
|
if (m_RelativeX == POSITION_RELATIVE_TL)
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetX(true) + m_X;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetX(true) + m_RelativeMeter->GetW() + m_X;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_RelativeX == POSITION_RELATIVE_TL)
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetX(true) + m_X;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetX(true) + m_RelativeMeter->GetW() + m_X;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
if (m_RelativeY != POSITION_ABSOLUTE)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (m_RelativeMeter == NULL)
|
|
|
|
{
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::list<CMeter*>& meters = m_MeterWindow->GetMeters();
|
2010-03-30 22:37:05 +00:00
|
|
|
std::list<CMeter*>::const_iterator iter = meters.begin();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
// Find this meter
|
2010-03-30 22:37:05 +00:00
|
|
|
for ( ; iter != meters.end(); ++iter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (*iter == this && iter != meters.begin())
|
|
|
|
{
|
2010-03-30 22:37:05 +00:00
|
|
|
--iter;
|
2009-02-10 18:37:48 +00:00
|
|
|
m_RelativeMeter = (*iter);
|
|
|
|
if (m_RelativeY == POSITION_RELATIVE_TL)
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetY() + m_Y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetY() + m_RelativeMeter->GetH() + m_Y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_RelativeY == POSITION_RELATIVE_TL)
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetY() + m_Y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_RelativeMeter->GetY() + m_RelativeMeter->GetH() + m_Y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
return m_Y;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (m_ToolTipHandle != NULL)
|
|
|
|
{
|
|
|
|
SendMessage(m_ToolTipHandle, TTM_ACTIVATE, FALSE, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
** Reads the meter-specific configs from the ini-file. The base implementation
|
2011-03-29 19:21:57 +00:00
|
|
|
** reads the common settings for all meters. The inherited classes must call
|
2009-02-10 18:37:48 +00:00
|
|
|
** the base implementation if they overwrite this method.
|
|
|
|
**
|
|
|
|
*/
|
2011-02-15 16:26:54 +00:00
|
|
|
void CMeter::ReadConfig(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
|
|
|
|
2010-11-04 00:17:42 +00:00
|
|
|
std::wstring oldStyleX = m_StyleX;
|
|
|
|
std::wstring oldStyleY = m_StyleY;
|
|
|
|
|
|
|
|
std::wstring coord = parser.ReadString(section, L"X", L"0");
|
|
|
|
m_StyleX = parser.GetLastUsedStyle();
|
2011-11-27 08:30:39 +00:00
|
|
|
if (!m_Initialized || parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && wcscmp(m_StyleX.c_str(), oldStyleX.c_str()) != 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
if (!coord.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
size_t len = coord.size();
|
|
|
|
if (coord[len - 1] == L'r')
|
|
|
|
{
|
|
|
|
m_RelativeX = POSITION_RELATIVE_TL;
|
|
|
|
coord.erase(--len);
|
|
|
|
}
|
|
|
|
else if (coord[len - 1] == L'R')
|
|
|
|
{
|
|
|
|
m_RelativeX = POSITION_RELATIVE_BR;
|
|
|
|
coord.erase(--len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_RelativeX = POSITION_ABSOLUTE;
|
|
|
|
}
|
2010-04-10 02:29:52 +00:00
|
|
|
|
2010-06-01 14:55:52 +00:00
|
|
|
double val;
|
2011-11-26 02:49:52 +00:00
|
|
|
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && parser.ParseFormula(coord, &val))
|
2010-06-01 14:55:52 +00:00
|
|
|
{
|
|
|
|
m_X = (int)val;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-26 02:49:52 +00:00
|
|
|
m_X = (int)parser.ParseDouble(coord.c_str(), 0.0);
|
2010-06-01 14:55:52 +00:00
|
|
|
}
|
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_X = 0;
|
|
|
|
m_RelativeX = POSITION_ABSOLUTE;
|
2009-07-30 15:19:47 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 00:17:42 +00:00
|
|
|
coord = parser.ReadString(section, L"Y", L"0");
|
|
|
|
m_StyleY = parser.GetLastUsedStyle();
|
2011-11-27 08:30:39 +00:00
|
|
|
if (!m_Initialized || parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && wcscmp(m_StyleY.c_str(), oldStyleY.c_str()) != 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
if (!coord.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
size_t len = coord.size();
|
|
|
|
if (coord[len - 1] == L'r')
|
|
|
|
{
|
|
|
|
m_RelativeY = POSITION_RELATIVE_TL;
|
|
|
|
coord.erase(--len);
|
|
|
|
}
|
|
|
|
else if (coord[len - 1] == L'R')
|
|
|
|
{
|
|
|
|
m_RelativeY = POSITION_RELATIVE_BR;
|
|
|
|
coord.erase(--len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_RelativeY = POSITION_ABSOLUTE;
|
|
|
|
}
|
|
|
|
|
|
|
|
double val;
|
2011-11-26 02:49:52 +00:00
|
|
|
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && parser.ParseFormula(coord, &val))
|
2010-06-01 14:55:52 +00:00
|
|
|
{
|
|
|
|
m_Y = (int)val;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-26 02:49:52 +00:00
|
|
|
m_Y = (int)parser.ParseDouble(coord.c_str(), 0.0);
|
2010-06-01 14:55:52 +00:00
|
|
|
}
|
2010-04-10 02:29:52 +00:00
|
|
|
}
|
2010-05-31 21:02:04 +00:00
|
|
|
else
|
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
m_Y = 0;
|
2010-05-31 21:02:04 +00:00
|
|
|
m_RelativeY = POSITION_ABSOLUTE;
|
|
|
|
}
|
2010-06-01 14:55:52 +00:00
|
|
|
}
|
2010-04-10 02:29:52 +00:00
|
|
|
|
2010-06-01 14:55:52 +00:00
|
|
|
m_W = (int)parser.ReadFormula(section, L"W", 1.0);
|
2011-11-01 04:56:46 +00:00
|
|
|
m_WDefined = parser.GetLastValueDefined();
|
2011-11-03 00:13:42 +00:00
|
|
|
|
2010-06-01 14:55:52 +00:00
|
|
|
m_H = (int)parser.ReadFormula(section, L"H", 1.0);
|
2011-11-01 04:56:46 +00:00
|
|
|
m_HDefined = parser.GetLastValueDefined();
|
2010-06-01 14:55:52 +00:00
|
|
|
|
|
|
|
if (!m_Initialized)
|
|
|
|
{
|
2011-11-03 00:13:42 +00:00
|
|
|
m_MeasureName = parser.ReadString(section, L"MeasureName", L"");
|
|
|
|
|
2010-06-01 14:55:52 +00:00
|
|
|
m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2010-05-31 21:02:04 +00:00
|
|
|
else
|
|
|
|
{
|
2011-11-27 08:30:39 +00:00
|
|
|
std::wstring oldStyleHidden = m_StyleHidden;
|
|
|
|
|
2010-11-04 00:17:42 +00:00
|
|
|
const std::wstring& result = parser.ReadString(section, L"Hidden", L"0");
|
|
|
|
m_StyleHidden = parser.GetLastUsedStyle();
|
2011-11-27 08:30:39 +00:00
|
|
|
if (parser.GetLastReplaced() || !parser.GetLastDefaultUsed() && wcscmp(m_StyleHidden.c_str(), oldStyleHidden.c_str()) != 0)
|
2010-06-01 14:55:52 +00:00
|
|
|
{
|
2011-11-26 02:49:52 +00:00
|
|
|
m_Hidden = 0!=parser.ParseInt(result.c_str(), 0);
|
2010-06-01 14:55:52 +00:00
|
|
|
}
|
2010-05-31 21:02:04 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
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
|
|
|
|
2009-10-01 03:13:19 +00:00
|
|
|
m_LeftMouseDownAction = parser.ReadString(section, L"LeftMouseDownAction", L"", false);
|
2011-11-18 22:40:58 +00:00
|
|
|
m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", L"", false);
|
2009-10-01 03:13:19 +00:00
|
|
|
m_MiddleMouseDownAction = parser.ReadString(section, L"MiddleMouseDownAction", L"", false);
|
|
|
|
m_LeftMouseUpAction = parser.ReadString(section, L"LeftMouseUpAction", L"", false);
|
2011-11-18 22:40:58 +00:00
|
|
|
m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", L"", false);
|
2009-10-01 03:13:19 +00:00
|
|
|
m_MiddleMouseUpAction = parser.ReadString(section, L"MiddleMouseUpAction", L"", false);
|
* 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
|
|
|
m_LeftMouseDoubleClickAction = parser.ReadString(section, L"LeftMouseDoubleClickAction", L"", false);
|
2011-11-18 22:40:58 +00:00
|
|
|
m_RightMouseDoubleClickAction = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false);
|
* 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
|
|
|
m_MiddleMouseDoubleClickAction = parser.ReadString(section, L"MiddleMouseDoubleClickAction", L"", false);
|
2009-10-01 03:13:19 +00:00
|
|
|
m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L"", false);
|
|
|
|
m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-11-08 10:32:57 +00:00
|
|
|
m_MouseActionCursor = 0!=parser.ReadInt(section, L"MouseActionCursor", m_MeterWindow->GetMeterMouseActionCursor());
|
2009-09-25 22:20:07 +00:00
|
|
|
|
2009-09-26 07:16:55 +00:00
|
|
|
m_HasMouseAction =
|
* 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
|
|
|
( !m_LeftMouseUpAction.empty() || !m_LeftMouseDownAction.empty() || !m_LeftMouseDoubleClickAction.empty()
|
|
|
|
|| !m_MiddleMouseUpAction.empty() || !m_MiddleMouseDownAction.empty() || !m_MiddleMouseDoubleClickAction.empty()
|
|
|
|
|| !m_RightMouseUpAction.empty() || !m_RightMouseDownAction.empty() || !m_RightMouseDoubleClickAction.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"");
|
2010-09-13 17:03:09 +00:00
|
|
|
m_ToolTipWidth = (int)parser.ReadFormula(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.
|
|
|
|
**
|
|
|
|
*/
|
2010-11-19 07:33:58 +00:00
|
|
|
void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
// The meter is not bound to anything
|
|
|
|
if (m_MeasureName.empty())
|
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
std::wstring error = L"The meter [" + m_Name;
|
2011-11-09 09:27:06 +00:00
|
|
|
error += L"] is unbound";
|
|
|
|
throw CError(error);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Go through the list and check it there is a measure for us
|
2011-11-16 16:47:20 +00:00
|
|
|
const WCHAR* measure = m_MeasureName.c_str();
|
2010-03-30 22:37:05 +00:00
|
|
|
std::list<CMeasure*>::const_iterator i = measures.begin();
|
2011-03-29 19:21:57 +00:00
|
|
|
for ( ; i != measures.end(); ++i)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-16 16:47:20 +00:00
|
|
|
if (_wcsicmp((*i)->GetName(), measure) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
m_Measure = (*i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-21 16:45:29 +00:00
|
|
|
// Error :)
|
2010-11-25 22:00:34 +00:00
|
|
|
std::wstring error = L"The meter [" + m_Name;
|
2010-11-25 15:34:49 +00:00
|
|
|
error += L"] cannot be bound with [";
|
|
|
|
error += m_MeasureName;
|
2011-12-04 22:18:40 +00:00
|
|
|
error += L']';
|
2011-11-09 09:27:06 +00:00
|
|
|
throw CError(error);
|
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
|
|
|
|
2010-09-21 16:45:29 +00:00
|
|
|
// Error
|
2010-11-25 15:34:49 +00:00
|
|
|
std::wstring error = L"Meter=";
|
|
|
|
error += meter;
|
2011-11-09 09:27:06 +00:00
|
|
|
error += L" is not valid in [";
|
2011-02-15 16:26:54 +00:00
|
|
|
error += name;
|
2011-12-04 22:18:40 +00:00
|
|
|
error += L']';
|
2011-11-09 09:27:06 +00:00
|
|
|
throw CError(error);
|
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
|
|
|
/*
|
2010-09-17 08:47:22 +00:00
|
|
|
** Creates a vector containing all the defined measures (for Histogram)
|
2010-09-10 17:29:30 +00:00
|
|
|
*/
|
|
|
|
void CMeter::SetAllMeasures(CMeasure* measure)
|
|
|
|
{
|
|
|
|
m_AllMeasures.clear();
|
2011-12-09 03:28:19 +00:00
|
|
|
m_AllMeasures.reserve(2);
|
2010-09-10 17:29:30 +00:00
|
|
|
m_AllMeasures.push_back(m_Measure);
|
|
|
|
m_AllMeasures.push_back(measure);
|
|
|
|
}
|
|
|
|
|
2010-09-17 08:47:22 +00:00
|
|
|
/*
|
2010-12-05 15:34:37 +00:00
|
|
|
** Creates a vector containing all the defined measures (for Image/Line/String)
|
2010-09-17 08:47:22 +00:00
|
|
|
*/
|
2010-11-19 07:33:58 +00:00
|
|
|
void CMeter::SetAllMeasures(const std::vector<CMeasure*>& measures)
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
|
|
|
m_AllMeasures.clear();
|
2011-12-09 03:28:19 +00:00
|
|
|
m_AllMeasures.reserve(1 + measures.size());
|
2010-09-10 17:29:30 +00:00
|
|
|
m_AllMeasures.push_back(m_Measure);
|
|
|
|
|
|
|
|
std::vector<CMeasure*>::const_iterator i = measures.begin();
|
2011-03-29 19:21:57 +00:00
|
|
|
for ( ; i != measures.end(); ++i)
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
|
|
|
m_AllMeasures.push_back(*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-05 15:34:37 +00:00
|
|
|
/*
|
|
|
|
** Reads measure names (MeasureName2 - MeasureName[N])
|
|
|
|
*/
|
|
|
|
void CMeter::ReadMeasureNames(CConfigParser& parser, const WCHAR* section, std::vector<std::wstring>& measureNames)
|
|
|
|
{
|
|
|
|
WCHAR tmpName[64];
|
|
|
|
|
|
|
|
int i = 2;
|
|
|
|
bool loop = true;
|
2011-03-29 19:21:57 +00:00
|
|
|
do
|
2010-12-05 15:34:37 +00:00
|
|
|
{
|
2010-12-16 20:35:44 +00:00
|
|
|
_snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i);
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::wstring& measure = parser.ReadString(section, tmpName, L"");
|
2010-12-05 15:34:37 +00:00
|
|
|
if (!measure.empty())
|
|
|
|
{
|
|
|
|
measureNames.push_back(measure);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
loop = false;
|
|
|
|
}
|
|
|
|
++i;
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
|
|
|
while(loop);
|
2010-12-05 15:34:37 +00:00
|
|
|
}
|
|
|
|
|
2010-09-10 17:29:30 +00:00
|
|
|
/*
|
|
|
|
** Replaces %1, %2 etc with the corresponding measure value
|
|
|
|
*/
|
2010-12-05 15:34:37 +00:00
|
|
|
bool CMeter::ReplaceMeasures(const std::vector<std::wstring>& stringValues, std::wstring& str)
|
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
|
|
|
|
2010-12-04 15:07:28 +00:00
|
|
|
// Create the actual text (i.e. replace %1, %2, .. with the measure texts)
|
|
|
|
for (size_t i = stringValues.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;
|
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)
|
|
|
|
{
|
2011-12-09 03:28:19 +00:00
|
|
|
str.replace(pos, len, stringValues[i - 1]);
|
2010-12-04 15:07:28 +00:00
|
|
|
start = pos + stringValues[i - 1].length();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Replaces %1, %2 etc with the corresponding measure value
|
|
|
|
*/
|
|
|
|
void CMeter::ReplaceToolTipMeasures(std::wstring& str)
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
|
|
|
std::vector<std::wstring> stringValues;
|
|
|
|
|
2010-11-19 07:33:58 +00:00
|
|
|
if (!m_AllMeasures.empty())
|
2011-03-29 19:21:57 +00:00
|
|
|
{
|
2010-09-17 08:47:22 +00:00
|
|
|
// Get the values for the measures
|
2011-11-08 10:32:57 +00:00
|
|
|
std::vector<CMeasure*>::const_iterator iter = m_AllMeasures.begin();
|
|
|
|
for ( ; iter != m_AllMeasures.end(); ++iter)
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
stringValues.push_back((*iter)->GetStringValue(AUTOSCALE_ON, 1, 0, false));
|
2010-09-10 17:29:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_Measure != NULL)
|
|
|
|
{
|
2011-01-19 15:31:45 +00:00
|
|
|
stringValues.push_back(m_Measure->GetStringValue(AUTOSCALE_ON, 1, 0, false));
|
2010-09-10 17:29:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-19 07:33:58 +00:00
|
|
|
return;
|
2010-09-10 17:29:30 +00:00
|
|
|
}
|
|
|
|
|
2010-11-19 07:33:58 +00:00
|
|
|
if (!stringValues.empty())
|
2010-09-10 17:29:30 +00:00
|
|
|
{
|
2010-11-19 07:33:58 +00:00
|
|
|
ReplaceMeasures(stringValues, str);
|
2010-09-10 17:29:30 +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();
|
|
|
|
HINSTANCE hInstance = m_MeterWindow->GetMainObject()->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;
|
|
|
|
ReplaceToolTipMeasures(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;
|
|
|
|
ReplaceToolTipMeasures(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);
|
|
|
|
}
|