-
Notifications
You must be signed in to change notification settings - Fork 0
/
CGraph.H
135 lines (110 loc) · 4.6 KB
/
CGraph.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright © NetworkDLS 2002, All rights reserved
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _CGRAPH_H
#define _CGRAPH_H
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define GRAPH_LEFT 0
#define GRAPH_RIGHT 1
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _tag_Graph_Settings {
DWORD BGColor;
DWORD GridColor;
bool IsFrozen;
short Direction;
short SpacingX;
short SpacingY;
bool IsInitialized;
bool UniformScaling;
int SpacingTop;
int SpacingBottom;
} GRAPHSETTINGS, *LPGRAPHSETTINGS;
typedef struct _tag_Graph_Config {
long Height;
long Width;
short SeriesCount;
short GridOffset;
HWND hWnd;
} GRAPHCONFIG, *LPGRAPHCONFIG;
typedef struct _tag_Graph_Stats {
double MinimumRange; // The minimum value that the graph should scale to.
double HighestValue; // The highest value in the values array (*Values).
double TopValue; // The value represented at the top of the graph.
} GRAPHSTATS, *LPGRAPHSTATS;
typedef struct _tag_Text_Arrtibutes {
HDC DC;
char Text[255];
int x;
int y;
DWORD BGColor;
DWORD FGColor;
int BGMode; //GDI Modes: TRANSPARENT or OPAQUE
char FontName[255];
int FontSize;
} GRAPHTEXTATTRIBUTES, *LPGRAPHTEXTATTRIBUTES;
typedef struct _tag_Series{
short Index; // The index of the series in the series array.
double *Values; // Array of floating point values that make up the graph.
POINT *pPoints; // The GDI points that will be drawn one the background.
DWORD LineColor; // The line-color for this series.
double MinimumRange; // The minimum value that the graph should scale to.
double HighestValue; // The highest value in the values array (*Values).
double TopValue; // The value represented at the top of the graph.
double CurrentScale; // Decimal value of the current graph scale (based on MinimumRange).
double LastValue; // The last value added to the values array (*Values).
void *pTextFormatCallback; // The text formatter callback for this series.
} GRAPHSERIES, *LPGRAPHSERIES;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CGraph {
public:
typedef bool (* GraphTextFormatCallback)(CGraph *pGraph, GRAPHSERIES *pSeries, GRAPHTEXTATTRIBUTES *pTextAttributes);
CGraph();
~CGraph();
CGraph(HWND hWnd, DWORD dwINBGColor, DWORD dwINGridColor, short iINGridSpacing, short iINDirection, bool bUniformScaling);
GRAPHSETTINGS Settings;
GRAPHSERIES *Series;
void AddSeries(DWORD dwINLineColor, double dINMinimumRange);
void AddSeries(DWORD dwINLineColor, double dINMinimumRange, GraphTextFormatCallback pGraphTextFormatCallback);
void Initialize(HWND hWnd, DWORD dwINBGColor, DWORD dwINGridColor, short iINGridSpacing, short iINDirection, bool bUniformScaling);
bool Update(double dValue);
bool Update(double *dValues);
bool Update(short iSeries, double dValue);
//void Resize(int iX, int iY, int iInWidth, int iInHeight);
void Redraw(HDC hGraphDC);
void Redraw(void);
void Destroy(void);
void Freeze(bool bFreeze);
bool IsFrozen(void);
void Invalidate(void);
void Reset(void);
int Width(void);
int Height(void);
int SeriesCount(void);
int GridOffset(void);
HWND hWnd(void);
bool UniformScaling(void);
int SpacingTop(void);
void SpacingTop(int Pixles);
int SpacingBottom(void);
void SpacingBottom(int Pixles);
void WriteText(GRAPHTEXTATTRIBUTES *gta);
void UnLock(void);
bool TryLock(void);
void Lock(void);
protected:
WNDPROC _OldGraphProc;
POINT *Points;
GRAPHSTATS Stats;
GRAPHCONFIG Config;
friend LRESULT NewGraphProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void Initialize(HWND hWnd, DWORD dwINBGColor, DWORD dwINGridColor, short iINGridSpacing, short iINDirection, bool bUniformScaling, bool bInitCS);
void Destroy(bool bDeleteCS);
CRITICAL_SECTION csLock;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif