Changeset 13 for trunk/StudioPackage/UDataModule.pas
- Timestamp:
- Aug 3, 2012, 4:03:59 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StudioPackage/UDataModule.pas
r11 r13 23 23 end; 24 24 25 TOpenFileEvent = procedure (OpenedFile: TOpenedFile) of object;26 27 25 { TOpenedFiles } 28 26 29 27 TOpenedFiles = class(TListObject) 30 28 private 31 FOn OpenFile: TOpenFileEvent;29 FOnChange: TNotifyEvent; 32 30 public 33 31 Selected: TOpenedFile; 34 procedure CloseFile(OpenedFile: TOpenedFile); 32 function FindByFileName(Value: string): TOpenedFile; 33 procedure CloseFile(FileName: string); 35 34 procedure OpenFile(FileName: string); 36 35 procedure NewFile; 37 property On OpenFile: TOpenFileEvent read FOnOpenFile write FOnOpenFile;36 property OnChange: TNotifyEvent read FOnChange write FOnChange; 38 37 end; 39 38 … … 62 61 UFormSourceCode, UFormMain, UFormSettings, UFormModuleList; 63 62 63 resourcestring 64 SNewFile = 'New file'; 65 64 66 procedure TOpenedFile.SetFileName(AValue: string); 65 67 begin … … 72 74 { TOpenedFiles } 73 75 74 procedure TOpenedFiles.CloseFile(OpenedFile: TOpenedFile); 76 function TOpenedFiles.FindByFileName(Value: string): TOpenedFile; 77 var 78 I: Integer; 75 79 begin 80 I := 0; 81 while (I < Count) and (TOpenedFile(Items[I]).FileName <> Value) do Inc(I); 82 if I < Count then Result := TOpenedFile(Items[I]) 83 else Result := nil; 84 end; 85 86 procedure TOpenedFiles.CloseFile(FileName: string); 87 var 88 OpenedFile: TOpenedFile; 89 begin 90 OpenedFile := FindByFileName(FileName); 76 91 FreeAndNil(OpenedFile.Form); 92 Remove(OpenedFile); 93 if Assigned(FOnChange) then FOnChange(Self); 77 94 end; 78 95 … … 87 104 NewFile.Form.Visible := True; 88 105 Selected := NewFile; 89 if Assigned(FOnOpenFile) then 90 FOnOpenFile(NewFile); 106 if Assigned(FOnChange) then FOnChange(Self); 91 107 end; 92 108 93 109 procedure TOpenedFiles.NewFile; 110 var 111 NewFile: TOpenedFile; 94 112 begin 95 113 NewFile := TOpenedFile(AddNew(TOpenedFile.Create)); 114 NewFile.FileName := SNewFile; 115 NewFile.Form := TFormSourceCode.Create(nil); 116 NewFile.Form.Caption := ExtractFileName(NewFile.FileName); 117 NewFile.Form.Visible := True; 118 Selected := NewFile; 119 if Assigned(FOnChange) then FOnChange(Self); 96 120 end; 97 121 … … 109 133 FormMain := TFormMain.Create(nil); 110 134 Application.UpdateMainForm(FormMain); 111 OpenedFiles.On OpenFile := FormMain.OpenFileExecute;135 OpenedFiles.OnChange := FormMain.OpenedFileChange; 112 136 FormSourceCode := TFormSourceCode.Create(nil); 113 137 FormSettings := TFormSettings.Create(nil);
Note:
See TracChangeset
for help on using the changeset viewer.