Process Hacker
graph.h
Go to the documentation of this file.
1 #ifndef _PH_GRAPH_H
2 #define _PH_GRAPH_H
3 
4 // Graph drawing
5 
6 #ifndef _PH_GRAPH_PRIVATE
7 extern RECT PhNormalGraphTextMargin;
8 extern RECT PhNormalGraphTextPadding;
9 #endif
10 
11 #define PH_GRAPH_USE_GRID 0x1
12 #define PH_GRAPH_USE_LINE_2 0x10
13 #define PH_GRAPH_OVERLAY_LINE_2 0x20
14 
15 typedef struct _PH_GRAPH_DRAW_INFO
16 {
17  // Basic
18  ULONG Width;
19  ULONG Height;
20  ULONG Flags;
21  ULONG Step;
22  COLORREF BackColor;
23 
24  // Data/lines
26  PFLOAT LineData1;
27  PFLOAT LineData2;
28  COLORREF LineColor1;
29  COLORREF LineColor2;
30  COLORREF LineBackColor1;
31  COLORREF LineBackColor2;
32 
33  // Grid
34  COLORREF GridColor;
35  ULONG GridWidth;
36  ULONG GridHeight;
37  ULONG GridStart;
38 
39  // Text
41  RECT TextRect;
43  COLORREF TextColor;
44  COLORREF TextBoxColor;
46 
47 // Graph control
48 
49 #define PH_GRAPH_CLASSNAME L"PhGraph"
50 
52  VOID
53  );
54 
57  _In_ HDC hdc,
58  _In_ PPH_GRAPH_DRAW_INFO DrawInfo
59  );
60 
63  _In_ HDC hdc,
64  _In_ PVOID Bits,
65  _In_ PPH_GRAPH_DRAW_INFO DrawInfo
66  );
67 
70  _In_ HDC hdc,
71  _Inout_ PPH_GRAPH_DRAW_INFO DrawInfo,
72  _In_ PPH_STRINGREF Text,
73  _In_ PRECT Margin,
74  _In_ PRECT Padding,
75  _In_ ULONG Align
76  );
77 
78 // Configuration
79 
80 typedef struct _PH_GRAPH_OPTIONS
81 {
82  COLORREF FadeOutBackColor;
83  ULONG FadeOutWidth;
84  HCURSOR DefaultCursor;
86 
87 // Styles
88 
89 #define GC_STYLE_FADEOUT 0x1
90 #define GC_STYLE_DRAW_PANEL 0x2
91 
92 // Messages
93 
94 #define GCM_GETDRAWINFO (WM_USER + 1301)
95 #define GCM_SETDRAWINFO (WM_USER + 1302)
96 #define GCM_DRAW (WM_USER + 1303)
97 #define GCM_MOVEGRID (WM_USER + 1304)
98 #define GCM_GETBUFFEREDCONTEXT (WM_USER + 1305)
99 #define GCM_SETTOOLTIP (WM_USER + 1306)
100 #define GCM_UPDATETOOLTIP (WM_USER + 1307)
101 #define GCM_GETOPTIONS (WM_USER + 1308)
102 #define GCM_SETOPTIONS (WM_USER + 1309)
103 
104 #define Graph_GetDrawInfo(hWnd, DrawInfo) \
105  SendMessage((hWnd), GCM_GETDRAWINFO, 0, (LPARAM)(DrawInfo))
106 #define Graph_SetDrawInfo(hWnd, DrawInfo) \
107  SendMessage((hWnd), GCM_SETDRAWINFO, 0, (LPARAM)(DrawInfo))
108 #define Graph_Draw(hWnd) \
109  SendMessage((hWnd), GCM_DRAW, 0, 0)
110 #define Graph_MoveGrid(hWnd, Increment) \
111  SendMessage((hWnd), GCM_MOVEGRID, (WPARAM)(Increment), 0)
112 #define Graph_GetBufferedContext(hWnd) \
113  ((HDC)SendMessage((hWnd), GCM_GETBUFFEREDCONTEXT, 0, 0))
114 #define Graph_SetTooltip(hWnd, Enable) \
115  ((HDC)SendMessage((hWnd), GCM_SETTOOLTIP, (WPARAM)(Enable), 0))
116 #define Graph_UpdateTooltip(hWnd) \
117  ((HDC)SendMessage((hWnd), GCM_UPDATETOOLTIP, 0, 0))
118 #define Graph_GetOptions(hWnd, Options) \
119  SendMessage((hWnd), GCM_GETOPTIONS, 0, (LPARAM)(Options))
120 #define Graph_SetOptions(hWnd, Options) \
121  SendMessage((hWnd), GCM_SETOPTIONS, 0, (LPARAM)(Options))
122 
123 // Notifications
124 
125 #define GCN_GETDRAWINFO (WM_USER + 1351)
126 #define GCN_GETTOOLTIPTEXT (WM_USER + 1352)
127 #define GCN_MOUSEEVENT (WM_USER + 1353)
128 #define GCN_DRAWPANEL (WM_USER + 1354)
129 
130 typedef struct _PH_GRAPH_GETDRAWINFO
131 {
132  NMHDR Header;
133  PPH_GRAPH_DRAW_INFO DrawInfo;
135 
137 {
138  NMHDR Header;
139  ULONG Index;
140  ULONG TotalCount;
141 
142  PH_STRINGREF Text; // must be null-terminated
144 
145 typedef struct _PH_GRAPH_MOUSEEVENT
146 {
147  NMHDR Header;
148  ULONG Index;
149  ULONG TotalCount;
150 
151  ULONG Message;
152  ULONG Keys;
153  POINT Point;
155 
156 typedef struct _PH_GRAPH_DRAWPANEL
157 {
158  NMHDR Header;
159  HDC hdc;
160  RECT Rect;
162 
163 // Graph buffer management
164 
165 #define PH_GRAPH_DATA_COUNT(Width, Step) (((Width) + (Step) - 1) / (Step) + 1) // round up in division
166 
167 typedef struct _PH_GRAPH_BUFFERS
168 {
169  PFLOAT Data1; // invalidate by setting Valid to FALSE
170  PFLOAT Data2; // invalidate by setting Valid to FALSE
172  BOOLEAN Valid; // indicates the data is valid
174 
176  _Out_ PPH_GRAPH_BUFFERS Buffers
177  );
178 
180  _Inout_ PPH_GRAPH_BUFFERS Buffers
181  );
182 
183 PHLIBAPI
185  _Inout_ PPH_GRAPH_BUFFERS Buffers,
186  _Inout_ PPH_GRAPH_DRAW_INFO DrawInfo,
187  _In_ ULONG DataCount
188  );
189 
190 // Graph control state
191 
192 // The basic buffer management structure was moved out of this section because
193 // the text management is not needed for most cases.
194 
195 typedef struct _PH_GRAPH_STATE
196 {
197  // Union for compatibility
198  union
199  {
200  struct
201  {
202  PFLOAT Data1; // invalidate by setting Valid to FALSE
203  PFLOAT Data2; // invalidate by setting Valid to FALSE
205  BOOLEAN Valid; // indicates the data is valid
206  };
208  };
209 
211  PPH_STRING TooltipText; // invalidate by setting TooltipIndex to -1
212  ULONG TooltipIndex; // indicates the tooltip text is valid for this index
214 
215 PHLIBAPI
217  _Out_ PPH_GRAPH_STATE State
218  );
219 
220 PHLIBAPI
222  _Inout_ PPH_GRAPH_STATE State
223  );
224 
225 PHLIBAPI
227  _Inout_ PPH_GRAPH_STATE State,
228  _In_ PPH_GRAPH_GETDRAWINFO GetDrawInfo,
229  _In_ ULONG DataCount
230  );
231 
232 #endif