wxFreeChart
barrenderer.h
1 // Name: barrenderer.h
3 // Purpose: bar renderer and bar types declarations
4 // Author: Moskvichev Andrey V.
5 // Created: 14.11.2008
6 // Copyright: (c) 2008-2010 Moskvichev Andrey V.
7 // Licence: wxWidgets licence
9 
10 #ifndef BARRENDERER_H_
11 #define BARRENDERER_H_
12 
13 #include "wx/xy/xyrenderer.h"
14 #include "wx/areadraw.h"
15 
16 class CategoryDataset;
17 class BarRenderer;
18 
23 class WXDLLIMPEXP_FREECHART BarType
24 {
25 public:
26  BarType(double base);
27  virtual ~BarType();
28 
40  virtual void Draw(BarRenderer *barRenderer, wxDC &dc, wxRect rc, Axis *horizAxis, Axis *vertAxis, bool vertical, size_t item, CategoryDataset *dataset);
41 
42  //
43  // Called from BarRenderer. Don't call from programs.
44  //
45  virtual double GetMinValue(CategoryDataset *dataset);
46  virtual double GetMaxValue(CategoryDataset *dataset);
47 
48 protected:
60  virtual void GetBarGeometry(CategoryDataset *dataset, size_t item, size_t serie,
61  int &width, wxCoord &shift, double &base, double &value) = 0;
62 
63  double m_base;
64 };
65 
69 class WXDLLIMPEXP_FREECHART NormalBarType : public BarType
70 {
71 public:
78  NormalBarType(int barWidth, int serieGap = 1, double base = 0.0);
79  virtual ~NormalBarType();
80 
81 protected:
82  virtual void GetBarGeometry(CategoryDataset *dataset, size_t item, size_t serie,
83  int &width, wxCoord &shift, double &base, double &value);
84 
85 private:
86  int m_barWidth;
87  int m_serieGap;
88 };
89 
93 class WXDLLIMPEXP_FREECHART StackedBarType : public BarType
94 {
95 public:
101  StackedBarType(int barWidth, double base);
102  virtual ~StackedBarType();
103 
104  virtual double GetMinValue(CategoryDataset *dataset);
105  virtual double GetMaxValue(CategoryDataset *dataset);
106 
107 protected:
108  virtual void GetBarGeometry(CategoryDataset *dataset, size_t item, size_t serie,
109  int &width, wxCoord &shift, double &base, double &value);
110 
111 private:
112  int m_barWidth;
113 };
114 
118 class WXDLLIMPEXP_FREECHART LayeredBarType : public BarType
119 {
120 public:
126  LayeredBarType(int initialBarWidth, double base);
127  virtual ~LayeredBarType();
128 
129 protected:
130  virtual void GetBarGeometry(CategoryDataset *dataset, size_t item, size_t serie,
131  int &width, wxCoord &shift, double &base, double &value);
132 
133 private:
134  int m_initialBarWidth;
135 };
136 
140 class WXDLLIMPEXP_FREECHART BarRenderer : public Renderer
141 {
142  DECLARE_CLASS(BarRenderer)
143 public:
149  BarRenderer(BarType *barType);
150  virtual ~BarRenderer();
151 
152  //
153  // Renderer
154  //
155  virtual void DrawLegendSymbol(wxDC &dc, wxRect rcSymbol, size_t serie);
156 
165  void Draw(wxDC &dc, wxRect rc, Axis *horizAxis, Axis *vertAxis, bool vertical, CategoryDataset *dataset);
166 
173  void SetBarType(BarType *barType);
174 
179  BarType *GetBarType();
180 
186  void SetBarDraw(size_t serie, AreaDraw *areaDraw);
187 
193  AreaDraw *GetBarDraw(size_t serie);
194 
195  double GetMinValue(CategoryDataset *dataset);
196  double GetMaxValue(CategoryDataset *dataset);
197 
198 private:
199  BarType *m_barType;
200 
201  AreaDrawCollection m_barDraws;
202 };
203 
204 #endif /*BARRENDERER_H_*/
Base class for all renderers.
Definition: chartrenderer.h:21
Dataset for data values in form [category name, value].
Draws series' bars overlapped.
Definition: barrenderer.h:118
Collection of areadraws for series.
Definition: areadraw.h:179
Bar renderer.
Definition: barrenderer.h:140
Draws series' bars in stack, after each other.
Definition: barrenderer.h:93
Normal bar type.
Definition: barrenderer.h:69
virtual void GetBarGeometry(CategoryDataset *dataset, size_t item, size_t serie, int &width, wxCoord &shift, double &base, double &value)=0
Called to calculate bar geometry params.
Base class for all axes.
Definition: axis.h:39
Base class for drawing area background.
Definition: areadraw.h:22
Bar types base class.
Definition: barrenderer.h:23
virtual void DrawLegendSymbol(wxDC &dc, wxRect rcSymbol, size_t serie)
Draws legend symbol.