/** * Copyright Mikael Högdahl - triyana@users.sourceforge.net * * This source is distributed under the terms of the Q Public License version 1.0, * created by Trolltech (www.trolltech.com). */ #ifndef MHDayChart_h #define MHDayChart_h #include "MHDate.h" #include "MHString.h" #include "MHVector.h" class MHDC; class MHPrice; /** * */ class MHXValue : public MH { public: MHString aMinDate; MHString aMaxDate; double aMin; double aMax; double aTick; double aYPixel; bool aLeft; MHXValue(); void Clear (bool left = true); double Diff () {return aMax - aMin;} void Debug (); }; /** * Store data for a chart area */ class MHArea : public MH { public: double aXPos; double aYPos; double aWidth; double aHeight; MHXValue aLeft; MHXValue aRight; double aSize; MHArea (); void Clear (); void Debug (); }; /** * Chart line object */ class MHChartLine : public MH { public: int aType; int aAlign; int aPos; MHString aName; MHVector* aPrices; MHVector* aClosed; MHChartLine (); void Clear (); void Debug (); }; /** * This is a chart object for date charts. */ class MHDayChart : public MH { public: enum { LEFT = 0, RIGHT, MAX_DATA_AREAS = 5, MAX_DATA_SERIES = 30, MIN_AREA_HEIGHT = 10, LINE_CHART = 1, LINE_CHART_HORIZONTAL_BLACK, LINE_CHART_HORIZONTAL_GRAY, VERTICAL_CHART, BAR_CHART, VOLUME_CHART, RECTANGLE_CHART, GREY_RECTANGLE_CHART, }; MHDayChart (int vspace, int bspace, int vsize1 = 100, int vsize2 = 0, int vsize3 = 0, int vsize4 = 0, int vsize5 = 0); virtual ~MHDayChart (); void AddData (const char* name, int type, int align, int pos, MHVector* ve, MHVector* ve2 = 0); void AddDates (int timeType = MHDate::WEEKDAY); const char* Class () {return "MHDayChart";} void Clear (); void Debug (); void Init (MHDC* dc); void Paint (MHDC* dc); void Query (int x, int y, MHPrice* left, MHPrice* right); private: MHArea aAreas[MAX_DATA_AREAS + 1]; MHChartLine aLine[MAX_DATA_SERIES + 1]; int aLines; int aWidth; int aHeight; int aVSpace; int aBSpace; int aTopBorder; int aBottomBorder; int aLeftBorder; int aRightBorder; int aTimeType; bool aFirstTime; void calcSize (MHDC* dc); void calcYMinYMax (); void calcYTick (MHXValue* val); void drawArea (int f, MHDC* dc); void drawLabel (int x, int y, int labelpos, MHChartLine* line, MHDC* dc); void drawLine (MHChartLine* line, MHArea* area, MHDC* dc); void drawVerLines (int f, MHDC* dc); void drawXLabels (MHDC* dc); void drawYLabels (int x1, int x2, double start, double stop, MHXValue* value, MHDC* dc); public: int aVerPos[100]; MHVector aDates; bool aHorLines; bool aVerLines; int aDateStart; int aTicks; int aTickWidth; int aBgColor; }; #endif