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
|
{
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Mattias Gaertner
Abstract:
A dialog to choose a TCustomTextConverterToolClass.
}
unit IDETextConvListAdd;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
StdCtrls, IDETextConverter, h2passtrconsts;
type
{ TIDETextConvListAddDlg }
TIDETextConvListAddDlg = class(TForm)
ClassLabel: TLabel;
ClassComboBox: TComboBox;
AddButton: TButton;
CancelButton: TButton;
procedure AddButtonClick(Sender: TObject);
procedure ClassComboBoxEditingDone(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FToolClass: TCustomTextConverterToolClass;
procedure SetToolClass(const AValue: TCustomTextConverterToolClass);
procedure FillClassComboBox;
public
property ToolClass: TCustomTextConverterToolClass read FToolClass write SetToolClass;
end;
function ShowIDETextConvListAddDlg(out ToolClass: TCustomTextConverterToolClass
): TModalResult;
implementation
{$R idetextconvlistadd.lfm}
function ShowIDETextConvListAddDlg(out ToolClass: TCustomTextConverterToolClass
): TModalResult;
var
IDETextConvListAddDlg: TIDETextConvListAddDlg;
begin
IDETextConvListAddDlg:=TIDETextConvListAddDlg.Create(nil);
Result:=IDETextConvListAddDlg.ShowModal;
ToolClass:=IDETextConvListAddDlg.ToolClass;
IDETextConvListAddDlg.Free;
end;
{ TIDETextConvListAddDlg }
procedure TIDETextConvListAddDlg.FormCreate(Sender: TObject);
begin
ClassLabel.Caption := h2pSelectAClass;
AddButton.Caption := h2pAdd;
CancelButton.Caption := h2pCancel2;
FillClassComboBox;
ToolClass:=TextConverterToolClasses[0];
end;
procedure TIDETextConvListAddDlg.ClassComboBoxEditingDone(Sender: TObject);
begin
FToolClass:=TextConverterToolClasses.FindByFirstLineOfClassDescription(
ClassComboBox.Text);
end;
procedure TIDETextConvListAddDlg.AddButtonClick(Sender: TObject);
begin
if FToolClass=nil then begin
MessageDlg(h2pInvalidClass,
h2pInvalidClass, mtError, [mbCancel], 0);
exit;
end;
ModalResult:=mrOk;
end;
procedure TIDETextConvListAddDlg.SetToolClass(
const AValue: TCustomTextConverterToolClass);
begin
if FToolClass=AValue then exit;
FToolClass:=AValue;
if FToolClass<>nil then
ClassComboBox.Text:=FToolClass.FirstLineOfClassDescription;
end;
procedure TIDETextConvListAddDlg.FillClassComboBox;
var
i: Integer;
begin
ClassComboBox.Items.BeginUpdate;
ClassComboBox.Items.Clear;
for i:=0 to TextConverterToolClasses.Count-1 do begin
ClassComboBox.Items.Add(
TextConverterToolClasses[i].FirstLineOfClassDescription);
end;
ClassComboBox.Items.EndUpdate;
end;
end.
|