fixed warnings
[TortoiseGit.git] / src / Utils / MiscUI / MyGraph.h
blob0caa5ee40b9df50fb8e9e1a73d59a7c692ab94dd
1 // MyGraph.h
3 #if !defined(MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_)
4 #define MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_
5 #pragma once
8 /////////////////////////////////////////////////////////////////////////////
9 // MyGraphSeries
11 class MyGraphSeries : public CObject
13 friend class MyGraph;
15 // Construction.
16 public:
17 MyGraphSeries(const CString& sLabel = _T(""));
18 virtual ~MyGraphSeries();
20 // Declared but not defined.
21 private:
22 MyGraphSeries(const MyGraphSeries& rhs);
23 MyGraphSeries& operator=(const MyGraphSeries& rhs);
25 // Operations.
26 public:
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;
33 // Implementation.
34 private:
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;
43 // Data.
44 private:
45 CString m_sLabel; // Series label.
46 CDWordArray m_dwaValues; // Values array.
47 CArray<CRgn*,CRgn*> m_oaRegions; // Tooltip regions.
51 /////////////////////////////////////////////////////////////////////////////
52 // MyGraph
54 class MyGraph : public CStatic
56 // Enum.
57 public:
58 enum GraphType { Bar, Line, PieChart }; // Renamed 'Pie' because it hides a GDI function name
60 // Construction.
61 public:
62 MyGraph(GraphType eGraphType = MyGraph::PieChart, bool bStackedGraph = false);
63 virtual ~MyGraph();
65 // Declared but not defined.
66 private:
67 MyGraph(const MyGraph& rhs);
68 MyGraph& operator=(const MyGraph& rhs);
70 // Operations.
71 public:
72 void Clear();
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);
83 // Implementation.
84 private:
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);
115 // Overrides
116 // ClassWizard generated virtual function overrides
117 //{{AFX_VIRTUAL(MyGraph)
118 protected:
119 virtual void PreSubclassWindow();
120 //}}AFX_VIRTUAL
122 // Generated message map functions
123 protected:
124 //{{AFX_MSG(MyGraph)
125 afx_msg void OnPaint();
126 afx_msg void OnSize(UINT nType, int cx, int cy);
127 //}}AFX_MSG
128 afx_msg BOOL OnNeedText(UINT uiId, NMHDR* pNMHDR, LRESULT* pResult);
129 DECLARE_MESSAGE_MAP()
131 // Data.
132 private:
133 int m_nXAxisWidth;
134 int m_nYAxisHeight;
135 int m_nAxisLabelHeight;
136 int m_nAxisTickLabelHeight;
137 CPoint m_ptOrigin;
138 CRect m_rcGraph;
139 CRect m_rcLegend;
140 CRect m_rcTitle;
141 CString m_sXAxisLabel;
142 CString m_sYAxisLabel;
143 CString m_sTitle;
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_)