//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ComCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <ExtDlgs.hpp>
#include <Menus.hpp>
#include <DXFConv.hpp>
#include <sgTools.hpp>
#include <sgDrawingNavigator.hpp>

#include "CSPIN.h"
#include <Graphics.hpp>
#include <ActnList.hpp>
#include "cspin.h"
#ifndef sgDXFONLY
#include <DWG.hpp>
#include <HPGL2.hpp>
#include <CGM.hpp>
#include <SVG.hpp>
#endif
#include <Graphics.hpp>

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

class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TPanel *Panel2;
        TPanel *Panel1;
        TPanel *Panel3;
        TPageControl *PageControl1;
  TTabSheet *tbsImage;
  TTabSheet *tbsStructure;
        TSplitter *Splitter1;
        TTreeView *TreeView1;
        TListBox *ListBox1;
        TPanel *Panel4;
        TSpeedButton *BtnOpen;
        TSpeedButton *BtnPlus;
        TSpeedButton *BtnMinus;
        TSpeedButton *BtnReal;
        TSpeedButton *BtnPrev;
        TSpeedButton *BtnPrint;
        TSpeedButton *BtnSave;
        TMainMenu *MainMenu1;
        TMenuItem *MIFile;
        TMenuItem *MIOpen;
        TMenuItem *miSaveAs;
        TMenuItem *MIPrint;
        TMenuItem *MIClose;
        TMenuItem *N4;
        TMenuItem *MIExit;
        TMenuItem *MIView;
        TMenuItem *MiOEM;
        TMenuItem *MIScale;
        TMenuItem *MIAuto;
        TMenuItem *MIPrev;
        TMenuItem *N1;
  TMenuItem *mmix10;
  TMenuItem *mmix25;
  TMenuItem *mmix50;
  TMenuItem *mmix100;
  TMenuItem *mmix200;
  TMenuItem *mmix400;
  TMenuItem *mmix800;
        TMenuItem *ImageColors1;
  TMenuItem *mmiDisabled;
  TMenuItem *mmiBlack;
  TMenuItem *mmiNormal;
        TMenuItem *N2;
        TMenuItem *MIAbout;
        TMenuItem *SoftGoldHomePage1;
        TPrintDialog *PrintDialog1;
        TOpenPictureDialog *OpenDialog1;
        TSavePictureDialog *SavePictureDialog;
        TSpeedButton *btnLayers;
        TSpeedButton *btnIsWithoutBorder;
        TSpeedButton *btnDrawAllColor;
        TSpeedButton *btnBlackWhite;
        TSpeedButton *btnWhiteBackground;
        TSpeedButton *btnBlackBackground;
        TSpeedButton *btnShowLineWeight;
        TSpeedButton *btnHideLineWeight;
        TSpeedButton *btnSplittedArc;
        TSpeedButton *btnArcNormal;
        TSpeedButton *btnFitToScreen;
        TPanel *pnlLayouts;
        TLabel *lblLayouts;
        TComboBox *cbLayouts;
        TLabel *lblNumPartsCircle;
        TLabel *lblNumPartsSpline;
        TSpeedButton *sb3DOrbit;
        TSpeedButton *sb3DAxes;
        TCSpinEdit *speNumPartsCircle;
        TCSpinEdit *speNumPartsSpline;
        TSpeedButton *sbShowBorder;
  TSpeedButton *sbShowSHXFonts;
  TSpeedButton *sbDrid;
  TLabel *lblDridCount;
  TCSpinEdit *speGridCount;
  TPopupMenu *pmPrint;
  TMenuItem *pmiPrinrer;
  TMenuItem *pmiMetafile;
  TSpeedButton *BtnPrint2;
  TMenuItem *mmiFindText;
  TPanel *pnlCoords;
  TProgressBar *ProgressBar1;
  TMenuItem *mmiShowPoint;
  TPanel *pnlSize;
        TMenuItem *Snap1;
  TMenuItem *mmiObjectSnapAll;
  TImage *imgFrame;
  TActionList *alMain;
  TAction *actMain;
  TSavePictureDialog *SavePictureDialogEMF;
  TMenuItem *mmiSaveAsBigEMF;
        void __fastcall MIAutoClick(TObject *Sender);
        void __fastcall sgPaintBoxScaling(TObject *Sender);
        void __fastcall MiOEMClick(TObject *Sender);
        void __fastcall SoftGoldHomePage1Click(TObject *Sender);
        void __fastcall MIAboutClick(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall MICloseClick(TObject *Sender);
        void __fastcall MIOpenClick(TObject *Sender);
        void __fastcall miSaveAsClick(TObject *Sender);
        void __fastcall MIPrintClick(TObject *Sender);
        void __fastcall MIExitClick(TObject *Sender);
        void __fastcall MIPrevClick(TObject *Sender);
        void __fastcall mmiScaleClick(TObject *Sender);
        void __fastcall mmiDisabledClick(TObject *Sender);
        void __fastcall mmiBlackClick(TObject *Sender);
        void __fastcall mmiNormalClick(TObject *Sender);
        void __fastcall TreeView1Change(TObject *Sender, TTreeNode *Node);
        void __fastcall FormKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall BtnPlusClick(TObject *Sender);
        void __fastcall BtnMinusClick(TObject *Sender);
        void __fastcall sgPaintBoxProgress(TObject *Sender,
          TProgressStage Stage, BYTE PercentDone, bool RedrawNow,
          const TRect &R, const AnsiString Msg);
        void __fastcall PageControl1Changing(TObject *Sender,
          bool &AllowChange);
        void __fastcall btnLayersClick(TObject *Sender);
        void __fastcall sgPaintBoxPaint(TObject *Sender);
        void __fastcall btnIsWithoutBorderClick(TObject *Sender);
        void __fastcall btnFitToScreenClick(TObject *Sender);
        void __fastcall btnDrawAllColorClick(TObject *Sender);
        void __fastcall btnWhiteBackgroundClick(TObject *Sender);
        void __fastcall btnShowLineWeightClick(TObject *Sender);
        void __fastcall btnSplittedArcClick(TObject *Sender);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall sb3DOrbitClick(TObject *Sender);
        void __fastcall cbLayoutsChange(TObject *Sender);
        void __fastcall sb3DAxesClick(TObject *Sender);
        void __fastcall speNumPartsCircleChange(TObject *Sender);
        void __fastcall speNumPartsSplineChange(TObject *Sender);
        void __fastcall sbShowBorderClick(TObject *Sender);
  void __fastcall sbShowSHXFontsClick(TObject *Sender);
  void __fastcall sbDridClick(TObject *Sender);
  void __fastcall speGridCountChange(TObject *Sender);
  void __fastcall BtnPrint2Click(TObject *Sender);
  void __fastcall pmiPrinrerClick(TObject *Sender);
  void __fastcall pmiMetafileClick(TObject *Sender);
  void __fastcall mmiFindTextClick(TObject *Sender);
  bool __fastcall FindText(AnsiString S, int ASelection, bool ASearch);
  void __fastcall sgPaintBoxMouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
  void __fastcall mmiShowPointClick(TObject *Sender);
        void __fastcall mmiObjectSnapAllClick(TObject *Sender);
  void __fastcall FormShow(TObject *Sender);
  void __fastcall actMainUpdate(TObject *Sender);
  void __fastcall BtnRealClick(TObject *Sender);
  void __fastcall tbsStructureShow(TObject *Sender);
  void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
  void __fastcall mmiSaveAsBigEMFClick(TObject *Sender);
private:
    TIniFile *FOptions;
    TList *FIntPoints;
    AnsiString FSearchingText;
    TList *FSelectedEntities;
    TsgCADIterate FCADParams;
    TFRect FTextBox;
    TFPoint FTextPoint;
    TsgDXFImage *FImg;
    TSGDrawingNavigator *FsgPaintBox;
    bool FSearchModeIsAll;
    bool FFindFlag;
    bool FSearchResult;
    int FSelectionMode;

    void LoadStructure(void);
    void Time(void);
    void EnableScales(void);
    void Open(AnsiString FileName);
    void AddTree(TTreeNode * Parent, TsgDXFEntity *E);
    void Scroll(TShiftState Shift, bool Both, WORD Msg, WORD Code1, WORD Code2);
    void SetImgOpt(void);
    void ViewLayouts();
    void Enable3DAxes(bool AIsEnabled);
    void Enable3DOrbit(bool AIsEnabled);
    void LoadOptions(void);
    bool CreateLines(int D, int AWidth, int AHeight);
    void DrawPolyPolyLine(HDC DC);
    void ActualGraphic(TMetafile *vResult);
    TsgDXFEntity * AddRectToConv(TFRect ABox);
    void SelectEntities(void);
    void SetPnlSizeCaption();
    int __fastcall ReadCADEntities(TsgDXFEntity *Entity);
    TsgDXFImage * __fastcall GetImg();
    void __fastcall SaveToDXF(AnsiString AFileName);
public:		// User declarations
    __fastcall TForm1(TComponent* Owner);
    __property TSGDrawingNavigator* sgPaintBox = {read=FsgPaintBox};
};

//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
