Beispiel #1
0
/*
** Read the common options specified in the ini file. The inherited classes must
** call this base implementation if they overwrite this method.
**
*/
void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
	// 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"");
	if (!style.empty())
	{
		parser.SetStyleTemplate(style);
	}

	std::wstring oldStyleX = m_StyleX;
	std::wstring oldStyleY = m_StyleY;
	std::wstring oldStyleHidden = m_StyleHidden;

	std::wstring coord = parser.ReadString(section, L"X", L"0");
	m_StyleX = parser.GetLastUsedStyle();
	if (!m_Initialized || parser.GetLastReplaced() || wcscmp(m_StyleX.c_str(), oldStyleX.c_str()) != 0)
	{
		if (!coord.empty())
		{
			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;
			}

			m_X = parser.ParseInt(coord.c_str(), 0);
		}
		else
		{
			m_X = 0;
			m_RelativeX = POSITION_ABSOLUTE;
		}
	}

	coord = parser.ReadString(section, L"Y", L"0");
	m_StyleY = parser.GetLastUsedStyle();
	if (!m_Initialized || parser.GetLastReplaced() || wcscmp(m_StyleY.c_str(), oldStyleY.c_str()) != 0)
	{
		if (!coord.empty())
		{
			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;
			}

			m_Y = parser.ParseInt(coord.c_str(), 0);
		}
		else
		{
			m_Y = 0;
			m_RelativeY = POSITION_ABSOLUTE;
		}
	}

	m_W = parser.ReadInt(section, L"W", 1);
	m_WDefined = parser.GetLastValueDefined();

	m_H = parser.ReadInt(section, L"H", 1);
	m_HDefined = parser.GetLastValueDefined();

	const std::wstring& hidden = parser.ReadString(section, L"Hidden", L"0");
	m_StyleHidden = parser.GetLastUsedStyle();
	if (!m_Initialized || parser.GetLastReplaced() || wcscmp(m_StyleHidden.c_str(), oldStyleHidden.c_str()) != 0)
	{
		m_Hidden = 0!=parser.ParseInt(hidden.c_str(), 0);
	}

	if (!m_Initialized)
	{
		m_MeasureName = parser.ReadString(section, L"MeasureName", L"");
	}

	m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", BEVELTYPE_NONE);

	m_SolidColor = parser.ReadColor(section, L"SolidColor", Color::MakeARGB(0, 0, 0, 0));
	m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor.GetValue());
	m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0);

	m_Mouse.ReadOptions(parser, section, m_MeterWindow);

	m_HasMouseAction =
		!(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());

	m_ToolTipText = parser.ReadString(section, L"ToolTipText", L"");
	m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L"");
	m_ToolTipIcon = parser.ReadString(section, L"ToolTipIcon", L"");
	m_ToolTipWidth = (int)parser.ReadFloat(section, L"ToolTipWidth", 1000);
	m_ToolTipType = 0!=parser.ReadInt(section, L"ToolTipType", 0);
	m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden());

	int updateDivider = parser.ReadInt(section, L"UpdateDivider", 1);
	if (updateDivider != m_UpdateDivider)
	{
		m_UpdateCounter = m_UpdateDivider = updateDivider;
	}

	m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0);
	m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0);

	std::vector<Gdiplus::REAL> matrix = parser.ReadFloats(section, L"TransformationMatrix");
	if (matrix.size() == 6)
	{
		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]);
		}
	}
	else if (!matrix.empty())
	{
		delete m_Transformation;
		m_Transformation = NULL;

		LogWithArgs(LOG_ERROR, L"Meter: Incorrect number of values in TransformationMatrix=%s", parser.ReadString(section, L"TransformationMatrix", L"").c_str());
	}

	const std::wstring& group = parser.ReadString(section, L"Group", L"");
	InitializeGroup(group);
}
Beispiel #2
0
/*
** Reads the common configs for all Measures. The inherited classes
** must call the base implementation if they overwrite this method.
**
*/
void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
	// Clear substitutes to prevent from being added more than once.
	if (!m_Substitute.empty())
	{
		m_Substitute.clear();
	}

	m_Invert = 0!=parser.ReadInt(section, L"InvertMeasure", 0);

	if (!m_Initialized)
	{
		m_Disabled = 0!=parser.ReadInt(section, L"Disabled", 0);
	}
	else
	{
		const std::wstring& result = parser.ReadString(section, L"Disabled", L"0");
		if (parser.GetLastReplaced())
		{
			m_Disabled = 0!=parser.ParseInt(result.c_str(), 0);
		}
	}

	int updateDivider = parser.ReadInt(section, L"UpdateDivider", 1);
	if (updateDivider != m_UpdateDivider)
	{
		m_UpdateCounter = m_UpdateDivider = updateDivider;
	}

	m_MinValue = parser.ReadFormula(section, L"MinValue", m_MinValue);
	m_MaxValue = parser.ReadFormula(section, L"MaxValue", m_MaxValue);

	// The ifabove/ifbelow define actions that are ran when the value goes above/below the given number.

	m_IfAboveValue = parser.ReadFormula(section, L"IfAboveValue", 0.0);
	m_IfAboveAction = parser.ReadString(section, L"IfAboveAction", L"", false);

	m_IfBelowValue = parser.ReadFormula(section, L"IfBelowValue", 0.0);
	m_IfBelowAction = parser.ReadString(section, L"IfBelowAction", L"", false);

	m_IfEqualValue = parser.ReadFormula(section, L"IfEqualValue", 0.0);
	m_IfEqualAction = parser.ReadString(section, L"IfEqualAction", L"", false);

	m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0);

	m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0);

	m_RegExpSubstitute = 0!=parser.ReadInt(section, L"RegExpSubstitute", 0);
	std::wstring subs = parser.ReadString(section, L"Substitute", L"");
	if (!subs.empty())
	{
		if ((subs[0] != L'"' || subs[subs.length() - 1] != L'\'') &&
			(subs[0] != L'\'' || subs[subs.length() - 1] != L'"'))
		{
			// Add quotes since they are removed by the GetProfileString
			subs.insert(0, 1, L'"');
			subs += L'"';
		}
		if (!ParseSubstitute(subs))
		{
			LogWithArgs(LOG_ERROR, L"Measure: Invalid Substitute=%s", subs.c_str());
		}
	}

	const std::wstring& group = parser.ReadString(section, L"Group", L"");
	InitializeGroup(group);
}
Beispiel #3
0
/*
** Read the common options specified in the ini file. The inherited classes must
** call this base implementation if they overwrite this method.
**
*/
void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
	// 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"");
	if (!style.empty())
	{
		parser.SetStyleTemplate(style);
	}

	CSection::ReadOptions(parser, section);

	BindMeasures(parser, section);

	int oldX = m_X;
	std::wstring& x = (std::wstring&)parser.ReadString(section, L"X", L"0");
	if (!x.empty())
	{
		WCHAR lastChar = x[x.size() - 1];
		if (lastChar == L'r')
		{
			m_RelativeX = POSITION_RELATIVE_TL;
			x.pop_back();
		}
		else if (lastChar == L'R')
		{
			m_RelativeX = POSITION_RELATIVE_BR;
			x.pop_back();
		}
		else
		{
			m_RelativeX = POSITION_ABSOLUTE;
		}

		m_X = parser.ParseInt(x.c_str(), 0);
	}
	else
	{
		m_X = 0;
		m_RelativeX = POSITION_ABSOLUTE;
	}

	int oldY = m_Y;
	std::wstring& y = (std::wstring&)parser.ReadString(section, L"Y", L"0");
	if (!y.empty())
	{
		WCHAR lastChar = y[y.size() - 1];
		if (lastChar == L'r')
		{
			m_RelativeY = POSITION_RELATIVE_TL;
			y.pop_back();
		}
		else if (lastChar == L'R')
		{
			m_RelativeY = POSITION_RELATIVE_BR;
			y.pop_back();
		}
		else
		{
			m_RelativeY = POSITION_ABSOLUTE;
		}

		m_Y = parser.ParseInt(y.c_str(), 0);
	}
	else
	{
		m_Y = 0;
		m_RelativeY = POSITION_ABSOLUTE;
	}

	bool oldWDefined = m_WDefined;
	int w = parser.ReadInt(section, L"W", m_W);
	m_WDefined = parser.GetLastValueDefined();
	if (IsFixedSize(true)) m_W = w;
	if (!m_WDefined && oldWDefined && IsFixedSize())
	{
		m_W = 0;
	}
	
	bool oldHDefined = m_HDefined;
	int h = parser.ReadInt(section, L"H", m_H);
	m_HDefined = parser.GetLastValueDefined();
	if (IsFixedSize(true)) m_H = h;
	if (!m_HDefined && oldHDefined && IsFixedSize())
	{
		m_H = 0;
	}

	bool oldHidden = m_Hidden;
	m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0);

	if (oldX != m_X || oldY != m_Y || oldHidden != m_Hidden)
	{
		m_MeterWindow->SetResizeWindowMode(RESIZEMODE_CHECK);	// Need to recalculate the window size
	}

	m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", BEVELTYPE_NONE);

	m_SolidColor = parser.ReadColor(section, L"SolidColor", Color::MakeARGB(0, 0, 0, 0));
	m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor.GetValue());
	m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0);

	m_Mouse.ReadOptions(parser, section);
	m_HasMouseAction = m_Mouse.HasButtonAction() || m_Mouse.HasScrollAction();

	m_ToolTipText = parser.ReadString(section, L"ToolTipText", L"");
	m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L"");
	m_ToolTipIcon = parser.ReadString(section, L"ToolTipIcon", L"");
	m_ToolTipWidth = parser.ReadInt(section, L"ToolTipWidth", 1000);
	m_ToolTipType = 0!=parser.ReadInt(section, L"ToolTipType", 0);
	m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden());

	m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0);

	std::vector<Gdiplus::REAL> matrix = parser.ReadFloats(section, L"TransformationMatrix");
	if (matrix.size() == 6)
	{
		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]);
		}
	}
	else if (!matrix.empty())
	{
		delete m_Transformation;
		m_Transformation = NULL;

		LogWithArgs(LOG_ERROR, L"Meter: Incorrect number of values in TransformationMatrix=%s", parser.ReadString(section, L"TransformationMatrix", L"").c_str());
	}
}