1 { 2 *************************************************************************** 3 * * 4 * This source is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This code is distributed in the hope that it will be useful, but * 10 * WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 12 * General Public License for more details. * 13 * * 14 * A copy of the GNU General Public License is available on the World * 15 * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also * 16 * obtain it by writing to the Free Software Foundation, * 17 * Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. * 18 * * 19 *************************************************************************** 20 21 Author: Mattias Gaertner 22 23 Abstract: 24 An IDE window for context sensitive codetools. 25 } 26 unit CodyFrm; 27 28 {$mode objfpc}{$H+} 29 30 {$R *.lfm} 31 32 interface 33 34 uses 35 Classes, SysUtils, FileProcs, LResources, Forms, Controls, Graphics, Dialogs, 36 Buttons, ComCtrls, 37 // codetools 38 //FileProcs, CodeToolManager, SourceLog, CodeCache, EventCodeTool, 39 //LinkScanner, PascalParserTool, CodeTree, 40 // IDEIntf 41 LazIDEIntf, IDEWindowIntf, 42 // cody 43 CodyStrConsts; 44 45 const 46 CodyWindowName = 'CodyWindow'; 47 type 48 49 { TCodyWindow } 50 51 TCodyWindow = class(TForm) 52 ImageList1: TImageList; 53 ToolBar1: TToolBar; 54 RefreshToolButton: TToolButton; 55 OptionsToolButton: TToolButton; 56 TreeView1: TTreeView; 57 procedure FormCreate(Sender: TObject); 58 procedure FormDestroy(Sender: TObject); 59 private 60 ImgIDRefresh: Integer; 61 ImgIDOptions: Integer; 62 public 63 end; 64 65 var 66 CodyWindow: TCodyWindow = nil; 67 CodyWindowCreator: TIDEWindowCreator; // set by CodyRegistration.Register 68 69 procedure ShowCodyWindow(Sender: TObject); 70 procedure CreateCodyWindow(Sender: TObject; aFormName: string; 71 var AForm: TCustomForm; DoDisableAutoSizing: boolean); 72 73 implementation 74 75 procedure ShowCodyWindow(Sender: TObject); 76 begin 77 IDEWindowCreators.ShowForm(CodyWindowCreator.FormName,true); 78 end; 79 80 procedure CreateCodyWindow(Sender: TObject; aFormName: string; 81 var AForm: TCustomForm; DoDisableAutoSizing: boolean); 82 begin 83 if CompareText(aFormName,CodyWindowName)<>0 then begin 84 debugln(['ERROR: CreateCodyWindow: there is already a form with this name']); 85 exit; 86 end; 87 IDEWindowCreators.CreateForm(AForm,TCodyWindow,DoDisableAutoSizing, 88 LazarusIDE.OwningComponent); 89 AForm.Name:=aFormName; 90 end; 91 92 { TCodyWindow } 93 94 procedure TCodyWindow.FormCreate(Sender: TObject); 95 begin 96 if CodyWindow=nil then CodyWindow:=Self; 97 Caption:='Cody'; 98 99 ImgIDRefresh := Imagelist1.AddResourceName(HInstance, 'laz_refresh'); 100 ImgIDOptions := Imagelist1.AddResourceName(HInstance, 'menu_environment_options'); 101 ToolBar1.Images:=ImageList1; 102 OptionsToolButton.Hint:=crsOptions; 103 OptionsToolButton.ImageIndex:=ImgIDOptions; 104 RefreshToolButton.Hint:=crsRefresh; 105 RefreshToolButton.ImageIndex:=ImgIDRefresh; 106 end; 107 108 procedure TCodyWindow.FormDestroy(Sender: TObject); 109 begin 110 111 if CodyWindow=Self then CodyWindow:=nil; 112 end; 113 114 115 end. 116 117