{ *************************************************************************** }
{                                                                             }
{ EControl Syntax Editor SDK                                                  }
{                                                                             }
{ Copyright (c) 2004 - 2008 EControl Ltd., Zaharov Michael                    }
{     www.econtrol.ru                                                         }
{     support@econtrol.ru                                                     }
{                                                                             }
{ *************************************************************************** }
{$I ecSyntEdit.INC}

unit ecLocalizerEditText;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ecSyntMemo, ComCtrls, ToolWin, ImgList,
  ecActns, ActnList, ecSyntDlg, ecSyntAnal;

type
  TLocalizerTextEditDlg = class(TForm)
    Panel1: TPanel;
    Button2: TButton;
    Button1: TButton;
    SyntAnalyzer1: TSyntAnalyzer;
    SyntFindDialog1: TSyntFindDialog;
    SyntReplaceDialog1: TSyntReplaceDialog;
    ActionList1: TActionList;
    ecCut1: TecCut;
    ecCopy1: TecCopy;
    ecPaste1: TecPaste;
    ecClear1: TecClear;
    ecUndo1: TecUndo;
    ecRedo1: TecRedo;
    ecToggleWordWrap1: TecToggleWordWrap;
    ecSearch1: TecSearch;
    ecReplace1: TecReplace;
    ecToggleNonPrinted1: TecToggleNonPrinted;
    ImageList1: TImageList;
    ToolBar1: TToolBar;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    ToolButton11: TToolButton;
    ToolButton14: TToolButton;
    ToolButton15: TToolButton;
    ToolButton17: TToolButton;
    ToolButton16: TToolButton;
    ToolButton12: TToolButton;
    SyntaxMemo1: TSyntaxMemo;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function EditTextDlg(var AText: string; ACharset: TFontCharset = DEFAULT_CHARSET; Flags: Cardinal = 0 ): Boolean;

implementation

uses ClipBrd, ecShareEdits;

{$R *.dfm}

function EditTextDlg(var AText: string; ACharset: TFontCharset; Flags: Cardinal): Boolean;
begin
  with TLocalizerTextEditDlg.Create(nil) do
    try
      SyntaxMemo1.Lines.Text := AText;
      SyntaxMemo1.Charset := ACharset;
      SyntaxMemo1.Modified := False;
      Result := ShowModal = mrOk;
      if Result then
        AText := SyntaxMemo1.Lines.Text;
    finally
      Free;
    end;
end;

procedure TLocalizerTextEditDlg.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  if (ModalResult = mrCancel) and SyntaxMemo1.Modified then
    case MessageDlg('Do you want to save changes?', mtConfirmation, mbYesNoCancel, 0) of
      mrYes:    ModalResult := mrOk;
      mrCancel: CanClose := False;
    end;
end;

initialization
  TextEditDlgProc := EditTextDlg;

end.
