Changeset 16 for trunk/StudioPackage/UDataModule.pas
- Timestamp:
- Aug 6, 2012, 3:16:26 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StudioPackage/UDataModule.pas
r15 r16 11 11 12 12 type 13 14 { TTextTemplate }15 16 TTextTemplate = class(TFileTemplate)17 constructor Create; override;18 end;19 20 { TTextFileType }21 22 TTextFileType = class(TSourceType)23 constructor Create; override;24 end;25 26 13 { TOpenedFiles } 27 14 … … 35 22 procedure OpenFileName(FileName: string); 36 23 procedure OpenFile(Source: TSource); 37 procedure NewFile;38 24 property OnChange: TNotifyEvent read FOnChange write FOnChange; 39 25 end; … … 65 51 procedure DataModuleDestroy(Sender: TObject); 66 52 private 67 TextFileType: TSourceType;68 TextFileTemplate: TTextTemplate;69 53 procedure AutoOpen; 70 54 procedure DockToPageControl(PageControl: TPageControl; Form: TForm); … … 88 72 89 73 uses 90 UForm SourceCode, UFormMain, UFormSettings, UFormModuleList, UFormNewFile;74 UFormMain, UFormSettings, UFormModuleList, UFormNewFile, ULDModuleBasic; 91 75 92 76 resourcestring 93 77 SNewFile = 'New file'; 94 STextFile = 'Text file';95 96 { TTextFileType }97 98 constructor TTextFileType.Create;99 begin100 inherited Create;101 Extension := '.txt';102 Title := 'Text file';;103 end;104 105 { TTextTemplate }106 107 constructor TTextTemplate.Create;108 begin109 inherited Create;110 Name := STextFile;111 end;112 113 78 114 79 { TOpenedFiles } … … 133 98 procedure TOpenedFiles.OpenFileName(FileName: string); 134 99 var 135 NewFile: TSourceText; 136 begin 137 NewFile := TSourceText.Create; 138 NewFile.Name := FileName; 139 OpenFile(NewFile); 100 NewFile: TSource; 101 FileType: TSourceType; 102 begin 103 FileType := DataModule1.FileTypes.FindByExt(ExtractFileExt(FileName)); 104 if Assigned(FileType) then begin 105 NewFile := FileType.SourceClass.Create; 106 NewFile.Name := FileName; 107 OpenFile(NewFile); 108 end; 140 109 end; 141 110 … … 143 112 begin 144 113 AddNew(Source); 145 Source.Form := TFormSourceCode.Create(nil);114 Source.Form := Source.FileType.Form.Create(nil); 146 115 Source.Form.Caption := ExtractFileName(Source.Name); 147 116 Source.Form.Visible := True; 148 117 Selected := Source; 149 if Assigned(FOnChange) then FOnChange(Self);150 end;151 152 procedure TOpenedFiles.NewFile;153 var154 NewFile: TSource;155 begin156 NewFile := TSourceText(AddNew(TSource.Create));157 NewFile.Name := SNewFile;158 NewFile.Form := TFormSourceCode.Create(nil);159 NewFile.Form.Caption := ExtractFileName(NewFile.Name);160 NewFile.Form.Visible := True;161 Selected := NewFile;162 118 if Assigned(FOnChange) then FOnChange(Self); 163 119 end; … … 175 131 ModuleManager.API := API; 176 132 177 TextFileType := TTextFileType.Create;178 API.RegisterFileType(TextFileType);179 TextFileTemplate := TTextTemplate.Create;180 API.RegisterFileTemplate(TextFileTemplate);181 182 133 FormMain := TFormMain.Create(nil); 183 134 Application.UpdateMainForm(FormMain); 184 135 OpenedFiles.OnChange := FormMain.OpenedFileChange; 185 FormSourceCode := TFormSourceCode.Create(nil);186 136 FormSettings := TFormSettings.Create(nil); 187 137 FormModuleList := TFormModuleList.Create(nil); … … 301 251 procedure TDataModule1.DataModuleDestroy(Sender: TObject); 302 252 begin 303 API.UnregisterFileType(TextFileType);304 FreeAndNil(TextFileType);305 API.UnregisterFileTemplate(TextFileTemplate);306 FreeAndNil(TextFileTemplate);307 308 253 SaveToRegistry(RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey)); 309 254 FreeAndNil(ModuleManager); 310 255 FreeAndNil(FormNewFile); 311 256 FreeAndNil(FormMain); 312 FreeAndNil(FormSourceCode);313 257 FreeAndNil(FormSettings); 314 258 FreeAndNil(FormModuleList);
Note:
See TracChangeset
for help on using the changeset viewer.