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