1 { Lazarus IDE wizard for fpweb package.
2 
3   Copyright (C) 2010 Lagunov Aleksey alexs75@hotbox.ru
4 
5   This library is free software; you can redistribute it and/or modify it
6   under the terms of the GNU Library General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or (at your
8   option) any later version with the following modification:
9 
10   As a special exception, the copyright holders of this library give you
11   permission to link this library with independent modules to produce an
12   executable, regardless of the license terms of these independent modules,and
13   to copy and distribute the resulting executable under terms of your choice,
14   provided that you also meet, for each linked independent module, the terms
15   and conditions of the license of that module. An independent module is a
16   module which is not derived from or based on this library. If you modify
17   this library, you may extend this exception to your version of the library,
18   but you are not obligated to do so. If you do not wish to do so, delete this
19   exception statement from your version.
20 
21   This program is distributed in the hope that it will be useful, but WITHOUT
22   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
24   for more details.
25 
26   You should have received a copy of the GNU Library General Public License
27   along with this library; if not, write to the Free Software Foundation,
28   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.
29 }
30 unit fpIDEExtEditorInsertFileNameUnit;
31 
32 {$mode objfpc}{$H+}
33 
34 interface
35 
36 uses
37   Classes, SysUtils, LazFileUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
38   ButtonPanel;
39 
40 type
41 
42   { TfpIDEExtEditorInsertFileNameForm }
43 
44   TfpIDEExtEditorInsertFileNameForm = class(TForm)
45     ButtonPanel1: TButtonPanel;
46     CBFullPath: TCheckBox;
47     EFileName: TEdit;
48     LEFileName: TLabel;
49     LBFiles: TListBox;
50     procedure FormCreate(Sender: TObject);
51     procedure LBFilesDblClick(Sender: TObject);
52   private
53     procedure FillFilesList;
54   public
SelectedFilenull55     function SelectedFile:string;
56   end;
57 
58 var
59   fpIDEExtEditorInsertFileNameForm: TfpIDEExtEditorInsertFileNameForm;
60 
61 implementation
62 uses fpWebStrConsts, SrcEditorIntf, ProjectIntf, LazIDEIntf;
63 
64 {$R *.lfm}
65 
66 { TfpIDEExtEditorInsertFileNameForm }
67 
68 procedure TfpIDEExtEditorInsertFileNameForm.FormCreate(Sender: TObject);
69 begin
70   FillFilesList;
71 end;
72 
73 procedure TfpIDEExtEditorInsertFileNameForm.LBFilesDblClick(Sender: TObject);
74 begin
75   ModalResult:=mrOk;
76 end;
77 
78 procedure TfpIDEExtEditorInsertFileNameForm.FillFilesList;
79 var
80   i:integer;
81   S:string;
82 begin
83   LBFiles.Items.Clear;
84   if Assigned(LazarusIDE) and Assigned(LazarusIDE.ActiveProject) then
85   begin
86     for i:=0 to LazarusIDE.ActiveProject.FileCount - 1 do
87     begin
88       if LazarusIDE.ActiveProject.Files[i].IsPartOfProject then
89       begin
90         S:=LazarusIDE.ActiveProject.Files[i].Filename;
91         LBFiles.Items.Add(S);
92       end;
93     end;
94   end;
95 end;
96 
SelectedFilenull97 function TfpIDEExtEditorInsertFileNameForm.SelectedFile: string;
98 begin
99   if (LBFiles.Items.Count>0) and (LBFiles.ItemIndex>-1) and (LBFiles.ItemIndex < LBFiles.Items.Count) then
100   begin
101     Result:=LBFiles.Items[LBFiles.ItemIndex];
102     if not CBFullPath.Checked then
103       Result:=ExtractFileNameOnly(Result);
104   end
105   else
106     Result:='';
107 end;
108 
109 end.
110 
111