mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 15:21:26 +01:00 
			
		
		
		
	Move function LoadProjectIconIntoImages from ProjectIntf to IDEUtils. Eliminate LCL dependency from ProjectIntf.
git-svn-id: trunk@58242 -
This commit is contained in:
		
							parent
							
								
									962ded835b
								
							
						
					
					
						commit
						ff1599f57a
					
				| @ -30,9 +30,16 @@ unit favorites_impl; | |||||||
| interface | interface | ||||||
| 
 | 
 | ||||||
| uses | uses | ||||||
|   Classes, SysUtils, ToolBarIntf, IDEImagesIntf, Graphics, PackageIntf, |   Classes, SysUtils, | ||||||
|   Menus, LazIDEIntf, ProjectIntf, Laz2_XMLCfg, IDEOptionsIntf, |   // LCL | ||||||
|   IDECommands, ComCtrls, favoritesstr, ImgList, LazFileUtils; |   Graphics, ComCtrls, Menus, ImgList, | ||||||
|  |   // LazUtils | ||||||
|  |   LazFileUtils, Laz2_XMLCfg, | ||||||
|  |   // IdeIntf | ||||||
|  |   ToolBarIntf, IDEImagesIntf, LazIDEIntf, ProjectIntf, IDEOptionsIntf, | ||||||
|  |   IDECommands, IDEUtils, | ||||||
|  |   // Favorites | ||||||
|  |   favoritesstr; | ||||||
| 
 | 
 | ||||||
| type | type | ||||||
|   TFavoritesHandler = class |   TFavoritesHandler = class | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ interface | |||||||
| uses | uses | ||||||
|   Classes, SysUtils, |   Classes, SysUtils, | ||||||
|   // LCL |   // LCL | ||||||
|   StdCtrls, |   StdCtrls, ImgList, Graphics, | ||||||
|   // LazUtils |   // LazUtils | ||||||
|   LazUTF8, LazFileUtils; |   LazUTF8, LazFileUtils; | ||||||
| 
 | 
 | ||||||
| @ -30,6 +30,9 @@ type | |||||||
| function IndexInStringList(List: TStrings; Cmp: TCmpStrType; s: string): integer; | function IndexInStringList(List: TStrings; Cmp: TCmpStrType; s: string): integer; | ||||||
| procedure SetComboBoxText(AComboBox: TComboBox; const AText: String; | procedure SetComboBoxText(AComboBox: TComboBox; const AText: String; | ||||||
|                           Cmp: TCmpStrType; MaxCount: integer = 1000); |                           Cmp: TCmpStrType; MaxCount: integer = 1000); | ||||||
|  | function LoadProjectIconIntoImages(const ProjFile: string; | ||||||
|  |   const Images: TCustomImageList; const Index: TStringList): Integer; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| implementation | implementation | ||||||
| 
 | 
 | ||||||
| @ -68,5 +71,50 @@ begin | |||||||
|   AComboBox.Text := AText; |   AComboBox.Text := AText; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
|  | type | ||||||
|  |   TLoadProjectIconIntoImagesObject = class | ||||||
|  |     ImageIndex: Integer; | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  | function LoadProjectIconIntoImages(const ProjFile: string; | ||||||
|  |   const Images: TCustomImageList; const Index: TStringList): Integer; | ||||||
|  | var | ||||||
|  |   xIconFile: String; | ||||||
|  |   xIcon: TIcon; | ||||||
|  |   I: Integer; | ||||||
|  |   xObj: TLoadProjectIconIntoImagesObject; | ||||||
|  | begin | ||||||
|  |   //ToDo: better index | ||||||
|  | 
 | ||||||
|  |   I := Index.IndexOf(ProjFile); | ||||||
|  |   if I >= 0 then | ||||||
|  |     Exit(TLoadProjectIconIntoImagesObject(Index.Objects[I]).ImageIndex); | ||||||
|  | 
 | ||||||
|  |   if not Index.Sorted or (Index.Count = 0) then | ||||||
|  |   begin // initialize index | ||||||
|  |     Index.Sorted := True; | ||||||
|  |     Index.Duplicates := dupIgnore; | ||||||
|  |     Index.CaseSensitive := False; | ||||||
|  |     Index.OwnsObjects := True; | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  |   Result := -1; | ||||||
|  |   xIconFile := ChangeFileExt(ProjFile, '.ico'); | ||||||
|  |   if FileExists(xIconFile) then | ||||||
|  |   begin | ||||||
|  |     xIcon := TIcon.Create; | ||||||
|  |     try | ||||||
|  |       xIcon.LoadFromFile(xIconFile); | ||||||
|  |       Result := Images.AddIcon(xIcon); | ||||||
|  |     finally | ||||||
|  |       xIcon.Free; | ||||||
|  |     end; | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  |   xObj := TLoadProjectIconIntoImagesObject.Create; | ||||||
|  |   xObj.ImageIndex := Result; | ||||||
|  |   Index.AddObject(ProjFile, xObj); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
| end. | end. | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -18,12 +18,9 @@ interface | |||||||
| uses | uses | ||||||
|   Classes, SysUtils, Contnrs, |   Classes, SysUtils, Contnrs, | ||||||
|   // LazUtils |   // LazUtils | ||||||
|   FileUtil, LazFileUtils, LazFileCache, LazMethodList, AvgLvlTree, |   FileUtil, LazFileUtils, LazFileCache, LazMethodList, UITypes, AvgLvlTree, | ||||||
|   // LCL |  | ||||||
|   Controls, Forms, ImgList, Graphics, |  | ||||||
|   // IdeIntf |   // IdeIntf | ||||||
|   IDEOptionsIntf, NewItemIntf, ProjPackIntf, CompOptsIntf, IDEImagesIntf, |   IDEOptionsIntf, NewItemIntf, ProjPackIntf, CompOptsIntf, ObjInspStrConsts; | ||||||
|   ObjInspStrConsts; |  | ||||||
| 
 | 
 | ||||||
| const | const | ||||||
|   FileDescGroupName = 'File'; |   FileDescGroupName = 'File'; | ||||||
| @ -638,9 +635,6 @@ const | |||||||
|                          pfMainUnitHasTitleStatement, |                          pfMainUnitHasTitleStatement, | ||||||
|                          pfMainUnitHasScaledStatement]; |                          pfMainUnitHasScaledStatement]; | ||||||
| 
 | 
 | ||||||
| function LoadProjectIconIntoImages(const ProjFile: string; |  | ||||||
|   const Images: TCustomImageList; const Index: TStringList): Integer; |  | ||||||
| 
 |  | ||||||
| function ProjectFlagsToStr(Flags: TProjectFlags): string; | function ProjectFlagsToStr(Flags: TProjectFlags): string; | ||||||
| function StrToProjectSessionStorage(const s: string): TProjectSessionStorage; | function StrToProjectSessionStorage(const s: string): TProjectSessionStorage; | ||||||
| function CompilationExecutableTypeNameToType(const s: string | function CompilationExecutableTypeNameToType(const s: string | ||||||
| @ -668,9 +662,9 @@ procedure RegisterProjectDescriptor(ProjDesc: TProjectDescriptor; | |||||||
|   Description: A brief summary of your form class as it appears in the New... dialog |   Description: A brief summary of your form class as it appears in the New... dialog | ||||||
|   Units: A list of units to add the uses clause of a unit with your form class |   Units: A list of units to add the uses clause of a unit with your form class | ||||||
|     (Typically just the name of the unit defining your form class) } |     (Typically just the name of the unit defining your form class) } | ||||||
| procedure RegisterForm(const Package: string; FormClass: TCustomFormClass; | {procedure RegisterForm(const Package: string; FormClass: TCustomFormClass; | ||||||
|   const Category, Caption, Description, Units: string); |   const Category, Caption, Description, Units: string); | ||||||
| 
 | } | ||||||
| 
 | 
 | ||||||
| implementation | implementation | ||||||
| 
 | 
 | ||||||
| @ -764,51 +758,6 @@ begin | |||||||
|   Result:=ProjectDescriptors.FindByName(ProjDescNameEmpty); |   Result:=ProjectDescriptors.FindByName(ProjDescNameEmpty); | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| type |  | ||||||
|   TLoadProjectIconIntoImagesObject = class |  | ||||||
|     ImageIndex: Integer; |  | ||||||
|   end; |  | ||||||
| 
 |  | ||||||
| function LoadProjectIconIntoImages(const ProjFile: string; |  | ||||||
|   const Images: TCustomImageList; const Index: TStringList): Integer; |  | ||||||
| var |  | ||||||
|   xIconFile: String; |  | ||||||
|   xIcon: TIcon; |  | ||||||
|   I: Integer; |  | ||||||
|   xObj: TLoadProjectIconIntoImagesObject; |  | ||||||
| begin |  | ||||||
|   //ToDo: better index |  | ||||||
| 
 |  | ||||||
|   I := Index.IndexOf(ProjFile); |  | ||||||
|   if I >= 0 then |  | ||||||
|     Exit(TLoadProjectIconIntoImagesObject(Index.Objects[I]).ImageIndex); |  | ||||||
| 
 |  | ||||||
|   if not Index.Sorted or (Index.Count = 0) then |  | ||||||
|   begin // initialize index |  | ||||||
|     Index.Sorted := True; |  | ||||||
|     Index.Duplicates := dupIgnore; |  | ||||||
|     Index.CaseSensitive := False; |  | ||||||
|     Index.OwnsObjects := True; |  | ||||||
|   end; |  | ||||||
| 
 |  | ||||||
|   Result := -1; |  | ||||||
|   xIconFile := ChangeFileExt(ProjFile, '.ico'); |  | ||||||
|   if FileExists(xIconFile) then |  | ||||||
|   begin |  | ||||||
|     xIcon := TIcon.Create; |  | ||||||
|     try |  | ||||||
|       xIcon.LoadFromFile(xIconFile); |  | ||||||
|       Result := Images.AddIcon(xIcon); |  | ||||||
|     finally |  | ||||||
|       xIcon.Free; |  | ||||||
|     end; |  | ||||||
|   end; |  | ||||||
| 
 |  | ||||||
|   xObj := TLoadProjectIconIntoImagesObject.Create; |  | ||||||
|   xObj.ImageIndex := Result; |  | ||||||
|   Index.AddObject(ProjFile, xObj); |  | ||||||
| end; |  | ||||||
| 
 |  | ||||||
| function ProjectFlagsToStr(Flags: TProjectFlags): string; | function ProjectFlagsToStr(Flags: TProjectFlags): string; | ||||||
| var f: TProjectFlag; | var f: TProjectFlag; | ||||||
| begin | begin | ||||||
| @ -1628,7 +1577,7 @@ begin | |||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| { TCustomFormDescriptor } | { TCustomFormDescriptor } | ||||||
| 
 | { | ||||||
| type | type | ||||||
|   TCustomFormDescriptor = class(TFileDescPascalUnitWithResource) |   TCustomFormDescriptor = class(TFileDescPascalUnitWithResource) | ||||||
|   private |   private | ||||||
| @ -1676,9 +1625,9 @@ begin | |||||||
|   Result := inherited GetInterfaceUsesSection |   Result := inherited GetInterfaceUsesSection | ||||||
|     + ', Controls, Forms,'#13#10 + '  ' + FUnits; |     + ', Controls, Forms,'#13#10 + '  ' + FUnits; | ||||||
| end; | end; | ||||||
| 
 | } | ||||||
| { RegisterForm } | { RegisterForm } | ||||||
| 
 | { | ||||||
| procedure RegisterForm(const Package: string; FormClass: TCustomFormClass; | procedure RegisterForm(const Package: string; FormClass: TCustomFormClass; | ||||||
|   const Category, Caption, Description, Units: string); |   const Category, Caption, Description, Units: string); | ||||||
| begin | begin | ||||||
| @ -1688,7 +1637,7 @@ begin | |||||||
|   RegisterProjectFileDescriptor(TCustomFormDescriptor.Create(Package, FormClass, |   RegisterProjectFileDescriptor(TCustomFormDescriptor.Create(Package, FormClass, | ||||||
|     Caption, Description, Units), Category); |     Caption, Description, Units), Category); | ||||||
| end; | end; | ||||||
| 
 | } | ||||||
| initialization | initialization | ||||||
|   ProjectFileDescriptors:=nil; |   ProjectFileDescriptors:=nil; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -67,7 +67,7 @@ uses | |||||||
|   // IDEIntf |   // IDEIntf | ||||||
|   IDEImagesIntf, SrcEditorIntf, LazIDEIntf, MenuIntf, NewItemIntf, PackageIntf, |   IDEImagesIntf, SrcEditorIntf, LazIDEIntf, MenuIntf, NewItemIntf, PackageIntf, | ||||||
|   IDECommands, IDEWindowIntf, ProjectIntf, ToolBarIntf, ObjectInspector, |   IDECommands, IDEWindowIntf, ProjectIntf, ToolBarIntf, ObjectInspector, | ||||||
|   PropEdits, IDEDialogs, EditorSyntaxHighlighterDef, |   PropEdits, IDEDialogs, IDEUtils, EditorSyntaxHighlighterDef, | ||||||
|   // IDE |   // IDE | ||||||
|   LazConf, LazarusIDEStrConsts, Project, BuildManager, IDEProcs, |   LazConf, LazarusIDEStrConsts, Project, BuildManager, IDEProcs, | ||||||
|   EnvironmentOpts, EditorOptions, CompilerOptions, SourceEditor, SourceSynEditor, |   EnvironmentOpts, EditorOptions, CompilerOptions, SourceEditor, SourceSynEditor, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 juha
						juha