//---------------------------------------------------------------------------

#ifndef PlugInChartFH
#define PlugInChartFH
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <DBClient.hpp>
//---------------------------------------------------------------------------
#include "DataTypesF.h"

#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <CheckLst.hpp>
#include <Menus.hpp>
#include "DBChart.hpp"
#include "Chart.hpp"
#include "Series.hpp"
#include "TeeShape.hpp"
#include "ArrowCha.hpp"
#include "BubbleCh.hpp"
#include "GanttCh.hpp"
#include "DBChart.hpp"
#include "Series.hpp"
#include "TeEngine.hpp"
#include "TeeProcs.hpp"
#include <ImgList.hpp>
#include "cxButtons.hpp"
#include "cxCheckBox.hpp"
#include "cxContainer.hpp"
#include "cxControls.hpp"
#include "cxDropDownEdit.hpp"
#include "cxEdit.hpp"
#include "cxGraphics.hpp"
#include "cxImageComboBox.hpp"
#include "cxLabel.hpp"
#include "cxLookAndFeelPainters.hpp"
#include "cxLookAndFeels.hpp"
#include "cxMaskEdit.hpp"
#include "cxSplitter.hpp"
#include "cxTextEdit.hpp"
#include "dxSkinBlack.hpp"
#include "dxSkinBlue.hpp"
#include "dxSkinsCore.hpp"

//---------------------------------------------------------------------------
#pragma warn -8111         

/*
*****************************************************************************
*  Chart information define
*****************************************************************************
*/
typedef enum
{
    ctpLine = 0,
    ctpBar,
    ctpArea,
    ctpPoint,
    ctpPie,
    ctpBubble,
    ctpFast_Line,
    ctpArrow,
    ctpHorizontal_Bar,
    ctpHorizontal_Line,
    ctpHorizontal_Area,
    ctpShape,
    ctpGantt,
} SeriesType;

typedef struct
{
    SeriesType  SrsType;
    void        *ChartSeries;
} SeriesItem;

/*
*****************************************************************************
*  Traffic color information define
*****************************************************************************
*/
#define   COLOR_SPEED1    (TColor)0x00B0B0FF
#define   COLOR_SPEED2    (TColor)0x00B5DAFF
#define   COLOR_SPEED3    (TColor)0x00FFE1C4
#define   COLOR_SELECTED  (TColor)0x00F8ECE4
#define   COLOR_FIXEDCOL  (TColor)0x00F9F9F9

#define   COLOR_CURR_ROW  (TColor)0x00F5E6DC
#define   COLOR_CURR_COL  (TColor)0x00F5E6DC

#define   COLOR_TOT       (TColor)0x00EEEBDF
#define   COLOR_TOT_SUB   (TColor)0x00E7F9FE
#define   COLOR_AVG       (TColor)0x00EEEBDF

//---------------------------------------------------------------------------

class TPlugInChart : public TForm
{
__published:	// IDE-managed Components
    TPanel *PnlLegendBack;
    TPanel *PnlLegend;
    TPanel *PnlLegendSet;
    TCheckListBox *LstLegend;
    TcxButton *BtnChkAll;
    TcxButton *BtnReverse;
    TcxButton *BtnProperty;
    TcxButton *BtnApply;
    TPanel *PnlGraphBack;
    TPanel *PnlGraphTop;
    TcxLabel *cxLabel1;
    TcxCheckBox *Chk3D;
    TDBChart *DbChart;
    TBarSeries *Series1;
    TcxCheckBox *ChkDispValue;
    TcxSplitter *Splitter;
    TcxImageComboBox *CbChartKind;
    TcxLabel *LblForm;
    TImageList *ImgChartSmall;
    TImage *ImgDesc01;
    TcxLabel *cxLabel2;
    TcxLabel *lblEA;
    TcxLabel *lblSel;
    TcxLabel *lblSoge;
    TPanel *PnlOption;
    TImage *ImgDesc02;
    TcxLabel *LblOptionName;
    TcxComboBox *CbOption;
    void __fastcall FormShow(TObject *Sender);
    void __fastcall BtnChkAllClick(TObject *Sender);
    void __fastcall BtnReverseClick(TObject *Sender);
    void __fastcall BtnPropertyClick(TObject *Sender);
    void __fastcall Chk3DClick(TObject *Sender);
    void __fastcall CbChartKindPropertiesEditValueChanged(TObject *Sender);
    void __fastcall LstLegendClickCheck(TObject *Sender);
    void __fastcall LstLegendDblClick(TObject *Sender);
    void __fastcall LstLegendDrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State);
    void __fastcall BtnApplyClick(TObject *Sender);
    void __fastcall ChkDispValueClick(TObject *Sender);
    void __fastcall DbChartClickSeries(TCustomChart *Sender, TChartSeries *Series, int ValueIndex, TMouseButton Button, TShiftState Shift,
          int X, int Y);
    void __fastcall DbChartMouseMove(TObject *Sender, TShiftState Shift, int X, int Y);
    void __fastcall FormClose(TObject *Sender, TCloseAction &Action);

private:	// User declarations
    void __fastcall FormInit();
    void __fastcall CommClose();

public:
    SeriesType __fastcall GetSeriesType(int nIdx);
    TColor __fastcall GetSeriesColor(int nIdx);
    void __fastcall DrawSeriesType(SeriesType SrsType, TCanvas* pCvs, TRect Rct);
    bool __fastcall SetActive(int nIdx);
    double __fastcall GetActiveMaxY(void);
    void __fastcall ChangeSeriesItem(int nIdx, SeriesType ToSrsType);
    void __fastcall ChangeSeries(TDBChart *pDBChart, SeriesType nSeriesTp, int nSeriesCount);

    void __fastcall ShowBarChart();

public:
    String  m_sCaption;
    String  m_sTitle;
    String  m_sType;
    String  m_sTerm;

    void __fastcall SetInfo(String sCaption, String sTitle, String sType, String sTerm)
    {
        m_sCaption = sCaption; m_sTitle = sTitle; m_sType = sType; m_sTerm = sTerm;
    }
    void __fastcall LoadLocalSkin();

    void __fastcall Clear();
    void __fastcall ClearData();
    void __fastcall ClearChart();
    void __fastcall SetChartInfo(String sTitle, String sAxisX, String sAxisY);
    void __fastcall BeginDraw(String sTitle, String sAxisX, String sAxisY);
    void __fastcall DrawChart1(TcxGridDBTableView *TvList, int nAxisY, int nStColIdx, int nTotColIdx=-1);
    void __fastcall DrawChart2(TcxGridDBBandedTableView *TvList, int nAxisY, int nStColIdx,
                               int nTotColIdx=-1, bool bBarSeries=true, bool bBandText=true, int nEdColIdx=-1);
    void __fastcall DrawChart3(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nStColIdx, int nTotColIdx=-1);
    void __fastcall DrawChart4(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nStColIdx, int nTotColIdx=-1);
    void __fastcall DrawChart5(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nAxisY3, int nStColIdx, int nEdColIdx=-1,int nTotColIdx=-1);
    void __fastcall DrawChart5_1(TcxGridTableView *TvList, int nAxisY1, int nAxisY2, int nStColIdx, int nEdColIdx=-1,int nTotColIdx=-1);
    void __fastcall DrawChart6(TcxGridDBTableView *TvList, int nAxisY1, int nAxisY2, int nAxisY3, int nStColIdx, int nEdColIdx=-1,int nTotColIdx=-1);

    void __fastcall EndDraw();
    SeriesType __fastcall GetChartType();

    TChartSeries* __fastcall AddSeriesItem(String     sTitle,
                                           SeriesType SrsType,
                                           TColor     clSrsColor,
                                           bool       bActive=true);
    TChartSeries* __fastcall MakeChartSeries(SeriesType nSeriesTp);


public:		// User declarations
    __fastcall TPlugInChart(TComponent* Owner);
};
//---------------------------------------------------------------------------
//extern PACKAGE TPlugInChart *PlugInChart;
//---------------------------------------------------------------------------
#endif
