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

#ifndef FRAME_OpenMapFH
#define FRAME_OpenMapFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
#include <SHDocVw.hpp>

//---------------------------------------------------------------------------
#include "cxButtons.hpp"
#include "cxCheckBox.hpp"
#include "cxContainer.hpp"
#include "cxControls.hpp"
#include "cxEdit.hpp"
#include "cxGraphics.hpp"
#include "cxLabel.hpp"
#include "cxLookAndFeelPainters.hpp"
#include "cxLookAndFeels.hpp"
#include "cxTextEdit.hpp"
#include "dxSkinBlue.hpp"
#include "dxSkinsCore.hpp"
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <ImgList.hpp>
#include <Menus.hpp>
#include <OleCtrls.hpp>
#include "dxSkinBlack.hpp"
#include "dxSkinCaramel.hpp"
#include "dxSkinCoffee.hpp"
#include "dxSkinDarkRoom.hpp"
#include "dxSkinDarkSide.hpp"
#include "dxSkinFoggy.hpp"
#include "dxSkinGlassOceans.hpp"
#include "dxSkiniMaginary.hpp"
#include "dxSkinLilian.hpp"
#include "dxSkinLiquidSky.hpp"
#include "dxSkinLondonLiquidSky.hpp"
#include "dxSkinMcSkin.hpp"
#include "dxSkinMoneyTwins.hpp"
#include "dxSkinOffice2007Black.hpp"
#include "dxSkinOffice2007Blue.hpp"
#include "dxSkinOffice2007Green.hpp"
#include "dxSkinOffice2007Pink.hpp"
#include "dxSkinOffice2007Silver.hpp"
#include "dxSkinOffice2010Black.hpp"
#include "dxSkinOffice2010Blue.hpp"
#include "dxSkinOffice2010Silver.hpp"
#include "dxSkinSeven.hpp"
#include "dxSkinSharp.hpp"
#include "dxSkinSilver.hpp"
#include "dxSkinStardust.hpp"

//---------------------------------------------------------------------------
#include "UJSExec.hpp"

typedef void (*CALLBACK_MAP)(TObject *ASender, const String AFunc, const String AArgs, const bool AFirst);

//---------------------------------------------------------------------------
class TFRAMEOpenMap : public TFrame
{
__published:	// IDE-managed Components
    TPanel *PnlToolbar;
    TcxButton *BtnMapToJpg;
    TcxButton *BtnZoomIn;
    TcxButton *BtnZoomOut;
    TcxButton *BtnRefresh;
    TEdit *EdFocus;
    TcxButton *BtnMoveDefBounds;
    TcxButton *BtnZoomPrev;
    TcxButton *BtnZoomNext;
    TcxButton *BtnMapClick;
    TcxLabel *cxLabel26;
    TcxLabel *cxLabel27;
    TSaveDialog *SaveDialog1;
    TcxImageList *ilToolbarsSmall;
    TPanel *PnlGisTool;
    TcxLabel *cxLabel1;
    TPanel *PnlLoading;
    TImage *ImgLoading;
    TcxLabel *lblTitle;
    TMemo *reMsg;
    TcxLabel *LblZoom;
    TTimer *TmrMapOpen;
    TcxButton *BtnMoveMapToFit;
    TcxCheckBox *ChkShowNmbr;
    TcxTextEdit *EdMapPos;
    TcxButton *BtnMapSelect;
    TImage *Image1;
    TPanel *PnlMap;
    TWebBrowser *WebBrowser1;
    void __fastcall BtnMapToJpgClick(TObject *Sender);
    void __fastcall WebBrowser1DownloadComplete(TObject *Sender);
    void __fastcall BtnZoomInClick(TObject *Sender);
    void __fastcall BtnZoomOutClick(TObject *Sender);
    void __fastcall BtnZoomPrevClick(TObject *Sender);
    void __fastcall BtnZoomNextClick(TObject *Sender);
    void __fastcall BtnMoveDefBoundsClick(TObject *Sender);
    void __fastcall WebBrowser1BeforeNavigate2(TObject *ASender, const IDispatch *pDisp, OleVariant &URL, OleVariant &Flags,
          OleVariant &TargetFrameName, OleVariant &PostData, OleVariant &Headers, WordBool &Cancel);
    void __fastcall LblZoomDblClick(TObject *Sender);
    void __fastcall BtnRefreshClick(TObject *Sender);
    void __fastcall TmrMapOpenTimer(TObject *Sender);
    void __fastcall reMsgDblClick(TObject *Sender);
    void __fastcall BtnMapClickClick(TObject *Sender);
    void __fastcall BtnMoveMapToFitClick(TObject *Sender);
    void __fastcall ChkShowNmbrClick(TObject *Sender);
    void __fastcall PnlGisToolDblClick(TObject *Sender);
    void __fastcall BtnMapSelectClick(TObject *Sender);



private:	// User declarations
    void __fastcall SetLinkLevel(int ALinkLevel);

    String          FHtmlFileName;
    TJSExec        *fJSExec;

    bool            FMapStart;
    int             FMapZoom;
    double          FCenterX;
    double          FCenterY;
    int             FLayerIdx;

    String          FTitle;

public:
    CALLBACK_MAP    MapCallbackFunc;

public:
	void __fastcall OnCloseQuery(bool &CanClose);
    void __fastcall LoadLocalSkin();

    void __fastcall OpenMap();
    void __fastcall LoadMap();

    void WriteLog(char *AFmt, ...);
    bool __fastcall ExecScript(String AScript);

    void __fastcall SelectObjectByPos(double dPosX, double dPosY, bool bArrow=false);
    bool __fastcall SelectLinkByPos(int X, int Y, String &ALinkId);
    bool __fastcall GetLevelLinkId(int ALinkLevel, String &sLinkId, int X, int Y);
    void __fastcall SelGisItem(int AType, String AId);


public:		// User declarations
    __fastcall TFRAMEOpenMap(TComponent* Owner);

    __property int    LayerIdx = { read = FLayerIdx, write=FLayerIdx };
    __property bool   MapStart = { read = FMapStart };
    __property int    MapZoom  = { read = FMapZoom };
    __property double CenterX  = { read = FCenterX };
    __property double CenterY  = { read = FCenterY };
};
//---------------------------------------------------------------------------
//extern PACKAGE TFRAMEOpenMap *FRAMEOpenMap;
//---------------------------------------------------------------------------
#endif
