//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Chart.hpp>
#include <ExtCtrls.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
#include <TeeShape.hpp>
#include <Series.hpp>
//---------------------------------------------------------------------------

enum TErrorSeriesStyle {essLeft,essRight,essLeftRight,
                      essTop,essBottom,essTopBottom};
enum TErrorWidthUnits {ewuPercent,ewuPixels};

class TErrPointSeries : public TPointSeries {
private:
    bool ftype;
    double percentage;
    double fixed  ;
    TColor StaticColour;
    TChartPen *FErrorPen;
    TErrorSeriesStyle FErrorStyle;
    TChartValueList *FErrorValues;
    //TChartValueList FErrorValues5;
    long int FErrorWidth;
    TErrorWidthUnits FErrorWidthUnits;
    double GetErrorValue(long int Index); //);
    void __fastcall PrepareErrorPen(int ValueIndex);
    void __fastcall SetErrorStyle(TErrorSeriesStyle Value);
    void __fastcall SetErrorValue(long int Index, double const Value);
    void __fastcall SetErrorValues(TChartValueList *Value);
    void __fastcall SetErrorWidthUnits(TErrorWidthUnits Value);
    void __fastcall SetErrorPen(TChartPen *Value);
    void __fastcall SetErrorWidth(long int Value);
protected:
    void DrawError(int long X, int long Y, int long AWidth,int long AHeight, bool Draw3D);
    void DrawHoriz(int long XPos,int long X, int long Y, int long AWidth,int long AHeight, bool Draw3D);
    void DrawVert(int long YPos,int long X, int long Y, int long AWidth,int long AHeight, bool Draw3D);
    void __fastcall SetSeriesColor(TColor *AColor);
public:

    void __fastcall  DrawValue(int ValueIndex);
    __fastcall TErrPointSeries(TComponent* Owner,AnsiString name="",TColor pcolour = clBlack);
    __fastcall ~TErrPointSeries();
    long int AddErrorPoint(const double AX,const double AY, const double AError = -1,
                         const AnsiString AXLabel="",
                         TColor AColor = clBlue);
    void __fastcall CalcHorizMargins(int LeftMargin, int RightMargin);
    void __fastcall CalcVerticalMargins(long int TopMargin, long int BottomMargin);
    void __fastcall DrawLegendShape(long int ValueIndex, const TRect *Rect);
    void __fastcall FillSampleValues(long int NumValues); //overide; { <-- to add random error values }
    void __fastcall fixedw(double f);
    void __fastcall percentagew(double p);
    void __fastcall staticcolourw(TColor s); //
    AnsiString __fastcall GetEditorClass(); // override;
    double __fastcall MinYValue(); // override;
    double __fastcall MaxYValue(); // override;
    double __fastcall MinXValue(); // override;
    double __fastcall MaxXValue(); // override;
    //__property double ErrorValue = { read=GetErrorValue , write=SetErrorValue} ;
    void __fastcall Assign(TPersistent *Source); //override;
    void __fastcall PrepareForGallery(bool IsEnabled); //override;
    // try and published declarations
    __property TChartPen *ErrorPen = {read=FErrorPen, write = SetErrorPen, default = 0};
    __property TErrorSeriesStyle ErrorStyle = {read=FErrorStyle, write=SetErrorStyle,default=essTopBottom };
    __property TChartValueList *ErrorValues = {read=FErrorValues, write=SetErrorValues};
    __property int long ErrorWidth = {read=FErrorWidth, write=SetErrorWidth, default = 100 } ;
    __property TErrorWidthUnits ErrorWidthUnits = {read=FErrorWidthUnits,
                                              write=SetErrorWidthUnits, default=ewuPercent  } ;
    __property double StdErr = {read = fixed, write = fixedw} ;
    __property double PerErr = {read = percentage, write = percentagew} ;
    __property TColor colour = {read = StaticColour, write = staticcolourw};



};


 