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

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

//---------------------------------------------------------------------------
#include "DataTypesF.h"
#include "CDSCodeF.h"
#include "WindowMsgF.h"
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <Menus.hpp>
#include <OleCtrls.hpp>
#include <SHDocVw.hpp>
#include "GMClasses.hpp"
#include "GMMap.hpp"
#include "GMMapVCL.hpp"
#include <Dialogs.hpp>
#include <ImgList.hpp>
#include "GMLinkedComponents.hpp"
#include "GMMarker.hpp"
#include "GMMarkerVCL.hpp"
#include "cxCheckBox.hpp"
#include <GIFImg.hpp>
#include "cxButtons.hpp"
#include "cxContainer.hpp"
#include "cxControls.hpp"
#include "cxEdit.hpp"
#include "cxGraphics.hpp"
#include "cxLabel.hpp"
#include "cxLookAndFeelPainters.hpp"
#include "cxLookAndFeels.hpp"
#include "dxSkinBlack.hpp"
#include "dxSkinBlue.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 "dxSkinsCore.hpp"
#include "dxSkinSeven.hpp"
#include "dxSkinSharp.hpp"
#include "dxSkinSilver.hpp"
#include "dxSkinStardust.hpp"
//---------------------------------------------------------------------------
/*
*  이전/다음 구현을 위한 구조체 선언
*  정적 이중링크로 구현
*/
#define             D_EXT_QUEUE_SIZE        256 //512//1024/2048
#define             D_EXT_QUEUE_MASK        (D_EXT_QUEUE_SIZE-1)

/*
*  레이어 Extent 정보
*/
typedef struct
{
    short   Zoom;
    double  Lat;
    double  Lng;
} TMapExtent;

typedef struct
{
    bool        Extent;
    short       TotCnt;
    short       CurIdx;
    TMapExtent  extent[D_EXT_QUEUE_SIZE+1];
} EXTENT_QUEUE;

//---------------------------------------------------------------------------
class TObjGMMap : public TCustomGMMap
{
public:
    void __fastcall SettingZoom(int Zoom) { SetZoom(Zoom); };
};

//---------------------------------------------------------------------------
class TFRAMEGoogleMap : public TFrame
{
__published:	// IDE-managed Components
    TPanel *PnlToolbar;
    TcxButton *BtnMapToJpg;
    TcxButton *BtnMoveMapToCenter;
    TcxButton *BtnZoomIn;
    TcxButton *BtnZoomOut;
    TcxButton *BtnEraseEvent;
    TEdit *EdFocus;
    TcxButton *BtnMoveDefBounds;
    TcxButton *BtnZoomPrev;
    TcxButton *BtnZoomNext;
    TcxButton *BtnIconSelect;
    TcxLabel *cxLabel26;
    TcxLabel *cxLabel27;
    TSaveDialog *SaveDialog1;
    TcxImageList *ilToolbarsSmall;
    TWebBrowser *WebBrowser1;
    TGMMap *GMMap1;
    TPanel *PnlGisTool;
    TcxLabel *cxLabel1;
    TcxCheckBox *ChkDrawCtv;
    TcxCheckBox *ChkDrawVds;
    TcxCheckBox *ChkDrawVms;
    TPanel *PnlLoading;
    TImage *ImgLoading;
    TcxCheckBox *ChkDrawTraffic;
    TcxCheckBox *ChkDrawRegion;
    TcxCheckBox *ChkDrawIncident;
    TcxLabel *cxLabel2;
    TcxLabel *LblZoom;
    TcxLabel *lblTitle;
    void __fastcall BtnMapToJpgClick(TObject *Sender);
    void __fastcall BtnMoveMapToCenterClick(TObject *Sender);
    void __fastcall WebBrowser1DownloadComplete(TObject *Sender);
    void __fastcall GMMap1AfterPageLoaded(TObject *Sender, bool First);
    void __fastcall GMMap1BoundsChanged(TObject *Sender, TLatLngBounds *NewBounds);
    void __fastcall GMMap1ZoomChanged(TObject *Sender, int NewZoom);
    void __fastcall GMMap1DragEnd(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 GMMap1CenterChanged(TObject *Sender, TLatLng *LatLng, double X,
          double Y);



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

    int             FLinkLevel;
    EXTENT_QUEUE    FExtent;    // 이전/다음 정보를 저장할 전역변수
    TMapExtent      FPrev;      // 이전
    String             FTitle;

public:
    TLatLng        *FCenLatLng;

    TMapTypeId      FMapTypeId;
    TLatLngBounds  *FMapBounds;
    int             FMapZoom;
    int             FBaseZoom;
    double          FCenterLat;
    double          FCenterLng;
    TNotifyEvent    FOnDrawFacilityClick;
    TNotifyEvent    FOnZoomChangeClick;

    double          FLat, FLng;

public:
    void __fastcall LoadLocalSkin();
    void __fastcall LoadGisMap();
    void __fastcall ShowHideTrafficLayer(bool AShow);
    void __fastcall SelectObjectByPos(double dPosX, double dPosY, bool bArrow=false);
    void __fastcall SelectObjectByPos();
    bool __fastcall SelectLinkByPos(int X, int Y, String &ALinkId);
    bool __fastcall GetLevelLinkId(int ALinkLevel, String &sLinkId, int X, int Y);
    int  __fastcall GetLayerIndex();
    void __fastcall SelGisItem(int AType, String AId);

	void __fastcall OnCloseQuery(bool &CanClose);

    bool __fastcall AddExtentQ(double ALat, double ALng, int FZoom);
    bool __fastcall PrevExtentQ();
    bool __fastcall NextExtentQ();

    void __fastcall RemoveMarker(TGMMarker *AMarker);

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

    __property int  LinkLevel = {read = FLinkLevel, write=SetLinkLevel };
};
//---------------------------------------------------------------------------
extern PACKAGE TFRAMEGoogleMap *FRAMEGoogleMap;
//---------------------------------------------------------------------------
#endif
