taskmgr: Reorder some functions to avoid forward declarations in graphctl.c.

This commit is contained in:
Francois Gouget 2009-02-05 00:10:52 +01:00 committed by Alexandre Julliard
parent 097863ba46
commit 07ccd5a36d
2 changed files with 123 additions and 127 deletions

View File

@ -124,7 +124,39 @@ TGraphCtrl::~TGraphCtrl(void)
} }
#endif #endif
BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID) void GraphCtrl_Resize(TGraphCtrl* this)
{
/* NOTE: Resize automatically gets called during the setup of the control */
GetClientRect(this->m_hWnd, &this->m_rectClient);
/* set some member variables to avoid multiple function calls */
this->m_nClientHeight = this->m_rectClient.bottom - this->m_rectClient.top;/* m_rectClient.Height(); */
this->m_nClientWidth = this->m_rectClient.right - this->m_rectClient.left;/* m_rectClient.Width(); */
/* the "left" coordinate and "width" will be modified in */
/* InvalidateCtrl to be based on the width of the y axis scaling */
#if 0
this->m_rectPlot.left = 20;
this->m_rectPlot.top = 10;
this->m_rectPlot.right = this->m_rectClient.right-10;
this->m_rectPlot.bottom = this->m_rectClient.bottom-25;
#else
this->m_rectPlot.left = 0;
this->m_rectPlot.top = -1;
this->m_rectPlot.right = this->m_rectClient.right-0;
this->m_rectPlot.bottom = this->m_rectClient.bottom-0;
#endif
/* set some member variables to avoid multiple function calls */
this->m_nPlotHeight = this->m_rectPlot.bottom - this->m_rectPlot.top;/* m_rectPlot.Height(); */
this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */
/* set the scaling factor for now, this can be adjusted */
/* in the SetRange functions */
this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
}
BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
{ {
GraphCtrl_Init(this); GraphCtrl_Init(this);
this->m_hParentWnd = hParentWnd; this->m_hParentWnd = hParentWnd;
@ -133,59 +165,6 @@ BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
return 0; return 0;
} }
void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDecimalPlaces)
{
/* ASSERT(dUpper > dLower); */
this->m_dLowerLimit = dLower;
this->m_dUpperLimit = dUpper;
this->m_nYDecimals = nDecimalPlaces;
this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit;
this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
/* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this);
}
#if 0
void TGraphCtrl::SetXUnits(const char* string)
{
lstrcpynA(m_strXUnitsString, string, sizeof(m_strXUnitsString));
/* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl();
}
void TGraphCtrl::SetYUnits(const char* string)
{
lstrcpynA(m_strYUnitsString, string, sizeof(m_strYUnitsString));
/* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl();
}
#endif
void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color)
{
this->m_crGridColor = color;
/* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this);
}
void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF color)
{
this->m_crPlotColor[plot] = color;
DeleteObject(this->m_penPlot[plot]);
this->m_penPlot[plot] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[plot]);
/* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this);
}
void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF color)
{
this->m_crBackColor = color;
DeleteObject(this->m_brushBack);
this->m_brushBack = CreateSolidBrush(this->m_crBackColor);
/* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this);
}
void GraphCtrl_InvalidateCtrl(TGraphCtrl* this) void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
{ {
/* There is a lot of drawing going on here - particularly in terms of */ /* There is a lot of drawing going on here - particularly in terms of */
@ -342,57 +321,57 @@ void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
ReleaseDC(this->m_hParentWnd, dc); ReleaseDC(this->m_hParentWnd, dc);
} }
double GraphCtrl_AppendPoint(TGraphCtrl* this, void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDecimalPlaces)
double dNewPoint0, double dNewPoint1,
double dNewPoint2, double dNewPoint3)
{ {
/* append a data point to the plot & return the previous point */ /* ASSERT(dUpper > dLower); */
double dPrevious; this->m_dLowerLimit = dLower;
this->m_dUpperLimit = dUpper;
dPrevious = this->m_dCurrentPosition[0]; this->m_nYDecimals = nDecimalPlaces;
this->m_dCurrentPosition[0] = dNewPoint0; this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit;
this->m_dCurrentPosition[1] = dNewPoint1; this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
this->m_dCurrentPosition[2] = dNewPoint2; /* clear out the existing garbage, re-start with a clean plot */
this->m_dCurrentPosition[3] = dNewPoint3; GraphCtrl_InvalidateCtrl(this);
GraphCtrl_DrawPoint(this);
/* Invalidate(); */
return dPrevious;
} }
void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc) #if 0
void TGraphCtrl::SetXUnits(const char* string)
{ {
HDC memDC; lstrcpynA(m_strXUnitsString, string, sizeof(m_strXUnitsString));
HBITMAP memBitmap; /* clear out the existing garbage, re-start with a clean plot */
HBITMAP oldBitmap; /* bitmap originally found in CMemDC */ InvalidateCtrl();
}
/* RECT rcClient; */ void TGraphCtrl::SetYUnits(const char* string)
/* GetClientRect(hWnd, &rcClient); */ {
/* FillSolidRect(dc, &rcClient, RGB(255, 0, 255)); */ lstrcpynA(m_strYUnitsString, string, sizeof(m_strYUnitsString));
/* m_nClientWidth = rcClient.right - rcClient.left; */ /* clear out the existing garbage, re-start with a clean plot */
/* m_nClientHeight = rcClient.bottom - rcClient.top; */ InvalidateCtrl();
}
#endif
/* no real plotting work is performed here, */ void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color)
/* just putting the existing bitmaps on the client */ {
this->m_crGridColor = color;
/* to avoid flicker, establish a memory dc, draw to it */ /* clear out the existing garbage, re-start with a clean plot */
/* and then BitBlt it to the client */ GraphCtrl_InvalidateCtrl(this);
memDC = CreateCompatibleDC(dc); }
memBitmap = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
oldBitmap = SelectObject(memDC, memBitmap);
if (memDC != NULL) void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF color)
{ {
/* first drop the grid on the memory dc */ this->m_crPlotColor[plot] = color;
BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcGrid, 0, 0, SRCCOPY); DeleteObject(this->m_penPlot[plot]);
/* now add the plot on top as a "pattern" via SRCPAINT. */ this->m_penPlot[plot] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[plot]);
/* works well with dark background and a light plot */ /* clear out the existing garbage, re-start with a clean plot */
BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcPlot, 0, 0, SRCPAINT); /* SRCPAINT */ GraphCtrl_InvalidateCtrl(this);
/* finally send the result to the display */ }
BitBlt(dc, 0, 0, this->m_nClientWidth, this->m_nClientHeight, memDC, 0, 0, SRCCOPY);
} void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF color)
SelectObject(memDC, oldBitmap); {
DeleteObject(memBitmap); this->m_crBackColor = color;
DeleteDC(memDC); DeleteObject(this->m_brushBack);
this->m_brushBack = CreateSolidBrush(this->m_crBackColor);
/* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this);
} }
void GraphCtrl_DrawPoint(TGraphCtrl* this) void GraphCtrl_DrawPoint(TGraphCtrl* this)
@ -481,36 +460,57 @@ void GraphCtrl_DrawPoint(TGraphCtrl* this)
} }
} }
void GraphCtrl_Resize(TGraphCtrl* this) double GraphCtrl_AppendPoint(TGraphCtrl* this,
double dNewPoint0, double dNewPoint1,
double dNewPoint2, double dNewPoint3)
{ {
/* NOTE: Resize automatically gets called during the setup of the control */ /* append a data point to the plot & return the previous point */
GetClientRect(this->m_hWnd, &this->m_rectClient); double dPrevious;
/* set some member variables to avoid multiple function calls */ dPrevious = this->m_dCurrentPosition[0];
this->m_nClientHeight = this->m_rectClient.bottom - this->m_rectClient.top;/* m_rectClient.Height(); */ this->m_dCurrentPosition[0] = dNewPoint0;
this->m_nClientWidth = this->m_rectClient.right - this->m_rectClient.left;/* m_rectClient.Width(); */ this->m_dCurrentPosition[1] = dNewPoint1;
this->m_dCurrentPosition[2] = dNewPoint2;
this->m_dCurrentPosition[3] = dNewPoint3;
GraphCtrl_DrawPoint(this);
/* Invalidate(); */
return dPrevious;
}
/* the "left" coordinate and "width" will be modified in */ void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc)
/* InvalidateCtrl to be based on the width of the y axis scaling */ {
#if 0 HDC memDC;
this->m_rectPlot.left = 20; HBITMAP memBitmap;
this->m_rectPlot.top = 10; HBITMAP oldBitmap; /* bitmap originally found in CMemDC */
this->m_rectPlot.right = this->m_rectClient.right-10;
this->m_rectPlot.bottom = this->m_rectClient.bottom-25;
#else
this->m_rectPlot.left = 0;
this->m_rectPlot.top = -1;
this->m_rectPlot.right = this->m_rectClient.right-0;
this->m_rectPlot.bottom = this->m_rectClient.bottom-0;
#endif
/* set some member variables to avoid multiple function calls */ /* RECT rcClient; */
this->m_nPlotHeight = this->m_rectPlot.bottom - this->m_rectPlot.top;/* m_rectPlot.Height(); */ /* GetClientRect(hWnd, &rcClient); */
this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */ /* FillSolidRect(dc, &rcClient, RGB(255, 0, 255)); */
/* m_nClientWidth = rcClient.right - rcClient.left; */
/* m_nClientHeight = rcClient.bottom - rcClient.top; */
/* set the scaling factor for now, this can be adjusted */ /* no real plotting work is performed here, */
/* in the SetRange functions */ /* just putting the existing bitmaps on the client */
this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
/* to avoid flicker, establish a memory dc, draw to it */
/* and then BitBlt it to the client */
memDC = CreateCompatibleDC(dc);
memBitmap = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
oldBitmap = SelectObject(memDC, memBitmap);
if (memDC != NULL)
{
/* first drop the grid on the memory dc */
BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcGrid, 0, 0, SRCCOPY);
/* now add the plot on top as a "pattern" via SRCPAINT. */
/* works well with dark background and a light plot */
BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcPlot, 0, 0, SRCPAINT); /* SRCPAINT */
/* finally send the result to the display */
BitBlt(dc, 0, 0, this->m_nClientWidth, this->m_nClientHeight, memDC, 0, 0, SRCCOPY);
}
SelectObject(memDC, oldBitmap);
DeleteObject(memBitmap);
DeleteDC(memDC);
} }
#if 0 #if 0

View File

@ -91,11 +91,7 @@ double GraphCtrl_AppendPoint(TGraphCtrl* this,
double dNewPoint2, double dNewPoint3); double dNewPoint2, double dNewPoint3);
BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd,
UINT nID); UINT nID);
void GraphCtrl_DrawPoint(TGraphCtrl* this);
void GraphCtrl_InvalidateCtrl(TGraphCtrl* this);
void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc);
void GraphCtrl_Reset(TGraphCtrl* this); void GraphCtrl_Reset(TGraphCtrl* this);
void GraphCtrl_Resize(TGraphCtrl* this);
void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF
color); color);
void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color); void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color);