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 GetNonZeroElementCount() const;
37 int GetDataTotal() const;
38 void SetTipRegion(int nGroup
, const CRect
& rc
);
39 void SetTipRegion(int nGroup
, CRgn
* prgn
);
40 int HitTest(const CPoint
& pt
, int searchStart
) const;
41 CString
GetTipText(int nGroup
, const CString
&unitString
) const;
45 CString m_sLabel
; // Series label.
46 CDWordArray m_dwaValues
; // Values array.
47 CArray
<CRgn
*,CRgn
*> m_oaRegions
; // Tooltip regions.
51 /////////////////////////////////////////////////////////////////////////////
54 class MyGraph
: public CStatic
58 enum GraphType
{ Bar
, Line
, PieChart
}; // Renamed 'Pie' because it hides a GDI function name
62 MyGraph(GraphType eGraphType
= MyGraph::PieChart
, bool bStackedGraph
= false);
65 // Declared but not defined.
67 MyGraph(const MyGraph
& rhs
);
68 MyGraph
& operator=(const MyGraph
& rhs
);
73 void AddSeries(MyGraphSeries
& rMyGraphSeries
);
74 void SetXAxisLabel(const CString
& sLabel
);
75 void SetYAxisLabel(const CString
& sLabel
);
76 int AppendGroup(const CString
& sLabel
);
77 void SetLegend(int nGroup
, const CString
& sLabel
);
78 void SetGraphType(GraphType eType
, bool bStackedGraph
);
79 void SetGraphTitle(const CString
& sTitle
);
80 int LookupLabel(const CString
& sLabel
) const;
81 void DrawGraph(CDC
& dc
);
85 void DrawTitle(CDC
& dc
);
86 void SetupAxes(CDC
& dc
);
87 void DrawAxes(CDC
& dc
) const;
88 void DrawLegend(CDC
& dc
);
89 void DrawSeriesBar(CDC
& dc
) const;
90 void DrawSeriesLine(CDC
& dc
) const;
91 void DrawSeriesLineStacked(CDC
& dc
) const;
92 void DrawSeriesPie(CDC
& dc
) const;
94 int GetMaxLegendLabelLength(CDC
& dc
) const;
95 int GetMaxSeriesSize() const;
96 int GetMaxNonZeroSeriesSize() const;
97 int GetMaxDataValue() const;
98 int GetNonZeroSeriesCount() const;
100 CString
GetTipText() const;
102 INT_PTR
OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const;
104 CPoint
WedgeEndFromDegrees(double degrees
, const CPoint
& ptCenter
,
105 double radius
) const;
107 static UINT
SpinTheMessageLoop(bool bNoDrawing
= false,
108 bool bOnlyDrawing
= false,
109 UINT uiMsgAllowed
= WM_NULL
);
111 static void RGBtoHLS(COLORREF crRGB
, WORD
& wH
, WORD
& wL
, WORD
& wS
);
112 static COLORREF
HLStoRGB(WORD wH
, WORD wL
, WORD wS
);
113 static WORD
HueToRGB(WORD w1
, WORD w2
, WORD wH
);
116 // ClassWizard generated virtual function overrides
117 //{{AFX_VIRTUAL(MyGraph)
119 virtual void PreSubclassWindow();
122 // Generated message map functions
125 afx_msg
void OnPaint();
126 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
128 afx_msg BOOL
OnNeedText(UINT uiId
, NMHDR
* pNMHDR
, LRESULT
* pResult
);
129 DECLARE_MESSAGE_MAP()
135 int m_nAxisLabelHeight
;
136 int m_nAxisTickLabelHeight
;
141 CString m_sXAxisLabel
;
142 CString m_sYAxisLabel
;
144 CDWordArray m_dwaColors
;
145 CStringArray m_saLegendLabels
;
146 CList
<MyGraphSeries
*,MyGraphSeries
*> m_olMyGraphSeries
;
147 GraphType m_eGraphType
;
148 bool m_bStackedGraph
;
151 //{{AFX_INSERT_LOCATION}}
152 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
154 #endif // !defined(MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_)