diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-12-21 09:49:05 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-12-21 09:49:05 +0000 |
commit | 9b119cadd74e1343cad493e8b366e69743a620d0 (patch) | |
tree | e11d3923e86eb667f1a2f20e1126066e51ed73ce /plugins/Quotes/src/Chart.h | |
parent | 1b85ad91e7aa1af9d295d399e560a2adc6d413d3 (diff) |
Quotes: changed warning level to w4
git-svn-id: http://svn.miranda-ng.org/main/trunk@11552 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Quotes/src/Chart.h')
-rw-r--r-- | plugins/Quotes/src/Chart.h | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/plugins/Quotes/src/Chart.h b/plugins/Quotes/src/Chart.h index 4e00d3cba4..ba42d6a7b2 100644 --- a/plugins/Quotes/src/Chart.h +++ b/plugins/Quotes/src/Chart.h @@ -18,7 +18,7 @@ namespace detail }
};
- template<> struct CConverter<double>
+ template<> struct CConverter < double >
{
static double Convert(double v)
{
@@ -35,15 +35,15 @@ namespace detail };
}
-template<class TXValue,class TYValue,class TXConverter = detail::CConverter<TXValue>,class TYConverter = detail::CConverter<TYValue> >
+template<class TXValue, class TYValue, class TXConverter = detail::CConverter<TXValue>, class TYConverter = detail::CConverter<TYValue> >
class CChart
{
private:
- typedef std::pair<TXValue,TYValue> TValue;
+ typedef std::pair<TXValue, TYValue> TValue;
typedef std::vector<TValue> TValues;
public:
- CChart() : m_MaxY(),m_MinY()
+ CChart() : m_MaxY(), m_MinY()
{
memset(&m_rect, 0, sizeof(m_rect));
}
@@ -52,21 +52,21 @@ public: {
}
- void AddValue(const TXValue& x,const TYValue& y)
+ void AddValue(const TXValue& x, const TYValue& y)
{
- if(m_aValues.empty())
+ if (m_aValues.empty())
{
m_MaxY = m_MinY = y;
}
- else
+ else
{
- m_MaxY = __max(y,m_MaxY);
- m_MinY = __min(y,m_MinY);
+ m_MaxY = __max(y, m_MaxY);
+ m_MinY = __min(y, m_MinY);
}
- m_aValues.push_back(std::make_pair(x,y));
+ m_aValues.push_back(std::make_pair(x, y));
}
- void SetRect(int x,int y,int cx,int cy)
+ void SetRect(int x, int y, int cx, int cy)
{
m_rect.left = x;
m_rect.right = x + cx;
@@ -77,117 +77,117 @@ public: void Draw(HDC hdc)const
{
RECT rc = m_rect;
- DrawBackground(hdc,rc);
- if(false == m_aValues.empty())
+ DrawBackground(hdc, rc);
+ if (false == m_aValues.empty())
{
- ::InflateRect(&rc,-10,-10);
- DrawGrid(hdc,rc);
- DrawAxis(hdc,rc);
- DrawPoints(hdc,rc);
+ ::InflateRect(&rc, -10, -10);
+ DrawGrid(hdc, rc);
+ DrawAxis(hdc, rc);
+ DrawPoints(hdc, rc);
}
else
{
HFONT hFont = static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
- HFONT hOldFont = static_cast<HFONT>(::SelectObject(hdc,hFont));
+ HFONT hOldFont = static_cast<HFONT>(::SelectObject(hdc, hFont));
LPCTSTR pszText = TranslateT("There is no to show");
int nDrawTextResult = ::DrawText(hdc, pszText, -1, &rc, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
assert(0 != nDrawTextResult);
- ::SelectObject(hdc,hOldFont);
+ ::SelectObject(hdc, hOldFont);
BOOL bResult = ::DeleteObject(hFont);
assert(TRUE == bResult);
}
}
private:
- void DrawBackground(HDC hdc,RECT& rc)const
+ void DrawBackground(HDC hdc, RECT& rc)const
{
-// HBRUSH hBrush = ::CreateSolidBrush(RGB(255,0,0));//user preferable background color here!
-// ::FillRect(hdc,&m_rect,hBrush);
-// ::DeleteBrush(hBrush);
+ // HBRUSH hBrush = ::CreateSolidBrush(RGB(255,0,0));//user preferable background color here!
+ // ::FillRect(hdc,&m_rect,hBrush);
+ // ::DeleteBrush(hBrush);
}
- void DrawGrid(HDC hdc,RECT& rc)const
+ void DrawGrid(HDC hdc, RECT& rc)const
{
- enum{number_of_lines = 5};
- HPEN hPen = ::CreatePen(PS_SOLID,1,RGB(125,125,125));
- HPEN hPenOld = static_cast<HPEN>(::SelectObject(hdc,hPen));
+ enum{ number_of_lines = 5 };
+ HPEN hPen = ::CreatePen(PS_SOLID, 1, RGB(125, 125, 125));
+ HPEN hPenOld = static_cast<HPEN>(::SelectObject(hdc, hPen));
HFONT hFont = static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
- HFONT hOldFont = static_cast<HFONT>(::SelectObject(hdc,hFont));
+ HFONT hOldFont = static_cast<HFONT>(::SelectObject(hdc, hFont));
//vertical grid
- int step = (rc.bottom-rc.top)/number_of_lines;
- TYValue y_val = m_MinY + ((m_MaxY-m_MinY)/number_of_lines);
+ int step = (rc.bottom - rc.top) / number_of_lines;
+ TYValue y_val = m_MinY + ((m_MaxY - m_MinY) / number_of_lines);
int nXIndent = 0;
- for(int y = rc.bottom-step;y > rc.top;y-=step,y_val+=((m_MaxY-m_MinY)/number_of_lines))
+ for (int y = rc.bottom - step; y > rc.top; y -= step, y_val += ((m_MaxY - m_MinY) / number_of_lines))
{
tstring sY = TYConverter::ToString(y_val);
- SIZE sizeText = {0,0};
- BOOL bResult = ::GetTextExtentPoint32(hdc,sY.c_str(), (int)sY.size(), &sizeText);
+ SIZE sizeText = { 0, 0 };
+ BOOL bResult = ::GetTextExtentPoint32(hdc, sY.c_str(), (int)sY.size(), &sizeText);
assert(TRUE == bResult);
- nXIndent = __max(nXIndent,sizeText.cx);
+ nXIndent = __max(nXIndent, sizeText.cx);
}
- y_val = m_MinY + ((m_MaxY-m_MinY)/number_of_lines);
+ y_val = m_MinY + ((m_MaxY - m_MinY) / number_of_lines);
nXIndent += 2;
rc.left += nXIndent;
- for (int y = rc.bottom-step;y > rc.top;y-=step,y_val+=((m_MaxY-m_MinY)/number_of_lines))
+ for (int y = rc.bottom - step; y > rc.top; y -= step, y_val += ((m_MaxY - m_MinY) / number_of_lines))
{
tstring sY = TYConverter::ToString(y_val);
- SIZE sizeText = {0,0};
+ SIZE sizeText = { 0, 0 };
BOOL bResult = ::GetTextExtentPoint32(hdc, sY.c_str(), (int)sY.size(), &sizeText);
assert(TRUE == bResult);
- RECT rcText = {rc.left-nXIndent,y-(sizeText.cy/2),rc.left-1,y+(sizeText.cy/2)};
- int nDrawTextResult = ::DrawText(hdc, sY.c_str(), -1, &rcText, DT_SINGLELINE|DT_VCENTER|DT_RIGHT);
+ RECT rcText = { rc.left - nXIndent, y - (sizeText.cy / 2), rc.left - 1, y + (sizeText.cy / 2) };
+ int nDrawTextResult = ::DrawText(hdc, sY.c_str(), -1, &rcText, DT_SINGLELINE | DT_VCENTER | DT_RIGHT);
assert(0 != nDrawTextResult);
- bResult = ::MoveToEx(hdc,rc.left,y,NULL);
+ bResult = ::MoveToEx(hdc, rc.left, y, NULL);
assert(TRUE == bResult);
- bResult = ::LineTo(hdc,rc.right,y);
+ bResult = ::LineTo(hdc, rc.right, y);
assert(TRUE == bResult);
}
// horizontal grid
- HRGN rgnAllLables = ::CreateRectRgn(0,0,0,0);
- HRGN rgnTemporary = ::CreateRectRgn(0,0,0,0);
+ HRGN rgnAllLables = ::CreateRectRgn(0, 0, 0, 0);
+ HRGN rgnTemporary = ::CreateRectRgn(0, 0, 0, 0);
bool bFixedRect = false;
- step = (rc.right-rc.left)/number_of_lines;
- TXValue x_val = m_aValues[0].first + ((m_aValues[m_aValues.size()-1].first-m_aValues[0].first)/number_of_lines);
- for(int x = rc.left+step;x < rc.right;x+=step,x_val+=((m_aValues[m_aValues.size()-1].first-m_aValues[0].first)/number_of_lines))
+ step = (rc.right - rc.left) / number_of_lines;
+ TXValue x_val = m_aValues[0].first + ((m_aValues[m_aValues.size() - 1].first - m_aValues[0].first) / number_of_lines);
+ for (int x = rc.left + step; x < rc.right; x += step, x_val += ((m_aValues[m_aValues.size() - 1].first - m_aValues[0].first) / number_of_lines))
{
tstring sX = TXConverter::ToString(x_val);
- SIZE sizeText = {0,0};
+ SIZE sizeText = { 0, 0 };
BOOL bResult = ::GetTextExtentPoint32(hdc, sX.c_str(), (int)sX.size(), &sizeText);
assert(TRUE == bResult);
- if(false == bFixedRect)
+ if (false == bFixedRect)
{
- rc.bottom -= sizeText.cy+2;
+ rc.bottom -= sizeText.cy + 2;
bFixedRect = true;
}
- RECT rcText = {x-(sizeText.cx/2),rc.bottom,x+(sizeText.cx/2),rc.bottom+sizeText.cy-1};
+ RECT rcText = { x - (sizeText.cx / 2), rc.bottom, x + (sizeText.cx / 2), rc.bottom + sizeText.cy - 1 };
// Draw a label if it doesn't overlap with previous ones
HRGN rgnCurrentLable = ::CreateRectRgnIndirect(&rcText);
- if(NULLREGION == ::CombineRgn(rgnTemporary,rgnCurrentLable,rgnAllLables,RGN_AND))
+ if (NULLREGION == ::CombineRgn(rgnTemporary, rgnCurrentLable, rgnAllLables, RGN_AND))
{
- int nDrawTextResult = ::DrawText(hdc, sX.c_str(), (int)sX.size(), &rcText, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
+ int nDrawTextResult = ::DrawText(hdc, sX.c_str(), (int)sX.size(), &rcText, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
assert(0 != nDrawTextResult);
- int nCombineRgnResult = ::CombineRgn(rgnTemporary,rgnCurrentLable,rgnAllLables,RGN_OR);
+ int nCombineRgnResult = ::CombineRgn(rgnTemporary, rgnCurrentLable, rgnAllLables, RGN_OR);
assert(ERROR != nCombineRgnResult);
- nCombineRgnResult = ::CombineRgn(rgnAllLables,rgnTemporary,NULL,RGN_COPY);
+ nCombineRgnResult = ::CombineRgn(rgnAllLables, rgnTemporary, NULL, RGN_COPY);
assert(ERROR != nCombineRgnResult);
}
bResult = ::DeleteObject(rgnCurrentLable);
assert(TRUE == bResult);
-
- bResult = ::MoveToEx(hdc,x,rc.bottom,NULL);
+
+ bResult = ::MoveToEx(hdc, x, rc.bottom, NULL);
assert(TRUE == bResult);
- bResult = ::LineTo(hdc,x,rc.top);
+ bResult = ::LineTo(hdc, x, rc.top);
assert(TRUE == bResult);
}
@@ -196,76 +196,76 @@ private: bResult = ::DeleteObject(rgnTemporary);
assert(TRUE == bResult);
- ::SelectObject(hdc,hOldFont);
- ::SelectObject(hdc,hPenOld);
+ ::SelectObject(hdc, hOldFont);
+ ::SelectObject(hdc, hPenOld);
bResult = ::DeleteObject(hFont);
assert(TRUE == bResult);
bResult = ::DeleteObject(hPen);
assert(TRUE == bResult);
}
- void DrawAxis(HDC hdc,RECT& rc)const
+ void DrawAxis(HDC hdc, RECT& rc)const
{
- HPEN hPen = ::CreatePen(PS_SOLID,2,RGB(0,0,0));
- HPEN hPenOld = static_cast<HPEN>(::SelectObject(hdc,hPen));
+ HPEN hPen = ::CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
+ HPEN hPenOld = static_cast<HPEN>(::SelectObject(hdc, hPen));
// draw Y-axes
- BOOL bResult = ::MoveToEx(hdc,rc.left+1,rc.bottom-1,NULL);
+ BOOL bResult = ::MoveToEx(hdc, rc.left + 1, rc.bottom - 1, NULL);
assert(TRUE == bResult);
- bResult = ::LineTo(hdc,rc.left+1,rc.top+1);
+ bResult = ::LineTo(hdc, rc.left + 1, rc.top + 1);
assert(TRUE == bResult);
// draw X-axes
- bResult = ::MoveToEx(hdc,rc.left+1,rc.bottom-1,NULL);
+ bResult = ::MoveToEx(hdc, rc.left + 1, rc.bottom - 1, NULL);
assert(TRUE == bResult);
- bResult = ::LineTo(hdc,rc.right-1,rc.bottom-1);
+ bResult = ::LineTo(hdc, rc.right - 1, rc.bottom - 1);
assert(TRUE == bResult);
- ::SelectObject(hdc,hPenOld);
+ ::SelectObject(hdc, hPenOld);
bResult = ::DeleteObject(hPen);
assert(TRUE == bResult);
}
- void DrawPoints(HDC hdc,RECT& rc)const
- {
+ void DrawPoints(HDC hdc, RECT& rc)const
+ {
TXValue xMin(m_aValues[0].first);
- double dx = TXConverter::Convert(m_aValues[m_aValues.size()-1].first-xMin);
- double dY = TYConverter::Convert(m_MaxY-m_MinY);
+ double dx = TXConverter::Convert(m_aValues[m_aValues.size() - 1].first - xMin);
+ double dY = TYConverter::Convert(m_MaxY - m_MinY);
- HPEN hPen = ::CreatePen(PS_SOLID,1,RGB(255,0,0));
- HGDIOBJ hPenOld = ::SelectObject(hdc,hPen);
+ HPEN hPen = ::CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
+ HGDIOBJ hPenOld = ::SelectObject(hdc, hPen);
- HBRUSH hBrush = ::CreateSolidBrush(RGB(255,0,0));
- HGDIOBJ hBrushOld = ::SelectObject(hdc,hBrush);
+ HBRUSH hBrush = ::CreateSolidBrush(RGB(255, 0, 0));
+ HGDIOBJ hBrushOld = ::SelectObject(hdc, hBrush);
bool bPrevValid = false;
- int xPrex,yPrev;
+ int xPrex, yPrev;
- BOOST_FOREACH(const TValue& v,m_aValues)
+ BOOST_FOREACH(const TValue& v, m_aValues)
{
- double k = TXConverter::Convert(v.first-xMin);
+ double k = TXConverter::Convert(v.first - xMin);
- int x = rc.left+boost::numeric_cast<int>((rc.right-rc.left)*(k/dx));
- k = TYConverter::Convert(v.second-m_MinY);
- int y = rc.bottom-boost::numeric_cast<int>((rc.bottom-rc.top)*(k/dY));
- ::Ellipse(hdc,x-5,y-5,x+5,y+5);
- if(bPrevValid)
+ int x = rc.left + boost::numeric_cast<int>((rc.right - rc.left)*(k / dx));
+ k = TYConverter::Convert(v.second - m_MinY);
+ int y = rc.bottom - boost::numeric_cast<int>((rc.bottom - rc.top)*(k / dY));
+ ::Ellipse(hdc, x - 5, y - 5, x + 5, y + 5);
+ if (bPrevValid)
{
- BOOL bResult = ::MoveToEx(hdc,xPrex,yPrev,NULL);
+ BOOL bResult = ::MoveToEx(hdc, xPrex, yPrev, NULL);
assert(TRUE == bResult);
- bResult = ::LineTo(hdc,x,y);
+ bResult = ::LineTo(hdc, x, y);
assert(TRUE == bResult);
}
- xPrex = x,yPrev = y;
+ xPrex = x, yPrev = y;
bPrevValid = true;
}
- ::SelectObject(hdc,hPenOld);
+ ::SelectObject(hdc, hPenOld);
BOOL bResult = ::DeleteObject(hPen);
assert(TRUE == bResult);
- ::SelectObject(hdc,hBrushOld);
+ ::SelectObject(hdc, hBrushOld);
bResult = ::DeleteObject(hBrush);
assert(TRUE == bResult);
}
|