1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
{
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Mattias Gaertner
Abstract:
Dialog for the TStrings property editor.
}
unit StringsPropEditDlg;
{$mode objfpc}{$H+}
interface
uses
SysUtils,
// LCL
Forms, Controls, StdCtrls, ButtonPanel, Dialogs,
// LazUtils
LazUTF8,
// IdeIntf
TextTools, ObjInspStrConsts, IDEWindowIntf, Classes;
type
{ TStringsPropEditorFrm }
TStringsPropEditorFrm = class(TForm)
BtnPanel: TButtonPanel;
ClearButton: TButton;
SaveButton: TButton;
SaveDialog1: TSaveDialog;
StatusLabel: TLabel;
SortButton: TButton;
TextGroupBox: TGroupBox;
Memo: TMemo;
procedure ClearButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure MemoChange(Sender: TObject);
procedure SaveButtonClick(Sender: TObject);
procedure SortButtonClick(Sender: TObject);
public
procedure AddButtons; virtual;
end;
implementation
{$R *.lfm}
{ TStringsPropEditorFrm }
procedure TStringsPropEditorFrm.FormCreate(Sender: TObject);
begin
Caption := oisStringsEditorDialog;
StatusLabel.Caption := ois0Lines0Chars;
SortButton.Caption := oisSort;
ClearButton.Caption := oisClear;
SaveButton.Caption := oisSave;
AddButtons;
IDEDialogLayoutList.ApplyLayout(Self);
end;
procedure TStringsPropEditorFrm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TStringsPropEditorFrm.ClearButtonClick(Sender: TObject);
begin
Memo.Clear;
end;
procedure TStringsPropEditorFrm.MemoChange(Sender: TObject);
var
NumChars: Integer;
I: Integer;
begin
NumChars := 0;
for I := 0 to Memo.Lines.Count - 1 do
Inc(NumChars, Utf8Length(Memo.Lines[I]));
if Memo.Lines.Count = 1 then
StatusLabel.Caption := Format(ois1LineDChars, [NumChars])
else
StatusLabel.Caption := Format(oisDLinesDChars, [Memo.Lines.Count, NumChars]);
end;
procedure TStringsPropEditorFrm.SaveButtonClick(Sender: TObject);
begin
SaveDialog1.Title:=sccsSGEdtSaveDialog;
if SaveDialog1.Execute then
Memo.Lines.SaveToFile(SaveDialog1.FileName);
end;
procedure TStringsPropEditorFrm.SortButtonClick(Sender: TObject);
var
OldText, NewSortedText: String;
SortOnlySelection: Boolean;
begin
if not Assigned(ShowSortSelectionDialogFunc) then
begin
SortButton.Enabled := False;
Exit;
end;
SortOnlySelection := True;
OldText := Memo.SelText;
if OldText = '' then
begin
SortOnlySelection := False;
OldText := Memo.Lines.Text;
end;
NewSortedText:='';
if ShowSortSelectionDialogFunc(OldText, nil, NewSortedText) <> mrOk then Exit;
if SortOnlySelection then
Memo.SelText := NewSortedText
else
Memo.Lines.Text := NewSortedText;
end;
procedure TStringsPropEditorFrm.AddButtons;
begin
//
end;
end.
|