reactos/base/applications/taskmgr/graphctl.h
Hermès Bélusca-Maïto 129f10ea26 [TASKMGR] Cherry pick Hermes fixes
** WIP ** [TASKMGR] Get rid of thread-oriented updates. Just do it synchronously on WM_TIMER.

** WIP ** Merge RefreshPerformancePage() and PerformancePageRefreshThread(), now that we removed the separate performance page refreshing thread.

- Use _ui64tow() instead of _ultow() for converting ULONGLONGs into
  a string representation.

- Isolate the update of the status bar.

- Isolate the actual graphs redrawing. The idea for later is to not
  trigger any redrawings (and run unnecessary code) if the page is deactivated.

[TASKMGR] No need to get and save global handles for all the controls in the performance page.

... and especially for controls that are used only in one place.
Only handles to the graph controls are sufficient. For the others,
we can manage by using dialog control IDs.

- Rename AdjustFrameSize() 'pos' parameter to be more explicit.

** WIP ** Group trios of Memory performance getters together, as they are always used in succession.

- Group PerfDataGetCommitCharge[Total|Limit|Peak]K() together into
  PerfDataGetCommitChargeK().

- Group PerfDataGetKernelMemory[Total|Paged|NonPaged]K() together
  into PerfDataGetKernelMemoryK().

- Group PerfDataGetPhysicalMemory[Total|Available|SystemCache]K()
  together into PerfDataGetPhysicalMemoryK().

- Use these new Mem performance getters.

[TASKMGR] Use owner-drawn performance graphs.

- Use owner-drawn buttons to implement correct graph painting while
  maintaining the 3D appearance. As done on Windows (TM)

  Why using buttons (that should be disabled btw.)?
  Because we want, if the graphs fail to be created (due to e.g.
  lack of resources), to show a descriptive label of what's missing.

  This also allow the graphs to be drawn **properly** inside a 3D-border window.

- Redraw graphs on WM_DRAWITEM.

- Don't need to subclass button controls.

- Use DeferWindowPos() to avoid controls blinking on resize.

- Fix the problem of the buttons resizing as "1/x": this was due to
  the fact, using GetClientRect + Mapping, did't take the border into
  account. Instead, use GetWindowRect + a different coord mapping to
  fix all that.

- Remove some dead code.

- Rename the remaining ridiculously long variable names.

** WIP ** CPU/Mem meters: keep a separate copy of the CPU/Mem perf values.

+ Use structure for keeping state.

** WIP ** Add support for multiple-CPU stats. (In progress, needs code cleanup.)

In particular, use SystemProcessorTimeInfo to calculate the idle time
as done in ROSAPPS' ctm.exe, see commit c0873723.

See also https://ladydebug.com/blog/codes/cpuusage_win.htm

+ Fix the problem of NtQuerySystemInformation(SystemPerformanceInformation)
  that shows up when running a 32-bit build under Windows 7 x64.

** WIP ** Investigating showing physical memory in the MEM gauge.
2025-02-01 16:36:33 +02:00

60 lines
1.7 KiB
C

/*
* PROJECT: ReactOS Task Manager
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Graph Plotting controls.
* COPYRIGHT: Copyright 2002 Robert Dickenson <robd@reactos.org>
* Copyright 2021 Wu Haotian <rigoligo03@gmail.com>
* Copyright 2021 Valerij Zaporogeci <vlrzprgts@gmail.com>
*/
#pragma once
#define NUM_PLOTS 2
#define PLOT_SHIFT 2
typedef struct _TM_GRAPH_CONTROL
{
HWND hParentWnd;
HWND hWnd;
HDC hdcGraph;
HBITMAP hbmGraph;
HPEN hPenGrid;
HPEN hPen0;
HPEN hPen1;
HBRUSH hBrushBack;
INT BitmapWidth;
INT BitmapHeight;
INT GridCellWidth;
INT GridCellHeight;
INT CurrShift;
PBYTE PointBuffer;
UINT32 NumberOfPoints;
UINT32 CurrIndex;
FLOAT ftPixelsPerPercent;
BOOL DrawSecondaryPlot;
}
TM_GRAPH_CONTROL, *PTM_GRAPH_CONTROL;
typedef struct _TM_FORMAT
{
COLORREF clrBack;
COLORREF clrGrid;
COLORREF clrPlot0;
COLORREF clrPlot1;
INT GridCellWidth;
INT GridCellHeight;
BOOL DrawSecondaryPlot;
}
TM_FORMAT, *PTM_FORMAT;
INT_PTR CALLBACK GraphCtrl_OnSize(HWND hWnd, PTM_GRAPH_CONTROL graph, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK GraphCtrl_OnDraw(HWND hWnd, PTM_GRAPH_CONTROL graph, WPARAM wParam, LPARAM lParam);
BOOL GraphCtrl_Create(PTM_GRAPH_CONTROL inst, HWND hWnd, HWND hParentWnd, PTM_FORMAT fmt);
void GraphCtrl_Dispose(PTM_GRAPH_CONTROL inst);
void GraphCtrl_AddPoint(PTM_GRAPH_CONTROL inst, BYTE val0, BYTE val1);
void GraphCtrl_RedrawOnHeightChange(PTM_GRAPH_CONTROL inst, INT nh);
void GraphCtrl_RedrawBitmap(PTM_GRAPH_CONTROL inst, INT h);