You've already forked lazarus-ccr
* The form is no longer stored inside a .lfm resource, but directly in a
.xib resource-file. Property-values are not stored inside the fake- components, but reside inside a DOM-tree. The property getters and setters are used to obtain their values. This way all nodes which are unknown to the fake-components are not touched. The .xib file could be edited by xcode as well as Lazarus. The system to create a .xib file from the .lfm has now become obsolete. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2620 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -20,7 +20,7 @@
|
|||||||
<Description Value="A designer to create iOS applications"/>
|
<Description Value="A designer to create iOS applications"/>
|
||||||
<License Value="Modified LGPL (Same license as Lazarus' LCL)"/>
|
<License Value="Modified LGPL (Same license as Lazarus' LCL)"/>
|
||||||
<Version Minor="1"/>
|
<Version Minor="1"/>
|
||||||
<Files Count="5">
|
<Files Count="6">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="README.txt"/>
|
<Filename Value="README.txt"/>
|
||||||
<Type Value="Text"/>
|
<Type Value="Text"/>
|
||||||
@ -43,11 +43,15 @@
|
|||||||
<Filename Value="MainWindow_iPhone.template"/>
|
<Filename Value="MainWindow_iPhone.template"/>
|
||||||
<Type Value="Text"/>
|
<Type Value="Text"/>
|
||||||
</Item5>
|
</Item5>
|
||||||
|
<Item6>
|
||||||
|
<Filename Value="iosxibresource.pas"/>
|
||||||
|
<UnitName Value="iOSXIBResource"/>
|
||||||
|
</Item6>
|
||||||
</Files>
|
</Files>
|
||||||
<Type Value="DesignTime"/>
|
<Type Value="DesignTime"/>
|
||||||
<RequiredPkgs Count="4">
|
<RequiredPkgs Count="4">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="ide"/>
|
<PackageName Value="CodeTools"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<PackageName Value="iphonelazext"/>
|
<PackageName Value="iphonelazext"/>
|
||||||
@ -67,5 +71,8 @@
|
|||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
<IgnoreBinaries Value="False"/>
|
<IgnoreBinaries Value="False"/>
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
|
<CustomOptions Items="ExternHelp" Version="2">
|
||||||
|
<_ExternHelp Items="Count"/>
|
||||||
|
</CustomOptions>
|
||||||
</Package>
|
</Package>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
@ -7,7 +7,7 @@ unit iOSDesigner;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
iOSNIBDesigner, iOS_Views, iOSIdeIntf, LazarusPackageIntf;
|
iOSNIBDesigner, iOS_Views, iOSIdeIntf, iOSXIBResource, LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ procedure register;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses LazIDEIntf, Controls, iOS_Views;
|
uses LazIDEIntf, Controls, iOS_Views, iOSXIBResource, UnitResources;
|
||||||
|
|
||||||
procedure register;
|
procedure register;
|
||||||
begin
|
begin
|
||||||
@ -76,6 +76,7 @@ begin
|
|||||||
GiOSObjectDelegateWindowFileDesc:=TiOSObjectDelegateWindowFileDesc.Create;
|
GiOSObjectDelegateWindowFileDesc:=TiOSObjectDelegateWindowFileDesc.Create;
|
||||||
RegisterProjectFileDescriptor(GiOSObjectDelegateWindowFileDesc);
|
RegisterProjectFileDescriptor(GiOSObjectDelegateWindowFileDesc);
|
||||||
|
|
||||||
|
RegisterUnitResourcefileFormat(TXIBResourcefileFormat);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TiOSObjectDelegateWindowFileDesc }
|
{ TiOSObjectDelegateWindowFileDesc }
|
||||||
@ -90,6 +91,7 @@ begin
|
|||||||
inherited Create;
|
inherited Create;
|
||||||
Name:='iOS NIB-Delegate';
|
Name:='iOS NIB-Delegate';
|
||||||
ResourceClass:=NSObject;
|
ResourceClass:=NSObject;
|
||||||
|
DefaultResFileExt:='.xib';
|
||||||
UseCreateFormStatements:=false;
|
UseCreateFormStatements:=false;
|
||||||
VisibleInNewDialog:=true;
|
VisibleInNewDialog:=true;
|
||||||
end;
|
end;
|
||||||
@ -107,7 +109,7 @@ begin
|
|||||||
' inherited dealloc;' + LineEnding +
|
' inherited dealloc;' + LineEnding +
|
||||||
'end;' + LineEnding +
|
'end;' + LineEnding +
|
||||||
LineEnding +
|
LineEnding +
|
||||||
'{$R *.lfm}' + LineEnding + LineEnding;
|
'{$FakeResource *.xib}' + LineEnding + LineEnding;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TiOSObjectDelegateWindowFileDesc.GetInterfaceSource(const Filename, SourceName, ResourceName: string): string;
|
function TiOSObjectDelegateWindowFileDesc.GetInterfaceSource(const Filename, SourceName, ResourceName: string): string;
|
||||||
|
@ -44,9 +44,6 @@ uses
|
|||||||
IDEWindowIntf,
|
IDEWindowIntf,
|
||||||
LazIDEIntf,
|
LazIDEIntf,
|
||||||
Dialogs,
|
Dialogs,
|
||||||
{$ifndef OutsideIDE}
|
|
||||||
CustomNonFormDesigner,
|
|
||||||
{$endif OutsideIDE}
|
|
||||||
Controls,
|
Controls,
|
||||||
ComponentReg,
|
ComponentReg,
|
||||||
typinfo,
|
typinfo,
|
||||||
@ -59,11 +56,7 @@ type
|
|||||||
TNSObjectDesignerMediator = class(TDesignerMediator,IMyWidgetDesigner)
|
TNSObjectDesignerMediator = class(TDesignerMediator,IMyWidgetDesigner)
|
||||||
private
|
private
|
||||||
FMyForm: NSObject;
|
FMyForm: NSObject;
|
||||||
procedure DoOnLoadBounds(Sender: TObject);
|
|
||||||
protected
|
|
||||||
procedure SetLCLForm(const AValue: TForm); override;
|
|
||||||
public
|
public
|
||||||
procedure SaveToXIB(AForm: NSObject);
|
|
||||||
// needed by the lazarus form editor
|
// needed by the lazarus form editor
|
||||||
class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; override;
|
class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; override;
|
||||||
class function FormClass: TComponentClass; override;
|
class function FormClass: TComponentClass; override;
|
||||||
@ -157,43 +150,6 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TNSObjectDesignerMediator.DoOnLoadBounds(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//debugln('----onsaveloadbounds--------');
|
|
||||||
SaveToXIB(FMyForm);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TNSObjectDesignerMediator.SetLCLForm(const AValue: TForm);
|
|
||||||
begin
|
|
||||||
{$ifndef OutsideIDE}
|
|
||||||
if assigned(LCLForm) then
|
|
||||||
TCustomNonFormDesignerForm(LCLForm).OnSaveBounds:=nil;
|
|
||||||
{$endif OutsideIDE}
|
|
||||||
inherited SetLCLForm(AValue);
|
|
||||||
{$ifndef OutsideIDE}
|
|
||||||
if assigned(LCLForm) then
|
|
||||||
TCustomNonFormDesignerForm(LCLForm).OnSaveBounds:=@DoOnLoadBounds;
|
|
||||||
{$endif OutsideIDE}
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TNSObjectDesignerMediator.SaveToXIB(AForm: NSObject);
|
|
||||||
var
|
|
||||||
AFileName: string;
|
|
||||||
AResourcesPath: string;
|
|
||||||
ALazFile: TLazProjectFile;
|
|
||||||
begin
|
|
||||||
ALazFile := LazarusIDE.GetProjectFileWithRootComponent(AForm);
|
|
||||||
if assigned(ALazFile) then
|
|
||||||
begin
|
|
||||||
AFileName:=ChangeFileExt(ALazFile.Filename,'.xib');
|
|
||||||
AResourcesPath:=ExtractFilePath(AFileName)+'Resources';
|
|
||||||
ForceDirectories(AResourcesPath);
|
|
||||||
AFileName:=AResourcesPath+PathDelim+ExtractFileName(AFileName);
|
|
||||||
AForm.SaveAsXIB(AFileName);
|
|
||||||
//DebugLn('XIB saved: '+AFileName);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TNSObjectDesignerMediator.CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator;
|
class function TNSObjectDesignerMediator.CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator;
|
||||||
var
|
var
|
||||||
Mediator: TNSObjectDesignerMediator;
|
Mediator: TNSObjectDesignerMediator;
|
||||||
@ -307,7 +263,7 @@ procedure TNSObjectDesignerMediator.InitComponent(AComponent, NewParent: TCompon
|
|||||||
begin
|
begin
|
||||||
inherited InitComponent(AComponent, NewParent, NewBounds);
|
inherited InitComponent(AComponent, NewParent, NewBounds);
|
||||||
if AComponent is tiOSFakeComponent then
|
if AComponent is tiOSFakeComponent then
|
||||||
tiOSFakeComponent(AComponent).InitializeDefaultChildren;
|
tiOSFakeComponent(AComponent).InitializeDefaults;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TNSObjectDesignerMediator.CreateComponent(ParentComp: TComponent;
|
function TNSObjectDesignerMediator.CreateComponent(ParentComp: TComponent;
|
||||||
|
105
components/iosdesigner/iosxibresource.pas
Normal file
105
components/iosdesigner/iosxibresource.pas
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
unit iOSXIBResource;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils,
|
||||||
|
LCLMemManager, forms,
|
||||||
|
dom, XMLRead,XMLWrite,
|
||||||
|
ProjectIntf, UnitResources;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TXIBResourcefileFormat }
|
||||||
|
|
||||||
|
TXIBResourcefileFormat = class(TUnitResourcefileFormat)
|
||||||
|
public
|
||||||
|
class function FindResourceDirective(Source: TObject): boolean; override;
|
||||||
|
class function ResourceDirectiveFilename: string; override;
|
||||||
|
class function GetUnitResourceFilename(AUnitFilenae: string): string; override;
|
||||||
|
class procedure TextStreamToBinStream(ATxtStream, ABinStream: TExtMemoryStream); override;
|
||||||
|
class procedure BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); override;
|
||||||
|
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; override;
|
||||||
|
class function CreateReader(s: TStream; var DestroyDriver: boolean): TReader; override;
|
||||||
|
class function CreateWriter(s: TStream; var DestroyDriver: boolean): TWriter; override;
|
||||||
|
class function QuickCheckResourceBuffer(PascalBuffer, LFMBuffer: TObject;
|
||||||
|
out LFMType, LFMComponentName, LFMClassName: string; out
|
||||||
|
LCLVersion: string; out MissingClasses: TStrings): TModalResult; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
CodeCache,
|
||||||
|
CodeToolManager,
|
||||||
|
BasicCodeTools,
|
||||||
|
ios_views;
|
||||||
|
|
||||||
|
{ TXIBResourcefileFormat }
|
||||||
|
|
||||||
|
class function TXIBResourcefileFormat.FindResourceDirective(Source: TObject): boolean;
|
||||||
|
var
|
||||||
|
cb: TCodeBuffer;
|
||||||
|
nx,ny,nt: integer;
|
||||||
|
r,p: integer;
|
||||||
|
begin
|
||||||
|
// CodeToolBoss.find;
|
||||||
|
r := FindNextCompilerDirectiveWithName((source as TCodeBuffer).Source, -1, 'FakeResource', False, p);
|
||||||
|
result := (r > -1)
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TXIBResourcefileFormat.ResourceDirectiveFilename: string;
|
||||||
|
begin
|
||||||
|
result := '*.xib';
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TXIBResourcefileFormat.GetUnitResourceFilename(
|
||||||
|
AUnitFilenae: string): string;
|
||||||
|
begin
|
||||||
|
result := ChangeFileExt(AUnitFilenae,'.xib');
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TXIBResourcefileFormat.TextStreamToBinStream(ATxtStream,
|
||||||
|
ABinStream: TExtMemoryStream);
|
||||||
|
begin
|
||||||
|
ABinStream.LoadFromStream(ATxtStream);
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TXIBResourcefileFormat.BinStreamToTextStream(ABinStream,
|
||||||
|
ATextStream: TExtMemoryStream);
|
||||||
|
begin
|
||||||
|
ATextStream.LoadFromStream(ABinStream);
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TXIBResourcefileFormat.GetClassNameFromStream(s: TStream; out
|
||||||
|
IsInherited: Boolean): shortstring;
|
||||||
|
begin
|
||||||
|
result := 'TSObject1';
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TXIBResourcefileFormat.CreateReader(s: TStream;
|
||||||
|
var DestroyDriver: boolean): TReader;
|
||||||
|
begin
|
||||||
|
result := TXIBReader.Create(S, 4096);
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TXIBResourcefileFormat.CreateWriter(s: TStream;
|
||||||
|
var DestroyDriver: boolean): TWriter;
|
||||||
|
begin
|
||||||
|
result := TWriter.Create(TNIBObjectWriter.Create(s));
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TXIBResourcefileFormat.QuickCheckResourceBuffer(PascalBuffer,
|
||||||
|
LFMBuffer: TObject; out LFMType, LFMComponentName, LFMClassName: string; out
|
||||||
|
LCLVersion: string; out MissingClasses: TStrings): TModalResult;
|
||||||
|
begin
|
||||||
|
LCLVersion:='1.1';
|
||||||
|
LFMType:='unknown';
|
||||||
|
LFMClassName:='TSObject1';
|
||||||
|
LFMComponentName:='SObject1';
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Reference in New Issue
Block a user