wxFreeChart
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/plot.h>
17 
18 #include <wx/areadraw.h>
19 
20 #include <wx/axis/axis.h>
21 
22 #include <wx/title.h>
23 
24 class WXDLLIMPEXP_FREECHART Chart;
25 class WXDLLIMPEXP_FREECHART wxChartPanel;
26 
30 class WXDLLIMPEXP_FREECHART Chart
31 {
32 public:
38  Chart(Plot *plot, const wxString &title = wxEmptyString);
39 
40  Chart(Plot *plot, Header* header = NULL, Footer* footer = NULL);
41 
42  virtual ~Chart();
43 
49  {
50  return m_plot;
51  }
52 
58  void Draw(ChartDC& dc, wxRect& rc, bool antialias = false);
59 
64  void SetBackground(AreaDraw *background)
65  {
66  wxREPLACE(m_background, background);
67  }
68 
69  AreaDraw* GetBackground()
70  {
71  return m_background;
72  }
73 
80  // wxRect CalcPlotRect(wxDC &dc, wxRect rc);
81 
86  void SetTitle(wxString title)
87  {
88  SetHeader(new Header(TextElement(title)));
89  }
90 
91  void SetHeader(Header* header)
92  {
93  wxREPLACE(m_header, header);
94  }
95 
96  void SetFooter(Footer* footer)
97  {
98  wxREPLACE(m_footer, footer);
99  }
100 
101  void SetMargin(wxCoord margin)
102  {
103  m_margin = margin;
104  }
105 
106  //
107  // TODO old scrolling code is deprecated,
108  // will be used Zoom/pan feature instead.
109  //
110 
111  void SetScrolledAxis(Axis *axis);
112 
113  Axis *GetHorizScrolledAxis();
114 
115  Axis *GetVertScrolledAxis();
116 
117 
118  wxChartPanel *GetChartPanel();
119 
120  void SetChartPanel(wxChartPanel *chartPanel);
121 
122  //
123  // PlotObserver
124  //
125  virtual void PlotNeedRedraw(Plot *plot);
126 
127  //
128  // AxisObserver
129  //
130  virtual void AxisChanged(Axis *axis);
131 
132  virtual void BoundsChanged(Axis *axis);
133 
134 private:
135  void Init(Plot* plot, Header* header = NULL, Footer* footer = NULL);
136 
137  Plot *m_plot;
138  AreaDraw *m_background;
139  Header* m_header;
140  Footer* m_footer;
141 
142  int m_headerGap;
143  wxCoord m_margin;
144 
145  Axis *m_horizScrolledAxis;
146  Axis *m_vertScrolledAxis;
147 
148  wxChartPanel *m_chartPanel;
149 };
150 
151 #endif /*CHART_H_*/
Chart.
Definition: chart.h:30
Base class for all plots.
Definition: plot.h:31
ChartPanel is wxWidgets panel for displaying chart.
Definition: chartpanel.h:34
DC that includes a flag to indicate antialiased drawing should be used where appropriate.
Definition: chartdc.h:18
Represents a chart title.
Definition: title.h:77
Plot * GetPlot()
Returns plot associated with chart.
Definition: chart.h:48
void SetTitle(wxString title)
Calcalate plot area rectangle.
Definition: chart.h:86
Base class for all axes.
Definition: axis.h:39
void SetBackground(AreaDraw *background)
Sets chart background.
Definition: chart.h:64
Represents a TitleElement, ie a box containing text which is displayed in the title area...
Definition: title.h:21
Base class for drawing area background.
Definition: areadraw.h:22