Ignore:
Timestamp:
Aug 3, 2012, 12:14:25 PM (12 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StudioPackage/UDataModule.pas

    r7 r8  
    99
    1010type
     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
    1137  { TDataModule1 }
    1238
     
    1945    Project: TProject;
    2046    FileTypes: TFileTypes;
     47    OpenedFiles: TOpenedFiles;
    2148  end;
    2249
     
    3259  UFormSourceCode, UFormMain, UFormProject, UFormSettings;
    3360
     61procedure TOpenedFile.SetFileName(AValue: string);
     62begin
     63  if FFileName = AValue then Exit;
     64  FFileName := AValue;
     65  if Assigned(Form) then
     66    Form.Caption := ExtractFileName(FFileName);
     67end;
     68
     69{ TOpenedFiles }
     70
     71procedure TOpenedFiles.OpenFile(FileName: string);
     72var
     73  NewFile: TOpenedFile;
     74begin
     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);
     82end;
     83
     84procedure TOpenedFiles.NewFile;
     85begin
     86
     87end;
     88
    3489{ TDataModule1 }
    3590
    3691procedure TDataModule1.DataModuleCreate(Sender: TObject);
    3792begin
     93  FileTypes := TFileTypes.Create;
     94  FileTypes.OwnsObjects := False;
     95  OpenedFiles := TOpenedFiles.Create;
     96
    3897  Application.CreateForm(TFormMain, FormMain);
     98  OpenedFiles.OnOpenFile := FormMain.OpenFileExecute;
    3999  Application.CreateForm(TFormProject, FormProject);
    40100  Application.CreateForm(TFormSourceCode, FormSourceCode);
    41101  Application.CreateForm(TFormSettings, FormSettings);
    42   FileTypes := TFileTypes.Create;
    43102end;
    44103
    45104procedure TDataModule1.DataModuleDestroy(Sender: TObject);
    46105begin
     106  FreeAndNil(OpenedFiles);
    47107  FreeAndNil(FileTypes);
    48108end;
Note: See TracChangeset for help on using the changeset viewer.