diff --git a/components/iphonelazext/ideext.pas b/components/iphonelazext/ideext.pas
index 84d0e12c3..ebe453700 100644
--- a/components/iphonelazext/ideext.pas
+++ b/components/iphonelazext/ideext.pas
@@ -94,6 +94,7 @@ begin
Info.DisplayName:=LazarusIDE.ActiveProject.Title;
Info.iPlatform:=EnvOptions.GetSDKName(ProjOptions.SDK, forSimulator);
Info.SDKVersion:=ProjOptions.SDK;
+ Info.MainNib:=UTF8Decode(ProjOptions.MainNib);
end;
procedure TiPhoneExtension.InstallAppToSim;
@@ -117,6 +118,7 @@ begin
nm:=GetProjectExeName(LazarusIDE.ActiveProject);
FillBunldeInfo(true, Info);
+
CreateBundle(bundleName, Space, ExtractFileName(nm), Info, RealSpace, bundlepath, exepath);
WriteIconTo( IncludeTrailingPathDelimiter(bundlepath)+'Icon.png');
diff --git a/components/iphonelazext/iphonebundle.pas b/components/iphonelazext/iphonebundle.pas
index bed563abe..333ea9fd6 100644
--- a/components/iphonelazext/iphonebundle.pas
+++ b/components/iphonelazext/iphonebundle.pas
@@ -35,6 +35,7 @@ type
iPlatform : WideString;
SDKVersion : WideString;
AppID : WideString;
+ MainNib : WideString;
end;
function GetUserHomeDir: WideString;
@@ -215,12 +216,20 @@ const
' CFBundlePackageType'#10+ ' APPL'#10+
' CFBundleSignature'#10+ ' ????'#10+
' CFBundleSupportedPlatforms'#10+ ' '#10+' %s'#10+' '#10+ {platform}
+ '%s'+ // optional MainNib name
' CFBundleVersion'#10+ ' 1.0'#10+
' DTPlatformName'#10+ ' %s'#10+ {platform}
' DTSDKName'#10+ ' %s'#10+ {sdk version}
' LSRequiresIPhoneOS'#10+ ' '#10+
''#10+
'';
+
+ function MainNibString(const NibName: WideString): AnsiString;
+ begin
+ if NibName='' then Result:=''
+ else Result:='NSMainNibFile'+UTF8Encode(NibName)+''#10;
+ end;
+
var
dispName : WideString;
s : String;
@@ -239,10 +248,12 @@ begin
UTF8Encode(AppID),
UTF8Encode(BundleName),
UTF8Encode(iPlatform),
+ MainNibString(info.MainNib),
UTF8Encode(iPlatform),
UTF8Encode(SDKVersion)
]);
if FileExists(InfoFileName) then DeleteFile(InfoFileName);
+
fs:=TFileStream.Create(InfoFileName, fmCreate or fmOpenWrite);
try
if s<>'' then fs.Write(s[1], length(s));
diff --git a/components/iphonelazext/iphoneextoptions.pas b/components/iphonelazext/iphoneextoptions.pas
index 89bfe24a5..324c55745 100644
--- a/components/iphonelazext/iphoneextoptions.pas
+++ b/components/iphonelazext/iphoneextoptions.pas
@@ -28,26 +28,28 @@ type
TiPhoneProjectOptions = class(TAbstractIDEProjectOptions)
private
- fisiPhone : Boolean;
- fAppID : string;
- fSDK : string;
- DataWritten : Boolean;
- fSpaceName : string;
- fResourceDir : string;
- fExcludeMask : string;
+ fisiPhone : Boolean;
+ fAppID : String;
+ fSDK : String;
+ DataWritten : Boolean;
+ fSpaceName : String;
+ fResourceDir : String;
+ fExcludeMask : String;
+ fMainNib : String;
public
constructor Create;
- class function GetGroupCaption: string; override;
+ class function GetGroupCaption: String; override;
class function GetInstance: TAbstractIDEOptions; override;
function Load: Boolean;
function Save: Boolean;
procedure Reset;
property isIPhoneApp: Boolean read fisIPhone write fisIPhone;
- property SDK: string read fSDK write fSDK;
- property AppID: string read fAppID write fAppID;
- property SpaceName: string read fSpaceName write fSpaceName;
- property ResourceDir: string read fResourceDir write fResourceDir;
- property ExcludeMask: string read fExcludeMask write fExcludeMask;
+ property SDK: String read fSDK write fSDK;
+ property AppID: String read fAppID write fAppID;
+ property SpaceName: String read fSpaceName write fSpaceName;
+ property ResourceDir: String read fResourceDir write fResourceDir;
+ property ExcludeMask: String read fExcludeMask write fExcludeMask;
+ property MainNib: String read fMainNib write fMainNib;
end;
{ TiPhoneEnvironmentOptions }
@@ -62,17 +64,17 @@ type
TiPhoneEnvironmentOptions = class(TAbstractIDEEnvironmentOptions)
private
- fPlatformsBaseDir : string;
- fCompilerPath : string;
- fBaseRTLPath : string;
- fCommonOpt : string;
- fSimAppsPath : string;
- fSimBundle : string;
- fDefaultSDK : string;
+ fPlatformsBaseDir : String;
+ fCompilerPath : String;
+ fBaseRTLPath : String;
+ fCommonOpt : String;
+ fSimAppsPath : String;
+ fSimBundle : String;
+ fDefaultSDK : String;
fVersions : TStringList;
protected
- function XMLFileName: string;
+ function XMLFileName: String;
procedure ClearVersionsInfo;
procedure FoundSDK(const Version, DevSDKName, DevSDKPath, SimSDKName, SimSDKPath: String);
@@ -80,27 +82,27 @@ type
public
constructor Create;
destructor Destroy; override;
- class function GetGroupCaption: string; override;
+ class function GetGroupCaption: String; override;
class function GetInstance: TAbstractIDEOptions; override;
function Load: Boolean;
function Save: Boolean;
- function GetSDKName(const SDKVer: string; simulator: Boolean): string;
- function GetSDKFullPath(const SDKVer: string; simulator: Boolean): string;
+ function GetSDKName(const SDKVer: String; simulator: Boolean): String;
+ function GetSDKFullPath(const SDKVer: String; simulator: Boolean): String;
procedure GetSDKVersions(Strings: TStrings);
procedure RefreshVersions;
- property PlatformsBaseDir: string read fPlatformsBaseDir write fPlatformsBaseDir;
- property CompilerPath: string read fCompilerPath write fCompilerPath;
- property BaseRTLPath: string read fBaseRTLPath write fBaseRTLPath;
- property CommonOpt: string read fCommonOpt write fCommonOpt;
+ property PlatformsBaseDir: String read fPlatformsBaseDir write fPlatformsBaseDir;
+ property CompilerPath: String read fCompilerPath write fCompilerPath;
+ property BaseRTLPath: String read fBaseRTLPath write fBaseRTLPath;
+ property CommonOpt: String read fCommonOpt write fCommonOpt;
- property SimBundle: string read fSimBundle write fSimBundle;
- property SimAppsPath: string read fSimAppsPath write fSimAppsPath;
+ property SimBundle: String read fSimBundle write fSimBundle;
+ property SimAppsPath: String read fSimAppsPath write fSimAppsPath;
- property DefaultSDK: string read fDefaultSDK write fDefaultSDK;
+ property DefaultSDK: String read fDefaultSDK write fDefaultSDK;
end;
function EnvOptions: TiPhoneEnvironmentOptions;
@@ -109,7 +111,7 @@ function ProjOptions: TiPhoneProjectOptions;
type
TSDKFoundEvent = procedure (const Version: String;
- const DeviceSDKName, DeviceSDKPath, SimSDKName, SimSDKPath: string) of object;
+ const DeviceSDKName, DeviceSDKPath, SimSDKName, SimSDKPath: String) of object;
function ScanForSDK(const PlatformDir: String; FoundProc: TSDKFoundEvent): Boolean;
@@ -132,6 +134,7 @@ const
optSpaceName = 'iPhone/SimSpaceName';
optResourceDir = 'iPhone/ResourceDir';
optExcludeMask = 'iPhone/ExcludeMask';
+ optMainNib = 'iPhone/MainNib';
function EnvOptions: TiPhoneEnvironmentOptions;
begin
@@ -162,7 +165,7 @@ end;
{ TiPhoneEnvironmentOptions }
-class function TiPhoneEnvironmentOptions.GetGroupCaption: string;
+class function TiPhoneEnvironmentOptions.GetGroupCaption: String;
begin
Result:='iPhone Environment';
end;
@@ -303,7 +306,7 @@ begin
end;
-function TiPhoneEnvironmentOptions.GetSDKName(const SDKVer: string; simulator: Boolean): string;
+function TiPhoneEnvironmentOptions.GetSDKName(const SDKVer: String; simulator: Boolean): String;
var
info : TSDKInfo;
begin
@@ -315,7 +318,7 @@ begin
end;
end;
-function TiPhoneEnvironmentOptions.GetSDKFullPath(const SDKVer: string; simulator: Boolean): string;
+function TiPhoneEnvironmentOptions.GetSDKFullPath(const SDKVer: String; simulator: Boolean): String;
var
info : TSDKInfo;
begin
@@ -358,7 +361,7 @@ begin
Reset;
end;
-class function TiPhoneProjectOptions.GetGroupCaption: string;
+class function TiPhoneProjectOptions.GetGroupCaption: String;
begin
Result:='iPhone';
end;
@@ -380,12 +383,13 @@ begin
if fSpaceName='' then fSpaceName:=RandomSpaceName;
if CustomData.Contains(optResourceDir) then fResourceDir:=CustomData.Values[optResourceDir];
if CustomData.Contains(optExcludeMask) then fExcludeMask:=CustomData.Values[optExcludeMask];
+ if CustomData.Contains(optMainNib) then fMainNib:=CustomData.Values[optMainNib];
end;
end;
function TiPhoneProjectOptions.Save: Boolean;
const
- BoolStr : array[Boolean] of string = ('false', 'true');
+ BoolStr : array[Boolean] of String = ('false', 'true');
begin
Result:=True;
{do not write iPhone related info to non-iPhone projects}
@@ -397,6 +401,7 @@ begin
CustomData.Values[optSpaceName]:=fSpaceName;
CustomData.Values[optResourceDir]:=fResourceDir;
CustomData.Values[optExcludeMask]:=fExcludeMask;
+ CustomData.Values[optMainNib]:=fMainNib;
end;
end;
@@ -410,7 +415,7 @@ type
end;
// todo: implement reading .plist via OSX functions! (in case a .plist format changes)
-function ReadSDKSettings(const FileName: string; var Descr: TSDKDescription): Boolean;
+function ReadSDKSettings(const FileName: String; var Descr: TSDKDescription): Boolean;
var
plist : TPListFile;
begin
@@ -426,7 +431,7 @@ end;
function isSDKDir(const SDKDir: String; var d: TSDKDescription): Boolean;
var
- plist : string;
+ plist : String;
begin
plist := IncludeTrailingPathDelimiter(SDKDir)+'SDKSettings.plist';
Result:=FileExists(plist);
@@ -437,17 +442,17 @@ end;
function ScanForSDK(const PlatformDir: String; FoundProc: TSDKFoundEvent): Boolean;
const
- PlatformName: array [Boolean] of string = ('iPhoneOS.platform','iPhoneSimulator.platform');
+ PlatformName: array [Boolean] of String = ('iPhoneOS.platform','iPhoneSimulator.platform');
SDKSubDir = PathDelim+'Developer'+PathDelim+'SDKs'+PathDelim;
var
- isSim : Boolean;
- dir : string;
- sr : TSearchRec;
- sdks : array of TSDKDescription;
- descr : TSDKDescription;
- cnt : Integer;
- simname : string;
- simpath : string;
+ isSim : Boolean;
+ dir : String;
+ sr : TSearchRec;
+ sdks : array of TSDKDescription;
+ descr : TSDKDescription;
+ cnt : Integer;
+ simname : String;
+ simpath : String;
i,j : Integer;
procedure AddDescription(const d: TSDKDescription);
diff --git a/components/iphonelazext/iphoneextstr.pas b/components/iphonelazext/iphoneextstr.pas
index 9e8d7c256..da5dfd6a1 100644
--- a/components/iphonelazext/iphoneextstr.pas
+++ b/components/iphonelazext/iphoneextstr.pas
@@ -35,6 +35,10 @@ resourcestring
strWNoSDKSelected = 'Warning: SDK is not selected using %s';
strWNoSDK = 'Warning: No SDK available. Linking might fail.';
+
+ strOpenXibAtIB = 'Open "%s" at Interface Builder';
+ strOpenAtIB = 'Open at Interface Builder';
+
implementation
end.
diff --git a/components/iphonelazext/iphonelazext.lpk b/components/iphonelazext/iphonelazext.lpk
index 1f593d2a4..4439f395e 100644
--- a/components/iphonelazext/iphonelazext.lpk
+++ b/components/iphonelazext/iphonelazext.lpk
@@ -15,10 +15,9 @@
-
+
-
+
diff --git a/components/iphonelazext/project_iphone_options.lfm b/components/iphonelazext/project_iphone_options.lfm
index 8e4bc6969..937a67c12 100644
--- a/components/iphonelazext/project_iphone_options.lfm
+++ b/components/iphonelazext/project_iphone_options.lfm
@@ -1,12 +1,11 @@
inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
- Height = 374
- Width = 618
- ClientHeight = 374
- ClientWidth = 618
+ Height = 474
+ Width = 620
+ ClientHeight = 474
+ ClientWidth = 620
OnClick = FrameClick
- TabOrder = 0
- DesignLeft = 355
- DesignTop = 224
+ DesignLeft = 246
+ DesignTop = 121
object chkisPhone: TCheckBox[0]
Left = 16
Height = 18
@@ -27,7 +26,7 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Left = 112
Height = 22
Top = 85
- Width = 488
+ Width = 490
Anchors = [akTop, akLeft, akRight]
TabOrder = 1
Text = 'com.mycompany.myapp'
@@ -64,8 +63,10 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Left = 120
Height = 22
Top = 176
- Width = 480
+ Width = 482
Anchors = [akTop, akLeft, akRight]
+ OnChange = edtResDirChange
+ OnExit = edtResDirExit
TabOrder = 3
Text = 'Resources'
end
@@ -81,7 +82,7 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Left = 120
Height = 22
Top = 224
- Width = 480
+ Width = 482
Anchors = [akTop, akLeft, akRight]
OnChange = edtExcludeChange
TabOrder = 4
@@ -105,4 +106,47 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
ParentColor = False
ParentFont = False
end
+ object Label4: TLabel[11]
+ Left = 16
+ Height = 18
+ Top = 256
+ Width = 54
+ Caption = 'Nib files:'
+ ParentColor = False
+ end
+ object nibFilesBox: TCheckListBox[12]
+ Left = 120
+ Height = 180
+ Top = 256
+ Width = 482
+ Anchors = [akTop, akLeft, akRight, akBottom]
+ ItemHeight = 0
+ OnClickCheck = nibFilesBoxClickCheck
+ OnItemClick = nibFilesBoxItemClick
+ OnMouseDown = nibFilesBoxMouseDown
+ OnMouseUp = nibFilesBoxMouseUp
+ PopupMenu = nibsPopup
+ TabOrder = 5
+ end
+ object Label5: TLabel[13]
+ AnchorSideTop.Control = nibFilesBox
+ AnchorSideTop.Side = asrBottom
+ Left = 120
+ Height = 14
+ Top = 436
+ Width = 246
+ Caption = 'The checked one is the main Nib of the application'
+ Font.Height = -10
+ ParentColor = False
+ ParentFont = False
+ end
+ object nibsPopup: TPopupMenu[14]
+ OnPopup = nibsPopupPopup
+ left = 256
+ top = 288
+ object mnuOpenIB: TMenuItem
+ Caption = 'Open Interface Builder'
+ OnClick = mnuOpenIBClick
+ end
+ end
end
diff --git a/components/iphonelazext/project_iphone_options.lrs b/components/iphonelazext/project_iphone_options.lrs
index c6a8245e6..14bc43e5c 100644
--- a/components/iphonelazext/project_iphone_options.lrs
+++ b/components/iphonelazext/project_iphone_options.lrs
@@ -2,33 +2,47 @@
LazarusResources.Add('TiPhoneProjectOptionsEditor','FORMDATA',[
'TPF0'#241#27'TiPhoneProjectOptionsEditor'#26'iPhoneProjectOptionsEditor'#6'H'
- +'eight'#3'v'#1#5'Width'#3'j'#2#12'ClientHeight'#3'v'#1#11'ClientWidth'#3'j'#2
- +#7'OnClick'#7#10'FrameClick'#8'TabOrder'#2#0#10'DesignLeft'#3'c'#1#9'DesignT'
- +'op'#3#224#0#0#242#2#0#9'TCheckBox'#10'chkisPhone'#4'Left'#2#16#6'Height'#2
- +#18#3'Top'#2#16#5'Width'#3#199#0#7'Caption'#6#29'is iPhone application proje'
- +'ct'#8'TabOrder'#2#0#0#0#242#2#1#6'TLabel'#8'lblAppID'#4'Left'#2#16#6'Height'
- +#2#18#3'Top'#2'X'#5'Width'#2'W'#7'Caption'#6#14'Application ID'#11'ParentCol'
- +'or'#8#0#0#242#2#2#5'TEdit'#8'edtAppID'#4'Left'#2'p'#6'Height'#2#22#3'Top'#2
- +'U'#5'Width'#3#232#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrde'
- +'r'#2#1#4'Text'#6#19'com.mycompany.myapp'#0#0#242#2#3#6'TLabel'#12'lblAppIDH'
- +'int'#4'Left'#2#16#6'Height'#2#14#3'Top'#2'u'#5'Width'#3#237#1#7'Caption'#6
- +'_It''s recommended by Apple to use domain-structured name, i.e. com.mycompa'
- +'ny.myApplication as ID'#11'Font.Height'#2#246#11'ParentColor'#8#10'ParentFo'
- +'nt'#8#0#0#242#2#4#6'TLabel'#9'lblSDKVer'#4'Left'#2#16#6'Height'#2#18#3'Top'
- +#2'3'#5'Width'#2'P'#7'Caption'#6#12'SDK version:'#11'ParentColor'#8#0#0#242#2
- +#5#9'TComboBox'#7'cmbSDKs'#4'Left'#2'p'#6'Height'#2#20#3'Top'#2'0'#5'Width'#3
- +#184#0#10'ItemHeight'#2#0#8'OnChange'#7#13'cmbSDKsChange'#5'Style'#7#14'csDr'
- +'opDownList'#8'TabOrder'#2#2#0#0#242#2#6#5'TEdit'#9'edtResDir'#4'Left'#2'x'#6
- +'Height'#2#22#3'Top'#3#176#0#5'Width'#3#224#1#7'Anchors'#11#5'akTop'#6'akLef'
- +'t'#7'akRight'#0#8'TabOrder'#2#3#4'Text'#6#9'Resources'#0#0#242#2#7#6'TLabel'
- +#6'Label1'#4'Left'#2#16#6'Height'#2#18#3'Top'#3#176#0#5'Width'#2'Y'#7'Captio'
- +'n'#6#14'Resources dir:'#11'ParentColor'#8#0#0#242#2#8#5'TEdit'#10'edtExclud'
- +'e'#4'Left'#2'x'#6'Height'#2#22#3'Top'#3#224#0#5'Width'#3#224#1#7'Anchors'#11
- +#5'akTop'#6'akLeft'#7'akRight'#0#8'OnChange'#7#16'edtExcludeChange'#8'TabOrd'
- +'er'#2#4#4'Text'#6#4'.svn'#0#0#242#2#9#6'TLabel'#6'Label2'#4'Left'#2#16#6'He'
- +'ight'#2#18#3'Top'#3#224#0#5'Width'#2'Q'#7'Caption'#6#12'Ignore mask:'#11'Pa'
- +'rentColor'#8#0#0#242#2#10#6'TLabel'#6'Label3'#4'Left'#2#16#6'Height'#2#14#3
- +'Top'#3#200#0#5'Width'#3'l'#1#7'Caption'#6'NIt''s recommended to set resourc'
- +'e dir as a relative (to project .lpr file) path'#11'Font.Height'#2#246#11'P'
- +'arentColor'#8#10'ParentFont'#8#0#0#0
+ +'eight'#3#218#1#5'Width'#3'l'#2#12'ClientHeight'#3#218#1#11'ClientWidth'#3'l'
+ +#2#7'OnClick'#7#10'FrameClick'#10'DesignLeft'#3#246#0#9'DesignTop'#2'y'#0#242
+ +#2#0#9'TCheckBox'#10'chkisPhone'#4'Left'#2#16#6'Height'#2#18#3'Top'#2#16#5'W'
+ +'idth'#3#199#0#7'Caption'#6#29'is iPhone application project'#8'TabOrder'#2#0
+ +#0#0#242#2#1#6'TLabel'#8'lblAppID'#4'Left'#2#16#6'Height'#2#18#3'Top'#2'X'#5
+ +'Width'#2'W'#7'Caption'#6#14'Application ID'#11'ParentColor'#8#0#0#242#2#2#5
+ +'TEdit'#8'edtAppID'#4'Left'#2'p'#6'Height'#2#22#3'Top'#2'U'#5'Width'#3#234#1
+ +#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrder'#2#1#4'Text'#6#19
+ +'com.mycompany.myapp'#0#0#242#2#3#6'TLabel'#12'lblAppIDHint'#4'Left'#2#16#6
+ +'Height'#2#14#3'Top'#2'u'#5'Width'#3#237#1#7'Caption'#6'_It''s recommended b'
+ +'y Apple to use domain-structured name, i.e. com.mycompany.myApplication as '
+ +'ID'#11'Font.Height'#2#246#11'ParentColor'#8#10'ParentFont'#8#0#0#242#2#4#6
+ +'TLabel'#9'lblSDKVer'#4'Left'#2#16#6'Height'#2#18#3'Top'#2'3'#5'Width'#2'P'#7
+ +'Caption'#6#12'SDK version:'#11'ParentColor'#8#0#0#242#2#5#9'TComboBox'#7'cm'
+ +'bSDKs'#4'Left'#2'p'#6'Height'#2#20#3'Top'#2'0'#5'Width'#3#184#0#10'ItemHeig'
+ +'ht'#2#0#8'OnChange'#7#13'cmbSDKsChange'#5'Style'#7#14'csDropDownList'#8'Tab'
+ +'Order'#2#2#0#0#242#2#6#5'TEdit'#9'edtResDir'#4'Left'#2'x'#6'Height'#2#22#3
+ +'Top'#3#176#0#5'Width'#3#226#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0
+ +#8'OnChange'#7#15'edtResDirChange'#6'OnExit'#7#13'edtResDirExit'#8'TabOrder'
+ +#2#3#4'Text'#6#9'Resources'#0#0#242#2#7#6'TLabel'#6'Label1'#4'Left'#2#16#6'H'
+ +'eight'#2#18#3'Top'#3#176#0#5'Width'#2'Y'#7'Caption'#6#14'Resources dir:'#11
+ +'ParentColor'#8#0#0#242#2#8#5'TEdit'#10'edtExclude'#4'Left'#2'x'#6'Height'#2
+ +#22#3'Top'#3#224#0#5'Width'#3#226#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRig'
+ +'ht'#0#8'OnChange'#7#16'edtExcludeChange'#8'TabOrder'#2#4#4'Text'#6#4'.svn'#0
+ +#0#242#2#9#6'TLabel'#6'Label2'#4'Left'#2#16#6'Height'#2#18#3'Top'#3#224#0#5
+ +'Width'#2'Q'#7'Caption'#6#12'Ignore mask:'#11'ParentColor'#8#0#0#242#2#10#6
+ +'TLabel'#6'Label3'#4'Left'#2#16#6'Height'#2#14#3'Top'#3#200#0#5'Width'#3'l'#1
+ +#7'Caption'#6'NIt''s recommended to set resource dir as a relative (to proje'
+ +'ct .lpr file) path'#11'Font.Height'#2#246#11'ParentColor'#8#10'ParentFont'#8
+ +#0#0#242#2#11#6'TLabel'#6'Label4'#4'Left'#2#16#6'Height'#2#18#3'Top'#3#0#1#5
+ +'Width'#2'6'#7'Caption'#6#10'Nib files:'#11'ParentColor'#8#0#0#242#2#12#13'T'
+ +'CheckListBox'#11'nibFilesBox'#4'Left'#2'x'#6'Height'#3#180#0#3'Top'#3#0#1#5
+ +'Width'#3#226#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#10
+ +'ItemHeight'#2#0#12'OnClickCheck'#7#21'nibFilesBoxClickCheck'#11'OnItemClick'
+ +#7#20'nibFilesBoxItemClick'#11'OnMouseDown'#7#20'nibFilesBoxMouseDown'#9'OnM'
+ +'ouseUp'#7#18'nibFilesBoxMouseUp'#9'PopupMenu'#7#9'nibsPopup'#8'TabOrder'#2#5
+ +#0#0#242#2#13#6'TLabel'#6'Label5'#21'AnchorSideTop.Control'#7#11'nibFilesBox'
+ +#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2'x'#6'Height'#2#14#3'Top'#3
+ +#180#1#5'Width'#3#246#0#7'Caption'#6'2The checked one is the main Nib of the'
+ +' application'#11'Font.Height'#2#246#11'ParentColor'#8#10'ParentFont'#8#0#0
+ +#242#2#14#10'TPopupMenu'#9'nibsPopup'#7'OnPopup'#7#14'nibsPopupPopup'#4'left'
+ +#3#0#1#3'top'#3' '#1#0#9'TMenuItem'#9'mnuOpenIB'#7'Caption'#6#22'Open Interf'
+ +'ace Builder'#7'OnClick'#7#14'mnuOpenIBClick'#0#0#0#0
]);
diff --git a/components/iphonelazext/project_iphone_options.pas b/components/iphonelazext/project_iphone_options.pas
index 673961ca2..e132fc948 100644
--- a/components/iphonelazext/project_iphone_options.pas
+++ b/components/iphonelazext/project_iphone_options.pas
@@ -19,15 +19,17 @@ unit project_iphone_options;
interface
uses
- Classes, SysUtils, FileUtil, LResources, Forms, StdCtrls,
- IDEOPtionsIntf, ProjectIntf,
- iPhoneExtStr, iPhoneExtOptions;
+ Classes,SysUtils,FileUtil,LResources,Forms,StdCtrls,Masks,CheckLst,Buttons,
+ Menus,IDEOptionsIntf,ProjectIntf,LazIDEIntf,iPhoneExtStr,iPhoneExtOptions, process, Controls;
type
{ TiPhoneProjectOptionsEditor }
TiPhoneProjectOptionsEditor = class(TAbstractIDEOptionsEditor)
+ Label5:TLabel;
+ mnuOpenIB:TMenuItem;
+ nibFilesBox:TCheckListBox;
chkisPhone: TCheckBox;
cmbSDKs: TComboBox;
edtResDir: TEdit;
@@ -36,16 +38,33 @@ type
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
+ Label4:TLabel;
lblAppID: TLabel;
lblAppIDHint: TLabel;
lblSDKVer: TLabel;
+ nibsPopup:TPopupMenu;
procedure cmbSDKsChange(Sender: TObject);
procedure edtExcludeChange(Sender: TObject);
+ procedure edtResDirChange(Sender:TObject);
+ procedure edtResDirExit(Sender:TObject);
procedure FrameClick(Sender: TObject);
+ procedure mnuOpenIBClick(Sender:TObject);
+ procedure nibFilesBoxClickCheck(Sender:TObject);
+ procedure nibFilesBoxItemClick(Sender:TObject;Index:integer);
+ procedure nibFilesBoxMouseDown(Sender:TObject;Button:TMouseButton;Shift:
+ TShiftState;X,Y:Integer);
+ procedure nibFilesBoxMouseUp(Sender:TObject;Button:TMouseButton;Shift:
+ TShiftState;X,Y:Integer);
+ procedure nibsPopupPopup(Sender:TObject);
private
{ private declarations }
- fOnChanged : TNotifyEvent;
+ SelXibFile : String;
+ ResDirChanged : Boolean;
+
+ fOnChanged : TNotifyEvent;
procedure DoChanged;
+
+ procedure RefreshXIBList;
public
{ public declarations }
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
@@ -58,6 +77,42 @@ type
implementation
+procedure EnumFilesAtDir(const PathUtf8, AMask : AnsiString; Dst: TStrings);
+var
+ mask : TMask;
+ sr : TSearchRec;
+ path : AnsiString;
+begin
+ if (AMask='') or (trim(AMask)='*') then mask:=nil else mask:=TMask.Create(AMask);
+ try
+ path:=IncludeTrailingPathDelimiter(PathUtf8);
+ if FindFirstUTF8(path+AllFilesMask, faAnyFile, sr) = 0 then begin
+ repeat
+ if (sr.Name<>'.') and (sr.Name<>'..') then
+ if not Assigned(mask) or mask.Matches(sr.Name) then
+ Dst.Add(path+sr.Name);
+ until FindNextUTF8(sr)<>0;
+ FindCloseUTF8(sr);
+ end;
+ finally
+ mask.Free;
+ end;
+end;
+
+procedure ExecCmdLine(const CmdLineUtf8: AnsiString; WaitExit: Boolean);
+var
+ proc : TProcess;
+begin
+ proc:=TProcess.Create(nil);
+ try
+ proc.CommandLine:=CmdLineUtf8;
+ //proc.WaitOnExit:=WaitExit;
+ proc.Execute;
+ finally
+ proc.Free;
+ end;
+end;
+
{ TiPhoneProjectOptionsEditor }
procedure TiPhoneProjectOptionsEditor.cmbSDKsChange(Sender: TObject);
@@ -70,16 +125,120 @@ begin
end;
+procedure TiPhoneProjectOptionsEditor.edtResDirChange(Sender:TObject);
+begin
+ ResDirChanged:=True;
+end;
+
+procedure TiPhoneProjectOptionsEditor.edtResDirExit(Sender:TObject);
+var
+ s : AnsiString;
+ chk : AnsiString;
+ i : Integer;
+begin
+ if not ResDirChanged then Exit;
+ ResDirChanged:=False;
+
+
+ // storing checked and selected items
+ for i:=0 to nibFilesBox.Count-1 do
+ if nibFilesBox.Checked[i] then
+ chk:=nibFilesBox.Items[i];
+ if nibFilesBox.ItemIndex>=0 then
+ s:=nibFilesBox.Items[nibFilesBox.ItemIndex]
+ else
+ s := '';
+
+ // refreshing the list
+ RefreshXIBList;
+
+ // restore selection and checked item
+ if s<>'' then nibFilesBox.ItemIndex:=nibFilesBox.Items.IndexOf(s);
+ i:=nibFilesBox.Items.IndexOf(chk);
+ nibFilesBox.Checked[i]:=True;
+end;
+
procedure TiPhoneProjectOptionsEditor.FrameClick(Sender: TObject);
begin
end;
+procedure TiPhoneProjectOptionsEditor.mnuOpenIBClick(Sender:TObject);
+var
+ path : AnsiString;
+begin
+ path:=ChangeFileExt(IncludeTrailingPathDelimiter(edtResDir.Text)+SelXibFile,'.xib');
+ LazarusIDE.ActiveProject.LongenFilename(path);
+ ExecCmdLine('open ' + path, false);
+end;
+
+procedure TiPhoneProjectOptionsEditor.nibFilesBoxClickCheck(Sender:TObject);
+begin
+end;
+
+procedure TiPhoneProjectOptionsEditor.nibFilesBoxItemClick(Sender:TObject;Index: integer);
+var
+ i, j : Integer;
+begin
+ j:=-1;
+ for i:=0 to nibFilesBox.Count-1 do
+ if nibFilesBox.Checked[i] and (Index<>i) then begin
+ j:=i;
+ end;
+ if j>=0 then nibFilesBox.Checked[j]:=false;
+end;
+
+procedure TiPhoneProjectOptionsEditor.nibFilesBoxMouseDown(Sender:TObject;Button
+ :TMouseButton;Shift:TShiftState;X,Y:Integer);
+var
+ i: Integer;
+begin
+ i:=nibFilesBox.ItemAtPos(Point(X,Y), True);
+ if i>=0 then begin
+ nibFilesBox.ItemIndex:=i;
+ SelXibFile:=nibFilesBox.Items[i];
+ end else
+ SelXibFile:='';
+end;
+
+procedure TiPhoneProjectOptionsEditor.nibFilesBoxMouseUp(Sender:TObject;Button:
+ TMouseButton;Shift:TShiftState;X,Y:Integer);
+begin
+end;
+
+procedure TiPhoneProjectOptionsEditor.nibsPopupPopup(Sender:TObject);
+begin
+ mnuOpenIB.Enabled:=SelXibFile<>'';
+ if mnuOpenIB.Enabled then
+ mnuOpenIB.Caption:=Format(strOpenXibAtIB, [SelXibFile])
+ else
+ mnuOpenIB.Caption:=strOpenAtIB;
+end;
+
procedure TiPhoneProjectOptionsEditor.DoChanged;
begin
if Assigned(fOnChanged) then fOnChanged(Self);
end;
+procedure TiPhoneProjectOptionsEditor.RefreshXIBList;
+var
+ path : AnsiString;
+ st : TStringList;
+ i : Integer;
+begin
+ path := edtResDir.Text;
+ st:=TStringList.Create;
+ try
+ LazarusIDE.ActiveProject.LongenFilename(path);
+ EnumFilesAtDir(path, '*.xib', st);
+ nibFilesBox.Clear;
+ for i:=0 to st.Count-1 do
+ nibFilesBox.Items.Add( ChangeFileExt( ExtractFileName(st[i]), ''));
+ finally
+ st.Free;
+ end;
+end;
+
function TiPhoneProjectOptionsEditor.GetTitle: String;
begin
Result:=strPrjOptTitle;
@@ -113,10 +272,25 @@ begin
edtExclude.Text:=ExcludeMask;
end;
+ RefreshXIBList;
+ if TiPhoneProjectOptions(AOptions).MainNib<>'' then begin
+ i:=nibFilesBox.Items.IndexOf(TiPhoneProjectOptions(AOptions).MainNib);
+ if i>=0 then nibFilesBox.Checked[i]:=True;
+ end;
end;
procedure TiPhoneProjectOptionsEditor.WriteSettings(AOptions: TAbstractIDEOptions);
+var
+ amainnib : AnsiString;
+ i : integer;
begin
+ amainnib:='';
+ for i:=0 to nibFilesBox.Count-1 do
+ if nibFilesBox.Checked[i] then begin
+ amainnib:=nibFilesBox.Items[i];
+ Break;
+ end;
+
with TiPhoneProjectOptions(AOptions) do
begin
isIPhoneApp:=chkisPhone.Checked;
@@ -124,6 +298,7 @@ begin
AppID:=edtAppID.Text;
ResourceDir:=edtResDir.Text;
ExcludeMask:=edtExclude.Text;
+ MainNib:=amainnib;
Save;
DoChanged;
end;