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"/>
|
||||
<License Value="Modified LGPL (Same license as Lazarus' LCL)"/>
|
||||
<Version Minor="1"/>
|
||||
<Files Count="5">
|
||||
<Files Count="6">
|
||||
<Item1>
|
||||
<Filename Value="README.txt"/>
|
||||
<Type Value="Text"/>
|
||||
@ -43,11 +43,15 @@
|
||||
<Filename Value="MainWindow_iPhone.template"/>
|
||||
<Type Value="Text"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
<Filename Value="iosxibresource.pas"/>
|
||||
<UnitName Value="iOSXIBResource"/>
|
||||
</Item6>
|
||||
</Files>
|
||||
<Type Value="DesignTime"/>
|
||||
<RequiredPkgs Count="4">
|
||||
<Item1>
|
||||
<PackageName Value="ide"/>
|
||||
<PackageName Value="CodeTools"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="iphonelazext"/>
|
||||
@ -67,5 +71,8 @@
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
<CustomOptions Items="ExternHelp" Version="2">
|
||||
<_ExternHelp Items="Count"/>
|
||||
</CustomOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
||||
|
@ -7,7 +7,7 @@ unit iOSDesigner;
|
||||
interface
|
||||
|
||||
uses
|
||||
iOSNIBDesigner, iOS_Views, iOSIdeIntf, LazarusPackageIntf;
|
||||
iOSNIBDesigner, iOS_Views, iOSIdeIntf, iOSXIBResource, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -63,7 +63,7 @@ procedure register;
|
||||
|
||||
implementation
|
||||
|
||||
uses LazIDEIntf, Controls, iOS_Views;
|
||||
uses LazIDEIntf, Controls, iOS_Views, iOSXIBResource, UnitResources;
|
||||
|
||||
procedure register;
|
||||
begin
|
||||
@ -76,6 +76,7 @@ begin
|
||||
GiOSObjectDelegateWindowFileDesc:=TiOSObjectDelegateWindowFileDesc.Create;
|
||||
RegisterProjectFileDescriptor(GiOSObjectDelegateWindowFileDesc);
|
||||
|
||||
RegisterUnitResourcefileFormat(TXIBResourcefileFormat);
|
||||
end;
|
||||
|
||||
{ TiOSObjectDelegateWindowFileDesc }
|
||||
@ -90,6 +91,7 @@ begin
|
||||
inherited Create;
|
||||
Name:='iOS NIB-Delegate';
|
||||
ResourceClass:=NSObject;
|
||||
DefaultResFileExt:='.xib';
|
||||
UseCreateFormStatements:=false;
|
||||
VisibleInNewDialog:=true;
|
||||
end;
|
||||
@ -107,7 +109,7 @@ begin
|
||||
' inherited dealloc;' + LineEnding +
|
||||
'end;' + LineEnding +
|
||||
LineEnding +
|
||||
'{$R *.lfm}' + LineEnding + LineEnding;
|
||||
'{$FakeResource *.xib}' + LineEnding + LineEnding;
|
||||
end;
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetInterfaceSource(const Filename, SourceName, ResourceName: string): string;
|
||||
|
@ -44,9 +44,6 @@ uses
|
||||
IDEWindowIntf,
|
||||
LazIDEIntf,
|
||||
Dialogs,
|
||||
{$ifndef OutsideIDE}
|
||||
CustomNonFormDesigner,
|
||||
{$endif OutsideIDE}
|
||||
Controls,
|
||||
ComponentReg,
|
||||
typinfo,
|
||||
@ -59,11 +56,7 @@ type
|
||||
TNSObjectDesignerMediator = class(TDesignerMediator,IMyWidgetDesigner)
|
||||
private
|
||||
FMyForm: NSObject;
|
||||
procedure DoOnLoadBounds(Sender: TObject);
|
||||
protected
|
||||
procedure SetLCLForm(const AValue: TForm); override;
|
||||
public
|
||||
procedure SaveToXIB(AForm: NSObject);
|
||||
// needed by the lazarus form editor
|
||||
class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; override;
|
||||
class function FormClass: TComponentClass; override;
|
||||
@ -157,43 +150,6 @@ begin
|
||||
inherited Destroy;
|
||||
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;
|
||||
var
|
||||
Mediator: TNSObjectDesignerMediator;
|
||||
@ -307,7 +263,7 @@ procedure TNSObjectDesignerMediator.InitComponent(AComponent, NewParent: TCompon
|
||||
begin
|
||||
inherited InitComponent(AComponent, NewParent, NewBounds);
|
||||
if AComponent is tiOSFakeComponent then
|
||||
tiOSFakeComponent(AComponent).InitializeDefaultChildren;
|
||||
tiOSFakeComponent(AComponent).InitializeDefaults;
|
||||
end;
|
||||
|
||||
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