6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 LONG OldGraphCtrlWndProc
;
27 static void GraphCtrl_Init(TGraphCtrl
* this)
32 this->m_hParentWnd
= 0;
35 this->m_bitmapOldGrid
= 0;
36 this->m_bitmapOldPlot
= 0;
37 this->m_bitmapGrid
= 0;
38 this->m_bitmapPlot
= 0;
39 this->m_brushBack
= 0;
41 this->m_penPlot
[0] = 0;
42 this->m_penPlot
[1] = 0;
43 this->m_penPlot
[2] = 0;
44 this->m_penPlot
[3] = 0;
46 /* since plotting is based on a LineTo for each new point
47 * we need a starting point (i.e. a "previous" point)
48 * use 0.0 as the default first point.
49 * these are public member variables, and can be changed outside
50 * (after construction). Therefore m_perviousPosition could be set to
51 * a more appropriate value prior to the first call to SetPosition.
53 this->m_dPreviousPosition
[0] = 0.0;
54 this->m_dPreviousPosition
[1] = 0.0;
55 this->m_dPreviousPosition
[2] = 0.0;
56 this->m_dPreviousPosition
[3] = 0.0;
58 /* public variable for the number of decimal places on the y axis */
59 this->m_nYDecimals
= 3;
61 /* set some initial values for the scaling until "SetRange" is called.
62 * these are protected varaibles and must be set with SetRange
63 * in order to ensure that m_dRange is updated accordingly
65 /* m_dLowerLimit = -10.0; */
66 /* m_dUpperLimit = 10.0; */
67 this->m_dLowerLimit
= 0.0;
68 this->m_dUpperLimit
= 100.0;
69 this->m_dRange
= this->m_dUpperLimit
- this->m_dLowerLimit
; /* protected member variable */
71 /* m_nShiftPixels determines how much the plot shifts (in terms of pixels) */
72 /* with the addition of a new data point */
73 this->m_nShiftPixels
= 4;
74 this->m_nHalfShiftPixels
= this->m_nShiftPixels
/2; /* protected */
75 this->m_nPlotShiftPixels
= this->m_nShiftPixels
+ this->m_nHalfShiftPixels
; /* protected */
77 /* background, grid and data colors */
78 /* these are public variables and can be set directly */
79 this->m_crBackColor
= RGB( 0, 0, 0); /* see also SetBackgroundColor */
80 this->m_crGridColor
= RGB( 0, 255, 255); /* see also SetGridColor */
81 this->m_crPlotColor
[0] = RGB(255, 255, 255); /* see also SetPlotColor */
82 this->m_crPlotColor
[1] = RGB(100, 255, 255); /* see also SetPlotColor */
83 this->m_crPlotColor
[2] = RGB(255, 100, 255); /* see also SetPlotColor */
84 this->m_crPlotColor
[3] = RGB(255, 255, 100); /* see also SetPlotColor */
86 /* protected variables */
87 for (i
= 0; i
< MAX_PLOTS
; i
++)
89 this->m_penPlot
[i
] = CreatePen(PS_SOLID
, 0, this->m_crPlotColor
[i
]);
91 this->m_brushBack
= CreateSolidBrush(this->m_crBackColor
);
93 /* public member variables, can be set directly */
94 strcpy(this->m_strXUnitsString
, "Samples"); /* can also be set with SetXUnits */
95 strcpy(this->m_strYUnitsString
, "Y units"); /* can also be set with SetYUnits */
97 /* protected bitmaps to restore the memory DC's */
98 this->m_bitmapOldGrid
= NULL
;
99 this->m_bitmapOldPlot
= NULL
;
102 void GraphCtrl_Dispose(TGraphCtrl
* this)
104 /* just to be picky restore the bitmaps for the two memory dc's */
105 /* (these dc's are being destroyed so there shouldn't be any leaks) */
106 if (this->m_bitmapOldGrid
!= NULL
) SelectObject(this->m_dcGrid
, this->m_bitmapOldGrid
);
107 if (this->m_bitmapOldPlot
!= NULL
) SelectObject(this->m_dcPlot
, this->m_bitmapOldPlot
);
108 if (this->m_bitmapGrid
!= NULL
) DeleteObject(this->m_bitmapGrid
);
109 if (this->m_bitmapPlot
!= NULL
) DeleteObject(this->m_bitmapPlot
);
110 if (this->m_dcGrid
!= NULL
) DeleteDC(this->m_dcGrid
);
111 if (this->m_dcPlot
!= NULL
) DeleteDC(this->m_dcPlot
);
112 if (this->m_brushBack
!= NULL
) DeleteObject(this->m_brushBack
);
115 BOOL
GraphCtrl_Create(TGraphCtrl
* this, HWND hWnd
, HWND hParentWnd
, UINT nID
)
119 GraphCtrl_Init(this);
120 this->m_hParentWnd
= hParentWnd
;
122 GraphCtrl_Resize(this);
124 GraphCtrl_InvalidateCtrl(this, FALSE
);
128 void GraphCtrl_SetRange(TGraphCtrl
* this, double dLower
, double dUpper
, int nDecimalPlaces
)
130 /* ASSERT(dUpper > dLower); */
131 this->m_dLowerLimit
= dLower
;
132 this->m_dUpperLimit
= dUpper
;
133 this->m_nYDecimals
= nDecimalPlaces
;
134 this->m_dRange
= this->m_dUpperLimit
- this->m_dLowerLimit
;
135 this->m_dVerticalFactor
= (double)this->m_nPlotHeight
/ this->m_dRange
;
136 /* clear out the existing garbage, re-start with a clean plot */
137 GraphCtrl_InvalidateCtrl(this, FALSE
);
141 void TGraphCtrl::SetXUnits(const char* string
)
143 strncpy(m_strXUnitsString
, string
, sizeof(m_strXUnitsString
) - 1);
144 /* clear out the existing garbage, re-start with a clean plot */
148 void TGraphCtrl::SetYUnits(const char* string
)
150 strncpy(m_strYUnitsString
, string
, sizeof(m_strYUnitsString
) - 1);
151 /* clear out the existing garbage, re-start with a clean plot */
156 void GraphCtrl_SetGridColor(TGraphCtrl
* this, COLORREF color
)
158 this->m_crGridColor
= color
;
159 /* clear out the existing garbage, re-start with a clean plot */
160 GraphCtrl_InvalidateCtrl(this, FALSE
);
163 void GraphCtrl_SetPlotColor(TGraphCtrl
* this, int plot
, COLORREF color
)
165 this->m_crPlotColor
[plot
] = color
;
166 DeleteObject(this->m_penPlot
[plot
]);
167 this->m_penPlot
[plot
] = CreatePen(PS_SOLID
, 0, this->m_crPlotColor
[plot
]);
168 /* clear out the existing garbage, re-start with a clean plot */
169 GraphCtrl_InvalidateCtrl(this, FALSE
);
172 void GraphCtrl_SetBackgroundColor(TGraphCtrl
* this, COLORREF color
)
174 this->m_crBackColor
= color
;
175 DeleteObject(this->m_brushBack
);
176 this->m_brushBack
= CreateSolidBrush(this->m_crBackColor
);
177 /* clear out the existing garbage, re-start with a clean plot */
178 GraphCtrl_InvalidateCtrl(this, FALSE
);
181 void GraphCtrl_InvalidateCtrl(TGraphCtrl
* this, BOOL bResize
)
183 /* There is a lot of drawing going on here - particularly in terms of */
184 /* drawing the grid. Don't panic, this is all being drawn (only once) */
185 /* to a bitmap. The result is then BitBlt'd to the control whenever needed. */
188 int nTopGridPix
, nMidGridPix
, nBottomGridPix
;
191 HPEN solidPen
= CreatePen(PS_SOLID
, 0, this->m_crGridColor
);
192 /* HFONT axisFont, yUnitFont, oldFont; */
193 /* char strTemp[50]; */
195 /* in case we haven't established the memory dc's */
196 /* CClientDC dc(this); */
197 HDC dc
= GetDC(this->m_hParentWnd
);
199 /* if we don't have one yet, set up a memory dc for the grid */
200 if (this->m_dcGrid
== NULL
)
202 this->m_dcGrid
= CreateCompatibleDC(dc
);
203 this->m_bitmapGrid
= CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
204 this->m_bitmapOldGrid
= (HBITMAP
)SelectObject(this->m_dcGrid
, this->m_bitmapGrid
);
208 // the size of the drawing area has changed
209 // so create a new bitmap of the appropriate size
210 if(this->m_bitmapGrid
!= NULL
)
212 DeleteObject(this->m_bitmapGrid
);
213 this->m_bitmapGrid
= CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
214 SelectObject(this->m_dcGrid
, this->m_bitmapGrid
);
218 SetBkColor(this->m_dcGrid
, this->m_crBackColor
);
220 /* fill the grid background */
221 FillRect(this->m_dcGrid
, &this->m_rectClient
, this->m_brushBack
);
223 /* draw the plot rectangle: */
224 /* determine how wide the y axis scaling values are */
225 nCharacters
= abs((int)log10(fabs(this->m_dUpperLimit
)));
226 nCharacters
= max(nCharacters
, abs((int)log10(fabs(this->m_dLowerLimit
))));
228 /* add the units digit, decimal point and a minus sign, and an extra space */
229 /* as well as the number of decimal places to display */
230 nCharacters
= nCharacters
+ 4 + this->m_nYDecimals
;
232 /* adjust the plot rectangle dimensions */
233 /* assume 6 pixels per character (this may need to be adjusted) */
234 /* m_rectPlot.left = m_rectClient.left + 6*(nCharacters); */
235 this->m_rectPlot
.left
= this->m_rectClient
.left
;
236 this->m_nPlotWidth
= this->m_rectPlot
.right
- this->m_rectPlot
.left
;/* m_rectPlot.Width(); */
238 /* draw the plot rectangle */
239 oldPen
= (HPEN
)SelectObject(this->m_dcGrid
, solidPen
);
240 MoveToEx(this->m_dcGrid
, this->m_rectPlot
.left
, this->m_rectPlot
.top
, NULL
);
241 LineTo(this->m_dcGrid
, this->m_rectPlot
.right
+1, this->m_rectPlot
.top
);
242 LineTo(this->m_dcGrid
, this->m_rectPlot
.right
+1, this->m_rectPlot
.bottom
+1);
243 LineTo(this->m_dcGrid
, this->m_rectPlot
.left
, this->m_rectPlot
.bottom
+1);
244 /* LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top); */
245 SelectObject(this->m_dcGrid
, oldPen
);
246 DeleteObject(solidPen
);
248 /* draw the dotted lines,
249 * use SetPixel instead of a dotted pen - this allows for a
250 * finer dotted line and a more "technical" look
252 nMidGridPix
= (this->m_rectPlot
.top
+ this->m_rectPlot
.bottom
)/2;
253 nTopGridPix
= nMidGridPix
- this->m_nPlotHeight
/4;
254 nBottomGridPix
= nMidGridPix
+ this->m_nPlotHeight
/4;
256 for (i
=this->m_rectPlot
.left
; i
<this->m_rectPlot
.right
; i
+=2)
258 SetPixel(this->m_dcGrid
, i
, nTopGridPix
, this->m_crGridColor
);
259 SetPixel(this->m_dcGrid
, i
, nMidGridPix
, this->m_crGridColor
);
260 SetPixel(this->m_dcGrid
, i
, nBottomGridPix
, this->m_crGridColor
);
263 for (i
=this->m_rectPlot
.left
; i
<this->m_rectPlot
.right
; i
+=10)
265 for (j
=this->m_rectPlot
.top
; j
<this->m_rectPlot
.bottom
; j
+=2)
267 SetPixel(this->m_dcGrid
, i
, j
, this->m_crGridColor
);
268 /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
269 /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
274 /* create some fonts (horizontal and vertical) */
275 /* use a height of 14 pixels and 300 weight */
276 /* (these may need to be adjusted depending on the display) */
277 axisFont
= CreateFont (14, 0, 0, 0, 300,
278 FALSE
, FALSE
, 0, ANSI_CHARSET
,
282 DEFAULT_PITCH
|FF_SWISS
, "Arial");
283 yUnitFont
= CreateFont (14, 0, 900, 0, 300,
284 FALSE
, FALSE
, 0, ANSI_CHARSET
,
288 DEFAULT_PITCH
|FF_SWISS
, "Arial");
290 /* grab the horizontal font */
291 oldFont
= (HFONT
)SelectObject(m_dcGrid
, axisFont
);
294 SetTextColor(m_dcGrid
, m_crGridColor
);
295 SetTextAlign(m_dcGrid
, TA_RIGHT
|TA_TOP
);
296 sprintf(strTemp
, "%.*lf", m_nYDecimals
, m_dUpperLimit
);
297 TextOut(m_dcGrid
, m_rectPlot
.left
-4, m_rectPlot
.top
, strTemp
, _tcslen(strTemp
));
300 SetTextAlign(m_dcGrid
, TA_RIGHT
|TA_BASELINE
);
301 sprintf(strTemp
, "%.*lf", m_nYDecimals
, m_dLowerLimit
);
302 TextOut(m_dcGrid
, m_rectPlot
.left
-4, m_rectPlot
.bottom
, strTemp
, _tcslen(strTemp
));
305 SetTextAlign(m_dcGrid
, TA_LEFT
|TA_TOP
);
306 TextOut(m_dcGrid
, m_rectPlot
.left
, m_rectPlot
.bottom
+4, "0", 1);
309 SetTextAlign(m_dcGrid
, TA_RIGHT
|TA_TOP
);
310 sprintf(strTemp
, "%d", m_nPlotWidth
/m_nShiftPixels
);
311 TextOut(m_dcGrid
, m_rectPlot
.right
, m_rectPlot
.bottom
+4, strTemp
, _tcslen(strTemp
));
314 SetTextAlign(m_dcGrid
, TA_CENTER
|TA_TOP
);
315 TextOut(m_dcGrid
, (m_rectPlot
.left
+m_rectPlot
.right
)/2,
316 m_rectPlot
.bottom
+4, m_strXUnitsString
, _tcslen(m_strXUnitsString
));
318 /* restore the font */
319 SelectObject(m_dcGrid
, oldFont
);
322 oldFont
= (HFONT
)SelectObject(m_dcGrid
, yUnitFont
);
323 SetTextAlign(m_dcGrid
, TA_CENTER
|TA_BASELINE
);
324 TextOut(m_dcGrid
, (m_rectClient
.left
+m_rectPlot
.left
)/2,
325 (m_rectPlot
.bottom
+m_rectPlot
.top
)/2, m_strYUnitsString
, _tcslen(m_strYUnitsString
));
326 SelectObject(m_dcGrid
, oldFont
);
328 /* at this point we are done filling the the grid bitmap, */
329 /* no more drawing to this bitmap is needed until the setting are changed */
331 /* if we don't have one yet, set up a memory dc for the plot */
332 if (this->m_dcPlot
== NULL
)
334 this->m_dcPlot
= CreateCompatibleDC(dc
);
335 this->m_bitmapPlot
= CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
336 this->m_bitmapOldPlot
= (HBITMAP
)SelectObject(this->m_dcPlot
, this->m_bitmapPlot
);
340 // the size of the drawing area has changed
341 // so create a new bitmap of the appropriate size
342 if(this->m_bitmapPlot
!= NULL
)
344 DeleteObject(this->m_bitmapPlot
);
345 this->m_bitmapPlot
= CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
346 SelectObject(this->m_dcPlot
, this->m_bitmapPlot
);
350 /* make sure the plot bitmap is cleared */
351 SetBkColor(this->m_dcPlot
, this->m_crBackColor
);
352 FillRect(this->m_dcPlot
, &this->m_rectClient
, this->m_brushBack
);
354 /* finally, force the plot area to redraw */
355 InvalidateRect(this->m_hParentWnd
, &this->m_rectClient
, TRUE
);
356 ReleaseDC(this->m_hParentWnd
, dc
);
359 double GraphCtrl_AppendPoint(TGraphCtrl
* this,
360 double dNewPoint0
, double dNewPoint1
,
361 double dNewPoint2
, double dNewPoint3
)
363 /* append a data point to the plot & return the previous point */
366 dPrevious
= this->m_dCurrentPosition
[0];
367 this->m_dCurrentPosition
[0] = dNewPoint0
;
368 this->m_dCurrentPosition
[1] = dNewPoint1
;
369 this->m_dCurrentPosition
[2] = dNewPoint2
;
370 this->m_dCurrentPosition
[3] = dNewPoint3
;
371 GraphCtrl_DrawPoint(this);
376 void GraphCtrl_Paint(TGraphCtrl
* this, HWND hWnd
, HDC dc
)
380 HBITMAP oldBitmap
; /* bitmap originally found in CMemDC */
383 /* GetClientRect(hWnd, &rcClient); */
384 /* FillSolidRect(dc, &rcClient, RGB(255, 0, 255)); */
385 /* m_nClientWidth = rcClient.right - rcClient.left; */
386 /* m_nClientHeight = rcClient.bottom - rcClient.top; */
388 /* no real plotting work is performed here, */
389 /* just putting the existing bitmaps on the client */
391 /* to avoid flicker, establish a memory dc, draw to it */
392 /* and then BitBlt it to the client */
393 memDC
= CreateCompatibleDC(dc
);
394 memBitmap
= (HBITMAP
)CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
395 oldBitmap
= (HBITMAP
)SelectObject(memDC
, memBitmap
);
399 /* first drop the grid on the memory dc */
400 BitBlt(memDC
, 0, 0, this->m_nClientWidth
, this->m_nClientHeight
, this->m_dcGrid
, 0, 0, SRCCOPY
);
401 /* now add the plot on top as a "pattern" via SRCPAINT. */
402 /* works well with dark background and a light plot */
403 BitBlt(memDC
, 0, 0, this->m_nClientWidth
, this->m_nClientHeight
, this->m_dcPlot
, 0, 0, SRCPAINT
); /* SRCPAINT */
404 /* finally send the result to the display */
405 BitBlt(dc
, 0, 0, this->m_nClientWidth
, this->m_nClientHeight
, memDC
, 0, 0, SRCCOPY
);
407 SelectObject(memDC
, oldBitmap
);
408 DeleteObject(memBitmap
);
412 void GraphCtrl_DrawPoint(TGraphCtrl
* this)
414 /* this does the work of "scrolling" the plot to the left
415 * and appending a new data point all of the plotting is
416 * directed to the memory based bitmap associated with m_dcPlot
417 * the will subsequently be BitBlt'd to the client in Paint
419 int currX
, prevX
, currY
, prevY
;
424 if (this->m_dcPlot
!= NULL
)
426 /* shift the plot by BitBlt'ing it to itself
427 * note: the m_dcPlot covers the entire client
428 * but we only shift bitmap that is the size
429 * of the plot rectangle
430 * grab the right side of the plot (exluding m_nShiftPixels on the left)
431 * move this grabbed bitmap to the left by m_nShiftPixels
433 BitBlt(this->m_dcPlot
, this->m_rectPlot
.left
, this->m_rectPlot
.top
+1,
434 this->m_nPlotWidth
, this->m_nPlotHeight
, this->m_dcPlot
,
435 this->m_rectPlot
.left
+this->m_nShiftPixels
, this->m_rectPlot
.top
+1,
438 /* establish a rectangle over the right side of plot */
439 /* which now needs to be cleaned up proir to adding the new point */
440 rectCleanUp
= this->m_rectPlot
;
441 rectCleanUp
.left
= rectCleanUp
.right
- this->m_nShiftPixels
;
443 /* fill the cleanup area with the background */
444 FillRect(this->m_dcPlot
, &rectCleanUp
, this->m_brushBack
);
446 /* draw the next line segement */
447 for (i
= 0; i
< MAX_PLOTS
; i
++)
449 /* grab the plotting pen */
450 oldPen
= (HPEN
)SelectObject(this->m_dcPlot
, this->m_penPlot
[i
]);
452 /* move to the previous point */
453 prevX
= this->m_rectPlot
.right
-this->m_nPlotShiftPixels
;
454 prevY
= this->m_rectPlot
.bottom
-
455 (long)((this->m_dPreviousPosition
[i
] - this->m_dLowerLimit
) * this->m_dVerticalFactor
);
456 MoveToEx(this->m_dcPlot
, prevX
, prevY
, NULL
);
458 /* draw to the current point */
459 currX
= this->m_rectPlot
.right
-this->m_nHalfShiftPixels
;
460 currY
= this->m_rectPlot
.bottom
-
461 (long)((this->m_dCurrentPosition
[i
] - this->m_dLowerLimit
) * this->m_dVerticalFactor
);
462 LineTo(this->m_dcPlot
, currX
, currY
);
464 /* Restore the pen */
465 SelectObject(this->m_dcPlot
, oldPen
);
467 /* if the data leaks over the upper or lower plot boundaries
468 * fill the upper and lower leakage with the background
469 * this will facilitate clipping on an as needed basis
470 * as opposed to always calling IntersectClipRect
472 if ((prevY
<= this->m_rectPlot
.top
) || (currY
<= this->m_rectPlot
.top
))
475 rc
.bottom
= this->m_rectPlot
.top
+1;
478 rc
.top
= this->m_rectClient
.top
;
479 FillRect(this->m_dcPlot
, &rc
, this->m_brushBack
);
481 if ((prevY
>= this->m_rectPlot
.bottom
) || (currY
>= this->m_rectPlot
.bottom
))
484 rc
.bottom
= this->m_rectClient
.bottom
+1;
487 rc
.top
= this->m_rectPlot
.bottom
+1;
488 /* RECT rc(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1); */
489 FillRect(this->m_dcPlot
, &rc
, this->m_brushBack
);
492 /* store the current point for connection to the next point */
493 this->m_dPreviousPosition
[i
] = this->m_dCurrentPosition
[i
];
498 void GraphCtrl_Resize(TGraphCtrl
* this)
500 /* NOTE: Resize automatically gets called during the setup of the control */
501 GetClientRect(this->m_hWnd
, &this->m_rectClient
);
503 /* set some member variables to avoid multiple function calls */
504 this->m_nClientHeight
= this->m_rectClient
.bottom
- this->m_rectClient
.top
;/* m_rectClient.Height(); */
505 this->m_nClientWidth
= this->m_rectClient
.right
- this->m_rectClient
.left
;/* m_rectClient.Width(); */
507 /* the "left" coordinate and "width" will be modified in */
508 /* InvalidateCtrl to be based on the width of the y axis scaling */
510 this->m_rectPlot
.left
= 20;
511 this->m_rectPlot
.top
= 10;
512 this->m_rectPlot
.right
= this->m_rectClient
.right
-10;
513 this->m_rectPlot
.bottom
= this->m_rectClient
.bottom
-25;
515 this->m_rectPlot
.left
= 0;
516 this->m_rectPlot
.top
= -1;
517 this->m_rectPlot
.right
= this->m_rectClient
.right
-0;
518 this->m_rectPlot
.bottom
= this->m_rectClient
.bottom
-0;
521 /* set some member variables to avoid multiple function calls */
522 this->m_nPlotHeight
= this->m_rectPlot
.bottom
- this->m_rectPlot
.top
;/* m_rectPlot.Height(); */
523 this->m_nPlotWidth
= this->m_rectPlot
.right
- this->m_rectPlot
.left
;/* m_rectPlot.Width(); */
525 /* set the scaling factor for now, this can be adjusted */
526 /* in the SetRange functions */
527 this->m_dVerticalFactor
= (double)this->m_nPlotHeight
/ this->m_dRange
;
531 void TGraphCtrl::Reset()
533 /* to clear the existing data (in the form of a bitmap) */
534 /* simply invalidate the entire control */
539 extern TGraphCtrl PerformancePageCpuUsageHistoryGraph
;
540 extern TGraphCtrl PerformancePageMemUsageHistoryGraph
;
541 extern HWND hPerformancePageCpuUsageHistoryGraph
;
542 extern HWND hPerformancePageMemUsageHistoryGraph
;
545 GraphCtrl_WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
556 * Filter out mouse & keyboard messages
558 /* case WM_APPCOMMAND: */
559 case WM_CAPTURECHANGED
:
560 case WM_LBUTTONDBLCLK
:
563 case WM_MBUTTONDBLCLK
:
566 case WM_MOUSEACTIVATE
:
570 /* case WM_MOUSEWHEEL: */
572 case WM_NCLBUTTONDBLCLK
:
573 case WM_NCLBUTTONDOWN
:
575 case WM_NCMBUTTONDBLCLK
:
576 case WM_NCMBUTTONDOWN
:
578 /* case WM_NCMOUSEHOVER: */
579 /* case WM_NCMOUSELEAVE: */
581 case WM_NCRBUTTONDBLCLK
:
582 case WM_NCRBUTTONDOWN
:
584 /* case WM_NCXBUTTONDBLCLK: */
585 /* case WM_NCXBUTTONDOWN: */
586 /* case WM_NCXBUTTONUP: */
587 case WM_RBUTTONDBLCLK
:
590 /* case WM_XBUTTONDBLCLK: */
591 /* case WM_XBUTTONDOWN: */
592 /* case WM_XBUTTONUP: */
613 if (hWnd
== hPerformancePageMemUsageHistoryGraph
)
615 GraphCtrl_Resize(&PerformancePageMemUsageHistoryGraph
);
616 GraphCtrl_InvalidateCtrl(&PerformancePageMemUsageHistoryGraph
, TRUE
);
618 if (hWnd
== hPerformancePageCpuUsageHistoryGraph
)
620 GraphCtrl_Resize(&PerformancePageCpuUsageHistoryGraph
);
621 GraphCtrl_InvalidateCtrl(&PerformancePageCpuUsageHistoryGraph
, TRUE
);
626 hdc
= BeginPaint(hWnd
, &ps
);
627 GetClientRect(hWnd
, &rcClient
);
628 if (hWnd
== hPerformancePageMemUsageHistoryGraph
)
629 GraphCtrl_Paint(&PerformancePageMemUsageHistoryGraph
, hWnd
, hdc
);
630 if (hWnd
== hPerformancePageCpuUsageHistoryGraph
)
631 GraphCtrl_Paint(&PerformancePageCpuUsageHistoryGraph
, hWnd
, hdc
);
637 * We pass on all non-handled messages
639 return CallWindowProc((WNDPROC
)OldGraphCtrlWndProc
, hWnd
, message
, wParam
, lParam
);