/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. Author: Mattias Gaertner
  13. Abstract:
  14. Dialog for the TStrings property editor.
  15. }
  16. unit StringsPropEditDlg;
  17. {$mode objfpc}{$H+}
  18. interface
  19. uses
  20. Classes, SysUtils, LResources, Forms, Controls, Buttons, Dialogs, StdCtrls,
  21. TextTools, ObjInspStrConsts, ExtCtrls, ButtonPanel;
  22. type
  23. { TStringsPropEditorFrm }
  24. TStringsPropEditorFrm = class(TForm)
  25. BtnPanel: TButtonPanel;
  26. StatusLabel: TLabel;
  27. SortButton: TButton;
  28. TextGroupBox: TGroupBox;
  29. Memo: TMemo;
  30. procedure FormCreate(Sender: TObject);
  31. procedure MemoChange(Sender: TObject);
  32. procedure SortButtonClick(Sender: TObject);
  33. public
  34. procedure AddButtons; virtual;
  35. end;
  36. implementation
  37. { TStringsPropEditorFrm }
  38. procedure TStringsPropEditorFrm.FormCreate(Sender: TObject);
  39. begin
  40. Caption := oisStringsEditorDialog;
  41. StatusLabel.Caption := ois0Lines0Chars;
  42. SortButton.Caption := oisSort;
  43. BtnPanel.OKButton.Caption := oisOk2;
  44. BtnPanel.CancelButton.Caption := oiStdActDataSetCancel1Hint;
  45. AddButtons;
  46. end;
  47. procedure TStringsPropEditorFrm.MemoChange(Sender: TObject);
  48. var
  49. NumChars: Integer;
  50. I: Integer;
  51. begin
  52. NumChars := 0;
  53. for I := 0 to Memo.Lines.Count - 1 do Inc(NumChars, Length(Memo.Lines[I]));
  54. if Memo.Lines.Count = 1 then
  55. StatusLabel.Caption := Format(ois1LineDChars, [NumChars])
  56. else
  57. StatusLabel.Caption := Format(oisDLinesDChars, [Memo.Lines.Count, NumChars]);
  58. end;
  59. procedure TStringsPropEditorFrm.SortButtonClick(Sender: TObject);
  60. var
  61. OldText, NewSortedText: String;
  62. SortOnlySelection: Boolean;
  63. begin
  64. if not Assigned(ShowSortSelectionDialogFunc) then
  65. begin
  66. SortButton.Enabled := False;
  67. Exit;
  68. end;
  69. SortOnlySelection := True;
  70. OldText := Memo.SelText;
  71. if OldText = '' then
  72. begin
  73. SortOnlySelection := False;
  74. OldText := Memo.Lines.Text;
  75. end;
  76. if ShowSortSelectionDialogFunc(OldText, nil, NewSortedText) <> mrOk then Exit;
  77. if SortOnlySelection then
  78. Memo.SelText := NewSortedText
  79. else
  80. Memo.Lines.Text := NewSortedText;
  81. end;
  82. procedure TStringsPropEditorFrm.AddButtons;
  83. begin
  84. //
  85. end;
  86. initialization
  87. {$I stringspropeditdlg.lrs}
  88. end.