3 #if !defined(MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_)
4 #define MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_
8 /////////////////////////////////////////////////////////////////////////////
11 class MyGraphSeries
: public CObject
17 MyGraphSeries(const CString
& sLabel
= _T(""));
18 virtual ~MyGraphSeries();
20 // Declared but not defined.
22 MyGraphSeries(const MyGraphSeries
& rhs
);
23 MyGraphSeries
& operator=(const MyGraphSeries
& rhs
);
27 void Clear() {m_dwaValues
.RemoveAll(); m_oaRegions
.RemoveAll();}
28 void SetLabel(const CString
& sLabel
);
29 CString
GetLabel() const;
30 void SetData(int nGroup
, int nValue
);
31 int GetData(int nGroup
) const;
35 int GetMaxDataValue(bool bStackedGraph
) const;
36 int GetAverageDataValue() const;
37 int GetNonZeroElementCount() const;
38 int GetDataTotal() const;
39 void SetTipRegion(int nGroup
, const CRect
& rc
);
40 void SetTipRegion(int nGroup
, CRgn
* prgn
);
41 int HitTest(const CPoint
& pt
, int searchStart
) const;
42 CString
GetTipText(int nGroup
, const CString
&unitString
) const;
46 CString m_sLabel
; // Series label.
47 CDWordArray m_dwaValues
; // Values array.
48 CArray
<CRgn
*,CRgn
*> m_oaRegions
; // Tooltip regions.
52 /////////////////////////////////////////////////////////////////////////////
55 class MyGraph
: public CStatic
59 enum GraphType
{ Bar
, Line
, PieChart
}; // Renamed 'Pie' because it hides a GDI function name
63 MyGraph(GraphType eGraphType
= MyGraph::PieChart
, bool bStackedGraph
= false);
66 // Declared but not defined.
68 MyGraph(const MyGraph
& rhs
);
69 MyGraph
& operator=(const MyGraph
& rhs
);
74 void AddSeries(MyGraphSeries
& rMyGraphSeries
);
75 void SetXAxisLabel(const CString
& sLabel
);
76 void SetYAxisLabel(const CString
& sLabel
);
77 int AppendGroup(const CString
& sLabel
);
78 void SetLegend(int nGroup
, const CString
& sLabel
);
79 void SetGraphType(GraphType eType
, bool bStackedGraph
);
80 void SetGraphTitle(const CString
& sTitle
);
81 int LookupLabel(const CString
& sLabel
) const;
82 void DrawGraph(CDC
& dc
);
86 void DrawTitle(CDC
& dc
);
87 void SetupAxes(CDC
& dc
);
88 void DrawAxes(CDC
& dc
) const;
89 void DrawLegend(CDC
& dc
);
90 void DrawSeriesBar(CDC
& dc
) const;
91 void DrawSeriesLine(CDC
& dc
) const;
92 void DrawSeriesLineStacked(CDC
& dc
) const;
93 void DrawSeriesPie(CDC
& dc
) const;
95 int GetMaxLegendLabelLength(CDC
& dc
) const;
96 int GetMaxSeriesSize() const;
97 int GetMaxNonZeroSeriesSize() const;
98 int GetMaxDataValue() const;
99 int GetAverageDataValue() const;
100 int GetNonZeroSeriesCount() const;
102 CString
GetTipText() const;
104 INT_PTR
OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const;
106 CPoint
WedgeEndFromDegrees(double degrees
, const CPoint
& ptCenter
,
107 double radius
) const;
109 static UINT
SpinTheMessageLoop(bool bNoDrawing
= false,
110 bool bOnlyDrawing
= false,
111 UINT uiMsgAllowed
= WM_NULL
);
113 static void RGBtoHLS(COLORREF crRGB
, WORD
& wH
, WORD
& wL
, WORD
& wS
);
114 static COLORREF
HLStoRGB(WORD wH
, WORD wL
, WORD wS
);
115 static WORD
HueToRGB(WORD w1
, WORD w2
, WORD wH
);
118 // ClassWizard generated virtual function overrides
119 //{{AFX_VIRTUAL(MyGraph)
121 virtual void PreSubclassWindow();
124 // Generated message map functions
127 afx_msg
void OnPaint();
128 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
130 afx_msg BOOL
OnNeedText(UINT uiId
, NMHDR
* pNMHDR
, LRESULT
* pResult
);
131 DECLARE_MESSAGE_MAP()
137 int m_nAxisLabelHeight
;
138 int m_nAxisTickLabelHeight
;
143 CString m_sXAxisLabel
;
144 CString m_sYAxisLabel
;
146 CDWordArray m_dwaColors
;
147 CStringArray m_saLegendLabels
;
148 CList
<MyGraphSeries
*,MyGraphSeries
*> m_olMyGraphSeries
;
149 GraphType m_eGraphType
;
150 bool m_bStackedGraph
;
153 //{{AFX_INSERT_LOCATION}}
154 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
156 #endif // !defined(MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_)