-
Notifications
You must be signed in to change notification settings - Fork 1
/
IDEPageFrame.pas
148 lines (126 loc) · 3.54 KB
/
IDEPageFrame.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
unit IDEPageFrame;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IDEEdit, IDEUnit, SearchForm;
type
TIDEPage = class(TFrame)
private
{ Private declarations }
FIDEEdit: TIDEEdit;
FIDEUnit: TIDEUnit;
FSearchForm: TSimpleSearchForm;
FOnUnitRenamed: TNotifyEvent;
FIDEIcons: TImageList;
procedure SetIDEUnit(const Value: TIDEUnit);
function GetIsPartOfProject: Boolean;
function GetNeedsSaving: Boolean;
procedure HandleOnRename(Sender: TObject);
procedure DoOnUnitRenamed();
procedure HandleAfterSave(Sender: TObject);
procedure HandleAfterLoad(Sender: TObject);
procedure SetIDEIcons(const Value: TImageList);
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure ShowSearch();
procedure HideSearch();
procedure FindNext();
procedure FindPrevious();
property IsPartOfProject: Boolean read GetIsPartOfProject;
property NeedsSaving: Boolean read GetNeedsSaving;
property IDEEdit: TIDEEdit read FIDEEdit;
property IDEUnit: TIDEUnit read FIDEUnit write SetIDEUnit;
property IDEIcons: TImageList read FIDEIcons write SetIDEIcons;
property OnUnitRenamed: TNotifyEvent read FOnUnitRenamed write FOnUnitRenamed;
end;
implementation
uses
UnitTemplates, LineInfo;
{$R *.dfm}
{ TIDEPage }
constructor TIDEPage.Create(AOwner: TComponent);
begin
inherited;
FIDEEdit := TIDEEdit.Create(Self);
FIDEEdit.Parent := Self;
FIDEEdit.Align := alClient;
FIDEEdit.Lines.Text := CDefaultUnit;
FSearchForm := TSimpleSearchForm.Create(Self, FIDEEdit);
FSearchForm.Visible := False;
FSearchForm.Parent := Self;
FSearchForm.Align := alBottom;
end;
destructor TIDEPage.Destroy;
begin
if Assigned(FIDEUnit) then
begin
FIDEUnit.OnRename := nil;
FIDEUnit.OnAfterSave := nil;
FIDEUnit.OnAfterLoad := nil;
end;
inherited;
end;
procedure TIDEPage.DoOnUnitRenamed;
begin
if Assigned(FOnUnitRenamed) then
begin
FOnUnitRenamed(FIDEUnit);
end;
end;
procedure TIDEPage.FindNext;
begin
FSearchForm.FindNext();
end;
procedure TIDEPage.FindPrevious;
begin
FSearchForm.FindPrevious();
end;
function TIDEPage.GetIsPartOfProject: Boolean;
begin
Result := Assigned(FIDEUnit);
end;
function TIDEPage.GetNeedsSaving: Boolean;
begin
Result := FIDEEdit.Modified;
end;
procedure TIDEPage.HandleAfterLoad(Sender: TObject);
begin
FIDEEdit.MarkAllLines(ltNone);
end;
procedure TIDEPage.HandleAfterSave(Sender: TObject);
begin
FIDEEdit.MarkAllLines(ltSaved);
end;
procedure TIDEPage.HandleOnRename(Sender: TObject);
begin
FIDEEdit.Refactor.RenameHeader(TIDEUnit(Sender).Caption);
FIDEEdit.D16UnitName := TIDEUnit(Sender).Caption;
DoOnUnitRenamed();
end;
procedure TIDEPage.HideSearch;
begin
FSearchForm.Visible := False;
end;
procedure TIDEPage.SetIDEIcons(const Value: TImageList);
begin
FIDEIcons := Value;
FIDEEdit.BookMarkOptions.BookmarkImages := Value;
end;
procedure TIDEPage.SetIDEUnit(const Value: TIDEUnit);
begin
FIDEUnit := Value;
FIDEUnit.SourceLink := FIDEEdit.Lines;
FIDEUnit.OnRename := HandleOnRename;
FIDEUnit.OnAfterSave := HandleAfterSave;
FIDEUnit.OnAfterLoad := HandleAfterLoad;
FIDEEdit.D16UnitName := FIDEUnit.Caption;
DoOnUnitRenamed();
end;
procedure TIDEPage.ShowSearch;
begin
FSearchForm.Visible := True;
FSearchForm.edFind.SetFocus();
end;
end.