Move function LoadProjectIconIntoImages from ProjectIntf to IDEUtils. Eliminate LCL dependency from ProjectIntf.

git-svn-id: trunk@58242 -
This commit is contained in:
juha 2018-06-13 08:33:16 +00:00
parent 962ded835b
commit ff1599f57a
4 changed files with 68 additions and 64 deletions

View File

@ -30,9 +30,16 @@ unit favorites_impl;
interface
uses
Classes, SysUtils, ToolBarIntf, IDEImagesIntf, Graphics, PackageIntf,
Menus, LazIDEIntf, ProjectIntf, Laz2_XMLCfg, IDEOptionsIntf,
IDECommands, ComCtrls, favoritesstr, ImgList, LazFileUtils;
Classes, SysUtils,
// LCL
Graphics, ComCtrls, Menus, ImgList,
// LazUtils
LazFileUtils, Laz2_XMLCfg,
// IdeIntf
ToolBarIntf, IDEImagesIntf, LazIDEIntf, ProjectIntf, IDEOptionsIntf,
IDECommands, IDEUtils,
// Favorites
favoritesstr;
type
TFavoritesHandler = class

View File

@ -16,7 +16,7 @@ interface
uses
Classes, SysUtils,
// LCL
StdCtrls,
StdCtrls, ImgList, Graphics,
// LazUtils
LazUTF8, LazFileUtils;
@ -30,6 +30,9 @@ type
function IndexInStringList(List: TStrings; Cmp: TCmpStrType; s: string): integer;
procedure SetComboBoxText(AComboBox: TComboBox; const AText: String;
Cmp: TCmpStrType; MaxCount: integer = 1000);
function LoadProjectIconIntoImages(const ProjFile: string;
const Images: TCustomImageList; const Index: TStringList): Integer;
implementation
@ -68,5 +71,50 @@ begin
AComboBox.Text := AText;
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.

View File

@ -18,12 +18,9 @@ interface
uses
Classes, SysUtils, Contnrs,
// LazUtils
FileUtil, LazFileUtils, LazFileCache, LazMethodList, AvgLvlTree,
// LCL
Controls, Forms, ImgList, Graphics,
FileUtil, LazFileUtils, LazFileCache, LazMethodList, UITypes, AvgLvlTree,
// IdeIntf
IDEOptionsIntf, NewItemIntf, ProjPackIntf, CompOptsIntf, IDEImagesIntf,
ObjInspStrConsts;
IDEOptionsIntf, NewItemIntf, ProjPackIntf, CompOptsIntf, ObjInspStrConsts;
const
FileDescGroupName = 'File';
@ -638,9 +635,6 @@ const
pfMainUnitHasTitleStatement,
pfMainUnitHasScaledStatement];
function LoadProjectIconIntoImages(const ProjFile: string;
const Images: TCustomImageList; const Index: TStringList): Integer;
function ProjectFlagsToStr(Flags: TProjectFlags): string;
function StrToProjectSessionStorage(const s: string): TProjectSessionStorage;
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
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) }
procedure RegisterForm(const Package: string; FormClass: TCustomFormClass;
{procedure RegisterForm(const Package: string; FormClass: TCustomFormClass;
const Category, Caption, Description, Units: string);
}
implementation
@ -764,51 +758,6 @@ begin
Result:=ProjectDescriptors.FindByName(ProjDescNameEmpty);
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;
var f: TProjectFlag;
begin
@ -1628,7 +1577,7 @@ begin
end;
{ TCustomFormDescriptor }
{
type
TCustomFormDescriptor = class(TFileDescPascalUnitWithResource)
private
@ -1676,9 +1625,9 @@ begin
Result := inherited GetInterfaceUsesSection
+ ', Controls, Forms,'#13#10 + ' ' + FUnits;
end;
}
{ RegisterForm }
{
procedure RegisterForm(const Package: string; FormClass: TCustomFormClass;
const Category, Caption, Description, Units: string);
begin
@ -1688,7 +1637,7 @@ begin
RegisterProjectFileDescriptor(TCustomFormDescriptor.Create(Package, FormClass,
Caption, Description, Units), Category);
end;
}
initialization
ProjectFileDescriptors:=nil;

View File

@ -67,7 +67,7 @@ uses
// IDEIntf
IDEImagesIntf, SrcEditorIntf, LazIDEIntf, MenuIntf, NewItemIntf, PackageIntf,
IDECommands, IDEWindowIntf, ProjectIntf, ToolBarIntf, ObjectInspector,
PropEdits, IDEDialogs, EditorSyntaxHighlighterDef,
PropEdits, IDEDialogs, IDEUtils, EditorSyntaxHighlighterDef,
// IDE
LazConf, LazarusIDEStrConsts, Project, BuildManager, IDEProcs,
EnvironmentOpts, EditorOptions, CompilerOptions, SourceEditor, SourceSynEditor,