* Initial start of NIB-designer for Lazarus
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2480 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
2075b60834
commit
0ffef64893
100
components/iosdesigner/MainWindow_iPhone.template
Normal file
100
components/iosdesigner/MainWindow_iPhone.template
Normal file
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1280</int>
|
||||
<string key="IBDocument.SystemVersion">11D50</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
|
||||
<string key="IBDocument.AppKitVersion">1138.32</string>
|
||||
<string key="IBDocument.HIToolboxVersion">568.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">1181</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>IBUIWindow</string>
|
||||
<string>IBUICustomObject</string>
|
||||
<string>IBUIButton</string>
|
||||
<string>IBProxyObject</string>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
[{Objects}]
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
[{ConnectionRecords}]
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<object class="NSArray" key="object" id="0">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
</object>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
[{ObjectRecords}]
|
||||
</object>
|
||||
</object>
|
||||
[{flattenedProperties}]
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="activeLocalization"/>
|
||||
<object class="NSMutableDictionary" key="localizations">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference key="dict.sortedKeys" ref="0"/>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">1000</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">AppDelegate</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">window</string>
|
||||
<string key="NS.object.0">UIWindow</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<string key="NS.key.0">window</string>
|
||||
<object class="IBToOneOutletInfo" key="NS.object.0">
|
||||
<string key="name">window</string>
|
||||
<string key="candidateClassName">UIWindow</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/AppDelegate.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
|
||||
<integer value="3100" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<string key="IBCocoaTouchPluginVersion">1181</string>
|
||||
</data>
|
||||
</archive>
|
2
components/iosdesigner/README.txt
Normal file
2
components/iosdesigner/README.txt
Normal file
@ -0,0 +1,2 @@
|
||||
This package contains a designer to create NIB-files which can be integrated
|
||||
into an iOS application.
|
1697
components/iosdesigner/ios_views.pas
Normal file
1697
components/iosdesigner/ios_views.pas
Normal file
File diff suppressed because it is too large
Load Diff
71
components/iosdesigner/iosdesigner.lpk
Normal file
71
components/iosdesigner/iosdesigner.lpk
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<Name Value="iOSDesigner"/>
|
||||
<Author Value="Joost van der Sluis"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="A designer to create iOS applications"/>
|
||||
<License Value="Modified LGPL (Same license as Lazarus' LCL)"/>
|
||||
<Version Minor="1"/>
|
||||
<Files Count="5">
|
||||
<Item1>
|
||||
<Filename Value="README.txt"/>
|
||||
<Type Value="Text"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="iosnibdesigner.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="iOSNIBDesigner"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Filename Value="ios_views.pas"/>
|
||||
<UnitName Value="iOS_Views"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="iosideintf.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="iOSIdeIntf"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Filename Value="MainWindow_iPhone.template"/>
|
||||
<Type Value="Text"/>
|
||||
</Item5>
|
||||
</Files>
|
||||
<Type Value="DesignTime"/>
|
||||
<RequiredPkgs Count="4">
|
||||
<Item1>
|
||||
<PackageName Value="ide"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="iphonelazext"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item4>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
22
components/iosdesigner/iosdesigner.pas
Normal file
22
components/iosdesigner/iosdesigner.pas
Normal file
@ -0,0 +1,22 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit iOSDesigner;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
iOSNIBDesigner, iOS_Views, iOSIdeIntf, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('iOSNIBDesigner', @iOSNIBDesigner.Register);
|
||||
RegisterUnit('iOSIdeIntf', @iOSIdeIntf.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('iOSDesigner', @Register);
|
||||
end.
|
297
components/iosdesigner/iosideintf.pas
Normal file
297
components/iosdesigner/iosideintf.pas
Normal file
@ -0,0 +1,297 @@
|
||||
unit iOSIdeIntf;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Forms, ProjectIntf, iPhoneExtOptions;
|
||||
|
||||
type
|
||||
|
||||
{ TiOSApplicationDescriptor }
|
||||
|
||||
TiOSApplicationDescriptor = class(TProjectDescriptor)
|
||||
public
|
||||
constructor Create; override;
|
||||
function GetLocalizedName: string; override;
|
||||
function GetLocalizedDescription: string; override;
|
||||
function InitProject(AProject: TLazProject): TModalResult; override;
|
||||
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
|
||||
end;
|
||||
|
||||
{ TiOSObjectDelegateWindowFileDesc }
|
||||
|
||||
TiOSObjectDelegateWindowFileDesc = class(TFileDescPascalUnitWithResource)
|
||||
protected
|
||||
function GetDelegateProtocols: string; virtual;
|
||||
public
|
||||
constructor Create; override;
|
||||
function GetInterfaceUsesSection: string; override;
|
||||
function GetImplementationSource(const Filename, SourceName, ResourceName: string): string;override;
|
||||
function GetInterfaceSource(const Filename, SourceName, ResourceName: string): string; override;
|
||||
function GetUnitDirectives: string; override;
|
||||
function GetLocalizedName: string; override;
|
||||
function GetLocalizedDescription: string; override;
|
||||
end;
|
||||
|
||||
|
||||
{ TiOSAppDelegateWindowFileDesc }
|
||||
|
||||
TiOSAppDelegateWindowFileDesc = class(TiOSObjectDelegateWindowFileDesc)
|
||||
protected
|
||||
function GetDelegateProtocols: string; override;
|
||||
public
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
{ TiOSInfo_PlistFileDesc }
|
||||
|
||||
TiOSInfo_PlistFileDesc = class(TProjectFileDescriptor)
|
||||
public
|
||||
constructor Create; override;
|
||||
function CreateSource(const Filename, SourceName, ResourceName: string): string; override;
|
||||
end;
|
||||
|
||||
var
|
||||
GiOSApplicationDescriptor: TiOSApplicationDescriptor;
|
||||
GiOSAppDelegateWindowFileDesc: TiOSAppDelegateWindowFileDesc;
|
||||
GiOSInfo_PlistFileDesc: TiOSInfo_PlistFileDesc;
|
||||
GiOSObjectDelegateWindowFileDesc: TiOSObjectDelegateWindowFileDesc;
|
||||
|
||||
procedure register;
|
||||
|
||||
implementation
|
||||
|
||||
uses LazIDEIntf, Controls, iOS_Views;
|
||||
|
||||
procedure register;
|
||||
begin
|
||||
GiOSApplicationDescriptor:=TiOSApplicationDescriptor.Create;
|
||||
RegisterProjectDescriptor(GiOSApplicationDescriptor);
|
||||
GiOSAppDelegateWindowFileDesc:=TiOSAppDelegateWindowFileDesc.Create;
|
||||
RegisterProjectFileDescriptor(GiOSAppDelegateWindowFileDesc);
|
||||
GiOSInfo_PlistFileDesc:=TiOSInfo_PlistFileDesc.Create;
|
||||
RegisterProjectFileDescriptor(GiOSInfo_PlistFileDesc);
|
||||
GiOSObjectDelegateWindowFileDesc:=TiOSObjectDelegateWindowFileDesc.Create;
|
||||
RegisterProjectFileDescriptor(GiOSObjectDelegateWindowFileDesc);
|
||||
|
||||
end;
|
||||
|
||||
{ TiOSObjectDelegateWindowFileDesc }
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetDelegateProtocols: string;
|
||||
begin
|
||||
result := '';
|
||||
end;
|
||||
|
||||
constructor TiOSObjectDelegateWindowFileDesc.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name:='iOS NIB-Delegate';
|
||||
ResourceClass:=NSObject;
|
||||
UseCreateFormStatements:=false;
|
||||
VisibleInNewDialog:=true;
|
||||
end;
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetInterfaceUsesSection: string;
|
||||
begin
|
||||
Result:='iPhoneAll';
|
||||
end;
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetImplementationSource(
|
||||
const Filename, SourceName, ResourceName: string): string;
|
||||
begin
|
||||
Result:='procedure T'+ResourceName+'.dealloc;' + LineEnding +
|
||||
'begin' + LineEnding +
|
||||
' inherited dealloc;' + LineEnding +
|
||||
'end;' + LineEnding +
|
||||
LineEnding +
|
||||
'{$R *.lfm}' + LineEnding + LineEnding;
|
||||
end;
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetInterfaceSource(const Filename, SourceName, ResourceName: string): string;
|
||||
var
|
||||
DelegateProtocol: string;
|
||||
begin
|
||||
DelegateProtocol:=GetDelegateProtocols;
|
||||
if DelegateProtocol<>'' then
|
||||
DelegateProtocol:=','+DelegateProtocol;
|
||||
Result:=
|
||||
'type'+LineEnding
|
||||
+' T'+ResourceName+' = objcclass('+ResourceClass.ClassName+DelegateProtocol+')'+LineEnding
|
||||
+' private'+LineEnding
|
||||
+' { private declarations }'+LineEnding
|
||||
+' public'+LineEnding
|
||||
+' procedure dealloc; override;'+LineEnding
|
||||
+' end;'+LineEnding
|
||||
+LineEnding;
|
||||
end;
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetUnitDirectives: string;
|
||||
begin
|
||||
Result:='{$modeswitch ObjectiveC1}';
|
||||
end;
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetLocalizedName: string;
|
||||
begin
|
||||
Result:='iOS NIB Delegate';
|
||||
end;
|
||||
|
||||
function TiOSObjectDelegateWindowFileDesc.GetLocalizedDescription: string;
|
||||
begin
|
||||
Result:='Create a new iOS-NIB file with a delegate to handle it''s contents. '+
|
||||
'The contents of the NIB can be changed with the designer.';
|
||||
end;
|
||||
|
||||
{ TiOSInfo_PlistFileDesc }
|
||||
|
||||
constructor TiOSInfo_PlistFileDesc.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name:='Info_Plist';
|
||||
DefaultFilename:='Info.Plist';
|
||||
IsPascalUnit:=false;
|
||||
VisibleInNewDialog:=false;
|
||||
end;
|
||||
|
||||
function TiOSInfo_PlistFileDesc.CreateSource(const Filename, SourceName, ResourceName: string): string;
|
||||
begin
|
||||
Result:='<?xml version="1.0" encoding="UTF-8"?>' + LineEnding +
|
||||
'<!DOCTYPE plist public "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' + LineEnding +
|
||||
'<plist version="1.0">' + LineEnding +
|
||||
'<dict>' + LineEnding +
|
||||
' <key>CFBundleDevelopmentRegion</key>' + LineEnding +
|
||||
' <string>en</string>' + LineEnding +
|
||||
' <key>CFBundleDisplayName</key>' + LineEnding +
|
||||
' <string>${PRODUCT_NAME}</string>' + LineEnding +
|
||||
' <key>CFBundleExecutable</key>' + LineEnding +
|
||||
' <string>${EXECUTABLE_NAME}</string>' + LineEnding +
|
||||
' <key>CFBundleIconFile</key>' + LineEnding +
|
||||
' <string></string>' + LineEnding +
|
||||
' <key>CFBundleIdentifier</key>' + LineEnding +
|
||||
' <string>CNOC.${PRODUCT_NAME:rfc1034identifier}</string>' + LineEnding +
|
||||
' <key>CFBundleInfoDictionaryVersion</key>' + LineEnding +
|
||||
' <string>6.0</string>' + LineEnding +
|
||||
' <key>CFBundleName</key>' + LineEnding +
|
||||
' <string>${PRODUCT_NAME}</string>' + LineEnding +
|
||||
' <key>CFBundlePackageType</key>' + LineEnding +
|
||||
' <string>APPL</string>' + LineEnding +
|
||||
' <key>CFBundleShortVersionString</key>' + LineEnding +
|
||||
' <string>1.0</string>' + LineEnding +
|
||||
' <key>CFBundleSignature</key>' + LineEnding +
|
||||
' <string>????</string>' + LineEnding +
|
||||
' <key>CFBundleVersion</key>' + LineEnding +
|
||||
' <string>1.0</string>' + LineEnding +
|
||||
' <key>LSRequiresIPhoneOS</key>' + LineEnding +
|
||||
' <true/>' + LineEnding +
|
||||
' <key>NSMainNibFile</key>' + LineEnding +
|
||||
' <string>MainWindow_iPhone</string>' + LineEnding +
|
||||
' <key>NSMainNibFile~ipad</key>' + LineEnding +
|
||||
' <string>MainWindow_iPad</string>' + LineEnding +
|
||||
' <key>UISupportedInterfaceOrientations</key>' + LineEnding +
|
||||
' <array>' + LineEnding +
|
||||
' <string>UIInterfaceOrientationLandscapeLeft</string>' + LineEnding +
|
||||
' <string>UIInterfaceOrientationLandscapeRight</string>' + LineEnding +
|
||||
' <string>UIInterfaceOrientationPortrait</string>' + LineEnding +
|
||||
' </array>' + LineEnding +
|
||||
' <key>UISupportedInterfaceOrientations~ipad</key>' + LineEnding +
|
||||
' <array>' + LineEnding +
|
||||
' <string>UIInterfaceOrientationPortrait</string>' + LineEnding +
|
||||
' <string>UIInterfaceOrientationPortraitUpsideDown</string>' + LineEnding +
|
||||
' <string>UIInterfaceOrientationLandscapeLeft</string>' + LineEnding +
|
||||
' <string>UIInterfaceOrientationLandscapeRight</string>' + LineEnding +
|
||||
' </array>' + LineEnding +
|
||||
'</dict>' + LineEnding +
|
||||
'</plist>'+LineEnding+LineEnding;
|
||||
end;
|
||||
|
||||
{ TiOSAppDelegateWindowFileDesc }
|
||||
|
||||
function TiOSAppDelegateWindowFileDesc.GetDelegateProtocols: string;
|
||||
begin
|
||||
Result:='UIApplicationDelegateProtocol';
|
||||
end;
|
||||
|
||||
constructor TiOSAppDelegateWindowFileDesc.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name:='iOS UIApplicationDelegate';
|
||||
VisibleInNewDialog:=false;
|
||||
end;
|
||||
|
||||
{ TiOSApplicationDescriptor }
|
||||
|
||||
constructor TiOSApplicationDescriptor.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'iOS application';
|
||||
end;
|
||||
|
||||
function TiOSApplicationDescriptor.GetLocalizedName: string;
|
||||
begin
|
||||
Result := 'iOS application';
|
||||
end;
|
||||
|
||||
function TiOSApplicationDescriptor.GetLocalizedDescription: string;
|
||||
begin
|
||||
Result:='iOS application'#13#13'An iOS program '
|
||||
+'designed in Lazarus without using the LCL. The program file is '
|
||||
+'automatically maintained by Lazarus.';
|
||||
end;
|
||||
|
||||
function TiOSApplicationDescriptor.InitProject(AProject: TLazProject): TModalResult;
|
||||
var
|
||||
NewSource: String;
|
||||
MainFile: TLazProjectFile;
|
||||
begin
|
||||
inherited InitProject(AProject);
|
||||
|
||||
MainFile:=AProject.CreateProjectFile('iosapp.lpr');
|
||||
MainFile.IsPartOfProject:=true;
|
||||
AProject.AddFile(MainFile,false);
|
||||
AProject.MainFileID:=0;
|
||||
|
||||
// create program source
|
||||
NewSource:='program iosapp;' + LineEnding +
|
||||
LineEnding +
|
||||
'{$modeswitch ObjectiveC1}' + LineEnding +
|
||||
LineEnding +
|
||||
'uses' + LineEnding +
|
||||
' iPhoneAll, AppDelegate_iPhoneU;' + LineEnding +
|
||||
LineEnding +
|
||||
'var' + LineEnding +
|
||||
' pool : NSAutoreleasePool;' + LineEnding +
|
||||
'begin' + LineEnding +
|
||||
' pool := NSAutoreleasePool.alloc.init;' + LineEnding +
|
||||
' UIApplicationMain(argc, argv, nil, nil);' + LineEnding +
|
||||
' pool.release;' + LineEnding +
|
||||
'end.' + LineEnding + LineEnding;
|
||||
|
||||
AProject.MainFile.SetSourceText(NewSource);
|
||||
|
||||
// add
|
||||
AProject.AddPackageDependency('FCL');
|
||||
|
||||
// compiler options
|
||||
AProject.LazCompilerOptions.Win32GraphicApp:=false;
|
||||
|
||||
//AProject.LazCompilerOptions.CustomOptions:='-XR/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk';
|
||||
AProject.LazCompilerOptions.TargetOS:='iphonesim';
|
||||
AProject.Flags := AProject.Flags - [pfMainUnitHasCreateFormStatements];
|
||||
Result:= mrOK;
|
||||
end;
|
||||
|
||||
function TiOSApplicationDescriptor.CreateStartFiles(AProject: TLazProject): TModalResult;
|
||||
begin
|
||||
//LazarusIDE.DoSaveAll([sfProjectSaving]);
|
||||
GiOSAppDelegateWindowFileDesc.DefaultResourceName:='AppDelegate_iPhone';
|
||||
LazarusIDE.DoNewEditorFile(GiOSAppDelegateWindowFileDesc,'appdelegate_iphoneu.pas','',[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
|
||||
result := mrOK;
|
||||
ProjOptions.isIPhoneApp:=true;
|
||||
ProjOptions.MainNib:='appdelegate_iphoneu';
|
||||
ProjOptions.Save;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
333
components/iosdesigner/iosnibdesigner.pas
Normal file
333
components/iosdesigner/iosnibdesigner.pas
Normal file
@ -0,0 +1,333 @@
|
||||
{ iOS NOB-designer for the Lazarus IDE
|
||||
|
||||
Copyright (C) 2012 Joost van der Sluis joost@cnoc.nl
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version with the following modification:
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent modules,and
|
||||
to copy and distribute the resulting executable under terms of your choice,
|
||||
provided that you also meet, for each linked independent module, the terms
|
||||
and conditions of the license of that module. An independent module is a
|
||||
module which is not derived from or based on this library. If you modify
|
||||
this library, you may extend this exception to your version of the library,
|
||||
but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
}
|
||||
|
||||
unit iOSNIBDesigner;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$typeinfo off}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LCLProc, LCLType, Classes, SysUtils, FormEditingIntf, LCLIntf, Graphics, propedits, CodeToolManager,
|
||||
ProjectIntf,
|
||||
iOS_Views,
|
||||
dom,
|
||||
IDEIntf,
|
||||
IDEWindowIntf,
|
||||
LazIDEIntf,
|
||||
Dialogs,
|
||||
{$ifndef OutsideIDE}
|
||||
CustomNonFormDesigner,
|
||||
{$endif OutsideIDE}
|
||||
Controls,
|
||||
ComponentReg,
|
||||
typinfo,
|
||||
forms;
|
||||
|
||||
type
|
||||
|
||||
{ TNSObjectDesignerMediator }
|
||||
|
||||
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;
|
||||
procedure GetBounds(AComponent: TComponent; out CurBounds: TRect); override;
|
||||
procedure SetBounds(AComponent: TComponent; NewBounds: TRect); override;
|
||||
procedure GetClientArea(AComponent: TComponent; out CurClientArea: TRect; out ScrollOffset: TPoint); override;
|
||||
procedure Paint; override;
|
||||
function ComponentIsIcon(AComponent: TComponent): boolean; override;
|
||||
function ParentAcceptsChild(Parent: TComponent; Child: TComponentClass): boolean; override;
|
||||
procedure InitComponent(AComponent, NewParent: TComponent; NewBounds: TRect); override;
|
||||
function CreateComponent(ParentComp: TComponent;
|
||||
TypeClass: TComponentClass;
|
||||
const AUnitName: shortstring;
|
||||
X,Y,W,H: Integer;
|
||||
DisableAutoSize: boolean): TComponent;
|
||||
public
|
||||
// needed by UIView
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean);
|
||||
property MyForm: NSObject read FMyForm;
|
||||
end;
|
||||
|
||||
{ TUIResponderDesignerMediator }
|
||||
|
||||
TUIResponderDesignerMediator = class(TNSObjectDesignerMediator)
|
||||
public
|
||||
class function FormClass: TComponentClass; override;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
|
||||
procedure SetFakeUnitname(AClass: TClass);
|
||||
var
|
||||
ATypInfo: PTypeInfo;
|
||||
ATypData: PTypeData;
|
||||
begin
|
||||
ATypInfo:=PTypeInfo(AClass.ClassInfo);
|
||||
ATypData:=GetTypeData(ATypInfo);
|
||||
|
||||
ATypData^.UnitName[1]:='i';
|
||||
ATypData^.UnitName[2]:='P';
|
||||
ATypData^.UnitName[3]:='h';
|
||||
ATypData^.UnitName[4]:='o';
|
||||
ATypData^.UnitName[5]:='n';
|
||||
ATypData^.UnitName[6]:='e';
|
||||
ATypData^.UnitName[7]:='A';
|
||||
ATypData^.UnitName[8]:='l';
|
||||
ATypData^.UnitName[9]:='l';
|
||||
end;
|
||||
|
||||
begin
|
||||
FormEditingHook.RegisterDesignerMediator(TNSObjectDesignerMediator);
|
||||
FormEditingHook.RegisterDesignerMediator(TUIResponderDesignerMediator);
|
||||
RegisterComponents('iOS',[UIWindow,UINavigationController,UIButton,UILabel,UITextField,UITableView,UISearchBar,UIView,UIViewController, UIProgressView]);
|
||||
|
||||
RegisterClass(UINavigationItem);
|
||||
RegisterClass(UIViewController);
|
||||
RegisterClass(UINavigationBar);
|
||||
|
||||
// This is a hack to overwrite the unitname RTTI-information of these objects.
|
||||
// This is to make sure that the Codetools add the right unit-name to the
|
||||
// source when an object is added to the NIB-file.
|
||||
SetFakeUnitname(UIButton);
|
||||
SetFakeUnitname(UILabel);
|
||||
SetFakeUnitname(UITextField);
|
||||
SetFakeUnitname(UITableView);
|
||||
SetFakeUnitname(UISearchBar);
|
||||
SetFakeUnitname(UIWindow);
|
||||
SetFakeUnitname(UIView);
|
||||
SetFakeUnitname(UINavigationController);
|
||||
SetFakeUnitname(UIViewController);
|
||||
SetFakeUnitname(UIProgressView);
|
||||
end;
|
||||
|
||||
{ TNSObjectDesignerMediator }
|
||||
|
||||
constructor TNSObjectDesignerMediator.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
end;
|
||||
|
||||
destructor TNSObjectDesignerMediator.Destroy;
|
||||
begin
|
||||
if FMyForm<>nil then FMyForm.Designer:=nil;
|
||||
FMyForm:=nil;
|
||||
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;
|
||||
begin
|
||||
Result:=inherited CreateMediator(TheOwner,aForm);
|
||||
Mediator:=TNSObjectDesignerMediator(Result);
|
||||
Mediator.FMyForm:=aForm as NSObject;
|
||||
Mediator.FMyForm.Designer:=Mediator;
|
||||
end;
|
||||
|
||||
class function TNSObjectDesignerMediator.FormClass: TComponentClass;
|
||||
begin
|
||||
Result:=NSObject;
|
||||
end;
|
||||
|
||||
procedure TNSObjectDesignerMediator.GetBounds(AComponent: TComponent; out CurBounds: TRect);
|
||||
var
|
||||
w: tiOSFakeComponent;
|
||||
begin
|
||||
if AComponent is tiOSFakeComponent then begin
|
||||
w:=tiOSFakeComponent(AComponent);
|
||||
CurBounds:=Bounds(w.Left,w.Top,w.Width,w.Height);
|
||||
end else
|
||||
inherited GetBounds(AComponent,CurBounds);
|
||||
end;
|
||||
|
||||
procedure TNSObjectDesignerMediator.InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean);
|
||||
begin
|
||||
if (LCLForm=nil) or (not LCLForm.HandleAllocated) then exit;
|
||||
LCLIntf.InvalidateRect(LCLForm.Handle,@ARect,Erase);
|
||||
end;
|
||||
|
||||
procedure TNSObjectDesignerMediator.SetBounds(AComponent: TComponent; NewBounds: TRect);
|
||||
begin
|
||||
if AComponent is tiOSFakeComponent then begin
|
||||
tiOSFakeComponent(AComponent).SetBounds(NewBounds.Left,NewBounds.Top,
|
||||
NewBounds.Right-NewBounds.Left,NewBounds.Bottom-NewBounds.Top);
|
||||
end else
|
||||
inherited SetBounds(AComponent,NewBounds);
|
||||
end;
|
||||
|
||||
procedure TNSObjectDesignerMediator.GetClientArea(AComponent: TComponent; out CurClientArea: TRect; out ScrollOffset: TPoint);
|
||||
var
|
||||
Widget: tiOSFakeComponent;
|
||||
begin
|
||||
if AComponent is tiOSFakeComponent then begin
|
||||
Widget:=tiOSFakeComponent(AComponent);
|
||||
CurClientArea:=Rect(0,0,
|
||||
Widget.Width,
|
||||
Widget.Height);
|
||||
ScrollOffset:=Point(0,0);
|
||||
end else
|
||||
inherited GetClientArea(AComponent, CurClientArea, ScrollOffset);
|
||||
end;
|
||||
|
||||
procedure TNSObjectDesignerMediator.Paint;
|
||||
|
||||
procedure PaintWidget(AWidget: tiOSFakeComponent);
|
||||
var
|
||||
i: Integer;
|
||||
Child: tiOSFakeComponent;
|
||||
begin
|
||||
with LCLForm.Canvas do
|
||||
begin
|
||||
if AWidget is NSObject then
|
||||
begin
|
||||
Brush.Style:=bsClear;
|
||||
Brush.Color:=clLtGray;
|
||||
Pen.Color:=clMaroon;
|
||||
Rectangle(0,0,AWidget.Width,AWidget.Height);
|
||||
end
|
||||
else
|
||||
begin
|
||||
AWidget.Paint(LCLForm.Canvas);
|
||||
end;
|
||||
// children
|
||||
if AWidget.ChildCount>0 then
|
||||
begin
|
||||
//SaveHandleState;
|
||||
// clip client area
|
||||
{if IntersectClipRect(Handle, AWidget.left, AWidget.Top, AWidget.left+AWidget.Width,
|
||||
AWidget.Height+AWidget.Top)<>NullRegion
|
||||
then} begin
|
||||
for i:=0 to AWidget.ChildCount-1 do begin
|
||||
SaveHandleState;
|
||||
Child:=AWidget.Children[i];
|
||||
// clip child area
|
||||
MoveWindowOrgEx(Handle,Child.Left,Child.Top);
|
||||
if IntersectClipRect(Handle,0,0,Child.Width,Child.Height)<>NullRegion then
|
||||
PaintWidget(Child);
|
||||
RestoreHandleState;
|
||||
end;
|
||||
end;
|
||||
//RestoreHandleState;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
PaintWidget(MyForm);
|
||||
inherited Paint;
|
||||
end;
|
||||
|
||||
function TNSObjectDesignerMediator.ComponentIsIcon(AComponent: TComponent): boolean;
|
||||
begin
|
||||
Result:=not (AComponent is tiOSFakeComponent);
|
||||
end;
|
||||
|
||||
function TNSObjectDesignerMediator.ParentAcceptsChild(Parent: TComponent; Child: TComponentClass): boolean;
|
||||
begin
|
||||
Result:=(Parent is tiOSFakeComponent) and (Child.InheritsFrom(tiOSFakeComponent))
|
||||
and (tiOSFakeComponent(Parent).AcceptChildsAtDesignTime);
|
||||
end;
|
||||
|
||||
procedure TNSObjectDesignerMediator.InitComponent(AComponent, NewParent: TComponent; NewBounds: TRect);
|
||||
begin
|
||||
inherited InitComponent(AComponent, NewParent, NewBounds);
|
||||
if AComponent is tiOSFakeComponent then
|
||||
tiOSFakeComponent(AComponent).InitializeDefaultChildren;
|
||||
end;
|
||||
|
||||
function TNSObjectDesignerMediator.CreateComponent(ParentComp: TComponent;
|
||||
TypeClass: TComponentClass; const AUnitName: shortstring; X, Y, W,
|
||||
H: Integer; DisableAutoSize: boolean): TComponent;
|
||||
begin
|
||||
result := FormEditingHook.CreateComponent(ParentComp,TypeClass,AUnitName,x,y,w,h,DisableAutoSize);
|
||||
end;
|
||||
|
||||
{ TUIResponderDesignerMediator }
|
||||
|
||||
class function TUIResponderDesignerMediator.FormClass: TComponentClass;
|
||||
begin
|
||||
Result:=UIResponder;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user