OSDN Git Service

Show Ignore Sub Menu
[tortoisegit/TortoiseGitJp.git] / src / Utils / MiscUI / MyGraph.h
1 // MyGraph.h\r
2 \r
3 #if !defined(MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_)\r
4 #define MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_\r
5 #pragma once\r
6 \r
7 \r
8 /////////////////////////////////////////////////////////////////////////////\r
9 // MyGraphSeries\r
10 \r
11 class MyGraphSeries : public CObject\r
12 {\r
13         friend class MyGraph;\r
14 \r
15 // Construction.\r
16 public:\r
17         MyGraphSeries(const CString& sLabel = _T(""));\r
18         virtual ~MyGraphSeries();\r
19 \r
20 // Declared but not defined.\r
21 private:\r
22         MyGraphSeries(const MyGraphSeries& rhs);\r
23         MyGraphSeries& operator=(const MyGraphSeries& rhs);\r
24 \r
25 // Operations.\r
26 public:\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
32 \r
33 // Implementation.\r
34 private:\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
42 \r
43 // Data.\r
44 private:\r
45         CString                 m_sLabel;                                                                               // Series label.\r
46         CDWordArray             m_dwaValues;                                                                    // Values array.\r
47         CArray<CRgn*,CRgn*>             m_oaRegions;                                                                    // Tooltip regions.\r
48 };\r
49 \r
50 \r
51 /////////////////////////////////////////////////////////////////////////////\r
52 // MyGraph\r
53 \r
54 class MyGraph : public CStatic\r
55 {\r
56 // Enum.\r
57 public:\r
58         enum GraphType          { Bar, Line, PieChart }; // Renamed 'Pie' because it hides a GDI function name\r
59 \r
60 // Construction.\r
61 public:\r
62         MyGraph(GraphType eGraphType = MyGraph::PieChart, bool bStackedGraph = false);\r
63         virtual ~MyGraph();\r
64 \r
65 // Declared but not defined.\r
66 private:\r
67         MyGraph(const MyGraph& rhs);\r
68         MyGraph& operator=(const MyGraph& rhs);\r
69 \r
70 // Operations.\r
71 public:\r
72         void    Clear();\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
82 \r
83 // Implementation.\r
84 private:\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
93 \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
99 \r
100         CString GetTipText() const;\r
101 \r
102         INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;\r
103 \r
104         CPoint  WedgeEndFromDegrees(int nDegrees, const CPoint& ptCenter,\r
105                                         int nRadius) const;\r
106 \r
107         static UINT                     SpinTheMessageLoop(bool bNoDrawing = false,\r
108                                                                 bool bOnlyDrawing = false,\r
109                                                                 UINT uiMsgAllowed = WM_NULL);\r
110 \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
114 \r
115         // Overrides\r
116         // ClassWizard generated virtual function overrides\r
117         //{{AFX_VIRTUAL(MyGraph)\r
118         protected:\r
119         virtual void PreSubclassWindow();\r
120         //}}AFX_VIRTUAL\r
121 \r
122 // Generated message map functions\r
123 protected:\r
124         //{{AFX_MSG(MyGraph)\r
125         afx_msg void OnPaint();\r
126         afx_msg void OnSize(UINT nType, int cx, int cy);\r
127         //}}AFX_MSG\r
128         afx_msg BOOL OnNeedText(UINT uiId, NMHDR* pNMHDR, LRESULT* pResult);\r
129         DECLARE_MESSAGE_MAP()\r
130 \r
131 // Data.\r
132 private:\r
133         int                             m_nXAxisWidth;\r
134         int                             m_nYAxisHeight;\r
135         int                             m_nAxisLabelHeight;\r
136         int                             m_nAxisTickLabelHeight;\r
137         CPoint                  m_ptOrigin;\r
138         CRect                   m_rcGraph;\r
139         CRect                   m_rcLegend;\r
140         CRect                   m_rcTitle;\r
141         CString                 m_sXAxisLabel;\r
142         CString                 m_sYAxisLabel;\r
143         CString                 m_sTitle;\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
149 };\r
150 \r
151 //{{AFX_INSERT_LOCATION}}\r
152 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.\r
153 \r
154 #endif // !defined(MYGRAPHH__9DB68B4D_3C7C_47E2_9F72_EEDA5D2CDBB0__INCLUDED_)\r