Changeset 13
- Timestamp:
- Aug 3, 2012, 4:03:59 PM (12 years ago)
- Location:
- trunk/StudioPackage
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StudioPackage/Forms/UFormMain.lfm
r11 r13 715 715 Caption = 'New...' 716 716 ImageIndex = 4 717 OnExecute = AFileNewExecute 717 718 ShortCut = 16462 718 719 end -
trunk/StudioPackage/Forms/UFormMain.pas
r11 r13 105 105 procedure AExitExecute(Sender: TObject); 106 106 procedure AFileCloseExecute(Sender: TObject); 107 procedure AFileNewExecute(Sender: TObject); 107 108 procedure AFileOpenExecute(Sender: TObject); 108 109 procedure AViewModulesExecute(Sender: TObject); … … 115 116 procedure DockInit; 116 117 public 117 procedure Open FileExecute(OpenedFile: TOpenedFile);118 procedure OpenedFileChange(Sender: TObject); 118 119 end; 119 120 … … 137 138 procedure TFormMain.AFileCloseExecute(Sender: TObject); 138 139 begin 139 // DataModule1.OpenedFiles.Close(DataModule1.OpenedFiles.Selected); 140 DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected.FileName); 141 end; 142 143 procedure TFormMain.AFileNewExecute(Sender: TObject); 144 begin 145 DataModule1.OpenedFiles.NewFile; 140 146 end; 141 147 … … 185 191 }end; 186 192 187 procedure TFormMain.Open FileExecute(OpenedFile: TOpenedFile);193 procedure TFormMain.OpenedFileChange(Sender: TObject); 188 194 var 189 195 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; 197 begin 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; 195 211 end; 196 212 -
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.