This commit is contained in:
Birunthan Mohanathas 2012-07-17 17:47:34 +03:00
parent 40212ddd5e
commit 3653e16f88

View File

@ -82,14 +82,31 @@ CMeter::~CMeter()
} }
/* /*
** Initializes the meter. The base implementation just stores the pointer. ** Initializes the meter. Usually this method is overwritten by the inherited
** Usually this method is overwritten by the inherited classes, which load ** classes, which load bitmaps and such things during initialization.
** bitmaps and such things during initialization.
** **
*/ */
void CMeter::Initialize() void CMeter::Initialize()
{ {
m_Initialized = true; m_Initialized = true;
if (!m_RelativeMeter)
{
const std::list<CMeter*>& meters = m_MeterWindow->GetMeters();
for (auto iter = meters.cbegin(); iter != meters.cend(); ++iter)
{
if (*iter == this)
{
if (iter != meters.begin())
{
--iter;
m_RelativeMeter = (*iter);
}
break;
}
}
}
} }
/* /*
@ -98,41 +115,15 @@ void CMeter::Initialize()
*/ */
int CMeter::GetX(bool abs) int CMeter::GetX(bool abs)
{ {
if (m_RelativeX != POSITION_ABSOLUTE) if (m_RelativeX != POSITION_ABSOLUTE && m_RelativeMeter)
{ {
if (m_RelativeMeter == NULL) if (m_RelativeX == POSITION_RELATIVE_TL)
{ {
const std::list<CMeter*>& meters = m_MeterWindow->GetMeters(); return m_RelativeMeter->GetX(true) + m_X;
std::list<CMeter*>::const_iterator iter = meters.begin();
// Find this meter
for ( ; iter != meters.end(); ++iter)
{
if (*iter == this && iter != meters.begin())
{
--iter;
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 else
{ {
if (m_RelativeX == POSITION_RELATIVE_TL) return m_RelativeMeter->GetX(true) + m_RelativeMeter->GetW() + m_X;
{
return m_RelativeMeter->GetX(true) + m_X;
}
else
{
return m_RelativeMeter->GetX(true) + m_RelativeMeter->GetW() + m_X;
}
} }
} }
return m_X; return m_X;
@ -144,41 +135,15 @@ int CMeter::GetX(bool abs)
*/ */
int CMeter::GetY(bool abs) int CMeter::GetY(bool abs)
{ {
if (m_RelativeY != POSITION_ABSOLUTE) if (m_RelativeY != POSITION_ABSOLUTE && m_RelativeMeter)
{ {
if (m_RelativeMeter == NULL) if (m_RelativeY == POSITION_RELATIVE_TL)
{ {
const std::list<CMeter*>& meters = m_MeterWindow->GetMeters(); return m_RelativeMeter->GetY() + m_Y;
std::list<CMeter*>::const_iterator iter = meters.begin();
// Find this meter
for ( ; iter != meters.end(); ++iter)
{
if (*iter == this && iter != meters.begin())
{
--iter;
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 else
{ {
if (m_RelativeY == POSITION_RELATIVE_TL) return m_RelativeMeter->GetY() + m_RelativeMeter->GetH() + m_Y;
{
return m_RelativeMeter->GetY() + m_Y;
}
else
{
return m_RelativeMeter->GetY() + m_RelativeMeter->GetH() + m_Y;
}
} }
} }
return m_Y; return m_Y;
@ -268,16 +233,16 @@ void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section)
{ {
if (!coord.empty()) if (!coord.empty())
{ {
size_t len = coord.size(); WCHAR lastChar = coord[coord.size() - 1];
if (coord[len - 1] == L'r') if (lastChar == L'r')
{ {
m_RelativeX = POSITION_RELATIVE_TL; m_RelativeX = POSITION_RELATIVE_TL;
coord.erase(--len); coord.pop_back();
} }
else if (coord[len - 1] == L'R') else if (lastChar == L'R')
{ {
m_RelativeX = POSITION_RELATIVE_BR; m_RelativeX = POSITION_RELATIVE_BR;
coord.erase(--len); coord.pop_back();
} }
else else
{ {
@ -299,16 +264,16 @@ void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section)
{ {
if (!coord.empty()) if (!coord.empty())
{ {
size_t len = coord.size(); WCHAR lastChar = coord[coord.size() - 1];
if (coord[len - 1] == L'r') if (lastChar == L'r')
{ {
m_RelativeY = POSITION_RELATIVE_TL; m_RelativeX = POSITION_RELATIVE_TL;
coord.erase(--len); coord.pop_back();
} }
else if (coord[len - 1] == L'R') else if (lastChar == L'R')
{ {
m_RelativeY = POSITION_RELATIVE_BR; m_RelativeX = POSITION_RELATIVE_BR;
coord.erase(--len); coord.pop_back();
} }
else else
{ {