Changeset 8 for trunk/StudioPackage/UDataModule.pas
- Timestamp:
- Aug 3, 2012, 12:14:25 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StudioPackage/UDataModule.pas
r7 r8 9 9 10 10 type 11 12 { TOpenedFile } 13 14 TOpenedFile = class 15 private 16 FFileName: string; 17 procedure SetFileName(AValue: string); 18 public 19 Modified: Boolean; 20 Form: TForm; 21 property FileName: string read FFileName write SetFileName; 22 end; 23 24 TOpenFileEvent = procedure (OpenedFile: TOpenedFile) of object; 25 26 { TOpenedFiles } 27 28 TOpenedFiles = class(TListObject) 29 private 30 FOnOpenFile: TOpenFileEvent; 31 public 32 procedure OpenFile(FileName: string); 33 procedure NewFile; 34 property OnOpenFile: TOpenFileEvent read FOnOpenFile write FOnOpenFile; 35 end; 36 11 37 { TDataModule1 } 12 38 … … 19 45 Project: TProject; 20 46 FileTypes: TFileTypes; 47 OpenedFiles: TOpenedFiles; 21 48 end; 22 49 … … 32 59 UFormSourceCode, UFormMain, UFormProject, UFormSettings; 33 60 61 procedure TOpenedFile.SetFileName(AValue: string); 62 begin 63 if FFileName = AValue then Exit; 64 FFileName := AValue; 65 if Assigned(Form) then 66 Form.Caption := ExtractFileName(FFileName); 67 end; 68 69 { TOpenedFiles } 70 71 procedure TOpenedFiles.OpenFile(FileName: string); 72 var 73 NewFile: TOpenedFile; 74 begin 75 NewFile := TOpenedFile(AddNew(TOpenedFile.Create)); 76 NewFile.FileName := FileName; 77 NewFile.Form := TFormSourceCode.Create(nil); 78 NewFile.Form.Caption := ExtractFileName(NewFile.FileName); 79 NewFile.Form.Visible := True; 80 if Assigned(FOnOpenFile) then 81 FOnOpenFile(NewFile); 82 end; 83 84 procedure TOpenedFiles.NewFile; 85 begin 86 87 end; 88 34 89 { TDataModule1 } 35 90 36 91 procedure TDataModule1.DataModuleCreate(Sender: TObject); 37 92 begin 93 FileTypes := TFileTypes.Create; 94 FileTypes.OwnsObjects := False; 95 OpenedFiles := TOpenedFiles.Create; 96 38 97 Application.CreateForm(TFormMain, FormMain); 98 OpenedFiles.OnOpenFile := FormMain.OpenFileExecute; 39 99 Application.CreateForm(TFormProject, FormProject); 40 100 Application.CreateForm(TFormSourceCode, FormSourceCode); 41 101 Application.CreateForm(TFormSettings, FormSettings); 42 FileTypes := TFileTypes.Create;43 102 end; 44 103 45 104 procedure TDataModule1.DataModuleDestroy(Sender: TObject); 46 105 begin 106 FreeAndNil(OpenedFiles); 47 107 FreeAndNil(FileTypes); 48 108 end;
Note:
See TracChangeset
for help on using the changeset viewer.