Version: 0.6.0
compdateaxis.h
1 // Name: compdateaxis.h
3 // Purpose: comp date axis declarations
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 COMPDATEAXIS_H_
11 #define COMPDATEAXIS_H_
12 
13 #include <wx/axis/axis.h>
14 #include <wx/areadraw.h>
15 
16 #include <wx/dynarray.h>
17 
18 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDateSpan, wxDateSpanArray, WXDLLIMPEXP_FREECHART);
19 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxTimeSpan, wxTimeSpanArray, WXDLLIMPEXP_FREECHART);
20 
26 class CompDateAxis : public Axis
27 {
28  DECLARE_CLASS(CompDateAxis)
29 public:
30  CompDateAxis(AXIS_LOCATION location);
31  virtual ~CompDateAxis();
32 
33  virtual void Draw(wxDC &dc, wxRect rc);
34 
35  virtual void DrawGridLines(wxDC &dc, wxRect rc);
36 
37  virtual wxCoord GetExtent(wxDC &dc);
38 
39  virtual void UpdateBounds();
40 
41  virtual void GetDataBounds(double &minValue, double &maxValue) const;
42 
43  virtual wxCoord ToGraphics(wxDC &dc, int minCoord, int gRange, double value);
44 
45  virtual double ToData(wxDC &dc, int minCoord, int gRange, wxCoord g);
46 
50  void AddInterval(const wxDateSpan &interval);
51 
52  void AddInterval(const wxTimeSpan &interval);
53 
59  void SetSpanDraw(AreaDraw *spanDraw)
60  {
61  wxREPLACE(m_spanDraw, spanDraw);
62  FireAxisChanged();
63  }
64 
65 protected:
66  virtual bool AcceptDataset(Dataset *dataset);
67 
68 private:
69  void DrawSpan(wxDC &dc, wxRect rcAxis, int spanNum, wxString spanLabel, double start, double end);
70 
71  wxString GetSpanLabel(wxDateTime date, wxDateSpan span);
72 
73  wxCoord GetSpanExtent(wxDC &dc);
74 
75  bool GetWindowDateBounds(wxDateTime &date0, wxDateTime &date1);
76 
77  double DateToDataCoord(wxDateTime &date);
78 
79  bool GetFirstDate(wxDateTime &date);
80  bool GetLastDate(wxDateTime &date);
81 
82  bool GetFirstLastDate(wxDateTime &firstDate, wxDateTime &lastDate);
83 
84  bool GetMinSpan(wxDateSpan &span);
85 
86  size_t m_dateCount;
87 
88  bool m_fillDateGaps;
89 
90  wxFont m_labelFont;
91  wxColour m_labelColour;
92 
93  wxCoord m_minLabelGap; // minimal distance between labels in date/time span
94  wxCoord m_labelMargin; // distance between label and span area bounds
95  AreaDraw *m_spanDraw;
96 
97  wxDateSpanArray m_dateSpans;
98 };
99 
100 #endif /* COMPDATEAXIS_H_ */
virtual void GetDataBounds(double &minValue, double &maxValue) const
Definition: compdateaxis.cpp:171
Definition: areadraw.h:22
virtual double ToData(wxDC &dc, int minCoord, int gRange, wxCoord g)
Definition: compdateaxis.cpp:390
Definition: axis.h:62
virtual wxCoord GetExtent(wxDC &dc)
Definition: compdateaxis.cpp:166
virtual void DrawGridLines(wxDC &dc, wxRect rc)
Definition: compdateaxis.cpp:200
void SetSpanDraw(AreaDraw *spanDraw)
Definition: compdateaxis.h:59
void AddInterval(const wxDateSpan &interval)
Definition: compdateaxis.cpp:558
Definition: compdateaxis.h:26
virtual void UpdateBounds()
Definition: compdateaxis.cpp:177
Definition: dataset.h:50
virtual void Draw(wxDC &dc, wxRect rc)
Definition: compdateaxis.cpp:238
virtual wxCoord ToGraphics(wxDC &dc, int minCoord, int gRange, double value)
Definition: compdateaxis.cpp:369
virtual bool AcceptDataset(Dataset *dataset)
Definition: compdateaxis.cpp:158