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 134 135
|
unit lr_funct_editor_unit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, LR_Class, Buttons, ButtonPanel, LR_Const;
type
{ TLR_FunctEditorForm }
TLR_FunctEditorForm = class(TForm)
ButtonPanel1: TButtonPanel;
Label1: TLabel;
Label2: TLabel;
ListBox1: TListBox;
ListBox2: TListBox;
Panel1: TPanel;
Splitter1: TSplitter;
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure ListBox2Click(Sender: TObject);
procedure ListBox2DblClick(Sender: TObject);
private
{ private declarations }
public
CurentFunctionDescription:TfrFunctionDescription;
end;
implementation
{$R *.lfm}
{ TLR_FunctEditorForm }
procedure TLR_FunctEditorForm.FormCreate(Sender: TObject);
var
i,j:integer;
F:TfrFunctionLibrary;
FD:TfrFunctionDescription;
begin
for i:=0 to frFunctionsCount-1 do
begin
F:=frFunctions[i].FunctionLibrary;
for j:=0 to F.FunctionCount-1 do
begin
FD := F.Description[j];
if Assigned(FD) then
begin
if ListBox1.Items.IndexOf(FD.funGroup)=-1 then
ListBox1.Items.Add(FD.funGroup);
end
end;
end;
if ListBox1.Items.Count>0 then
ListBox1.ItemIndex:=0;
ListBox1Click(nil);
CurentFunctionDescription:=nil;
Caption:=sFunctions;
end;
procedure TLR_FunctEditorForm.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
if ModalResult = mrOk then
begin
if (ListBox2.Items.Count>0) and (ListBox2.ItemIndex>-1) and (ListBox2.ItemIndex<ListBox2.Items.Count) then
begin
CurentFunctionDescription:=TfrFunctionDescription(ListBox2.Items.Objects[ListBox2.ItemIndex]);
end;
end
end;
procedure TLR_FunctEditorForm.ListBox1Click(Sender: TObject);
var
i,j:integer;
F:TfrFunctionLibrary;
FD:TfrFunctionDescription;
GrpName:string;
begin
if (ListBox1.Items.Count>0) and (ListBox1.ItemIndex>-1) and (ListBox1.ItemIndex<ListBox1.Items.Count) then
begin
GrpName:=ListBox1.Items[ListBox1.ItemIndex];
ListBox2.Items.Clear;
for i:=0 to frFunctionsCount-1 do
begin
F:=frFunctions[i].FunctionLibrary;
for j:=0 to F.FunctionCount-1 do
begin
FD := F.Description[j];
if Assigned(FD) then
begin
if FD.funGroup = GrpName then
begin
ListBox2.Items.Add(FD.funName);
ListBox2.Items.Objects[ListBox2.Items.Count-1]:=FD;
end;
end
end;
end;
if ListBox2.Items.Count>0 then
ListBox2.ItemIndex:=0;
ListBox2Click(nil);
end;
end;
procedure TLR_FunctEditorForm.ListBox2Click(Sender: TObject);
var
FD:TfrFunctionDescription;
S:string;
begin
if (ListBox2.Items.Count>0) and (ListBox2.ItemIndex>-1) and (ListBox2.ItemIndex<ListBox2.Items.Count) then
begin
FD:=TfrFunctionDescription(ListBox2.Items.Objects[ListBox2.ItemIndex]);
if Assigned(FD) then
begin
S:=FD.funDescription;
Label1.Caption:=Copy(S, 1, Pos('/', S)-1);
Delete(S, 1, Pos('/', S));
Label2.Caption:=S;
end;
end;
end;
procedure TLR_FunctEditorForm.ListBox2DblClick(Sender: TObject);
begin
ModalResult:=mrOk;
end;
end.
|