-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathamScript.Editor.Container.pas
More file actions
68 lines (56 loc) · 1.7 KB
/
amScript.Editor.Container.pas
File metadata and controls
68 lines (56 loc) · 1.7 KB
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
unit amScript.Editor.Container;
interface
uses
Classes,
Controls,
amScript.Editor.API;
// -----------------------------------------------------------------------------
//
// TScriptEditorContainer
//
// -----------------------------------------------------------------------------
// Facilitates "communication" from the editor to the container control.
// Specifically it allows the editor to embed itself within the container
// control and to set the caption of the container control.
// The object is owned, via reference counting, by the editor.
// -----------------------------------------------------------------------------
type
TScriptEditorContainer = class(TInterfacedObject, IScriptEditorContainer)
private
FContainer: TWinControl;
FEditorControl: TControl;
private
// IScriptEditorContainer
procedure SetCaption(const ACaption: string); virtual;
procedure EmbedEditorControl(AControl: TControl);
public
constructor Create(AContainer: TWinControl);
end;
implementation
constructor TScriptEditorContainer.Create(AContainer: TWinControl);
begin
inherited Create;
FContainer := AContainer;
end;
procedure TScriptEditorContainer.EmbedEditorControl(AControl: TControl);
begin
if (FEditorControl <> nil) then
begin
FEditorControl.Visible := False;
FEditorControl.Parent := nil;
end;
FEditorControl := AControl;
if (FEditorControl <> nil) then
begin
FEditorControl.Parent := FContainer;
FEditorControl.Align := alClient;
FEditorControl.Visible := True;
end;
end;
type
TControlCracker = class(TCustomControl);
procedure TScriptEditorContainer.SetCaption(const ACaption: string);
begin
TControlCracker(FContainer).Caption := ACaption;
end;
end.