//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "RichView.hpp"
#include "RVEdit.hpp"
#include "RVScroll.hpp"
#include "RVStyle.hpp"
#include <Buttons.hpp>
#include <ComCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <Graphics.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TPanel *Panel1;
	TSpeedButton *btnBold;
	TSpeedButton *btnItalic;
	TSpeedButton *btnUnderline;
	TSpeedButton *btnFont;
	TSpeedButton *btnLeft;
	TSpeedButton *btnCenter;
	TSpeedButton *btnRight;
	TSpeedButton *btnJustify;
	TSpeedButton *btnOpen;
	TSpeedButton *btnSave;
	TSpeedButton *btnSaveAs;
	TSpeedButton *btnNew;
	TLabel *Label2;
	TLabel *Label3;
	TSpeedButton *btnIdentInc;
	TSpeedButton *btnIdentDec;
	TSpeedButton *btnFontColor;
	TSpeedButton *btnFontBackColor;
	TSpeedButton *btnParaBackColor;
	TComboBox *cmbFont;
	TComboBox *cmbFontSize;
	TStatusBar *StatusBar1;
	TRichViewEdit *rve;
	TRVStyle *rvs;
	TMainMenu *MainMenu1;
	TMenuItem *File1;
	TMenuItem *mitNew;
	TMenuItem *mitOpen;
	TMenuItem *mitSave;
	TMenuItem *mitSaveAs;
	TMenuItem *N1;
	TMenuItem *mitExit;
	TMenuItem *Edit1;
	TMenuItem *mitUndo;
	TMenuItem *mitRedo;
	TMenuItem *N2;
	TMenuItem *mitCut;
	TMenuItem *mitCopy;
	TMenuItem *mitPaste;
	TMenuItem *mitDelete;
	TOpenDialog *od;
	TSaveDialog *sd;
	TFontDialog *fd;
	TColorDialog *cd;
    void __fastcall FormCreate(TObject *Sender);
    void __fastcall mitNewClick(TObject *Sender);
    void __fastcall mitOpenClick(TObject *Sender);
    void __fastcall mitSaveClick(TObject *Sender);
    void __fastcall mitSaveAsClick(TObject *Sender);
    void __fastcall mitExitClick(TObject *Sender);
    void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
    void __fastcall mitUndoClick(TObject *Sender);
    void __fastcall mitRedoClick(TObject *Sender);
    void __fastcall mitCutClick(TObject *Sender);
    void __fastcall mitCopyClick(TObject *Sender);
    void __fastcall mitPasteClick(TObject *Sender);
    void __fastcall mitDeleteClick(TObject *Sender);
    void __fastcall mitFontClick(TObject *Sender);
    void __fastcall rveChange(TObject *Sender);
    void __fastcall rveCurTextStyleChanged(TObject *Sender);
    void __fastcall rveCurParaStyleChanged(TObject *Sender);
    void __fastcall cmbFontClick(TObject *Sender);
    void __fastcall cmbFontSizeClick(TObject *Sender);
    void __fastcall rveStyleConversion(TCustomRichViewEdit *Sender,
          int StyleNo, int UserData, bool AppliedToText, int &NewStyleNo);
    void __fastcall btnApplyPara(TObject *Sender);
    void __fastcall cmbFontSizeKeyPress(TObject *Sender, char &Key);
    void __fastcall cmbFontSizeExit(TObject *Sender);
	void __fastcall FontStyleButtonClick(TObject *Sender);
	void __fastcall btnFontColorClick(TObject *Sender);
	void __fastcall btnFontBackColorClick(TObject *Sender);
	void __fastcall btnParaBackColorClick(TObject *Sender);
	void __fastcall rveParaStyleConversion(TCustomRichViewEdit *Sender,
	int StyleNo, int UserData, bool AppliedToText, int &NewStyleNo);
	void __fastcall btnIdentDecClick(TObject *Sender);
	void __fastcall btnIdentIncClick(TObject *Sender);
private:	// User declarations
    AnsiString FileName, FontName;
    bool IgnoreChanges;
    int FontSize;
    bool SaveIfNeeded();
    bool Save();
    bool SaveAs();
    void Open();
    void New();
	TRVAlignment GetAlignmentFromUI();
    void SetAlignmentToUI(TRVAlignment Alignment);
public:		// User declarations
    __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
