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

#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
// only if you have installed EControl Localizer
// #define USE_LOCALIZER
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "ecActns.hpp"
#include "ecAutoReplace.hpp"
#include "ecKeyMap.hpp"
#include "ecPopupCtrl.hpp"
#include "ecPrint.hpp"
#include "ecPropManager.hpp"
#include "ecSpell.hpp"
#include "ecStylesCombo.hpp"
#include "ecSyntAnal.hpp"
#include "ecSyntDlg.hpp"
#include "ecSyntMemo.hpp"
#include "ecSyntTree.hpp"
#include <ActnList.hpp>
#include <ComCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <ImgList.hpp>
#include <Menus.hpp>
#include <StdActns.hpp>
#include <ToolWin.hpp>
#include "EditFrm.h"

#ifdef USE_LOCALIZER
#include "ecLocalizer.hpp"
#endif
//---------------------------------------------------------------------------
class TSyntEditMain : public TForm
{
__published:	// IDE-managed Components
    TActionList *ActionList1;
    TStatusBar *SB;
    TSyntFindDialog *SyntFindDialog1;
    TAction *actOpen;
    TAction *actSave;
    TOpenDialog *OD;
    TSaveDialog *SD;
    TSyntReplaceDialog *SyntReplaceDialog1;
    TMainMenu *MainMenu1;
    TAction *actSaveAs;
    TMenuItem *File1;
    TMenuItem *Edit1;
    TMenuItem *New1;
    TMenuItem *Open1;
    TMenuItem *Save1;
    TMenuItem *Saveas1;
    TMenuItem *N1;
    TMenuItem *Exit1;
    TMenuItem *Copy1;
    TMenuItem *Cut1;
    TMenuItem *Paste1;
    TMenuItem *Delete1;
    TMenuItem *N3;
    TMenuItem *Undo1;
    TMenuItem *Redo1;
    TMenuItem *Findnext1;
    TMenuItem *Replace1;
    TMenuItem *Options1;
    TMenuItem *actCustomize1;
    TMenuItem *N4;
    TMenuItem *SelectAll1;
    TMenuItem *EditorProperties1;
    TMenuItem *About1;
    TMenuItem *SyntaxHighlignting2;
    TMenuItem *LexerLibrary1;
    TMenuItem *SelLexMenu;
    TMenuItem *View1;
    TMenuItem *FullExpand1;
    TMenuItem *FullCollapse1;
    TSyntaxManager *SyntaxManager1;
    TMenuItem *Print1;
    TMenuItem *N9;
    TMenuItem *PrintSetup1;
    TMenuItem *actShowNonPrinted1;
    TMenuItem *N10;
    TMenuItem *ExportRTF1;
    TMenuItem *CopyasRTF1;
    TPrinterSetupDialog *PrinterSetupDialog1;
    TSplitter *Splitter1;
    TMenuItem *ExportHTML1;
    TImageList *ImageList1;
    TSyntKeyMapping *SyntKeyMapping1;
    TMenuItem *KeyMapping1;
    TMenuItem *Action11;
    TMenuItem *N12;
    TMenuItem *SynchronizeTree1;
    TecCommandAction *ecCommandRedo;
    TecCommandAction *ecCommandAction1;
    TecCommandAction *ecCommandAction2;
    TecFullCollapse *ecFullCollapse1;
    TecFullExpand *ecFullExpand1;
    TecCopyAsRTF *ecCopyAsRTF1;
    TMenuItem *Reopen1;
    TMenuItem *N8;
    TecCommandAction *ecCommandAction3;
    TMenuItem *CollapseSelection1;
    THelpContents *HelpContents1;
    TMenuItem *Contents1;
    TMenuItem *N5;
    TecSearch *ecSearch1;
    TecSearchAgain *ecSearchAgain1;
    TecReplace *ecReplace1;
    TSyntStyles *SyntStyles1;
    TMenuItem *Userstyles1;
    TecUserRangeDelete *ecUserRangeDelete1;
    TecUserRangeCollapsable *ecUserRangeCollapsable1;
    TecUserRangeTopLine *ecUserRangeTopLine1;
    TecUserRangeBottomLine *ecUserRangeBottomLine1;
    TecUserRangeLineHighlight *ecUserRangeLineHighlight1;
    TTemplatePopup *TemplatePopup1;
    TMenuItem *Wordwrap1;
    TecSyntPrinter *ecSyntPrinter1;
    TMenuItem *N11;
    TMenuItem *actPrintPreview1;
    TecPrintAction *ecPrintAction1;
    TecPreviewAction *ecPreviewAction1;
    TecExportRTFAction *ecExportRTFAction1;
    TecExportHTMLAction *ecExportHTMLAction1;
    TecCustomizeEditorOptionsAction *ecCustomizeEditorOptionsAction1;
    TecCustomizeSyntaxHighlightingAction *ecCustomizeSyntaxHighlightingAction1;
    TecCustomizeLexerPropertiesAction *ecCustomizeLexerPropertiesAction1;
    TecCustomizeKeyMappingAction *ecCustomizeKeyMappingAction1;
    TecCustomizeUserStylesAction *ecCustomizeUserStylesAction1;
    TMenuItem *PageSetup1;
    TecToggleNonPrinted *ecToggleNonPrinted1;
    TecToggleWordWrap *ecToggleWordWrap1;
    TPropsManager *PropsManager1;
    TSyntAutoReplace *SyntAutoReplace1;
    TecCustomizeLexerLib *ecCustomizeLexerLib1;
    TecToggleSyntTreeSync *ecToggleSyntTreeSync1;
    TecCustomizeAutoReplace *ecCustomizeAutoReplace1;
    TMenuItem *CustomizeAutoReplace1;
    TPropsManager *PropsManager2;
    TecIncrementalSearch *ecIncrementalSearch1;
    TMenuItem *IncrementalSearch1;
    TecPageSetupAction *ecPageSetupAction1;
    TMenuItem *Language1;
    TecFindCurrentWordNextAction *ecFindCurrentWordNextAction1;
    TecFindCurrentWordPriorAction *ecFindCurrentWordPriorAction1;
    TMenuItem *N14;
    TMenuItem *Search1;
    TMenuItem *FindCurrentWordNext1;
    TMenuItem *FindCurrentWordPrior1;
    TPrinterSetupDialog *PrinterSetupDialog2;
    TAction *PrintSetupAction;
    TAction *FileExitAction;
    TSyntStyles *SharedStyles;
    TMenuItem *Sharedstyles1;
    TMenuItem *N2;
    TMenuItem *EncodingMenu;
    TMenuItem *FormatMenu;
    TMenuItem *ANSI1;
    TMenuItem *Unicode1;
    TMenuItem *SwapedUnicode1;
    TMenuItem *UTF81;
    TMenuItem *Default1;
    TMenuItem *Windows1;
    TMenuItem *Unix1;
    TMenuItem *Macintosh1;
    TSyntaxMemo *TemplateEditor;
    TPageControl *PageControl1;
    TMenuItem *N6;
    TAction *actSaveAll;
    TAction *actClose;
    TAction *actCloseAll;
    TMenuItem *SaveAll1;
    TMenuItem *Close1;
    TMenuItem *CloseAll1;
    TAction *actMDIView;
    TMenuItem *N7;
    TMenuItem *MDIInterface1;
    TControlBar *ControlBar1;
    TToolBar *ToolBar1;
    TToolButton *ToolButton7;
    TToolButton *ToolButton8;
    TToolButton *ToolButton9;
    TToolButton *ToolButton3;
    TToolButton *ToolButton4;
    TToolButton *ToolButton6;
    TToolButton *ToolButton10;
    TToolButton *ToolButton12;
    TToolButton *ToolButton19;
    TToolButton *ToolButton20;
    TToolButton *ToolButton21;
    TToolButton *ToolButton32;
    TToolButton *ToolButton17;
    TToolBar *ToolBar2;
    TToolButton *ToolButton36;
    TToolButton *ToolButton37;
    TToolButton *ToolButton38;
    TToolButton *ToolButton39;
    TToolButton *ToolButton40;
    TToolButton *ToolButton41;
    TToolBar *ToolBar3;
    TToolButton *ToolButton1;
    TToolButton *ToolButton2;
    TToolButton *ToolButton5;
    TToolButton *ToolButton18;
    TUserStylesCombo *UserStylesCombo1;
    TToolButton *ToolButton33;
    TToolButton *ToolButton42;
    TToolBar *ToolBar4;
    TToolButton *ToolButton24;
    TToolButton *ToolButton25;
    TToolButton *ToolButton26;
    TToolButton *ToolButton22;
    TToolButton *ToolButton23;
    TToolButton *ToolButton27;
    TToolButton *ToolButton11;
    TToolButton *ToolButton14;
    TPopupMenu *ToolbarPopup;
    TWindowCascade *WindowCascade1;
    TWindowTileHorizontal *WindowTileHorizontal1;
    TWindowTileVertical *WindowTileVertical1;
    TWindowMinimizeAll *WindowMinimizeAll1;
    TWindowArrange *WindowArrange1;
    TMenuItem *WindowMenu;
    TMenuItem *Cascade1;
    TMenuItem *ileHorizontally1;
    TMenuItem *ileVertically1;
    TMenuItem *MinimizeAll1;
    TMenuItem *Arrange1;
    TToolButton *ToolButton13;
    TToolButton *ToolButton15;
    TToolButton *ToolButton16;
    TPopupMenu *PopupMenu1;
    TMenuItem *Close2;
    TMenuItem *N13;
    TMenuItem *Save2;
    TMenuItem *Saveas2;
    TAction *actSortTree;
    TMenuItem *Sortedtree1;
    TecCopy *ecCopy1;
    TecPaste *ecPaste1;
    TecCut *ecCut1;
    TecClear *ecClear1;
    TecUndo *ecUndo1;
    TecSelectAll *ecSelectAll1;
    TecToggleCollapse *ecToggleCollapse1;
    TMenuItem *oggleCollapse1;
    TecDictionary *ecDictionary1;
    TAction *actDictionaries;
    TMenuItem *Dictionaries1;
    TSyntaxTreeView *SyntaxTreeView1;
    TAction *actShowHyperlinks;
    TMenuItem *Showhyperlinks1;
    TToolButton *ToolButton28;
    TToolButton *ToolButton29;
    TecSyncEditMode *ecSyncEditMode1;
    TImageList *TreeImageList;
    void __fastcall UpdateStatusBar(TObject *Sender);
    void __fastcall actSaveUpdate(TObject *Sender);
    void __fastcall actOpenExecute(TObject *Sender);
    void __fastcall actSaveExecute(TObject *Sender);
    void __fastcall actNewFileExecute(TObject *Sender);
    void __fastcall actSaveAsExecute(TObject *Sender);
    void __fastcall About1Click(TObject *Sender);
    void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
    void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
    void __fastcall SyntaxMemo1IncSearchChange(TObject *Sender,
      TIncSearchState State);
    void __fastcall SyntaxManager1LexerChanged(TObject *Sender);
    void __fastcall LocalizeClick(TObject *Sender);
    void __fastcall ecCustomizeEditorOptionsAction1ExecuteOK(TObject *Sender);
    void __fastcall PrintSetupActionExecute(TObject *Sender);
    void __fastcall FileExitActionExecute(TObject *Sender);
    void __fastcall ecCustomizeLexerPropertiesAction1ExecuteOK(TObject *Sender);
    void __fastcall Sharedstyles1Click(TObject *Sender);
    void __fastcall ActionList1Update(TBasicAction *Action, bool &Handled);
    void __fastcall SetEncoding(TObject *Sender);
    void __fastcall SetFormat(TObject *Sender);
    void __fastcall PageControl1Change(TObject *Sender);
    void __fastcall SplitterMouseDown(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y);
    void __fastcall FormShow(TObject *Sender);
    void __fastcall actSaveAllUpdate(TObject *Sender);
    void __fastcall actCloseUpdate(TObject *Sender);
    void __fastcall actCloseAllUpdate(TObject *Sender);
    void __fastcall actSaveAllExecute(TObject *Sender);
    void __fastcall actCloseExecute(TObject *Sender);
    void __fastcall actCloseAllExecute(TObject *Sender);
    void __fastcall actMDIViewUpdate(TObject *Sender);
    void __fastcall actMDIViewExecute(TObject *Sender);
    void __fastcall ToolbarPopupPopup(TObject *Sender);
    void __fastcall ShowToolbar(TObject *Sender);
    void __fastcall actSortTreeUpdate(TObject *Sender);
    void __fastcall actSortTreeExecute(TObject *Sender);
    void __fastcall actDictionariesExecute(TObject *Sender);
    void __fastcall Splitter1Moved(TObject *Sender);
    void __fastcall actShowHyperlinksUpdate(TObject *Sender);
    void __fastcall actShowHyperlinksExecute(TObject *Sender);
  private:
    bool FReadOnly;
    bool FMDIView;
    bool FHyperlinkHlt;
    TSyntaxMemo *FCurrentEditor;
#ifdef USE_LOCALIZER
    TecLocalizer *FLocalizer;
#endif
    void __fastcall SaveFrame(TEditorFrame *Frame, bool PromtDialog = False);
    void __fastcall LoadLanguages();
    AnsiString __fastcall GetLanguage();
    void __fastcall SetLanguage(AnsiString Value);
    void __fastcall ApplySharedStyles();
    void __fastcall SetCurrentEditor(TSyntaxMemo *Value);
    void __fastcall SetCurrentFrame(TEditorFrame *Value);
    TEditorFrame* __fastcall GetCurrentFrame();
    int __fastcall GetFrameCount();
    TEditorFrame* __fastcall GetFrames(int Index);
    int __fastcall GetModifiedCount();
    TModalResult __fastcall PromtToSave(TEditorFrame *Frame, bool AllowAll);
    void __fastcall SetMDIView(const bool Value);
    void __fastcall ChildCloseQuery(TObject *Sender, bool &CanClose);
    void __fastcall ChildClose(TObject *Sender, TCloseAction &Action);
    void __fastcall TitleChanged(TObject *Sender);
    void __fastcall CloseAll(bool DoPromt);
    void __fastcall SetHyperlinkHlt(const bool Value);
  private:
#ifdef USE_RX_LIB
    TFormPlacement *FormPlacement;
    TMRUManager *MRU;
    void __fastcall MRUClick(TObject *Sender, const AnsiString RecentName, const AnsiString Caption,
      int UserData);
#endif
    void __fastcall FrameChanged();
    void __fastcall FrameClosed(TEditorFrame *Frame);
    void __fastcall RegisterNewEditorFrame(TEditorFrame *Frame);
    void __fastcall CreateBind(TEditorFrame *Frame);
    void __fastcall LoadTreeImages();
  protected:
    void __fastcall WndProc(TMessage &Message);
  public:
    __fastcall TSyntEditMain(TComponent *AOwner);
    TEditorFrame* __fastcall OpenFile(const AnsiString AFileName);
    TEditorFrame* __fastcall CreateFrame(const AnsiString FileName);
    void __fastcall CloseFrame(TEditorFrame *Frame);

    __property TSyntaxMemo *CurrentEditor = {read = FCurrentEditor, write = SetCurrentEditor};
    __property TEditorFrame *CurrentFrame = {read = GetCurrentFrame, write = SetCurrentFrame};
    __property int FrameCount = {read = GetFrameCount};
    __property TEditorFrame* Frames[int Index] = {read = GetFrames};
  __published:
    __property AnsiString Language = {read = GetLanguage, write = SetLanguage};
    __property bool MDIView = {read = FMDIView, write = SetMDIView};
    __property bool HyperlinkHlt = {read = FHyperlinkHlt, write = SetHyperlinkHlt};
};
//---------------------------------------------------------------------------
extern PACKAGE TSyntEditMain *SyntEditMain;
//---------------------------------------------------------------------------
#endif
