mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:59:22 +02:00
IDE: added unitresources
git-svn-id: trunk@40326 -
This commit is contained in:
parent
3d7f444396
commit
f595fb71f7
@ -44,7 +44,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, AvgLvlTree, BasicCodeTools, TypInfo, LCLProc, LResources,
|
Classes, SysUtils, AvgLvlTree, BasicCodeTools, TypInfo, LCLProc, LResources,
|
||||||
Forms, Controls, LCLMemManager, LCLIntf, Dialogs, PropEditUtils, PropEdits,
|
Forms, Controls, LCLMemManager, LCLIntf, Dialogs, PropEditUtils, PropEdits,
|
||||||
IDEProcs, PackageDefs, BasePkgManager;
|
IDEProcs, PackageDefs, BasePkgManager, UnitResources, lfmUnitResource;
|
||||||
|
|
||||||
type
|
type
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -146,7 +146,9 @@ type
|
|||||||
function GetItem(Index:integer):TComponent;
|
function GetItem(Index:integer):TComponent;
|
||||||
function OnFindGlobalComponent(const AName:AnsiString):TComponent;
|
function OnFindGlobalComponent(const AName:AnsiString):TComponent;
|
||||||
procedure InitReading;
|
procedure InitReading;
|
||||||
procedure CreateReader(BinStream: TStream; var Reader: TReader;
|
procedure CreateReader(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
|
var Reader: TReader;
|
||||||
DestroyDriver: Boolean); virtual;
|
DestroyDriver: Boolean); virtual;
|
||||||
function DoCreateJITComponent(const NewComponentName, NewClassName,
|
function DoCreateJITComponent(const NewComponentName, NewClassName,
|
||||||
NewUnitName: shortstring; AncestorClass: TClass;
|
NewUnitName: shortstring; AncestorClass: TClass;
|
||||||
@ -165,6 +167,7 @@ type
|
|||||||
AncestorClass: TClass;
|
AncestorClass: TClass;
|
||||||
DisableAutoSize: boolean): integer;
|
DisableAutoSize: boolean): integer;
|
||||||
function AddJITComponentFromStream(BinStream: TStream;
|
function AddJITComponentFromStream(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
AncestorClass: TClass;
|
AncestorClass: TClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive, Visible, DisableAutoSize: Boolean;
|
Interactive, Visible, DisableAutoSize: Boolean;
|
||||||
@ -830,6 +833,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TJITComponentList.AddJITComponentFromStream(BinStream: TStream;
|
function TJITComponentList.AddJITComponentFromStream(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
AncestorClass: TClass;
|
AncestorClass: TClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive, Visible, DisableAutoSize: Boolean;
|
Interactive, Visible, DisableAutoSize: Boolean;
|
||||||
@ -849,7 +853,7 @@ function TJITComponentList.AddJITComponentFromStream(BinStream: TStream;
|
|||||||
FCurReadStreamClass:=StreamClass;
|
FCurReadStreamClass:=StreamClass;
|
||||||
DestroyDriver:=false;
|
DestroyDriver:=false;
|
||||||
InitReading;
|
InitReading;
|
||||||
CreateReader(AStream,Reader,DestroyDriver);
|
CreateReader(AStream,UnitResourcefileFormat,Reader,DestroyDriver);
|
||||||
{$IFDEF VerboseJITForms}
|
{$IFDEF VerboseJITForms}
|
||||||
DebugLn(['TJITComponentList.AddJITComponentFromStream.ReadStream Reading: FCurReadJITComponent=',DbgSName(FCurReadJITComponent),' StreamClass=',DbgSName(StreamClass)]);
|
DebugLn(['TJITComponentList.AddJITComponentFromStream.ReadStream Reading: FCurReadJITComponent=',DbgSName(FCurReadJITComponent),' StreamClass=',DbgSName(StreamClass)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -908,7 +912,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
FContextObject:=ContextObj;
|
FContextObject:=ContextObj;
|
||||||
NewClassName:=GetClassNameFromLRSStream(BinStream, IsInherited);
|
NewClassName:=UnitResourcefileFormat.GetClassNameFromStream(BinStream,IsInherited);
|
||||||
if IsInherited then ;
|
if IsInherited then ;
|
||||||
if NewClassName='' then begin
|
if NewClassName='' then begin
|
||||||
MessageDlg('No classname in stream found.',mtError,[mbOK],0);
|
MessageDlg('No classname in stream found.',mtError,[mbOK],0);
|
||||||
@ -982,13 +986,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJITComponentList.CreateReader(BinStream: TStream;
|
procedure TJITComponentList.CreateReader(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
var Reader: TReader; DestroyDriver: Boolean);
|
var Reader: TReader; DestroyDriver: Boolean);
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseJITForms}
|
{$IFDEF VerboseJITForms}
|
||||||
debugln('[TJITComponentList.InitReading] A');
|
debugln('[TJITComponentList.InitReading] A');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
DestroyDriver:=false;
|
DestroyDriver:=false;
|
||||||
Reader:=CreateLRSReader(BinStream,DestroyDriver);
|
Reader:=UnitResourcefileFormat.CreateReader(BinStream,DestroyDriver);
|
||||||
// connect TReader events
|
// connect TReader events
|
||||||
Reader.OnError:=@ReaderError;
|
Reader.OnError:=@ReaderError;
|
||||||
Reader.OnPropertyNotFound:=@ReaderPropertyNotFound;
|
Reader.OnPropertyNotFound:=@ReaderPropertyNotFound;
|
||||||
@ -1142,7 +1147,7 @@ begin
|
|||||||
SubReader:=nil;
|
SubReader:=nil;
|
||||||
DestroyDriver:=false;
|
DestroyDriver:=false;
|
||||||
try
|
try
|
||||||
CreateReader(BinStream,SubReader,DestroyDriver);
|
CreateReader(BinStream,TLFMUnitResourcefileFormat,SubReader,DestroyDriver);
|
||||||
// The stream contains only the diff to the Ancestor instance,
|
// The stream contains only the diff to the Ancestor instance,
|
||||||
// => give it the Ancestor instance
|
// => give it the Ancestor instance
|
||||||
SubReader.Ancestor:=Ancestor;
|
SubReader.Ancestor:=Ancestor;
|
||||||
@ -1303,7 +1308,7 @@ begin
|
|||||||
try
|
try
|
||||||
DestroyDriver:=false;
|
DestroyDriver:=false;
|
||||||
InitReading;
|
InitReading;
|
||||||
CreateReader(BinStream,Reader,DestroyDriver);
|
CreateReader(BinStream,TLFMUnitResourcefileFormat, Reader,DestroyDriver);
|
||||||
{$IFDEF VerboseJITForms}
|
{$IFDEF VerboseJITForms}
|
||||||
debugln('[TJITComponentList.AddJITChildComponentFromStream] B');
|
debugln('[TJITComponentList.AddJITChildComponentFromStream] B');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
@ -44,6 +44,7 @@ uses
|
|||||||
LCLProc, Graphics, Controls, Forms, Menus, Dialogs,
|
LCLProc, Graphics, Controls, Forms, Menus, Dialogs,
|
||||||
// IDEIntf
|
// IDEIntf
|
||||||
PropEdits, PropEditUtils, ObjectInspector, IDECommands, FormEditingIntf,
|
PropEdits, PropEditUtils, ObjectInspector, IDECommands, FormEditingIntf,
|
||||||
|
UnitResources,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, ControlSelection, Project, JITForms, MainIntf,
|
LazarusIDEStrConsts, ControlSelection, Project, JITForms, MainIntf,
|
||||||
CustomNonFormDesigner, NonControlDesigner, FrameDesigner, ComponentReg,
|
CustomNonFormDesigner, NonControlDesigner, FrameDesigner, ComponentReg,
|
||||||
@ -200,6 +201,7 @@ type
|
|||||||
NewLeft,NewTop,NewWidth,NewHeight: Integer;
|
NewLeft,NewTop,NewWidth,NewHeight: Integer;
|
||||||
DisableAutoSize: boolean): TComponent; override;
|
DisableAutoSize: boolean): TComponent; override;
|
||||||
function CreateComponentFromStream(BinStream: TStream;
|
function CreateComponentFromStream(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
AncestorType: TComponentClass;
|
AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: boolean;
|
Interactive: boolean;
|
||||||
@ -207,6 +209,7 @@ type
|
|||||||
DisableAutoSize: boolean = false;
|
DisableAutoSize: boolean = false;
|
||||||
ContextObj: TObject = nil): TComponent; override;
|
ContextObj: TObject = nil): TComponent; override;
|
||||||
function CreateRawComponentFromStream(BinStream: TStream;
|
function CreateRawComponentFromStream(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
AncestorType: TComponentClass;
|
AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: boolean;
|
Interactive: boolean;
|
||||||
@ -1402,16 +1405,18 @@ end;
|
|||||||
|
|
||||||
function TCustomFormEditor.CreateComponentFromStream(
|
function TCustomFormEditor.CreateComponentFromStream(
|
||||||
BinStream: TStream;
|
BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
AncestorType: TComponentClass;
|
AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: boolean; Visible: boolean; DisableAutoSize: boolean;
|
Interactive: boolean; Visible: boolean; DisableAutoSize: boolean;
|
||||||
ContextObj: TObject): TComponent;
|
ContextObj: TObject): TComponent;
|
||||||
begin
|
begin
|
||||||
Result:=CreateRawComponentFromStream(BinStream,
|
Result:=CreateRawComponentFromStream(BinStream, UnitResourcefileFormat,
|
||||||
AncestorType,NewUnitName,Interactive,Visible,DisableAutoSize,ContextObj);
|
AncestorType,NewUnitName,Interactive,Visible,DisableAutoSize,ContextObj);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.CreateRawComponentFromStream(BinStream: TStream;
|
function TCustomFormEditor.CreateRawComponentFromStream(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
AncestorType: TComponentClass;
|
AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: boolean; Visible: boolean; DisableAutoSize: boolean;
|
Interactive: boolean; Visible: boolean; DisableAutoSize: boolean;
|
||||||
@ -1425,7 +1430,7 @@ begin
|
|||||||
if JITList=nil then
|
if JITList=nil then
|
||||||
RaiseException('TCustomFormEditor.CreateComponentFromStream ClassName='+
|
RaiseException('TCustomFormEditor.CreateComponentFromStream ClassName='+
|
||||||
AncestorType.ClassName);
|
AncestorType.ClassName);
|
||||||
NewJITIndex := JITList.AddJITComponentFromStream(BinStream,
|
NewJITIndex := JITList.AddJITComponentFromStream(BinStream, UnitResourcefileFormat,
|
||||||
AncestorType,NewUnitName,Interactive,Visible,DisableAutoSize,
|
AncestorType,NewUnitName,Interactive,Visible,DisableAutoSize,
|
||||||
ContextObj);
|
ContextObj);
|
||||||
if NewJITIndex < 0 then begin
|
if NewJITIndex < 0 then begin
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Files Count="421">
|
<Files Count="422">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="aboutfrm.lfm"/>
|
<Filename Value="aboutfrm.lfm"/>
|
||||||
<Type Value="LFM"/>
|
<Type Value="LFM"/>
|
||||||
@ -1895,6 +1895,10 @@
|
|||||||
<Filename Value="..\debugger\watchpropertydlg.pp"/>
|
<Filename Value="..\debugger\watchpropertydlg.pp"/>
|
||||||
<UnitName Value="WatchPropertyDlg"/>
|
<UnitName Value="WatchPropertyDlg"/>
|
||||||
</Item421>
|
</Item421>
|
||||||
|
<Item422>
|
||||||
|
<Filename Value="lfmunitresource.pas"/>
|
||||||
|
<UnitName Value="lfmUnitResource"/>
|
||||||
|
</Item422>
|
||||||
</Files>
|
</Files>
|
||||||
<Type Value="RunTimeOnly"/>
|
<Type Value="RunTimeOnly"/>
|
||||||
<RequiredPkgs Count="6">
|
<RequiredPkgs Count="6">
|
||||||
|
@ -54,13 +54,16 @@ uses
|
|||||||
CodeToolsConfig, ExprEval, FileProcs, DefineTemplates,
|
CodeToolsConfig, ExprEval, FileProcs, DefineTemplates,
|
||||||
BasicCodeTools, CodeToolsCfgScript, CodeToolManager, CodeCache,
|
BasicCodeTools, CodeToolsCfgScript, CodeToolManager, CodeCache,
|
||||||
// IDEIntf
|
// IDEIntf
|
||||||
PropEdits, CompOptsIntf, ProjectIntf, MacroIntf, MacroDefIntf, LazIDEIntf,
|
PropEdits, CompOptsIntf, ProjectIntf, MacroIntf, MacroDefIntf, UnitResources,
|
||||||
|
LazIDEIntf, PackageIntf, SrcEditorIntf, IDEOptionsIntf,
|
||||||
|
// synedit
|
||||||
|
SynEdit,
|
||||||
// IDE
|
// IDE
|
||||||
CompOptsModes, ProjectResources, LazConf, W32Manifest, ProjectIcon,
|
CompOptsModes, ProjectResources, LazConf, W32Manifest, ProjectIcon,
|
||||||
LazarusIDEStrConsts, CompilerOptions,
|
LazarusIDEStrConsts, CompilerOptions, lfmUnitResource,
|
||||||
TransferMacros, EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs,
|
TransferMacros, EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs,
|
||||||
FileReferenceList, EditDefineTree, PackageDefs, PackageSystem, IDEOptionsIntf,
|
FileReferenceList, EditDefineTree, PackageDefs, PackageSystem,
|
||||||
SrcEditorIntf, IDEDialogs, PackageIntf, SynEdit;
|
IDEDialogs;
|
||||||
|
|
||||||
type
|
type
|
||||||
TUnitInfo = class;
|
TUnitInfo = class;
|
||||||
@ -294,6 +297,7 @@ type
|
|||||||
FSourceDirNeedReference: boolean;
|
FSourceDirNeedReference: boolean;
|
||||||
fLastDirectoryReferenced: string;
|
fLastDirectoryReferenced: string;
|
||||||
FSetBookmarLock: Integer;
|
FSetBookmarLock: Integer;
|
||||||
|
FUnitResourceFileformat: TUnitResourcefileFormatClass;
|
||||||
|
|
||||||
function GetEditorInfo(Index: Integer): TUnitEditorInfo;
|
function GetEditorInfo(Index: Integer): TUnitEditorInfo;
|
||||||
function GetHasResources:boolean;
|
function GetHasResources:boolean;
|
||||||
@ -309,6 +313,7 @@ type
|
|||||||
function GetPrevPartOfProject: TUnitInfo;
|
function GetPrevPartOfProject: TUnitInfo;
|
||||||
function GetPrevUnitWithComponent: TUnitInfo;
|
function GetPrevUnitWithComponent: TUnitInfo;
|
||||||
function GetPrevUnitWithEditorIndex: TUnitInfo;
|
function GetPrevUnitWithEditorIndex: TUnitInfo;
|
||||||
|
function GetUnitResourceFileformat: TUnitResourcefileFormatClass;
|
||||||
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
procedure SetAutoReferenceSourceDir(const AValue: boolean);
|
||||||
procedure SetBuildFileIfActive(const AValue: boolean);
|
procedure SetBuildFileIfActive(const AValue: boolean);
|
||||||
procedure SetDefaultSyntaxHighlighter(const AValue: TLazSyntaxHighlighter);
|
procedure SetDefaultSyntaxHighlighter(const AValue: TLazSyntaxHighlighter);
|
||||||
@ -407,6 +412,8 @@ type
|
|||||||
procedure UpdateDefaultHighlighter(aDefaultHighlighter: TLazSyntaxHighlighter);
|
procedure UpdateDefaultHighlighter(aDefaultHighlighter: TLazSyntaxHighlighter);
|
||||||
public
|
public
|
||||||
{ Properties }
|
{ Properties }
|
||||||
|
property UnitResourceFileformat: TUnitResourcefileFormatClass read GetUnitResourceFileformat;
|
||||||
|
|
||||||
// Unit lists
|
// Unit lists
|
||||||
property NextUnitWithEditorIndex: TUnitInfo read GetNextUnitWithEditorIndex;
|
property NextUnitWithEditorIndex: TUnitInfo read GetNextUnitWithEditorIndex;
|
||||||
property PrevUnitWithEditorIndex: TUnitInfo read GetPrevUnitWithEditorIndex;
|
property PrevUnitWithEditorIndex: TUnitInfo read GetPrevUnitWithEditorIndex;
|
||||||
@ -2395,6 +2402,28 @@ begin
|
|||||||
Result:=fPrev[uilWithEditorIndex];
|
Result:=fPrev[uilWithEditorIndex];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TUnitInfo.GetUnitResourceFileformat: TUnitResourcefileFormatClass;
|
||||||
|
var
|
||||||
|
ResourceFormats : TUnitResourcefileFormatArr;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
if not assigned(FUnitResourceFileformat) then
|
||||||
|
begin
|
||||||
|
ResourceFormats := GetUnitResourcefileFormats;
|
||||||
|
for i := 0 to high(ResourceFormats) do
|
||||||
|
begin
|
||||||
|
if ResourceFormats[i].FindResourceDirective(Source) then
|
||||||
|
begin
|
||||||
|
FUnitResourceFileformat:=ResourceFormats[i];
|
||||||
|
result := FUnitResourceFileformat;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
FUnitResourceFileformat := TLFMUnitResourcefileFormat;
|
||||||
|
end;
|
||||||
|
result := FUnitResourceFileformat;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TUnitInfo.SetAutoReferenceSourceDir(const AValue: boolean);
|
procedure TUnitInfo.SetAutoReferenceSourceDir(const AValue: boolean);
|
||||||
begin
|
begin
|
||||||
if FAutoReferenceSourceDir=AValue then exit;
|
if FAutoReferenceSourceDir=AValue then exit;
|
||||||
|
@ -43,7 +43,8 @@ uses
|
|||||||
ControlSelection, TransferMacros, EnvironmentOpts, BuildManager, Designer,
|
ControlSelection, TransferMacros, EnvironmentOpts, BuildManager, Designer,
|
||||||
EditorMacroListViewer, KeywordFuncLists, FindRenameIdentifier, MsgView,
|
EditorMacroListViewer, KeywordFuncLists, FindRenameIdentifier, MsgView,
|
||||||
InputHistory, CheckLFMDlg, LCLMemManager, CodeToolManager, CodeToolsStructs,
|
InputHistory, CheckLFMDlg, LCLMemManager, CodeToolManager, CodeToolsStructs,
|
||||||
ConvCodeTool, CodeCache, CodeTree, FindDeclarationTool, BasicCodeTools;
|
ConvCodeTool, CodeCache, CodeTree, FindDeclarationTool, BasicCodeTools,
|
||||||
|
UnitResources;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -2851,7 +2852,7 @@ begin
|
|||||||
repeat
|
repeat
|
||||||
try
|
try
|
||||||
BinCompStream.Position:=0;
|
BinCompStream.Position:=0;
|
||||||
Writer:=CreateLRSWriter(BinCompStream,DestroyDriver);
|
Writer:=AnUnitInfo.UnitResourceFileformat.CreateWriter(BinCompStream,DestroyDriver);
|
||||||
// used to save lrt files
|
// used to save lrt files
|
||||||
HasI18N:=IsI18NEnabled(UnitOwners);
|
HasI18N:=IsI18NEnabled(UnitOwners);
|
||||||
if HasI18N then
|
if HasI18N then
|
||||||
@ -2956,7 +2957,7 @@ begin
|
|||||||
if (not AnUnitInfo.IsVirtual) or (sfSaveToTestDir in Flags) then
|
if (not AnUnitInfo.IsVirtual) or (sfSaveToTestDir in Flags) then
|
||||||
begin
|
begin
|
||||||
// save lfm file
|
// save lfm file
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
||||||
if AnUnitInfo.IsVirtual then
|
if AnUnitInfo.IsVirtual then
|
||||||
LFMFilename:=AppendPathDelim(MainBuildBoss.GetTestBuildDirectory)+LFMFilename;
|
LFMFilename:=AppendPathDelim(MainBuildBoss.GetTestBuildDirectory)+LFMFilename;
|
||||||
if LFMCode=nil then begin
|
if LFMCode=nil then begin
|
||||||
@ -2991,7 +2992,7 @@ begin
|
|||||||
+LRSStreamChunkSize;
|
+LRSStreamChunkSize;
|
||||||
try
|
try
|
||||||
BinCompStream.Position:=0;
|
BinCompStream.Position:=0;
|
||||||
LRSObjectBinaryToText(BinCompStream,TxtCompStream);
|
AnUnitInfo.UnitResourceFileformat.BinStreamToTextStream(BinCompStream,TxtCompStream);
|
||||||
AnUnitInfo.ComponentLastLFMStreamSize:=TxtCompStream.Size;
|
AnUnitInfo.ComponentLastLFMStreamSize:=TxtCompStream.Size;
|
||||||
// stream text to file
|
// stream text to file
|
||||||
TxtCompStream.Position:=0;
|
TxtCompStream.Position:=0;
|
||||||
@ -3860,26 +3861,28 @@ end;
|
|||||||
function TLazSourceFileManager.LoadResourceFile(AnUnitInfo: TUnitInfo;
|
function TLazSourceFileManager.LoadResourceFile(AnUnitInfo: TUnitInfo;
|
||||||
var LFMCode, LRSCode: TCodeBuffer;
|
var LFMCode, LRSCode: TCodeBuffer;
|
||||||
IgnoreSourceErrors, AutoCreateResourceCode, ShowAbort: boolean): TModalResult;
|
IgnoreSourceErrors, AutoCreateResourceCode, ShowAbort: boolean): TModalResult;
|
||||||
const
|
|
||||||
LfmSuffices: array[0..1] of string = ('.lfm', '.dfm');
|
|
||||||
var
|
var
|
||||||
LFMFilename: string;
|
LFMFilename: string;
|
||||||
LRSFilename: String;
|
LRSFilename: String;
|
||||||
ResType: TResourceType;
|
ResType: TResourceType;
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
LFMCode:=nil;
|
LFMCode:=nil;
|
||||||
LRSCode:=nil;
|
LRSCode:=nil;
|
||||||
//DebugLn(['TLazSourceFileManager.LoadResourceFile ',AnUnitInfo.Filename,' HasResources=',AnUnitInfo.HasResources,' IgnoreSourceErrors=',IgnoreSourceErrors,' AutoCreateResourceCode=',AutoCreateResourceCode]);
|
//DebugLn(['TLazSourceFileManager.LoadResourceFile ',AnUnitInfo.Filename,' HasResources=',AnUnitInfo.HasResources,' IgnoreSourceErrors=',IgnoreSourceErrors,' AutoCreateResourceCode=',AutoCreateResourceCode]);
|
||||||
// Load the lfm file (without parsing)
|
// Load the lfm file (without parsing)
|
||||||
if not AnUnitInfo.IsVirtual then begin // and (AnUnitInfo.Component<>nil)
|
if not AnUnitInfo.IsVirtual then begin // and (AnUnitInfo.Component<>nil)
|
||||||
for i := Low(LfmSuffices) to High(LfmSuffices) do begin
|
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,LfmSuffices[i]);
|
if (FileExistsUTF8(LFMFilename)) then begin
|
||||||
|
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
||||||
|
if not (Result in [mrOk,mrIgnore]) then
|
||||||
|
exit;
|
||||||
|
end else begin
|
||||||
|
// Is this still being used?!?
|
||||||
|
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
||||||
if (FileExistsUTF8(LFMFilename)) then begin
|
if (FileExistsUTF8(LFMFilename)) then begin
|
||||||
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
||||||
if not (Result in [mrOk,mrIgnore]) then
|
if not (Result in [mrOk,mrIgnore]) then
|
||||||
exit;
|
exit;
|
||||||
Break;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3914,18 +3917,20 @@ function TLazSourceFileManager.LoadLFM(AnUnitInfo: TUnitInfo;
|
|||||||
OpenFlags: TOpenFlags; CloseFlags: TCloseFlags): TModalResult;
|
OpenFlags: TOpenFlags; CloseFlags: TCloseFlags): TModalResult;
|
||||||
// if there is a .lfm file, open the resource
|
// if there is a .lfm file, open the resource
|
||||||
var
|
var
|
||||||
LFMFilename: string;
|
UnitResourceFilename: string;
|
||||||
|
UnitResourceFileformat: TUnitResourcefileFormatClass;
|
||||||
LFMBuf: TCodeBuffer;
|
LFMBuf: TCodeBuffer;
|
||||||
CanAbort: boolean;
|
CanAbort: boolean;
|
||||||
begin
|
begin
|
||||||
CanAbort:=[ofProjectLoading,ofMultiOpen]*OpenFlags<>[];
|
CanAbort:=[ofProjectLoading,ofMultiOpen]*OpenFlags<>[];
|
||||||
|
|
||||||
|
UnitResourceFileformat:=AnUnitInfo.UnitResourceFileformat;
|
||||||
// Note: think about virtual and normal .lfm files.
|
// Note: think about virtual and normal .lfm files.
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
UnitResourceFilename:=UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
||||||
if not FileExistsInIDE(LFMFilename,[pfsfOnlyEditorFiles]) then
|
if not FileExistsInIDE(UnitResourceFilename,[pfsfOnlyEditorFiles]) then
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
UnitResourceFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
||||||
LFMBuf:=nil;
|
LFMBuf:=nil;
|
||||||
if not FileExistsInIDE(LFMFilename,[pfsfOnlyEditorFiles]) then begin
|
if not FileExistsInIDE(UnitResourceFilename,[pfsfOnlyEditorFiles]) then begin
|
||||||
// there is no LFM file -> ok
|
// there is no LFM file -> ok
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
debugln('TLazSourceFileManager.LoadLFM there is no LFM file for "',AnUnitInfo.Filename,'"');
|
debugln('TLazSourceFileManager.LoadLFM there is no LFM file for "',AnUnitInfo.Filename,'"');
|
||||||
@ -3935,7 +3940,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// there is a lazarus form text file -> load it
|
// there is a lazarus form text file -> load it
|
||||||
Result:=LoadIDECodeBuffer(LFMBuf,LFMFilename,[lbfUpdateFromDisk],CanAbort);
|
Result:=LoadIDECodeBuffer(LFMBuf,UnitResourceFilename,[lbfUpdateFromDisk],CanAbort);
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
DebugLn(['TLazSourceFileManager.LoadLFM LoadIDECodeBuffer failed']);
|
DebugLn(['TLazSourceFileManager.LoadLFM LoadIDECodeBuffer failed']);
|
||||||
exit;
|
exit;
|
||||||
@ -4019,7 +4024,7 @@ begin
|
|||||||
AnUnitInfo.HasResources:=true;
|
AnUnitInfo.HasResources:=true;
|
||||||
|
|
||||||
// find the classname of the LFM, and check for inherited form
|
// find the classname of the LFM, and check for inherited form
|
||||||
QuickCheckLFMBuffer(AnUnitInfo.Source,LFMBuf,LFMType,LFMComponentName,
|
AnUnitInfo.UnitResourceFileformat.QuickCheckResourceBuffer(AnUnitInfo.Source,LFMBuf,LFMType,LFMComponentName,
|
||||||
NewClassName,LCLVersion,MissingClasses);
|
NewClassName,LCLVersion,MissingClasses);
|
||||||
|
|
||||||
{$IFDEF VerboseLFMSearch}
|
{$IFDEF VerboseLFMSearch}
|
||||||
@ -4105,7 +4110,7 @@ begin
|
|||||||
try
|
try
|
||||||
if AnUnitInfo.ComponentLastBinStreamSize>0 then
|
if AnUnitInfo.ComponentLastBinStreamSize>0 then
|
||||||
BinStream.Capacity:=AnUnitInfo.ComponentLastBinStreamSize+BufSize;
|
BinStream.Capacity:=AnUnitInfo.ComponentLastBinStreamSize+BufSize;
|
||||||
LRSObjectTextToBinary(TxtLFMStream,BinStream);
|
AnUnitInfo.UnitResourceFileformat.TextStreamToBinStream(TxtLFMStream, BinStream);
|
||||||
AnUnitInfo.ComponentLastBinStreamSize:=BinStream.Size;
|
AnUnitInfo.ComponentLastBinStreamSize:=BinStream.Size;
|
||||||
BinStream.Position:=0;
|
BinStream.Position:=0;
|
||||||
|
|
||||||
@ -4140,7 +4145,7 @@ begin
|
|||||||
NewUnitName:=ExtractFileNameOnly(AnUnitInfo.Filename);
|
NewUnitName:=ExtractFileNameOnly(AnUnitInfo.Filename);
|
||||||
// ToDo: create AncestorBinStream(s) via hook, not via parameters
|
// ToDo: create AncestorBinStream(s) via hook, not via parameters
|
||||||
DisableAutoSize:=true;
|
DisableAutoSize:=true;
|
||||||
NewComponent:=FormEditor1.CreateRawComponentFromStream(BinStream,
|
NewComponent:=FormEditor1.CreateRawComponentFromStream(BinStream, AnUnitInfo.UnitResourceFileformat,
|
||||||
AncestorType,copy(NewUnitName,1,255),true,true,DisableAutoSize,AnUnitInfo);
|
AncestorType,copy(NewUnitName,1,255),true,true,DisableAutoSize,AnUnitInfo);
|
||||||
if (NewComponent is TControl) then begin
|
if (NewComponent is TControl) then begin
|
||||||
NewControl:=TControl(NewComponent);
|
NewControl:=TControl(NewComponent);
|
||||||
|
@ -23,7 +23,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Math, Classes, SysUtils, LCLProc, TypInfo, types, Forms, Controls,
|
Math, Classes, SysUtils, LCLProc, TypInfo, types, Forms, Controls,
|
||||||
LCLClasses, ProjectIntf, ComponentEditors, ObjectInspector;
|
LCLClasses, ProjectIntf, ComponentEditors, ObjectInspector, UnitResources;
|
||||||
|
|
||||||
const
|
const
|
||||||
ComponentPaletteImageWidth = 24;
|
ComponentPaletteImageWidth = 24;
|
||||||
@ -118,6 +118,7 @@ type
|
|||||||
X,Y,W,H: Integer;
|
X,Y,W,H: Integer;
|
||||||
DisableAutoSize: boolean): TComponent; virtual; abstract;
|
DisableAutoSize: boolean): TComponent; virtual; abstract;
|
||||||
function CreateComponentFromStream(BinStream: TStream;
|
function CreateComponentFromStream(BinStream: TStream;
|
||||||
|
UnitResourcefileFormat: TUnitResourcefileFormatClass;
|
||||||
AncestorType: TComponentClass;
|
AncestorType: TComponentClass;
|
||||||
const NewUnitName: ShortString;
|
const NewUnitName: ShortString;
|
||||||
Interactive: boolean;
|
Interactive: boolean;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<Description Value="IDEIntf - the interface units for the Lazarus IDE"/>
|
<Description Value="IDEIntf - the interface units for the Lazarus IDE"/>
|
||||||
<License Value="Modified LPGL2"/>
|
<License Value="Modified LPGL2"/>
|
||||||
<Version Major="1"/>
|
<Version Major="1"/>
|
||||||
<Files Count="70">
|
<Files Count="71">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="actionseditor.lfm"/>
|
<Filename Value="actionseditor.lfm"/>
|
||||||
<Type Value="LFM"/>
|
<Type Value="LFM"/>
|
||||||
@ -298,12 +298,16 @@
|
|||||||
</Item68>
|
</Item68>
|
||||||
<Item69>
|
<Item69>
|
||||||
<Filename Value="oifavoriteproperties.pas"/>
|
<Filename Value="oifavoriteproperties.pas"/>
|
||||||
<UnitName Value="OIFavouriteProperties"/>
|
<UnitName Value="oifavoriteproperties"/>
|
||||||
</Item69>
|
</Item69>
|
||||||
<Item70>
|
<Item70>
|
||||||
|
<Filename Value="unitresources.pas"/>
|
||||||
|
<UnitName Value="UnitResources"/>
|
||||||
|
</Item70>
|
||||||
|
<Item71>
|
||||||
<Filename Value="macrodefintf.pas"/>
|
<Filename Value="macrodefintf.pas"/>
|
||||||
<UnitName Value="macrodefintf"/>
|
<UnitName Value="macrodefintf"/>
|
||||||
</Item70>
|
</Item71>
|
||||||
</Files>
|
</Files>
|
||||||
<LazDoc Paths="docs"/>
|
<LazDoc Paths="docs"/>
|
||||||
<i18n>
|
<i18n>
|
||||||
|
@ -18,7 +18,8 @@ uses
|
|||||||
newfield, NewItemIntf, ObjectInspector, ObjInspStrConsts, PackageIntf,
|
newfield, NewItemIntf, ObjectInspector, ObjInspStrConsts, PackageIntf,
|
||||||
ProjectIntf, ProjectResourcesIntf, PropEdits, PropEditUtils, SrcEditorIntf,
|
ProjectIntf, ProjectResourcesIntf, PropEdits, PropEditUtils, SrcEditorIntf,
|
||||||
StatusBarPropEdit, StringsPropEditDlg, TextTools, TreeViewPropEdit,
|
StatusBarPropEdit, StringsPropEditDlg, TextTools, TreeViewPropEdit,
|
||||||
CompOptsIntf, OIFavoriteProperties, MacroDefIntf, LazarusPackageIntf;
|
CompOptsIntf, OIFavoriteProperties, UnitResources, MacroDefIntf,
|
||||||
|
LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user