PageRenderTime 17ms CodeModel.GetById 14ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 1ms

/ideintf/stringspropeditdlg.pas

http://github.com/graemeg/lazarus
Pascal | 110 lines | 68 code | 20 blank | 22 comment | 6 complexity | e3982ece72c7bc75a4c7cef39832ac78 MD5 | raw file
  1{
  2 *****************************************************************************
  3 *                                                                           *
  4 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,    *
  5 *  for details about the copyright.                                         *
  6 *                                                                           *
  7 *  This program is distributed in the hope that it will be useful,          *
  8 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
  9 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
 10 *                                                                           *
 11 *****************************************************************************
 12
 13  Author: Mattias Gaertner
 14
 15  Abstract:
 16    Dialog for the TStrings property editor.
 17}
 18unit StringsPropEditDlg;
 19
 20{$mode objfpc}{$H+}
 21
 22interface
 23
 24uses
 25  Classes, SysUtils, LResources, Forms, Controls, Buttons, Dialogs, StdCtrls,
 26  TextTools, ObjInspStrConsts, ExtCtrls, ButtonPanel;
 27  
 28type
 29
 30  { TStringsPropEditorFrm }
 31
 32  TStringsPropEditorFrm = class(TForm)
 33    BtnPanel: TButtonPanel;
 34    StatusLabel: TLabel;
 35    SortButton: TButton;
 36    TextGroupBox: TGroupBox;
 37    Memo: TMemo;
 38    procedure FormCreate(Sender: TObject);
 39    procedure MemoChange(Sender: TObject);
 40    procedure SortButtonClick(Sender: TObject);
 41  public
 42    procedure AddButtons; virtual;
 43  end;
 44
 45
 46implementation
 47
 48{ TStringsPropEditorFrm }
 49
 50procedure TStringsPropEditorFrm.FormCreate(Sender: TObject);
 51begin
 52  Caption := oisStringsEditorDialog;
 53  StatusLabel.Caption := ois0Lines0Chars;
 54  SortButton.Caption := oisSort;
 55  BtnPanel.OKButton.Caption := oisOk2;
 56  BtnPanel.CancelButton.Caption := oiStdActDataSetCancel1Hint;
 57
 58  AddButtons;
 59end;
 60
 61procedure TStringsPropEditorFrm.MemoChange(Sender: TObject);
 62var
 63  NumChars: Integer;
 64  I: Integer;
 65begin
 66  NumChars := 0;
 67  for I := 0 to Memo.Lines.Count - 1 do Inc(NumChars, Length(Memo.Lines[I]));
 68
 69  if Memo.Lines.Count = 1 then
 70    StatusLabel.Caption := Format(ois1LineDChars, [NumChars])
 71  else
 72    StatusLabel.Caption := Format(oisDLinesDChars, [Memo.Lines.Count, NumChars]);
 73end;
 74
 75procedure TStringsPropEditorFrm.SortButtonClick(Sender: TObject);
 76var
 77  OldText, NewSortedText: String;
 78  SortOnlySelection: Boolean;
 79begin
 80  if not Assigned(ShowSortSelectionDialogFunc) then
 81  begin
 82    SortButton.Enabled := False;
 83    Exit;
 84  end;
 85
 86  SortOnlySelection := True;
 87  OldText := Memo.SelText;
 88  if OldText = '' then
 89  begin
 90    SortOnlySelection := False;
 91    OldText := Memo.Lines.Text;
 92  end;
 93
 94  if ShowSortSelectionDialogFunc(OldText, nil, NewSortedText) <> mrOk then Exit;
 95  if SortOnlySelection then
 96    Memo.SelText := NewSortedText
 97  else
 98    Memo.Lines.Text := NewSortedText;
 99end;
100
101procedure TStringsPropEditorFrm.AddButtons;
102begin
103  //
104end;
105
106initialization
107  {$I stringspropeditdlg.lrs}
108
109end.
110