void Button_Panel::Paint()
{
	BaseClass::Paint();

	DrawButton();
	DrawText();
	DrawDescription();
}
Beispiel #2
0
// 
// lpRect This is the owner window client area
// xShift shift on X axis from the client area rectangle
// yShift shift on Y axis from the client area rectangle
// 
//
// Call by OnPaint as DrawChart(hMemDC, &rcClient, dx, dy);
//
void GDisplay::DrawChart( HDC hDC,  LPRECT lpRect, INT xShift, INT yShift)
{
	// At this point lpRect is owner window client rectangle
	MyFillRect(hDC, lpRect, m_clrBackDark);
	InflateRect(lpRect, -xShift, -yShift);

	// Uncomment the next line to see proper chart rectangle
	//BorderRect(hDC, lpRect, RGB(255,255,255));

	DrawGrid(hDC, lpRect);


	// Form rectangle for painting

	SetRect(&m_rcChart, 
		xShift + m_dxText,
		lpRect->top, 
		m_nMarginRight,		// These margings came from DrawGrid() 
		m_nMarginBottom);	// where they are calculated

	// How many items the current screen can show ?
	// Note: m_xMinStep forced to be set to DEFAULT_XSTEP ('4' pixels)
	m_nScreenBufferSize = (m_rcChart.right - m_rcChart.left)/m_xMinStep;

	if (m_nScreenBufferSize < MIN_SCREEN_BUFFER_SIZE)
		m_nScreenBufferSize = MIN_SCREEN_BUFFER_SIZE;

	if (m_nScreenBufferSize > MAX_SCREEN_BUFFER_SIZE)
		m_nScreenBufferSize = MAX_SCREEN_BUFFER_SIZE;


	POINT ptOld[MAX_CHART_COUNT];	// Start point
	POINT ptNew[MAX_CHART_COUNT];	// End point

	double new_value[MAX_CHART_COUNT];
	double old_value[MAX_CHART_COUNT];

	for (int i = 0; i < m_nScreenBufferSize; i++)
	{
		for (int k = 0; k < m_nChartCount; k++)
		{
			new_value[k] = m_dScreenBuffer[k][i+1];
			old_value[k] = m_dScreenBuffer[k][i];


			ptOld[k].x = m_xMinStep*i + m_rcChart.left;
			ptNew[k].x = m_xMinStep*(i+1)+ m_rcChart.left;

			// Convert actual value to screen units
			if (!dtoi(m_rcChart.bottom, 
				m_rcChart.top, 
				m_dblMin[k],
				m_dblMax[k], 
				old_value[k], &(ptOld[k].y)))
			{
				ptOld[k].y = m_rcChart.bottom;
			}

			if (!dtoi(m_rcChart.bottom, 
				m_rcChart.top, 
				m_dblMin[k], 
				m_dblMax[k],  
				new_value[k], &(ptNew[k].y)))
			{
				ptNew[k].y = m_rcChart.bottom;	
			}


			if (ptOld[k].y <= m_rcChart.top)
				ptOld[k].y = m_rcChart.top;

			if (ptOld[k].y >= m_rcChart.bottom)
				ptOld[k].y = m_rcChart.bottom;

			if (ptNew[k].y <= m_rcChart.top)
				ptNew[k].y = m_rcChart.top;

			if (ptNew[k].y >= m_rcChart.bottom)
				ptNew[k].y = m_rcChart.bottom;

			// we out of the right border
			if (ptNew[k].x >= m_rcChart.right)
			{
				ResetBuffer(INIT_BUFFER_VALUE);
			}

			DrawMarker(hDC, &ptOld[k], &ptNew[k], m_rcChart.right, m_clrMarker[k]);
			DrawUpdateLine(hDC, m_xUpdatePosition, &m_rcChart);
			DrawDescription(hDC, &m_rcChart);			


		} // for (k < m_nChartCount)
	} // for (i < m_nScreenBufferSize)
}