diff --git a/components/iosdesigner/iosdesigner.lpk b/components/iosdesigner/iosdesigner.lpk
index c565eb844..19aa316b8 100644
--- a/components/iosdesigner/iosdesigner.lpk
+++ b/components/iosdesigner/iosdesigner.lpk
@@ -20,7 +20,7 @@
-
+
@@ -43,11 +43,15 @@
+
+
+
+
-
+
@@ -67,5 +71,8 @@
+
+ <_ExternHelp Items="Count"/>
+
diff --git a/components/iosdesigner/iosdesigner.pas b/components/iosdesigner/iosdesigner.pas
index e3fc3db81..015aa67c8 100644
--- a/components/iosdesigner/iosdesigner.pas
+++ b/components/iosdesigner/iosdesigner.pas
@@ -7,7 +7,7 @@ unit iOSDesigner;
interface
uses
- iOSNIBDesigner, iOS_Views, iOSIdeIntf, LazarusPackageIntf;
+ iOSNIBDesigner, iOS_Views, iOSIdeIntf, iOSXIBResource, LazarusPackageIntf;
implementation
diff --git a/components/iosdesigner/iosideintf.pas b/components/iosdesigner/iosideintf.pas
index e3ab187d7..b8b735008 100644
--- a/components/iosdesigner/iosideintf.pas
+++ b/components/iosdesigner/iosideintf.pas
@@ -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;
diff --git a/components/iosdesigner/iosnibdesigner.pas b/components/iosdesigner/iosnibdesigner.pas
index b51d0e5e8..4423e1a1c 100644
--- a/components/iosdesigner/iosnibdesigner.pas
+++ b/components/iosdesigner/iosnibdesigner.pas
@@ -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;
diff --git a/components/iosdesigner/iosxibresource.pas b/components/iosdesigner/iosxibresource.pas
new file mode 100644
index 000000000..e47632a81
--- /dev/null
+++ b/components/iosdesigner/iosxibresource.pas
@@ -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.
+