summaryrefslogtreecommitdiff
path: root/examples/apps
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2013-03-17 17:41:00 +0000
committerDavid Laurence Emerson <dle3ab@angelbase.com>2013-05-28 00:42:48 -0700
commit70e46213113d01aa763074ee33e9abcb656d2206 (patch)
treea44d4c21f599cd0a6b444b2fabda224441a712a1 /examples/apps
parentb784656edc05621b737d90dd0389e68b47030b24 (diff)
downloadfpGUI-70e46213113d01aa763074ee33e9abcb656d2206.tar.xz
ide: refactor out Adding Unit To Project code into separate method.
Diffstat (limited to 'examples/apps')
-rw-r--r--examples/apps/ide/src/frm_main.pas24
1 files changed, 16 insertions, 8 deletions
diff --git a/examples/apps/ide/src/frm_main.pas b/examples/apps/ide/src/frm_main.pas
index e3876da4..46d51352 100644
--- a/examples/apps/ide/src/frm_main.pas
+++ b/examples/apps/ide/src/frm_main.pas
@@ -95,6 +95,7 @@ type
procedure miRecentProjectsClick(Sender: TObject; const FileName: String);
procedure miProjectSave(Sender: TObject);
procedure miProjectSaveAs(Sender: TObject);
+ procedure AddUnitToProject(const AUnitName: TfpgString);
procedure miProjectAddUnitToProject(Sender: TObject);
procedure tvProjectDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
procedure grdMessageKeyPressed(Sender: TObject; var KeyCode: Word; var ShiftState: TShiftState; var Consumed: Boolean);
@@ -485,21 +486,15 @@ begin
end;
end;
-procedure TMainForm.miProjectAddUnitToProject(Sender: TObject);
+procedure TMainForm.AddUnitToProject(const AUnitName: TfpgString);
var
u: TUnit;
s: TfpgString;
r: TfpgTreeNode;
n: TfpgTreeNode;
begin
- s := pcEditor.ActivePage.Hint;
-// writeln('adding unit: ', s);
- if s = '' then
- Exit;
- if GProject.UnitList.FileExists(s) then
- Exit;
u := TUnit.Create;
- u.FileName := s;
+ u.FileName := AUnitName;
u.Opened := True;
GProject.UnitList.Add(u);
// add reference to tabsheet
@@ -512,6 +507,19 @@ begin
tvProject.Invalidate;
end;
+procedure TMainForm.miProjectAddUnitToProject(Sender: TObject);
+var
+ s: TfpgString;
+begin
+ s := pcEditor.ActivePage.Hint;
+// writeln('adding unit: ', s);
+ if s = '' then
+ Exit;
+ if GProject.UnitList.FileExists(s) then
+ Exit;
+ AddUnitToProject(s);
+end;
+
procedure TMainForm.tvProjectDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
var
r: TfpgTreeNode;