Changeset 15
- Timestamp:
- Aug 6, 2012, 2:35:22 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 15 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Studio/LibreDevelopStudio.lpi
r11 r15 33 33 </local> 34 34 </RunParams> 35 <RequiredPackages Count=" 6">35 <RequiredPackages Count="7"> 36 36 <Item1> 37 <PackageName Value="LD ModuleProject"/>37 <PackageName Value="LDStudioCommon"/> 38 38 </Item1> 39 39 <Item2> 40 <PackageName Value="LDModuleP ascal"/>40 <PackageName Value="LDModuleProject"/> 41 41 </Item2> 42 42 <Item3> 43 <PackageName Value="LDModule Brainfuck"/>43 <PackageName Value="LDModulePascal"/> 44 44 </Item3> 45 45 <Item4> 46 <PackageName Value="LDModule Debug"/>46 <PackageName Value="LDModuleBrainfuck"/> 47 47 </Item4> 48 48 <Item5> 49 <PackageName Value="L ibreDevelopStudio"/>49 <PackageName Value="LDModuleDebug"/> 50 50 </Item5> 51 51 <Item6> 52 <PackageName Value="LibreDevelopStudio"/> 53 </Item6> 54 <Item7> 52 55 <PackageName Value="LCL"/> 53 </Item 6>56 </Item7> 54 57 </RequiredPackages> 55 58 <Units Count="2"> -
trunk/Studio/UCore.pas
r11 r15 47 47 begin 48 48 with DataModule1.ModuleManager do begin 49 RegisterModule(TLDModuleProject.Create, True); 50 RegisterModule(TLDModulePascal.Create, True); 51 RegisterModule(TLDModuleBrainfuck.Create, True); 49 52 RegisterModule(TLDModuleDebug.Create, True); 50 RegisterModule(TLDModuleBrainfuck.Create, True);51 RegisterModule(TLDModulePascal.Create, True);52 RegisterModule(TLDModuleProject.Create, True);53 53 InstallMarked; 54 54 end; -
trunk/StudioCommon/LDStudioCommon.lpk
r14 r15 28 28 </Item2> 29 29 </Files> 30 <i18n> 31 <EnableI18N Value="True"/> 32 <OutDir Value="Languages"/> 33 <EnableI18NForLFM Value="True"/> 34 </i18n> 30 35 <Type Value="RunAndDesignTime"/> 31 <RequiredPkgs Count=" 4">36 <RequiredPkgs Count="5"> 32 37 <Item1> 33 <PackageName Value=" TemplateGenerics"/>38 <PackageName Value="Common"/> 34 39 </Item1> 35 40 <Item2> 36 <PackageName Value=" LCL"/>41 <PackageName Value="TemplateGenerics"/> 37 42 </Item2> 38 43 <Item3> 39 <PackageName Value=" ModularSystem"/>44 <PackageName Value="LCL"/> 40 45 </Item3> 41 46 <Item4> 47 <PackageName Value="ModularSystem"/> 48 </Item4> 49 <Item5> 42 50 <PackageName Value="FCL"/> 43 </Item 4>51 </Item5> 44 52 </RequiredPkgs> 45 53 <UsageOptions> -
trunk/StudioCommon/ULDStudioAPI.pas
r14 r15 7 7 uses 8 8 Classes, SysUtils, UModularSystem, ActnList, Menus, Forms, USource, 9 SpecializedList ;9 SpecializedList, URegistry; 10 10 11 11 type … … 19 19 TUnregisterMainMenuItemEvent = procedure (MenuItem: TMenuItem) of object; 20 20 TDockFormEvent = procedure (Form: TForm; Target: TDockTarget) of object; 21 TGetRegistryContextEvent = function: TRegistryContext of object; 22 TRegisterFileTemplateEvent = procedure (Template: TFileTemplate) of object; 21 23 22 24 { TLDStudioAPI } … … 25 27 private 26 28 FOnDockForm: TDockFormEvent; 29 FOnGetRegistryContext: TGetRegistryContextEvent; 27 30 FOnOpenFile: TOpenFileEvent; 28 31 FOnRegisterAction: TRegisterActionEvent; 32 FOnRegisterFileTemplate: TRegisterFileTemplateEvent; 29 33 FOnRegisterFileType: TRegisterFileTypeEvent; 30 34 FOnRegisterForm: TRegisterFormEvent; 31 35 FOnRegisterMainMenuItem: TRegisterMainMenuItemEvent; 32 36 FOnUnregisterAction: TRegisterActionEvent; 37 FOnUnregisterFileTemplate: TRegisterFileTemplateEvent; 33 38 FOnUnregisterFileType: TRegisterFileTypeEvent; 34 39 FOnUnregisterForm: TRegisterFormEvent; … … 42 47 procedure RegisterFileType(FileType: TSourceType); 43 48 procedure UnregisterFileType(FileType: TSourceType); 49 procedure RegisterFileTemplate(Template: TFileTemplate); 50 procedure UnregisterFileTemplate(Template: TFileTemplate); 44 51 procedure RegisterForm(Form: TForm); 45 52 procedure UnregisterForm(Form: TForm); … … 50 57 procedure UnregisterMainMenuItem(MenuItem: TMenuItem); 51 58 procedure DockForm(Form: TForm; Target: TDockTarget); 52 59 function GetRegistryContext: TRegistryContext; 53 60 published 54 61 // API handling … … 71 78 read FOnUnregisterMainMenuItem write FOnUnregisterMainMenuItem; 72 79 property OnDockForm: TDockFormEvent read FOnDockForm write FOnDockForm; 80 property OnGetRegistryContext: TGetRegistryContextEvent 81 read FOnGetRegistryContext write FOnGetRegistryContext; 82 property OnRegisterFileTemplate: TRegisterFileTemplateEvent 83 read FOnRegisterFileTemplate write FOnRegisterFileTemplate; 84 property OnUnregisterFileTemplate: TRegisterFileTemplateEvent 85 read FOnUnregisterFileTemplate write FOnUnregisterFileTemplate; 73 86 end; 74 87 … … 110 123 if Assigned(FOnUnregisterFileType) then 111 124 FOnUnregisterFileType(FileType); 125 end; 126 127 procedure TLDStudioAPI.RegisterFileTemplate(Template: TFileTemplate); 128 begin 129 if Assigned(FOnRegisterFileTemplate) then 130 FOnRegisterFileTemplate(Template); 131 end; 132 133 procedure TLDStudioAPI.UnregisterFileTemplate(Template: TFileTemplate); 134 begin 135 if Assigned(FOnUnregisterFileTemplate) then 136 FOnUnregisterFileTemplate(Template); 112 137 end; 113 138 … … 155 180 end; 156 181 182 function TLDStudioAPI.GetRegistryContext: TRegistryContext; 183 begin 184 if Assigned(FOnGetRegistryContext) then 185 Result := FOnGetRegistryContext(); 186 end; 187 157 188 end. 158 189 -
trunk/StudioCommon/USource.pas
r8 r15 6 6 7 7 uses 8 Classes, SysUtils, SpecializedList ;8 Classes, SysUtils, SpecializedList, Forms; 9 9 10 10 type 11 12 { TSourceType } 13 11 14 TSourceType = class 12 15 Extension: string; 13 16 Title: string; 17 Form: TForm; 18 constructor Create; virtual; 14 19 end; 20 21 TFileTypeClass = class of TSourceType; 15 22 16 23 { TFileTypes } … … 20 27 end; 21 28 29 { TSource } 30 22 31 TSource = class 23 Name: string; 32 private 33 FName: string; 34 procedure SetName(AValue: string); 35 public 36 Modified: Boolean; 37 Form: TForm; 38 property Name: string read FName write SetName; 24 39 end; 25 40 … … 29 44 Items: TListObject; // TListObject<TSource> 30 45 Main: TSource; 46 end; 47 48 { TFileTemplate } 49 50 TFileTemplate = class 51 public 52 Name: string; 53 Description: TStringList; 54 FileTypeClass: TSourceType; 55 constructor Create; virtual; 56 destructor Destroy; override; 57 function Execute: TSource; virtual; 58 end; 59 60 TFileTemplates = class(TListObject) 31 61 end; 32 62 … … 54 84 TConvertorClass = class of TConvertor; 55 85 86 { TSourceText } 87 56 88 TSourceText = class(TSource) 57 Content: string; 58 InMemory: Boolean; 89 private 90 public 91 Loaded: Boolean; 92 Content: TStringList; 93 constructor Create; 94 destructor Destroy; override; 59 95 end; 96 60 97 61 98 … … 64 101 resourcestring 65 102 SAllFiles = 'All files'; 103 104 { TSourceType } 105 106 constructor TSourceType.Create; 107 begin 108 inherited; 109 end; 110 111 procedure TSource.SetName(AValue: string); 112 begin 113 if FName = AValue then Exit; 114 FName := AValue; 115 if Assigned(Form) then 116 Form.Caption := ExtractFileName(FName); 117 end; 118 119 120 { TFileTemplate } 121 122 constructor TFileTemplate.Create; 123 begin 124 Description := TStringList.Create; 125 end; 126 127 destructor TFileTemplate.Destroy; 128 begin 129 Description.Free; 130 inherited Destroy; 131 end; 132 133 function TFileTemplate.Execute: TSource; 134 begin 135 136 end; 137 66 138 67 139 { TFileTypes } … … 97 169 end; 98 170 171 { TSourceText } 172 173 constructor TSourceText.Create; 174 begin 175 Content := TStringList.Create; 176 end; 177 178 destructor TSourceText.Destroy; 179 begin 180 Content.Free; 181 inherited Destroy; 182 end; 183 99 184 end. 100 185 -
trunk/StudioModules/LDModuleBrainfuck/UBrainfuckCode.pas
r7 r15 62 62 TSourceBrainFuck(Output).Code.Clear; 63 63 Index := 0; 64 Code := TSourceText(Input).Content ;64 Code := TSourceText(Input).Content.Text; 65 65 for I := 1 to Length(Code) do begin 66 66 case Code[I] of -
trunk/StudioModules/LDModuleDebug/LDModuleDebug.lpk
r5 r15 39 39 </Item5> 40 40 </Files> 41 <i18n> 42 <EnableI18N Value="True"/> 43 <OutDir Value="Languages"/> 44 <EnableI18NForLFM Value="True"/> 45 </i18n> 41 46 <Type Value="RunAndDesignTime"/> 42 47 <RequiredPkgs Count="3"> -
trunk/StudioModules/LDModulePascal/LDModulePascal.lpk
r8 r15 8 8 <PathDelim Value="\"/> 9 9 <SearchPaths> 10 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS) \"/>10 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 11 11 </SearchPaths> 12 12 <Other> … … 24 24 </Files> 25 25 <Type Value="RunAndDesignTime"/> 26 <RequiredPkgs Count=" 2">26 <RequiredPkgs Count="3"> 27 27 <Item1> 28 <PackageName Value="LD StudioCommon"/>28 <PackageName Value="LDModuleProject"/> 29 29 </Item1> 30 30 <Item2> 31 <PackageName Value="LDStudioCommon"/> 32 </Item2> 33 <Item3> 31 34 <PackageName Value="FCL"/> 32 </Item 2>35 </Item3> 33 36 </RequiredPkgs> 34 37 <UsageOptions> -
trunk/StudioModules/LDModulePascal/ULDModulePascal.pas
r12 r15 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, USource ;8 Classes, SysUtils, UModularSystem, USource, UProject; 9 9 10 10 type 11 { TProjectTemplateConsoleApp } 12 13 TProjectTemplateConsoleApp = class(TFileTemplate) 14 constructor Create; override; 15 function Execute: TSource; override; 16 end; 17 18 { TProjectTemplateGUIApp } 19 20 TProjectTemplateGUIApp = class(TFileTemplate) 21 constructor Create; override; 22 function Execute: TSource; override; 23 end; 24 25 { TProjectTemplatePackage } 26 27 TProjectTemplatePackage = class(TFileTemplate) 28 constructor Create; override; 29 function Execute: TSource; override; 30 end; 31 32 { TProjectTemplateUnit } 33 34 TProjectTemplateUnit = class(TFileTemplate) 35 constructor Create; override; 36 function Execute: TSource; override; 37 end; 11 38 12 39 { TLDModulePascal } … … 15 42 private 16 43 PasFileType: TSourceType; 44 ProjectTemplateConsoleApp: TProjectTemplateConsoleApp; 45 ProjectTemplateGUIApp: TProjectTemplateGUIApp; 46 ProjectTemplateUnit: TProjectTemplateUnit; 17 47 public 18 48 constructor Create; override; … … 48 78 PasFileType.Title := 'Pascal source'; 49 79 RegisterFileType(PasFileType); 80 ProjectTemplateConsoleApp := TProjectTemplateConsoleApp.Create; 81 RegisterFileTemplate(ProjectTemplateConsoleApp); 82 ProjectTemplateGUIApp := TProjectTemplateGUIApp.Create; 83 RegisterFileTemplate(ProjectTemplateGUIApp); 84 ProjectTemplateUnit := TProjectTemplateUnit.Create; 85 RegisterFileTemplate(ProjectTemplateUnit); 50 86 end; 51 87 inherited Install; … … 56 92 inherited Uninstall; 57 93 with TLDStudioAPI(API) do begin 94 RegisterFileTemplate(ProjectTemplateUnit); 95 FreeAndNil(ProjectTemplateUnit); 96 UnregisterFileTemplate(ProjectTemplateGUIApp); 97 FreeAndNil(ProjectTemplateGUIApp); 98 UnregisterFileTemplate(ProjectTemplateConsoleApp); 99 FreeAndNil(ProjectTemplateConsoleApp); 58 100 UnregisterFileType(PasFileType); 59 PasFileType.Free; 60 end; 101 FreeAndNil(PasFileType); 102 end; 103 end; 104 105 resourcestring 106 SConsoleApplication = 'Console application'; 107 SUnit = 'Unit'; 108 SPackage = 'Package'; 109 SGUIApplication = 'GUI application'; 110 111 { TProjectTemplateUnit } 112 113 constructor TProjectTemplateUnit.Create; 114 begin 115 inherited Create; 116 Name := SUnit; 117 //FileTypeClass := TSourceText; 118 end; 119 120 function TProjectTemplateUnit.Execute: TSource; 121 var 122 NewFile: TSource; 123 begin 124 //inherited InitProject(Project); 125 Result := TSourceText.Create; 126 Result.Name := 'Unit1.pas'; 127 with TSourceText(Result).Content do begin 128 Add('unit Unit1;'); 129 Add(''); 130 Add('interface'); 131 Add(''); 132 Add('implementation'); 133 Add(''); 134 Add('end.'); 135 end; 136 end; 137 138 { TProjectTemplatePackage } 139 140 constructor TProjectTemplatePackage.Create; 141 begin 142 inherited Create; 143 Name := SPackage; 144 end; 145 146 function TProjectTemplatePackage.Execute: TSource; 147 var 148 NewFile: TSourceText; 149 begin 150 { Result := TProject.Create; 151 Result.Name := 'Package1'; 152 NewFile := TSourceText.Create; 153 NewFile.Name := 'Package1.bpl'; 154 with NewFile.Content do begin 155 Add('package Package1;'); 156 Add(''); 157 Add('requires'); 158 Add(' RTL;'); 159 Add(''); 160 Add('end.'); 161 end; 162 TProject(Result).Files.Add(); 163 TProject(Result).MainSource := NewFile; 164 }end; 165 166 { TProjectTemplateGUIApp } 167 168 constructor TProjectTemplateGUIApp.Create; 169 begin 170 inherited Create; 171 Name := SGUIApplication; 172 end; 173 174 function TProjectTemplateGUIApp.Execute: TSource; 175 var 176 NewFile: TProjectFile; 177 begin 178 { inherited InitProject(Project); 179 NewFile := Project.Files.AddFile('Project1.dpr'); 180 with NewFile.Source do begin 181 Add('program Project1;'); 182 Add(''); 183 Add('uses'); 184 Add(' GUI;'); 185 Add(''); 186 Add('var'); 187 Add(' Application: TApplication'); 188 Add('begin'); 189 Add(' Application := TApplication.Create;'); 190 Add(' Application.Run;'); 191 Add(' Application.Free;'); 192 Add('end.'); 193 end; 194 Project.MainSource := NewFile; 195 }end; 196 197 { TProjectTemplateConsoleApp } 198 199 constructor TProjectTemplateConsoleApp.Create; 200 begin 201 inherited Create; 202 Name := SConsoleApplication; 203 end; 204 205 function TProjectTemplateConsoleApp.Execute: TSource; 206 var 207 NewFile: TProjectFile; 208 begin 209 { inherited InitProject(Project); 210 NewFile := Project.Files.AddFile('Project1.dpr'); 211 with NewFile.Source do begin 212 Add('program Project1;'); 213 Add(''); 214 Add('begin'); 215 Add('end.'); 216 end; 217 Project.MainSource := NewFile;} 61 218 end; 62 219 -
trunk/StudioModules/LDModuleProject/LDModuleProject.lpk
r11 r15 31 31 </Item3> 32 32 </Files> 33 <i18n> 34 <EnableI18N Value="True"/> 35 <OutDir Value="Languages"/> 36 <EnableI18NForLFM Value="True"/> 37 </i18n> 33 38 <Type Value="RunAndDesignTime"/> 34 <RequiredPkgs Count=" 2">39 <RequiredPkgs Count="3"> 35 40 <Item1> 36 <PackageName Value=" LDStudioCommon"/>41 <PackageName Value="Common"/> 37 42 </Item1> 38 43 <Item2> 44 <PackageName Value="LDStudioCommon"/> 45 </Item2> 46 <Item3> 39 47 <PackageName Value="FCL"/> 40 </Item 2>48 </Item3> 41 49 </RequiredPkgs> 42 50 <UsageOptions> -
trunk/StudioModules/LDModuleProject/ULDModuleProject.lfm
r12 r15 1 1 object DataModuleProject: TDataModuleProject 2 OnCreate = DataModuleCreate 2 3 OnDestroy = DataModuleDestroy 3 4 OldCreateOrder = False 4 5 Height = 328 5 HorizontalOffset = 2556 VerticalOffset = 756 HorizontalOffset = 390 7 VerticalOffset = 142 7 8 Width = 409 8 9 object ActionList1: TActionList … … 19 20 object AOpenRecent: TAction 20 21 Caption = 'Open recent' 22 OnExecute = AOpenRecentExecute 21 23 end 22 24 object ASave: TAction … … 46 48 Action = AOpen 47 49 end 48 object MenuItem 3: TMenuItem50 object MenuItemOpenRecent: TMenuItem 49 51 Action = AOpenRecent 50 52 end … … 73 75 top = 120 74 76 end 77 object LastOpenedList1: TLastOpenedList 78 MaxCount = 10 79 OnChange = LastOpenedList1Change 80 left = 125 81 top = 64 82 end 75 83 end -
trunk/StudioModules/LDModuleProject/ULDModuleProject.pas
r14 r15 7 7 uses 8 8 Classes, SysUtils, FileUtil, ActnList, Menus, Dialogs, UModularSystem, 9 U Project;9 ULastOpenedList, UProject, URegistry, USource; 10 10 11 11 type … … 22 22 ANew: TAction; 23 23 ActionList1: TActionList; 24 LastOpenedList1: TLastOpenedList; 24 25 MenuItem1: TMenuItem; 25 26 MenuItem2: TMenuItem; 26 MenuItem 3: TMenuItem;27 MenuItemOpenRecent: TMenuItem; 27 28 MenuItem4: TMenuItem; 28 29 MenuItem5: TMenuItem; … … 36 37 procedure ANewExecute(Sender: TObject); 37 38 procedure AOpenExecute(Sender: TObject); 39 procedure AOpenRecentExecute(Sender: TObject); 38 40 procedure AProjectManagerExecute(Sender: TObject); 39 41 procedure ASaveAsExecute(Sender: TObject); 40 42 procedure ASaveExecute(Sender: TObject); 43 procedure DataModuleCreate(Sender: TObject); 41 44 procedure DataModuleDestroy(Sender: TObject); 45 procedure LastOpenedList1Change(Sender: TObject); 42 46 private 43 47 { private declarations } … … 45 49 Project: TProject; 46 50 procedure UpdateInterface; 51 procedure LoadFromRegistry(Context: TRegistryContext); 52 procedure SaveToRegistry(Context: TRegistryContext); 47 53 end; 48 54 … … 51 57 TLDModuleProject = class(TModule) 52 58 private 59 ProjectFileType: TSourceType; 53 60 public 54 61 constructor Create; override; … … 93 100 end; 94 101 102 procedure TDataModuleProject.DataModuleCreate(Sender: TObject); 103 begin 104 105 end; 106 95 107 procedure TDataModuleProject.DataModuleDestroy(Sender: TObject); 96 108 begin 97 109 AClose.Execute; 110 end; 111 112 procedure TDataModuleProject.LastOpenedList1Change(Sender: TObject); 113 begin 114 LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, AOpenRecentExecute); 98 115 end; 99 116 … … 103 120 ASaveAs.Enabled := Assigned(Project); 104 121 AClose.Enabled := Assigned(Project); 122 end; 123 124 procedure TDataModuleProject.LoadFromRegistry(Context: TRegistryContext); 125 begin 126 LastOpenedList1.LoadFromRegistry(Context.RootKey, Context.Key + '\RecentFile'); 127 end; 128 129 procedure TDataModuleProject.SaveToRegistry(Context: TRegistryContext); 130 begin 131 LastOpenedList1.SaveToRegistry(Context.RootKey, Context.Key + '\RecentFile'); 105 132 end; 106 133 … … 122 149 procedure TDataModuleProject.AOpenExecute(Sender: TObject); 123 150 begin 124 OpenDialog1.FileName := Project.FileName; 151 if Assigned(Project) then 152 OpenDialog1.FileName := Project.FileName; 125 153 if OpenDialog1.Execute then begin 126 154 Project.FileName := OpenDialog1.FileName; … … 128 156 UpdateInterface; 129 157 end; 158 end; 159 160 procedure TDataModuleProject.AOpenRecentExecute(Sender: TObject); 161 begin 162 130 163 end; 131 164 … … 150 183 DataModuleProject.PopupMenu1.Items.Caption := SProject; 151 184 RegisterMainMenuItem(DataModuleProject.PopupMenu1.Items, nil, 1); 185 DataModuleProject.LoadFromRegistry(RegContext(GetRegistryContext.RootKey, 186 GetRegistryContext.Key + '\Project')); 187 DataModuleProject.UpdateInterface; 188 ProjectFileType := TSourceType.Create; 189 ProjectFileType.Extension := '.ldp'; 190 ProjectFileType.Title := 'LibreDevelop project'; 191 RegisterFileType(ProjectFileType); 152 192 end; 153 193 inherited; … … 158 198 inherited; 159 199 with TLDStudioAPI(API) do begin 200 UnregisterFileType(ProjectFileType); 201 DataModuleProject.SaveToRegistry(RegContext(GetRegistryContext.RootKey, 202 GetRegistryContext.Key + '\Project')); 160 203 UnregisterMainMenuItem(DataModuleProject.PopupMenu1.Items); 161 204 FreeAndNil(DataModuleProject); -
trunk/StudioModules/LDModuleProject/UProject.pas
r11 r15 7 7 uses 8 8 Classes, SysUtils, Dialogs, DOM, XMLWrite, XMLRead, FileUtil, 9 SpecializedList ;9 SpecializedList, USource; 10 10 11 11 const … … 71 71 end; 72 72 73 TProject = class 73 TProject = class(TSource) 74 74 private 75 75 FModified: Boolean; -
trunk/StudioPackage/Forms/UFormMain.lfm
r14 r15 1 1 object FormMain: TFormMain 2 Left = 1502 Left = 240 3 3 Height = 520 4 Top = 1 124 Top = 108 5 5 Width = 747 6 6 Caption = 'LibreDevelop Studio' … … 27 27 Width = 747 28 28 Caption = 'ToolBar1' 29 Images = DataModule1.ImageListMain 29 30 TabOrder = 1 30 31 object ToolButton1: TToolButton 31 32 Left = 1 32 Hint = 'New project'33 33 Top = 2 34 Caption = 'New...' 35 ImageIndex = 4 34 Action = AFileNew 36 35 end 37 36 object ToolButton2: TToolButton 38 37 Left = 24 39 Hint = 'Open project'40 38 Top = 2 41 Caption = 'Open...' 42 ImageIndex = 8 39 Action = AFileOpen 40 DropdownMenu = PopupMenuRecentFiles 41 Style = tbsDropDown 43 42 end 44 43 object ToolButton3: TToolButton 45 Left = 47 46 Hint = 'Save project' 44 Left = 59 47 45 Top = 2 48 Caption = 'Save' 49 ImageIndex = 13 46 Action = AFileSaveAs 50 47 end 51 48 object ToolButton4: TToolButton 52 Left = 70 53 Hint = 'Close project' 49 Left = 82 54 50 Top = 2 55 Caption = 'Close' 56 ImageIndex = 3 51 Action = AFileClose 57 52 end 58 53 end … … 117 112 Action = AFileOpen 118 113 end 119 object MenuItem29: TMenuItem 120 Action = AFileOpenRecent 114 object MenuItemFileOpenRecent: TMenuItem 115 Caption = 'Open recent' 116 ImageIndex = 8 117 OnClick = MenuItemFileOpenRecentClick 121 118 end 122 119 object MenuItem30: TMenuItem … … 313 310 Caption = 'Open recent' 314 311 ImageIndex = 8 312 OnExecute = AFileOpenRecentExecute 315 313 end 316 314 object AFileSave: TAction … … 318 316 Caption = 'Save' 319 317 ImageIndex = 13 318 OnExecute = AFileSaveExecute 320 319 ShortCut = 16467 321 320 end … … 324 323 Caption = 'Save as...' 325 324 ImageIndex = 13 325 OnExecute = AFileSaveAsExecute 326 326 ShortCut = 24659 327 327 end … … 387 387 top = 272 388 388 end 389 object LastOpenedList1: TLastOpenedList 390 MaxCount = 10 391 OnChange = LastOpenedList1Change 392 left = 80 393 top = 160 394 end 395 object PopupMenuRecentFiles: TPopupMenu 396 Images = DataModule1.ImageListMain 397 left = 259 398 top = 69 399 end 389 400 end -
trunk/StudioPackage/Forms/UFormMain.lrt
r14 r15 1 1 TFORMMAIN.CAPTION=LibreDevelop Studio 2 2 TFORMMAIN.TOOLBAR1.CAPTION=ToolBar1 3 TFORMMAIN.TOOLBUTTON1.HINT=New project4 TFORMMAIN.TOOLBUTTON1.CAPTION=New...5 TFORMMAIN.TOOLBUTTON2.HINT=Open project6 TFORMMAIN.TOOLBUTTON2.CAPTION=Open...7 TFORMMAIN.TOOLBUTTON3.HINT=Save project8 TFORMMAIN.TOOLBUTTON3.CAPTION=Save9 TFORMMAIN.TOOLBUTTON4.HINT=Close project10 TFORMMAIN.TOOLBUTTON4.CAPTION=Close11 3 TFORMMAIN.MENUITEM26.CAPTION=File 4 TFORMMAIN.MENUITEMFILEOPENRECENT.CAPTION=Open recent 12 5 TFORMMAIN.MENUITEM33.CAPTION=- 13 6 TFORMMAIN.MENUITEM2.CAPTION=Edit -
trunk/StudioPackage/Forms/UFormMain.pas
r14 r15 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 9 ActnList, ComCtrls, ExtCtrls, UDataModule; 9 ActnList, ComCtrls, ExtCtrls, ULastOpenedList, UCoolTranslator, UDataModule, 10 URegistry; 10 11 11 12 type … … 44 45 AClipboardCut: TAction; 45 46 ActionListMain: TActionList; 47 LastOpenedList1: TLastOpenedList; 46 48 MainMenu: TMainMenu; 47 49 MenuItem15: TMenuItem; … … 60 62 MenuItem27: TMenuItem; 61 63 MenuItem28: TMenuItem; 62 MenuItem 29: TMenuItem;64 MenuItemFileOpenRecent: TMenuItem; 63 65 MenuItem30: TMenuItem; 64 66 MenuItem31: TMenuItem; … … 89 91 PageControlBottom: TPageControl; 90 92 PageControlCenter: TPageControl; 93 PopupMenuRecentFiles: TPopupMenu; 91 94 SaveDialogFile: TSaveDialog; 92 95 Splitter1: TSplitter; … … 102 105 procedure AFileNewExecute(Sender: TObject); 103 106 procedure AFileOpenExecute(Sender: TObject); 107 procedure AFileOpenRecentExecute(Sender: TObject); 108 procedure AFileSaveAsExecute(Sender: TObject); 109 procedure AFileSaveExecute(Sender: TObject); 104 110 procedure AViewModulesExecute(Sender: TObject); 105 111 procedure AViewSettingsExecute(Sender: TObject); … … 108 114 procedure FormDestroy(Sender: TObject); 109 115 procedure FormShow(Sender: TObject); 116 procedure LastOpenedList1Change(Sender: TObject); 117 procedure MenuItemFileOpenRecentClick(Sender: TObject); 110 118 private 111 119 procedure DockInit; 112 120 public 121 procedure UpdateInterface; 113 122 procedure OpenedFileChange(Sender: TObject); 123 procedure LoadFromRegistry(Context: TRegistryContext); 124 procedure SaveToRegistry(Context: TRegistryContext); 114 125 end; 115 126 … … 117 128 FormMain: TFormMain; 118 129 130 119 131 implementation 120 132 … … 122 134 123 135 uses 124 UFormSourceCode, UFormSettings, UFormModuleList ;136 UFormSourceCode, UFormSettings, UFormModuleList, UFormNewFile, USource; 125 137 126 138 { TFormMain } … … 133 145 procedure TFormMain.AFileCloseExecute(Sender: TObject); 134 146 begin 135 DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected .FileName);147 DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected); 136 148 end; 137 149 138 150 procedure TFormMain.AFileNewExecute(Sender: TObject); 139 begin 140 DataModule1.OpenedFiles.NewFile; 151 var 152 NewFile: TSource; 153 begin 154 if FormNewFile.ShowModal = mrOk then 155 if Assigned(FormNewFile.ListView1.Selected) then begin 156 NewFile := TFileTemplate(FormNewFile.ListView1.Selected.Data).Execute; 157 DataModule1.OpenedFiles.OpenFile(NewFile); 158 end; 141 159 end; 142 160 … … 145 163 OpenDialogFile.Filter := DataModule1.FileTypes.GetDialogFilter; 146 164 if OpenDialogFile.Execute then begin 147 DataModule1.OpenedFiles.OpenFile(OpenDialogFile.FileName); 148 end; 165 LastOpenedList1.AddItem(OpenDialogFile.FileName); 166 DataModule1.OpenedFiles.OpenFileName(OpenDialogFile.FileName); 167 end; 168 end; 169 170 procedure TFormMain.AFileOpenRecentExecute(Sender: TObject); 171 begin 172 if Sender is TMenuItem then 173 DataModule1.OpenedFiles.OpenFileName(TMenuItem(Sender).Caption); 174 end; 175 176 procedure TFormMain.AFileSaveAsExecute(Sender: TObject); 177 begin 178 SaveDialogFile.FileName := DataModule1.OpenedFiles.Selected.Name; 179 if SaveDialogFile.Execute then begin 180 LastOpenedList1.AddItem(SaveDialogFile.FileName); 181 DataModule1.OpenedFiles.Selected.Name := SaveDialogFile.FileName; 182 end; 183 end; 184 185 procedure TFormMain.AFileSaveExecute(Sender: TObject); 186 begin 187 149 188 end; 150 189 … … 177 216 begin 178 217 DockInit; 218 UpdateInterface; 219 end; 220 221 procedure TFormMain.LastOpenedList1Change(Sender: TObject); 222 begin 223 LastOpenedList1.LoadToMenuItem(PopupMenuRecentFiles.Items, AFileOpenRecentExecute); 224 LastOpenedList1.LoadToMenuItem(MenuItemFileOpenRecent, AFileOpenRecentExecute); 225 end; 226 227 procedure TFormMain.MenuItemFileOpenRecentClick(Sender: TObject); 228 begin 229 179 230 end; 180 231 … … 186 237 }end; 187 238 239 procedure TFormMain.UpdateInterface; 240 begin 241 AFileClose.Enabled := Assigned(DataModule1.OpenedFiles.Selected); 242 AFileSave.Enabled := Assigned(DataModule1.OpenedFiles.Selected); 243 AFileSaveAs.Enabled := Assigned(DataModule1.OpenedFiles.Selected); 244 end; 245 188 246 procedure TFormMain.OpenedFileChange(Sender: TObject); 189 247 var … … 193 251 with DataModule1.OpenedFiles do begin 194 252 for I := 0 to Count - 1 do 195 with T OpenedFile(Items[I]) do begin253 with TSource(Items[I]) do begin 196 254 if not Assigned(Form.Parent) then begin 197 255 NewTabSheet := PageControlCenter.AddTabSheet; 198 NewTabSheet.Caption := ExtractFileName( FileName);256 NewTabSheet.Caption := ExtractFileName(Name); 199 257 //NewTabSheet.PopupMenu := ; 200 258 Form.ManualDock(NewTabSheet, nil, alClient); … … 206 264 end; 207 265 266 procedure TFormMain.LoadFromRegistry(Context: TRegistryContext); 267 begin 268 LastOpenedList1.LoadFromRegistry(Context.RootKey, Context.Key + '\RecentFiles'); 269 end; 270 271 procedure TFormMain.SaveToRegistry(Context: TRegistryContext); 272 begin 273 LastOpenedList1.SaveToRegistry(Context.RootKey, Context.Key + '\RecentFiles'); 274 end; 275 208 276 end. 209 277 -
trunk/StudioPackage/Languages/UDataModule.po
r13 r15 6 6 msgstr "" 7 7 8 #: udatamodule.stextfile 9 msgid "Text file" 10 msgstr "" 11 -
trunk/StudioPackage/LibreDevelopStudio.lpk
r11 r15 23 23 </Other> 24 24 </CompilerOptions> 25 <Files Count=" 5">25 <Files Count="6"> 26 26 <Item1> 27 27 <Filename Value="Forms\UFormMain.pas"/> … … 44 44 <UnitName Value="UFormModuleList"/> 45 45 </Item5> 46 <Item6> 47 <Filename Value="Forms\UFormNewFile.pas"/> 48 <UnitName Value="UFormNewFile"/> 49 </Item6> 46 50 </Files> 47 51 <i18n> … … 51 55 </i18n> 52 56 <Type Value="RunAndDesignTime"/> 53 <RequiredPkgs Count=" 5">57 <RequiredPkgs Count="7"> 54 58 <Item1> 55 <PackageName Value=" LDStudioCommon"/>59 <PackageName Value="CoolTranslator"/> 56 60 </Item1> 57 61 <Item2> 58 <PackageName Value=" synedit"/>62 <PackageName Value="Common"/> 59 63 </Item2> 60 64 <Item3> 61 <PackageName Value=" TemplateGenerics"/>65 <PackageName Value="LDStudioCommon"/> 62 66 </Item3> 63 67 <Item4> 64 <PackageName Value=" LCL"/>68 <PackageName Value="synedit"/> 65 69 </Item4> 66 70 <Item5> 71 <PackageName Value="TemplateGenerics"/> 72 </Item5> 73 <Item6> 74 <PackageName Value="LCL"/> 75 </Item6> 76 <Item7> 67 77 <PackageName Value="FCL"/> 68 </Item 5>78 </Item7> 69 79 </RequiredPkgs> 70 80 <UsageOptions> -
trunk/StudioPackage/LibreDevelopStudio.pas
r11 r15 9 9 uses 10 10 UFormMain, UDataModule, UFormSourceCode, UFormSettings, UFormModuleList, 11 LazarusPackageIntf;11 UFormNewFile, LazarusPackageIntf; 12 12 13 13 implementation -
trunk/StudioPackage/UDataModule.lfm
r14 r15 733 733 OnUnregisterMainMenuItem = APIUnregisterMainMenuItem 734 734 OnDockForm = APIDockForm 735 OnGetRegistryContext = APIGetRegistryContext 736 OnRegisterFileTemplate = APIRegisterFileTemplate 737 OnUnregisterFileTemplate = APIUnregisterFileTemplate 735 738 left = 92 736 739 top = 168 737 740 end 741 object CoolTranslator1: TCoolTranslator 742 POFilesFolder = 'Languages' 743 left = 92 744 top = 8 745 end 746 object ApplicationInfo1: TApplicationInfo 747 Identification = 1 748 VersionMajor = 1 749 VersionMinor = 0 750 VersionBugFix = 0 751 VersionSuffix = 'alfa' 752 HomePage = 'http://svn.zdechov.net/trac/LibreDevelop' 753 AuthorsName = 'Chronos' 754 EmailContact = 'robie@centrum.cz' 755 AppName = 'LibreDevelop Studio' 756 ReleaseDate = 41096 757 RegistryKey = '\Software\LibreDevelop\Studio' 758 RegistryRoot = rrKeyCurrentUser 759 left = 92 760 top = 224 761 end 738 762 end -
trunk/StudioPackage/UDataModule.pas
r14 r15 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, ActnList, Controls, SpecializedList, 9 USource, UModularSystem, ULDStudioAPI, Menus, ComCtrls; 9 USource, UModularSystem, UCoolTranslator, ULDStudioAPI, Menus, ComCtrls, 10 Registry, URegistry, UApplicationInfo; 10 11 11 12 type 12 13 13 { T OpenedFile }14 15 T OpenedFile = class16 private17 FFileName: string;18 procedure SetFileName(AValue: string); 19 public20 Modified: Boolean; 21 Form: TForm;22 property FileName: string read FFileName write SetFileName;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; 23 24 end; 24 25 … … 29 30 FOnChange: TNotifyEvent; 30 31 public 31 Selected: TOpenedFile; 32 function FindByFileName(Value: string): TOpenedFile; 33 procedure CloseFile(FileName: string); 34 procedure OpenFile(FileName: string); 32 Selected: TSource; 33 function FindByFileName(Value: string): TSource; 34 procedure CloseFile(Source: TSource); 35 procedure OpenFileName(FileName: string); 36 procedure OpenFile(Source: TSource); 35 37 procedure NewFile; 36 38 property OnChange: TNotifyEvent read FOnChange write FOnChange; … … 42 44 published 43 45 ActionListRegistred: TActionList; 46 ApplicationInfo1: TApplicationInfo; 47 CoolTranslator1: TCoolTranslator; 44 48 ImageListMain: TImageList; 45 49 API: TLDStudioAPI; 46 50 procedure APIDockForm(Form: TForm; Target: TDockTarget); 51 function APIGetRegistryContext: TRegistryContext; 52 procedure APIRegisterFileTemplate(Template: TFileTemplate); 47 53 procedure APIRegisterFileType(FileType: TSourceType); 48 54 procedure APIRegisterForm(Form: TForm); … … 50 56 ParentItem: TMenuItem; Index: Integer); 51 57 procedure APIUnregisterAction(Action: TAction); 58 procedure APIUnregisterFileTemplate(Template: TFileTemplate); 52 59 procedure APIUnregisterFileType(FileType: TSourceType); 53 60 procedure APIUnregisterForm(Form: TForm); 54 61 procedure APIUnregisterMainMenuItem(MenuItem: TMenuItem); 62 procedure APIOpenFile(FileName: string); 63 procedure APIRegisterAction(Action: TAction); 55 64 procedure DataModuleCreate(Sender: TObject); 56 65 procedure DataModuleDestroy(Sender: TObject); 57 procedure APIOpenFile(FileName: string);58 procedure APIRegisterAction(Action: TAction);59 66 private 67 TextFileType: TSourceType; 68 TextFileTemplate: TTextTemplate; 69 procedure AutoOpen; 60 70 procedure DockToPageControl(PageControl: TPageControl; Form: TForm); 61 71 public 62 72 ModuleManager: TModuleManager; 63 73 FileTypes: TFileTypes; 74 FileTemplates: TFileTemplates; 64 75 OpenedFiles: TOpenedFiles; 65 end; 76 procedure LoadFromRegistry(Context: TRegistryContext); 77 procedure SaveToRegistry(Context: TRegistryContext); 78 end; 79 66 80 67 81 var … … 74 88 75 89 uses 76 UFormSourceCode, UFormMain, UFormSettings, UFormModuleList ;90 UFormSourceCode, UFormMain, UFormSettings, UFormModuleList, UFormNewFile; 77 91 78 92 resourcestring 79 93 SNewFile = 'New file'; 80 81 procedure TOpenedFile.SetFileName(AValue: string); 82 begin 83 if FFileName = AValue then Exit; 84 FFileName := AValue; 85 if Assigned(Form) then 86 Form.Caption := ExtractFileName(FFileName); 87 end; 94 STextFile = 'Text file'; 95 96 { TTextFileType } 97 98 constructor TTextFileType.Create; 99 begin 100 inherited Create; 101 Extension := '.txt'; 102 Title := 'Text file';; 103 end; 104 105 { TTextTemplate } 106 107 constructor TTextTemplate.Create; 108 begin 109 inherited Create; 110 Name := STextFile; 111 end; 112 88 113 89 114 { TOpenedFiles } 90 115 91 function TOpenedFiles.FindByFileName(Value: string): T OpenedFile;116 function TOpenedFiles.FindByFileName(Value: string): TSource; 92 117 var 93 118 I: Integer; 94 119 begin 95 120 I := 0; 96 while (I < Count) and (T OpenedFile(Items[I]).FileName <> Value) do Inc(I);97 if I < Count then Result := T OpenedFile(Items[I])121 while (I < Count) and (TSource(Items[I]).Name <> Value) do Inc(I); 122 if I < Count then Result := TSource(Items[I]) 98 123 else Result := nil; 99 124 end; 100 125 101 procedure TOpenedFiles.CloseFile(FileName: string); 102 var 103 OpenedFile: TOpenedFile; 104 begin 105 OpenedFile := FindByFileName(FileName); 106 FreeAndNil(OpenedFile.Form); 107 Remove(OpenedFile); 126 procedure TOpenedFiles.CloseFile(Source: TSource); 127 begin 128 FreeAndNil(Source.Form); 129 Remove(Source); 108 130 if Assigned(FOnChange) then FOnChange(Self); 109 131 end; 110 132 111 procedure TOpenedFiles.OpenFile(FileName: string); 112 var 113 NewFile: TOpenedFile; 114 begin 115 NewFile := TOpenedFile(AddNew(TOpenedFile.Create)); 116 NewFile.FileName := FileName; 133 procedure TOpenedFiles.OpenFileName(FileName: string); 134 var 135 NewFile: TSourceText; 136 begin 137 NewFile := TSourceText.Create; 138 NewFile.Name := FileName; 139 OpenFile(NewFile); 140 end; 141 142 procedure TOpenedFiles.OpenFile(Source: TSource); 143 begin 144 AddNew(Source); 145 Source.Form := TFormSourceCode.Create(nil); 146 Source.Form.Caption := ExtractFileName(Source.Name); 147 Source.Form.Visible := True; 148 Selected := Source; 149 if Assigned(FOnChange) then FOnChange(Self); 150 end; 151 152 procedure TOpenedFiles.NewFile; 153 var 154 NewFile: TSource; 155 begin 156 NewFile := TSourceText(AddNew(TSource.Create)); 157 NewFile.Name := SNewFile; 117 158 NewFile.Form := TFormSourceCode.Create(nil); 118 NewFile.Form.Caption := ExtractFileName(NewFile. FileName);159 NewFile.Form.Caption := ExtractFileName(NewFile.Name); 119 160 NewFile.Form.Visible := True; 120 161 Selected := NewFile; … … 122 163 end; 123 164 124 procedure TOpenedFiles.NewFile;125 var126 NewFile: TOpenedFile;127 begin128 NewFile := TOpenedFile(AddNew(TOpenedFile.Create));129 NewFile.FileName := SNewFile;130 NewFile.Form := TFormSourceCode.Create(nil);131 NewFile.Form.Caption := ExtractFileName(NewFile.FileName);132 NewFile.Form.Visible := True;133 Selected := NewFile;134 if Assigned(FOnChange) then FOnChange(Self);135 end;136 137 165 { TDataModule1 } 138 166 139 167 procedure TDataModule1.DataModuleCreate(Sender: TObject); 140 168 begin 169 FileTemplates := TFileTemplates.Create; 170 FileTemplates.OwnsObjects := False; 141 171 FileTypes := TFileTypes.Create; 142 172 FileTypes.OwnsObjects := False; … … 144 174 ModuleManager := TModuleManager.Create(nil); 145 175 ModuleManager.API := API; 176 177 TextFileType := TTextFileType.Create; 178 API.RegisterFileType(TextFileType); 179 TextFileTemplate := TTextTemplate.Create; 180 API.RegisterFileTemplate(TextFileTemplate); 146 181 147 182 FormMain := TFormMain.Create(nil); … … 151 186 FormSettings := TFormSettings.Create(nil); 152 187 FormModuleList := TFormModuleList.Create(nil); 153 188 FormNewFile := TFormNewFile.Create(nil); 189 190 LoadFromRegistry(RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey)); 191 192 DataModule1 := Self; 154 193 FormMain.Show; 194 AutoOpen; 155 195 end; 156 196 … … 191 231 end; 192 232 233 procedure TDataModule1.LoadFromRegistry(Context: TRegistryContext); 234 begin 235 with TRegistryEx.Create do 236 try 237 RootKey := Context.RootKey; 238 OpenKey(Context.Key, True); 239 240 finally 241 Free; 242 end; 243 FormMain.LoadFromRegistry(Context); 244 end; 245 246 procedure TDataModule1.SaveToRegistry(Context: TRegistryContext); 247 begin 248 with TRegistryEx.Create do 249 try 250 RootKey := Context.RootKey; 251 OpenKey(Context.Key, True); 252 253 finally 254 Free; 255 end; 256 FormMain.SaveToRegistry(Context); 257 end; 258 193 259 procedure TDataModule1.APIDockForm(Form: TForm; Target: TDockTarget); 194 260 begin … … 203 269 end; 204 270 271 function TDataModule1.APIGetRegistryContext: TRegistryContext; 272 begin 273 Result := RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey); 274 end; 275 276 procedure TDataModule1.APIRegisterFileTemplate(Template: TFileTemplate); 277 begin 278 FileTemplates.Add(Template); 279 end; 280 205 281 procedure TDataModule1.APIUnregisterAction(Action: TAction); 206 282 begin … … 208 284 end; 209 285 286 procedure TDataModule1.APIUnregisterFileTemplate(Template: TFileTemplate); 287 begin 288 FileTemplates.Remove(Template); 289 end; 290 210 291 procedure TDataModule1.APIUnregisterFileType(FileType: TSourceType); 211 292 begin … … 220 301 procedure TDataModule1.DataModuleDestroy(Sender: TObject); 221 302 begin 303 API.UnregisterFileType(TextFileType); 304 FreeAndNil(TextFileType); 305 API.UnregisterFileTemplate(TextFileTemplate); 306 FreeAndNil(TextFileTemplate); 307 308 SaveToRegistry(RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey)); 222 309 FreeAndNil(ModuleManager); 310 FreeAndNil(FormNewFile); 223 311 FreeAndNil(FormMain); 224 312 FreeAndNil(FormSourceCode); … … 227 315 FreeAndNil(OpenedFiles); 228 316 FreeAndNil(FileTypes); 317 FreeAndNil(FileTemplates); 318 end; 319 320 procedure TDataModule1.AutoOpen; 321 var 322 FileName: string; 323 begin 324 if (ParamCount > 0) then begin 325 FileName := UTF8Encode(ParamStr(1)); 326 if FileExistsUTF8(FileName) then begin 327 OpenedFiles.OpenFileName(FileName); 328 end; 329 end; 229 330 end; 230 331 231 332 procedure TDataModule1.APIOpenFile(FileName: string); 232 333 begin 233 OpenedFiles.OpenFile (FileName);334 OpenedFiles.OpenFileName(FileName); 234 335 end; 235 336
Note:
See TracChangeset
for help on using the changeset viewer.