Changeset 13


Ignore:
Timestamp:
Aug 3, 2012, 4:03:59 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Implementing base tabbed opened file list.
Location:
trunk/StudioPackage
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/StudioPackage/Forms/UFormMain.lfm

    r11 r13  
    715715      Caption = 'New...'
    716716      ImageIndex = 4
     717      OnExecute = AFileNewExecute
    717718      ShortCut = 16462
    718719    end
  • trunk/StudioPackage/Forms/UFormMain.pas

    r11 r13  
    105105    procedure AExitExecute(Sender: TObject);
    106106    procedure AFileCloseExecute(Sender: TObject);
     107    procedure AFileNewExecute(Sender: TObject);
    107108    procedure AFileOpenExecute(Sender: TObject);
    108109    procedure AViewModulesExecute(Sender: TObject);
     
    115116    procedure DockInit;
    116117  public
    117     procedure OpenFileExecute(OpenedFile: TOpenedFile);
     118    procedure OpenedFileChange(Sender: TObject);
    118119  end;
    119120
     
    137138procedure TFormMain.AFileCloseExecute(Sender: TObject);
    138139begin
    139 //  DataModule1.OpenedFiles.Close(DataModule1.OpenedFiles.Selected);
     140  DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected.FileName);
     141end;
     142
     143procedure TFormMain.AFileNewExecute(Sender: TObject);
     144begin
     145  DataModule1.OpenedFiles.NewFile;
    140146end;
    141147
     
    185191}end;
    186192
    187 procedure TFormMain.OpenFileExecute(OpenedFile: TOpenedFile);
     193procedure TFormMain.OpenedFileChange(Sender: TObject);
    188194var
    189195  NewTabSheet: TTabSheet;
    190 begin
    191   NewTabSheet := PageControlCenter.AddTabSheet;
    192   OpenedFile.Form.ManualDock(NewTabSheet, nil, alClient);
    193   OpenedFile.Form.Align := alClient;
    194   OpenedFile.Form.Show;
     196  I: Integer;
     197begin
     198  with DataModule1.OpenedFiles do begin
     199    for I := 0 to Count - 1 do
     200    with TOpenedFile(Items[I]) do begin
     201      if not Assigned(Form.Parent) then begin
     202        NewTabSheet := PageControlCenter.AddTabSheet;
     203        NewTabSheet.Caption := ExtractFileName(FileName);
     204        //NewTabSheet.PopupMenu := ;
     205        Form.ManualDock(NewTabSheet, nil, alClient);
     206        Form.Align := alClient;
     207        Form.Show;
     208      end;
     209    end;
     210  end;
    195211end;
    196212
  • trunk/StudioPackage/UDataModule.pas

    r11 r13  
    2323  end;
    2424
    25   TOpenFileEvent = procedure (OpenedFile: TOpenedFile) of object;
    26 
    2725  { TOpenedFiles }
    2826
    2927  TOpenedFiles = class(TListObject)
    3028  private
    31     FOnOpenFile: TOpenFileEvent;
     29    FOnChange: TNotifyEvent;
    3230  public
    3331    Selected: TOpenedFile;
    34     procedure CloseFile(OpenedFile: TOpenedFile);
     32    function FindByFileName(Value: string): TOpenedFile;
     33    procedure CloseFile(FileName: string);
    3534    procedure OpenFile(FileName: string);
    3635    procedure NewFile;
    37     property OnOpenFile: TOpenFileEvent read FOnOpenFile write FOnOpenFile;
     36    property OnChange: TNotifyEvent read FOnChange write FOnChange;
    3837  end;
    3938
     
    6261  UFormSourceCode, UFormMain, UFormSettings, UFormModuleList;
    6362
     63resourcestring
     64  SNewFile = 'New file';
     65
    6466procedure TOpenedFile.SetFileName(AValue: string);
    6567begin
     
    7274{ TOpenedFiles }
    7375
    74 procedure TOpenedFiles.CloseFile(OpenedFile: TOpenedFile);
     76function TOpenedFiles.FindByFileName(Value: string): TOpenedFile;
     77var
     78  I: Integer;
    7579begin
     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;
     84end;
     85
     86procedure TOpenedFiles.CloseFile(FileName: string);
     87var
     88  OpenedFile: TOpenedFile;
     89begin
     90  OpenedFile := FindByFileName(FileName);
    7691  FreeAndNil(OpenedFile.Form);
     92  Remove(OpenedFile);
     93  if Assigned(FOnChange) then FOnChange(Self);
    7794end;
    7895
     
    87104  NewFile.Form.Visible := True;
    88105  Selected := NewFile;
    89   if Assigned(FOnOpenFile) then
    90     FOnOpenFile(NewFile);
     106  if Assigned(FOnChange) then FOnChange(Self);
    91107end;
    92108
    93109procedure TOpenedFiles.NewFile;
     110var
     111  NewFile: TOpenedFile;
    94112begin
    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);
    96120end;
    97121
     
    109133  FormMain := TFormMain.Create(nil);
    110134  Application.UpdateMainForm(FormMain);
    111   OpenedFiles.OnOpenFile := FormMain.OpenFileExecute;
     135  OpenedFiles.OnChange := FormMain.OpenedFileChange;
    112136  FormSourceCode := TFormSourceCode.Create(nil);
    113137  FormSettings := TFormSettings.Create(nil);
Note: See TracChangeset for help on using the changeset viewer.