Version: 0.6.0
chart.h
1 // Name: chart.h
3 // Purpose: chart declarations
4 // Author: Moskvichev Andrey V., changes by Andreas Kuechler
5 // Created: 2008/11/07
6 // Copyright: (c) 2008-2010 Moskvichev Andrey V.
7 // Licence: wxWidgets licence
9 
10 #ifndef CHART_H_
11 #define CHART_H_
12 
13 #include <wx/wxfreechartdefs.h>
14 
15 #include <wx/refobject.h>
16 #include <wx/observable.h>
17 #include <wx/plot.h>
18 
19 #include <wx/areadraw.h>
20 
21 #include <wx/axis/axis.h>
22 
23 #include <wx/title.h>
24 
25 class WXDLLIMPEXP_FREECHART Chart;
26 class WXDLLIMPEXP_FREECHART wxChartPanel;
27 
31 class WXDLLIMPEXP_FREECHART ChartObserver
32 {
33 public:
34  ChartObserver();
35 
36  virtual ~ChartObserver();
37 
43  virtual void ChartChanged(Chart *chart) = 0;
44 
49  virtual void ChartScrollsChanged(Chart *chart) = 0;
50 };
51 
55 class WXDLLIMPEXP_FREECHART Chart : public Observable<ChartObserver>, public PlotObserver, public AxisObserver
56 {
57 public:
63  Chart(Plot *plot, const wxString &title = wxEmptyString, const wxColour &bgColor = wxColour(220, 220, 220));
64 
65  Chart(Plot *plot, Header* header = NULL, Footer* footer = NULL, const wxColour &bgColor = wxColour(220, 220, 220));
66 
67  virtual ~Chart();
68 
74  {
75  return m_plot;
76  }
77 
83  void Draw(wxDC &dc, wxRect &rc);
84 
89  void SetBackground(AreaDraw *background)
90  {
91  wxREPLACE(m_background, background);
92  FireChartChanged();
93  }
94 
101  // wxRect CalcPlotRect(wxDC &dc, wxRect rc);
102 
107  void SetTitle(wxString title)
108  {
109  SetHeader(new Header(title));
110  }
111 
112  void SetHeader(Header* header)
113  {
114  wxREPLACE(m_header, header);
115  FireChartChanged();
116  }
117 
118  void SetFooter(Footer* footer)
119  {
120  wxREPLACE(m_footer, footer);
121  FireChartChanged();
122  }
123 
124  void SetMargin(wxCoord margin)
125  {
126  m_margin = margin;
127  FireChartChanged();
128  }
129 
130  //
131  // TODO old scrolling code is deprecated,
132  // will be used Zoom/pan feature instead.
133  //
134 
135  void SetScrolledAxis(Axis *axis);
136 
137  Axis *GetHorizScrolledAxis();
138 
139  Axis *GetVertScrolledAxis();
140 
141 
142  wxChartPanel *GetChartPanel();
143 
144  void SetChartPanel(wxChartPanel *chartPanel);
145 
146  //
147  // PlotObserver
148  //
149  virtual void PlotNeedRedraw(Plot *plot);
150 
151  //
152  // AxisObserver
153  //
154  virtual void AxisChanged(Axis *axis);
155 
156  virtual void BoundsChanged(Axis *axis);
157 
158 private:
159  void Init(Plot* plot, Header* header = NULL, Footer* footer = NULL, const wxColour &bgColor = wxColour(220, 220, 220));
160 
161  Plot *m_plot;
162  AreaDraw *m_background;
163  Header* m_header;
164  Footer* m_footer;
165 
166  int m_headerGap;
167  wxCoord m_margin;
168 
169  Axis *m_horizScrolledAxis;
170  Axis *m_vertScrolledAxis;
171 
172  wxChartPanel *m_chartPanel;
173 
174  FIRE_WITH_THIS(ChartChanged);
175  FIRE_WITH_THIS(ChartScrollsChanged);
176 };
177 
178 #endif /*CHART_H_*/
Definition: chartpanel.h:51
void SetTitle(wxString title)
Definition: chart.h:107
virtual void PlotNeedRedraw(Plot *_plot)=0
Definition: areadraw.h:22
Definition: axis.h:62
Definition: chart.h:31
Definition: observable.h:14
Definition: title.h:77
void SetBackground(AreaDraw *background)
Definition: chart.h:89
virtual void AxisChanged(Axis *axis)=0
Definition: plot.h:24
virtual void BoundsChanged(Axis *axis)=0
Definition: plot.h:42
Definition: axis.h:33
Definition: chart.h:55
Plot * GetPlot()
Definition: chart.h:73