-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
ChatGPT.LoadedFunctions.pas
89 lines (74 loc) · 2.13 KB
/
ChatGPT.LoadedFunctions.pas
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
unit ChatGPT.LoadedFunctions;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
ChatGPT.Overlay, FMX.Objects, FMX.Controls.Presentation, FMX.Layouts,
FMX.ListBox;
type
TFrameLoadedFunctions = class(TFrameOveraly)
LayoutClient: TLayout;
RectangleFrame: TRectangle;
Layout2: TLayout;
ButtonOk: TButton;
ListBoxItems: TListBox;
LabelEmpty: TLabel;
Label1: TLabel;
Label20: TLabel;
Rectangle1: TRectangle;
procedure FrameResize(Sender: TObject);
procedure ButtonOkClick(Sender: TObject);
procedure RectangleBGClick(Sender: TObject);
private
FLayoutClientWidth, FLayoutClientHeight: Single;
public
constructor Create(AOwner: TComponent); override;
procedure Cancel; override;
class procedure Execute(AParent: TControl);
end;
var
FrameLoadedFunctions: TFrameLoadedFunctions;
implementation
uses
System.Math, ChatGPT.Manager;
{$R *.fmx}
procedure TFrameLoadedFunctions.ButtonOkClick(Sender: TObject);
begin
Cancel;
end;
procedure TFrameLoadedFunctions.Cancel;
begin
Release;
end;
constructor TFrameLoadedFunctions.Create(AOwner: TComponent);
begin
inherited;
Name := '';
FLayoutClientWidth := LayoutClient.Width;
FLayoutClientHeight := LayoutClient.Height;
for var Item in Manager.GPTFuncList do
begin
var ListItem := TListBoxItem.Create(ListBoxItems);
ListItem.Text := Item.GetDescription;
ListItem.ItemData.Detail := Item.GetName;
ListBoxItems.AddObject(ListItem);
end;
LabelEmpty.Visible := ListBoxItems.Count <= 0;
end;
class procedure TFrameLoadedFunctions.Execute(AParent: TControl);
begin
var Frame := TFrameLoadedFunctions.Create(AParent);
Frame.Parent := AParent;
Frame.Align := TAlignLayout.Contents;
Frame.BringToFront;
end;
procedure TFrameLoadedFunctions.FrameResize(Sender: TObject);
begin
LayoutClient.Width := Min(FLayoutClientWidth, Width);
LayoutClient.Height := Min(FLayoutClientHeight, Height);
end;
procedure TFrameLoadedFunctions.RectangleBGClick(Sender: TObject);
begin
Cancel;
end;
end.