Version: 0.6.0
labelaxis.h
1 // Name: labelaxis.h
3 // Purpose: label axis declaration
4 // Author: Moskvichev Andrey V.
5 // Created: 2008/11/07
6 // Copyright: (c) 2008-2010 Moskvichev Andrey V.
7 // Licence: wxWidgets licence
9 
10 #ifndef LABELAXIS_H_
11 #define LABELAXIS_H_
12 
13 #include <wx/axis/axis.h>
14 
18 class WXDLLIMPEXP_FREECHART LabelColourer
19 {
20 public:
21  virtual wxColor GetColour(int step) = 0;
22 };
23 
27 class WXDLLIMPEXP_FREECHART LabelAxis : public Axis
28 {
29  DECLARE_CLASS(LabelAxis)
30 public:
31  LabelAxis(AXIS_LOCATION location);
32  virtual ~LabelAxis();
33 
38  void SetTitle(const wxString &title)
39  {
40  m_title = title;
41  FireAxisChanged();
42  }
43 
48  const wxString &GetTitle()
49  {
50  return m_title;
51  }
52 
59  void SetTitleLocation(int location)
60  {
61  if (m_titleLocation != location) {
62  m_titleLocation = location;
63  FireAxisChanged();
64  }
65  }
66 
72  {
73  return m_titleLocation;
74  }
75 
80  void SetTitleFont(wxFont &font)
81  {
82  m_titleFont = font;
83  FireAxisChanged();
84  }
85 
90  const wxFont &GetTitleFont()
91  {
92  return m_titleFont;
93  }
94 
99  void SetTitleColour(wxColour &colour)
100  {
101  if (m_titleColour != colour) {
102  m_titleColour = colour;
103  FireAxisChanged();
104  }
105  }
106 
111  wxColour GetTitleColour()
112  {
113  return m_titleColour;
114  }
115 
120  void SetLabelPen(wxPen labelPen)
121  {
122  m_labelPen = labelPen;
123  FireAxisChanged();
124  }
125 
130  void SetLabelTextColour(wxColour labelTextColour)
131  {
132  m_labelTextColour = labelTextColour;
133  FireAxisChanged();
134  }
135 
141  {
142  return m_labelTextColour;
143  }
144 
149  void SetLabelTextFont(wxFont labelTextFont)
150  {
151  m_labelTextFont = labelTextFont;
152  FireAxisChanged();
153  }
154 
159  const wxFont& GetLabelTextFont()
160  {
161  return m_labelTextFont;
162  }
163 
168  void SetVerticalLabelText(bool verticalLabelText)
169  {
170  if (m_verticalLabelText != verticalLabelText) {
171  m_verticalLabelText = verticalLabelText;
172  FireAxisChanged();
173  }
174  }
175 
181  {
182  return m_verticalLabelText;
183  }
184 
189  void SetMajorLabelSteps(size_t step)
190  {
191  if (m_majorLabelStep != step) {
192  m_majorLabelStep = step;
193  FireAxisChanged();
194  }
195  }
196 
197  void SetLabelSkip(int blankLabels);
198 
199  int GetLabelSkip();
200 
201  void SetLabelColourer(LabelColourer *labelColourer)
202  {
203  wxREPLACE(m_labelColourer, labelColourer);
204  }
205 
206  LabelColourer *GetLabelColourer()
207  {
208  return m_labelColourer;
209  }
210 
215  void SetAxisVisible(bool bVisible);
216 
217  //
218  // Axis
219  //
220  virtual void Draw(wxDC &dc, wxRect rc);
221 
222  virtual void DrawGridLines(wxDC &dc, wxRect rc);
223 
224  virtual wxCoord GetExtent(wxDC &dc);
225 
226 protected:
227  //
228  // Functions that must be implemented by derivative classes
229  //
230 
236  virtual double GetValue(size_t step) = 0;
237 
243  virtual void GetLabel(size_t step, wxString &label) = 0;
244 
250  virtual bool IsEnd(size_t step) = 0;
251 
252  virtual wxSize GetLongestLabelExtent(wxDC &dc) = 0;
253 
254  virtual bool HasLabels();
255 
256 private:
257  void DrawLabels(wxDC &dc, wxRect rc);
258 
259  void DrawLabel(wxDC &dc, wxRect rc, const wxString &label, double value, bool isMajorLabel);
260 
261  void DrawBorderLine(wxDC &dc, wxRect rc);
262 
263  wxCoord m_labelLineSize;
264  wxCoord m_labelGap;
265 
266  // labels properties
267  wxFont m_labelTextFont;
268  wxColour m_labelTextColour;
269  wxPen m_labelPen;
270  bool m_verticalLabelText;
271  size_t m_majorLabelStep;
272 
273  // label title properties
274  wxString m_title;
275  wxFont m_titleFont;
276  wxColour m_titleColour;
277  int m_titleLocation;
278 
279  bool m_visible;
280  int m_blankLabels;
281 
282  LabelColourer *m_labelColourer;
283 };
284 
285 #endif /*LABELAXIS_H_*/
void SetLabelTextColour(wxColour labelTextColour)
Definition: labelaxis.h:130
virtual void DrawGridLines(wxDC &dc, wxRect rcData)=0
int GetTitleLocation()
Definition: labelaxis.h:71
Definition: labelaxis.h:27
void SetTitle(const wxString &title)
Definition: labelaxis.h:38
wxColour GetTitleColour()
Definition: labelaxis.h:111
const wxString & GetTitle()
Definition: labelaxis.h:48
Definition: labelaxis.h:18
void SetTitleColour(wxColour &colour)
Definition: labelaxis.h:99
void SetLabelPen(wxPen labelPen)
Definition: labelaxis.h:120
Definition: axis.h:62
wxColour GetLabelTextColour()
Definition: labelaxis.h:140
void SetVerticalLabelText(bool verticalLabelText)
Definition: labelaxis.h:168
const wxFont & GetTitleFont()
Definition: labelaxis.h:90
const wxFont & GetLabelTextFont()
Definition: labelaxis.h:159
void SetMajorLabelSteps(size_t step)
Definition: labelaxis.h:189
bool GetVerticalLabelText()
Definition: labelaxis.h:180
virtual void Draw(wxDC &dc, wxRect rc)=0
void SetTitleFont(wxFont &font)
Definition: labelaxis.h:80
void SetLabelTextFont(wxFont labelTextFont)
Definition: labelaxis.h:149
void SetTitleLocation(int location)
Definition: labelaxis.h:59
virtual wxCoord GetExtent(wxDC &dc)=0