00001
00002
00003
00004
00005
00006
00007
00009
00010 #ifndef COMPDATEAXIS_H_
00011 #define COMPDATEAXIS_H_
00012
00013 #include <wx/axis/axis.h>
00014 #include <wx/areadraw.h>
00015
00016 #include <wx/dynarray.h>
00017
00018 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDateSpan, wxDateSpanArray, WXDLLIMPEXP_FREECHART);
00019 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxTimeSpan, wxTimeSpanArray, WXDLLIMPEXP_FREECHART);
00020
00026 class CompDateAxis : public Axis
00027 {
00028 DECLARE_CLASS(CompDateAxis)
00029 public:
00030 CompDateAxis(AXIS_LOCATION location);
00031 virtual ~CompDateAxis();
00032
00033 virtual void Draw(wxDC &dc, wxRect rc);
00034
00035 virtual void DrawGridLines(wxDC &dc, wxRect rc);
00036
00037 virtual wxCoord GetExtent(wxDC &dc);
00038
00039 virtual void UpdateBounds();
00040
00041 virtual void GetDataBounds(double &minValue, double &maxValue);
00042
00043 virtual wxCoord ToGraphics(wxDC &dc, int minCoord, int gRange, double value);
00044
00045 virtual double ToData(wxDC &dc, int minCoord, int gRange, wxCoord g);
00046
00047 void AddInterval(const wxDateSpan &interval);
00048
00049 void AddInterval(const wxTimeSpan &interval);
00050
00056 void SetSpanDraw(AreaDraw *spanDraw)
00057 {
00058 wxREPLACE(m_spanDraw, spanDraw);
00059 FireAxisChanged();
00060 }
00061
00062 protected:
00063 virtual bool AcceptDataset(Dataset *dataset);
00064
00065 private:
00066 void DrawSpan(wxDC &dc, wxRect rcAxis, int spanNum, wxString spanLabel, double start, double end);
00067
00068 wxString GetSpanLabel(wxDateTime date, wxDateSpan span);
00069
00070 wxCoord GetSpanExtent(wxDC &dc);
00071
00072 bool GetWindowDateBounds(wxDateTime &date0, wxDateTime &date1);
00073
00074 double DateToDataCoord(wxDateTime &date);
00075
00076 bool GetFirstDate(wxDateTime &date);
00077 bool GetLastDate(wxDateTime &date);
00078
00079 bool GetFirstLastDate(wxDateTime &firstDate, wxDateTime &lastDate);
00080
00081 bool GetMinSpan(wxDateSpan &span);
00082
00083 size_t m_dateCount;
00084
00085 bool m_fillDateGaps;
00086
00087 wxFont m_labelFont;
00088 wxColour m_labelColour;
00089
00090 wxCoord m_minLabelGap;
00091 wxCoord m_labelMargin;
00092 AreaDraw *m_spanDraw;
00093
00094 wxDateSpanArray m_dateSpans;
00095 };
00096
00097 #endif