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 along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 WNDPROC OldGraphCtrlWndProc
;
29 static void GraphCtrl_Init(TGraphCtrl
* this)
34 this->m_hParentWnd
= 0;
37 this->m_bitmapOldGrid
= 0;
38 this->m_bitmapOldPlot
= 0;
39 this->m_bitmapGrid
= 0;
40 this->m_bitmapPlot
= 0;
41 this->m_brushBack
= 0;
43 this->m_penPlot
[0] = 0;
44 this->m_penPlot
[1] = 0;
45 this->m_penPlot
[2] = 0;
46 this->m_penPlot
[3] = 0;
48 /* since plotting is based on a LineTo for each new point
49 * we need a starting point (i.e. a "previous" point)
50 * use 0.0 as the default first point.
51 * these are public member variables, and can be changed outside
52 * (after construction). Therefore m_perviousPosition could be set to
53 * a more appropriate value prior to the first call to SetPosition.
55 this->m_dPreviousPosition
[0] = 0.0;
56 this->m_dPreviousPosition
[1] = 0.0;
57 this->m_dPreviousPosition
[2] = 0.0;
58 this->m_dPreviousPosition
[3] = 0.0;
60 /* public variable for the number of decimal places on the y axis */
61 this->m_nYDecimals
= 3;
63 /* set some initial values for the scaling until "SetRange" is called.
64 * these are protected variables and must be set with SetRange
65 * in order to ensure that m_dRange is updated accordingly
67 /* m_dLowerLimit = -10.0; */
68 /* m_dUpperLimit = 10.0; */
69 this->m_dLowerLimit
= 0.0;
70 this->m_dUpperLimit
= 100.0;
71 this->m_dRange
= this->m_dUpperLimit
- this->m_dLowerLimit
; /* protected member variable */
73 /* m_nShiftPixels determines how much the plot shifts (in terms of pixels) */
74 /* with the addition of a new data point */
75 this->m_nShiftPixels
= 4;
76 this->m_nHalfShiftPixels
= this->m_nShiftPixels
/2; /* protected */
77 this->m_nPlotShiftPixels
= this->m_nShiftPixels
+ this->m_nHalfShiftPixels
; /* protected */
79 /* background, grid and data colors */
80 /* these are public variables and can be set directly */
81 this->m_crBackColor
= RGB( 0, 0, 0); /* see also SetBackgroundColor */
82 this->m_crGridColor
= RGB( 0, 128, 64); /* see also SetGridColor */
83 this->m_crPlotColor
[0] = RGB(255, 255, 255); /* see also SetPlotColor */
84 this->m_crPlotColor
[1] = RGB(100, 255, 255); /* see also SetPlotColor */
85 this->m_crPlotColor
[2] = RGB(255, 100, 255); /* see also SetPlotColor */
86 this->m_crPlotColor
[3] = RGB(255, 255, 100); /* see also SetPlotColor */
88 /* protected variables */
89 for (i
= 0; i
< MAX_PLOTS
; i
++)
91 this->m_penPlot
[i
] = CreatePen(PS_SOLID
, 0, this->m_crPlotColor
[i
]);
93 this->m_brushBack
= CreateSolidBrush(this->m_crBackColor
);
95 /* public member variables, can be set directly */
96 strcpy(this->m_strXUnitsString
, "Samples"); /* can also be set with SetXUnits */
97 strcpy(this->m_strYUnitsString
, "Y units"); /* can also be set with SetYUnits */
99 /* protected bitmaps to restore the memory DC's */
100 this->m_bitmapOldGrid
= NULL
;
101 this->m_bitmapOldPlot
= NULL
;
104 void GraphCtrl_Dispose(TGraphCtrl
* this)
108 for (plot
= 0; plot
< MAX_PLOTS
; plot
++)
109 DeleteObject(this->m_penPlot
[plot
]);
111 /* just to be picky restore the bitmaps for the two memory dc's */
112 /* (these dc's are being destroyed so there shouldn't be any leaks) */
114 if (this->m_bitmapOldGrid
!= NULL
) SelectObject(this->m_dcGrid
, this->m_bitmapOldGrid
);
115 if (this->m_bitmapOldPlot
!= NULL
) SelectObject(this->m_dcPlot
, this->m_bitmapOldPlot
);
116 if (this->m_bitmapGrid
!= NULL
) DeleteObject(this->m_bitmapGrid
);
117 if (this->m_bitmapPlot
!= NULL
) DeleteObject(this->m_bitmapPlot
);
118 if (this->m_dcGrid
!= NULL
) DeleteDC(this->m_dcGrid
);
119 if (this->m_dcPlot
!= NULL
) DeleteDC(this->m_dcPlot
);
120 if (this->m_brushBack
!= NULL
) DeleteObject(this->m_brushBack
);
123 BOOL
GraphCtrl_Create(TGraphCtrl
* this, HWND hWnd
, HWND hParentWnd
, UINT nID
)
127 GraphCtrl_Init(this);
128 this->m_hParentWnd
= hParentWnd
;
130 GraphCtrl_Resize(this);
132 GraphCtrl_InvalidateCtrl(this, FALSE
);
136 void GraphCtrl_SetRange(TGraphCtrl
* this, double dLower
, double dUpper
, int nDecimalPlaces
)
138 /* ASSERT(dUpper > dLower); */
139 this->m_dLowerLimit
= dLower
;
140 this->m_dUpperLimit
= dUpper
;
141 this->m_nYDecimals
= nDecimalPlaces
;
142 this->m_dRange
= this->m_dUpperLimit
- this->m_dLowerLimit
;
143 this->m_dVerticalFactor
= (double)this->m_nPlotHeight
/ this->m_dRange
;
144 /* clear out the existing garbage, re-start with a clean plot */
145 GraphCtrl_InvalidateCtrl(this, FALSE
);
149 void TGraphCtrl::SetXUnits(const char* string
)
151 strncpy(m_strXUnitsString
, string
, sizeof(m_strXUnitsString
) - 1);
152 /* clear out the existing garbage, re-start with a clean plot */
156 void TGraphCtrl::SetYUnits(const char* string
)
158 strncpy(m_strYUnitsString
, string
, sizeof(m_strYUnitsString
) - 1);
159 /* clear out the existing garbage, re-start with a clean plot */
164 void GraphCtrl_SetGridColor(TGraphCtrl
* this, COLORREF color
)
166 this->m_crGridColor
= color
;
167 /* clear out the existing garbage, re-start with a clean plot */
168 GraphCtrl_InvalidateCtrl(this, FALSE
);
171 void GraphCtrl_SetPlotColor(TGraphCtrl
* this, int plot
, COLORREF color
)
173 this->m_crPlotColor
[plot
] = color
;
174 DeleteObject(this->m_penPlot
[plot
]);
175 this->m_penPlot
[plot
] = CreatePen(PS_SOLID
, 0, this->m_crPlotColor
[plot
]);
176 /* clear out the existing garbage, re-start with a clean plot */
177 GraphCtrl_InvalidateCtrl(this, FALSE
);
180 void GraphCtrl_SetBackgroundColor(TGraphCtrl
* this, COLORREF color
)
182 this->m_crBackColor
= color
;
183 DeleteObject(this->m_brushBack
);
184 this->m_brushBack
= CreateSolidBrush(this->m_crBackColor
);
185 /* clear out the existing garbage, re-start with a clean plot */
186 GraphCtrl_InvalidateCtrl(this, FALSE
);
189 void GraphCtrl_InvalidateCtrl(TGraphCtrl
* this, BOOL bResize
)
191 /* There is a lot of drawing going on here - particularly in terms of */
192 /* drawing the grid. Don't panic, this is all being drawn (only once) */
193 /* to a bitmap. The result is then BitBlt'd to the control whenever needed. */
196 //int nTopGridPix, nMidGridPix, nBottomGridPix;
199 HPEN solidPen
= CreatePen(PS_SOLID
, 0, this->m_crGridColor
);
200 /* HFONT axisFont, yUnitFont, oldFont; */
201 /* char strTemp[50]; */
203 /* in case we haven't established the memory dc's */
204 /* CClientDC dc(this); */
205 HDC dc
= GetDC(this->m_hParentWnd
);
207 /* if we don't have one yet, set up a memory dc for the grid */
208 if (this->m_dcGrid
== NULL
)
210 this->m_dcGrid
= CreateCompatibleDC(dc
);
211 this->m_bitmapGrid
= CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
212 this->m_bitmapOldGrid
= (HBITMAP
)SelectObject(this->m_dcGrid
, this->m_bitmapGrid
);
216 // the size of the drawing area has changed
217 // so create a new bitmap of the appropriate size
218 if(this->m_bitmapGrid
!= NULL
)
220 this->m_bitmapGrid
= (HBITMAP
)SelectObject(this->m_dcGrid
, this->m_bitmapOldGrid
);
221 DeleteObject(this->m_bitmapGrid
);
222 this->m_bitmapGrid
= CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
223 SelectObject(this->m_dcGrid
, this->m_bitmapGrid
);
227 SetBkColor(this->m_dcGrid
, this->m_crBackColor
);
229 /* fill the grid background */
230 FillRect(this->m_dcGrid
, &this->m_rectClient
, this->m_brushBack
);
232 /* draw the plot rectangle: */
233 /* determine how wide the y axis scaling values are */
234 nCharacters
= abs((int)log10(fabs(this->m_dUpperLimit
)));
235 nCharacters
= max(nCharacters
, abs((int)log10(fabs(this->m_dLowerLimit
))));
237 /* add the units digit, decimal point and a minus sign, and an extra space */
238 /* as well as the number of decimal places to display */
239 nCharacters
= nCharacters
+ 4 + this->m_nYDecimals
;
241 /* adjust the plot rectangle dimensions */
242 /* assume 6 pixels per character (this may need to be adjusted) */
243 /* m_rectPlot.left = m_rectClient.left + 6*(nCharacters); */
244 this->m_rectPlot
.left
= this->m_rectClient
.left
;
245 this->m_nPlotWidth
= this->m_rectPlot
.right
- this->m_rectPlot
.left
;/* m_rectPlot.Width(); */
247 /* draw the plot rectangle */
248 oldPen
= (HPEN
)SelectObject(this->m_dcGrid
, solidPen
);
249 MoveToEx(this->m_dcGrid
, this->m_rectPlot
.left
, this->m_rectPlot
.top
, NULL
);
250 LineTo(this->m_dcGrid
, this->m_rectPlot
.right
+1, this->m_rectPlot
.top
);
251 LineTo(this->m_dcGrid
, this->m_rectPlot
.right
+1, this->m_rectPlot
.bottom
+1);
252 LineTo(this->m_dcGrid
, this->m_rectPlot
.left
, this->m_rectPlot
.bottom
+1);
253 /* LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top); */
255 /* draw the horizontal axis */
256 for (i
= this->m_rectPlot
.top
; i
< this->m_rectPlot
.bottom
; i
+= 12)
258 MoveToEx(this->m_dcGrid
, this->m_rectPlot
.left
, this->m_rectPlot
.top
+ i
, NULL
);
259 LineTo(this->m_dcGrid
, this->m_rectPlot
.right
, this->m_rectPlot
.top
+ i
);
262 /* draw the vertical axis */
263 for (i
= this->m_rectPlot
.left
; i
< this->m_rectPlot
.right
; i
+= 12)
265 MoveToEx(this->m_dcGrid
, this->m_rectPlot
.left
+ i
, this->m_rectPlot
.bottom
, NULL
);
266 LineTo(this->m_dcGrid
, this->m_rectPlot
.left
+ i
, this->m_rectPlot
.top
);
269 SelectObject(this->m_dcGrid
, oldPen
);
270 DeleteObject(solidPen
);
273 /* create some fonts (horizontal and vertical) */
274 /* use a height of 14 pixels and 300 weight */
275 /* (these may need to be adjusted depending on the display) */
276 axisFont
= CreateFont (14, 0, 0, 0, 300,
277 FALSE
, FALSE
, 0, ANSI_CHARSET
,
281 DEFAULT_PITCH
|FF_SWISS
, "Arial");
282 yUnitFont
= CreateFont (14, 0, 900, 0, 300,
283 FALSE
, FALSE
, 0, ANSI_CHARSET
,
287 DEFAULT_PITCH
|FF_SWISS
, "Arial");
289 /* grab the horizontal font */
290 oldFont
= (HFONT
)SelectObject(m_dcGrid
, axisFont
);
293 SetTextColor(m_dcGrid
, m_crGridColor
);
294 SetTextAlign(m_dcGrid
, TA_RIGHT
|TA_TOP
);
295 sprintf(strTemp
, "%.*lf", m_nYDecimals
, m_dUpperLimit
);
296 TextOut(m_dcGrid
, m_rectPlot
.left
-4, m_rectPlot
.top
, strTemp
, wcslen(strTemp
));
299 SetTextAlign(m_dcGrid
, TA_RIGHT
|TA_BASELINE
);
300 sprintf(strTemp
, "%.*lf", m_nYDecimals
, m_dLowerLimit
);
301 TextOut(m_dcGrid
, m_rectPlot
.left
-4, m_rectPlot
.bottom
, strTemp
, wcslen(strTemp
));
304 SetTextAlign(m_dcGrid
, TA_LEFT
|TA_TOP
);
305 TextOut(m_dcGrid
, m_rectPlot
.left
, m_rectPlot
.bottom
+4, "0", 1);
308 SetTextAlign(m_dcGrid
, TA_RIGHT
|TA_TOP
);
309 sprintf(strTemp
, "%d", m_nPlotWidth
/m_nShiftPixels
);
310 TextOut(m_dcGrid
, m_rectPlot
.right
, m_rectPlot
.bottom
+4, strTemp
, wcslen(strTemp
));
313 SetTextAlign(m_dcGrid
, TA_CENTER
|TA_TOP
);
314 TextOut(m_dcGrid
, (m_rectPlot
.left
+m_rectPlot
.right
)/2,
315 m_rectPlot
.bottom
+4, m_strXUnitsString
, wcslen(m_strXUnitsString
));
317 /* restore the font */
318 SelectObject(m_dcGrid
, oldFont
);
321 oldFont
= (HFONT
)SelectObject(m_dcGrid
, yUnitFont
);
322 SetTextAlign(m_dcGrid
, TA_CENTER
|TA_BASELINE
);
323 TextOut(m_dcGrid
, (m_rectClient
.left
+m_rectPlot
.left
)/2,
324 (m_rectPlot
.bottom
+m_rectPlot
.top
)/2, m_strYUnitsString
, wcslen(m_strYUnitsString
));
325 SelectObject(m_dcGrid
, oldFont
);
327 /* at this point we are done filling the grid bitmap, */
328 /* no more drawing to this bitmap is needed until the settings are changed */
330 /* if we don't have one yet, set up a memory dc for the plot */
331 if (this->m_dcPlot
== NULL
)
333 this->m_dcPlot
= CreateCompatibleDC(dc
);
334 this->m_bitmapPlot
= CreateCompatibleBitmap(dc
, this->m_nClientWidth
, this->m_nClientHeight
);
335 this->m_bitmapOldPlot
= (HBITMAP
)SelectObject(this->m_dcPlot
, this->m_bitmapPlot
);
339 // the size of the drawing area has changed
340 // so create a new bitmap of the appropriate size
341 if(this->m_bitmapPlot
!= NULL
)
343 this->m_bitmapPlot
= (HBITMAP
)SelectObject(this->m_dcPlot
, this->m_bitmapOldPlot
);
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 (excluding 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 segment */
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 CallWindowProcW(OldGraphCtrlWndProc
, hWnd
, message
, wParam
, lParam
);