iphonelazext: added nib files support

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1205 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2010-04-25 08:47:00 +00:00
parent ba71677f7c
commit 9941cd6ca4
8 changed files with 348 additions and 94 deletions

View File

@ -94,6 +94,7 @@ begin
Info.DisplayName:=LazarusIDE.ActiveProject.Title; Info.DisplayName:=LazarusIDE.ActiveProject.Title;
Info.iPlatform:=EnvOptions.GetSDKName(ProjOptions.SDK, forSimulator); Info.iPlatform:=EnvOptions.GetSDKName(ProjOptions.SDK, forSimulator);
Info.SDKVersion:=ProjOptions.SDK; Info.SDKVersion:=ProjOptions.SDK;
Info.MainNib:=UTF8Decode(ProjOptions.MainNib);
end; end;
procedure TiPhoneExtension.InstallAppToSim; procedure TiPhoneExtension.InstallAppToSim;
@ -117,6 +118,7 @@ begin
nm:=GetProjectExeName(LazarusIDE.ActiveProject); nm:=GetProjectExeName(LazarusIDE.ActiveProject);
FillBunldeInfo(true, Info); FillBunldeInfo(true, Info);
CreateBundle(bundleName, Space, ExtractFileName(nm), Info, RealSpace, bundlepath, exepath); CreateBundle(bundleName, Space, ExtractFileName(nm), Info, RealSpace, bundlepath, exepath);
WriteIconTo( IncludeTrailingPathDelimiter(bundlepath)+'Icon.png'); WriteIconTo( IncludeTrailingPathDelimiter(bundlepath)+'Icon.png');

View File

@ -35,6 +35,7 @@ type
iPlatform : WideString; iPlatform : WideString;
SDKVersion : WideString; SDKVersion : WideString;
AppID : WideString; AppID : WideString;
MainNib : WideString;
end; end;
function GetUserHomeDir: WideString; function GetUserHomeDir: WideString;
@ -215,12 +216,20 @@ const
' <key>CFBundlePackageType</key>'#10+ ' <string>APPL</string>'#10+ ' <key>CFBundlePackageType</key>'#10+ ' <string>APPL</string>'#10+
' <key>CFBundleSignature</key>'#10+ ' <string>????</string>'#10+ ' <key>CFBundleSignature</key>'#10+ ' <string>????</string>'#10+
' <key>CFBundleSupportedPlatforms</key>'#10+ ' <array>'#10+' <string>%s</string>'#10+' </array>'#10+ {platform} ' <key>CFBundleSupportedPlatforms</key>'#10+ ' <array>'#10+' <string>%s</string>'#10+' </array>'#10+ {platform}
'%s'+ // optional MainNib name
' <key>CFBundleVersion</key>'#10+ ' <string>1.0</string>'#10+ ' <key>CFBundleVersion</key>'#10+ ' <string>1.0</string>'#10+
' <key>DTPlatformName</key>'#10+ ' <string>%s</string>'#10+ {platform} ' <key>DTPlatformName</key>'#10+ ' <string>%s</string>'#10+ {platform}
' <key>DTSDKName</key>'#10+ ' <string>%s</string>'#10+ {sdk version} ' <key>DTSDKName</key>'#10+ ' <string>%s</string>'#10+ {sdk version}
' <key>LSRequiresIPhoneOS</key>'#10+ ' <true/>'#10+ ' <key>LSRequiresIPhoneOS</key>'#10+ ' <true/>'#10+
'</dict>'#10+ '</dict>'#10+
'</plist>'; '</plist>';
function MainNibString(const NibName: WideString): AnsiString;
begin
if NibName='' then Result:=''
else Result:='<key>NSMainNibFile</key><string>'+UTF8Encode(NibName)+'</string>'#10;
end;
var var
dispName : WideString; dispName : WideString;
s : String; s : String;
@ -239,10 +248,12 @@ begin
UTF8Encode(AppID), UTF8Encode(AppID),
UTF8Encode(BundleName), UTF8Encode(BundleName),
UTF8Encode(iPlatform), UTF8Encode(iPlatform),
MainNibString(info.MainNib),
UTF8Encode(iPlatform), UTF8Encode(iPlatform),
UTF8Encode(SDKVersion) UTF8Encode(SDKVersion)
]); ]);
if FileExists(InfoFileName) then DeleteFile(InfoFileName); if FileExists(InfoFileName) then DeleteFile(InfoFileName);
fs:=TFileStream.Create(InfoFileName, fmCreate or fmOpenWrite); fs:=TFileStream.Create(InfoFileName, fmCreate or fmOpenWrite);
try try
if s<>'' then fs.Write(s[1], length(s)); if s<>'' then fs.Write(s[1], length(s));

View File

@ -29,25 +29,27 @@ type
TiPhoneProjectOptions = class(TAbstractIDEProjectOptions) TiPhoneProjectOptions = class(TAbstractIDEProjectOptions)
private private
fisiPhone : Boolean; fisiPhone : Boolean;
fAppID : string; fAppID : String;
fSDK : string; fSDK : String;
DataWritten : Boolean; DataWritten : Boolean;
fSpaceName : string; fSpaceName : String;
fResourceDir : string; fResourceDir : String;
fExcludeMask : string; fExcludeMask : String;
fMainNib : String;
public public
constructor Create; constructor Create;
class function GetGroupCaption: string; override; class function GetGroupCaption: String; override;
class function GetInstance: TAbstractIDEOptions; override; class function GetInstance: TAbstractIDEOptions; override;
function Load: Boolean; function Load: Boolean;
function Save: Boolean; function Save: Boolean;
procedure Reset; procedure Reset;
property isIPhoneApp: Boolean read fisIPhone write fisIPhone; property isIPhoneApp: Boolean read fisIPhone write fisIPhone;
property SDK: string read fSDK write fSDK; property SDK: String read fSDK write fSDK;
property AppID: string read fAppID write fAppID; property AppID: String read fAppID write fAppID;
property SpaceName: string read fSpaceName write fSpaceName; property SpaceName: String read fSpaceName write fSpaceName;
property ResourceDir: string read fResourceDir write fResourceDir; property ResourceDir: String read fResourceDir write fResourceDir;
property ExcludeMask: string read fExcludeMask write fExcludeMask; property ExcludeMask: String read fExcludeMask write fExcludeMask;
property MainNib: String read fMainNib write fMainNib;
end; end;
{ TiPhoneEnvironmentOptions } { TiPhoneEnvironmentOptions }
@ -62,17 +64,17 @@ type
TiPhoneEnvironmentOptions = class(TAbstractIDEEnvironmentOptions) TiPhoneEnvironmentOptions = class(TAbstractIDEEnvironmentOptions)
private private
fPlatformsBaseDir : string; fPlatformsBaseDir : String;
fCompilerPath : string; fCompilerPath : String;
fBaseRTLPath : string; fBaseRTLPath : String;
fCommonOpt : string; fCommonOpt : String;
fSimAppsPath : string; fSimAppsPath : String;
fSimBundle : string; fSimBundle : String;
fDefaultSDK : string; fDefaultSDK : String;
fVersions : TStringList; fVersions : TStringList;
protected protected
function XMLFileName: string; function XMLFileName: String;
procedure ClearVersionsInfo; procedure ClearVersionsInfo;
procedure FoundSDK(const Version, DevSDKName, DevSDKPath, SimSDKName, SimSDKPath: String); procedure FoundSDK(const Version, DevSDKName, DevSDKPath, SimSDKName, SimSDKPath: String);
@ -80,27 +82,27 @@ type
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
class function GetGroupCaption: string; override; class function GetGroupCaption: String; override;
class function GetInstance: TAbstractIDEOptions; override; class function GetInstance: TAbstractIDEOptions; override;
function Load: Boolean; function Load: Boolean;
function Save: Boolean; function Save: Boolean;
function GetSDKName(const SDKVer: string; simulator: Boolean): string; function GetSDKName(const SDKVer: String; simulator: Boolean): String;
function GetSDKFullPath(const SDKVer: string; simulator: Boolean): string; function GetSDKFullPath(const SDKVer: String; simulator: Boolean): String;
procedure GetSDKVersions(Strings: TStrings); procedure GetSDKVersions(Strings: TStrings);
procedure RefreshVersions; procedure RefreshVersions;
property PlatformsBaseDir: string read fPlatformsBaseDir write fPlatformsBaseDir; property PlatformsBaseDir: String read fPlatformsBaseDir write fPlatformsBaseDir;
property CompilerPath: string read fCompilerPath write fCompilerPath; property CompilerPath: String read fCompilerPath write fCompilerPath;
property BaseRTLPath: string read fBaseRTLPath write fBaseRTLPath; property BaseRTLPath: String read fBaseRTLPath write fBaseRTLPath;
property CommonOpt: string read fCommonOpt write fCommonOpt; property CommonOpt: String read fCommonOpt write fCommonOpt;
property SimBundle: string read fSimBundle write fSimBundle; property SimBundle: String read fSimBundle write fSimBundle;
property SimAppsPath: string read fSimAppsPath write fSimAppsPath; property SimAppsPath: String read fSimAppsPath write fSimAppsPath;
property DefaultSDK: string read fDefaultSDK write fDefaultSDK; property DefaultSDK: String read fDefaultSDK write fDefaultSDK;
end; end;
function EnvOptions: TiPhoneEnvironmentOptions; function EnvOptions: TiPhoneEnvironmentOptions;
@ -109,7 +111,7 @@ function ProjOptions: TiPhoneProjectOptions;
type type
TSDKFoundEvent = procedure (const Version: String; 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; function ScanForSDK(const PlatformDir: String; FoundProc: TSDKFoundEvent): Boolean;
@ -132,6 +134,7 @@ const
optSpaceName = 'iPhone/SimSpaceName'; optSpaceName = 'iPhone/SimSpaceName';
optResourceDir = 'iPhone/ResourceDir'; optResourceDir = 'iPhone/ResourceDir';
optExcludeMask = 'iPhone/ExcludeMask'; optExcludeMask = 'iPhone/ExcludeMask';
optMainNib = 'iPhone/MainNib';
function EnvOptions: TiPhoneEnvironmentOptions; function EnvOptions: TiPhoneEnvironmentOptions;
begin begin
@ -162,7 +165,7 @@ end;
{ TiPhoneEnvironmentOptions } { TiPhoneEnvironmentOptions }
class function TiPhoneEnvironmentOptions.GetGroupCaption: string; class function TiPhoneEnvironmentOptions.GetGroupCaption: String;
begin begin
Result:='iPhone Environment'; Result:='iPhone Environment';
end; end;
@ -303,7 +306,7 @@ begin
end; end;
function TiPhoneEnvironmentOptions.GetSDKName(const SDKVer: string; simulator: Boolean): string; function TiPhoneEnvironmentOptions.GetSDKName(const SDKVer: String; simulator: Boolean): String;
var var
info : TSDKInfo; info : TSDKInfo;
begin begin
@ -315,7 +318,7 @@ begin
end; end;
end; end;
function TiPhoneEnvironmentOptions.GetSDKFullPath(const SDKVer: string; simulator: Boolean): string; function TiPhoneEnvironmentOptions.GetSDKFullPath(const SDKVer: String; simulator: Boolean): String;
var var
info : TSDKInfo; info : TSDKInfo;
begin begin
@ -358,7 +361,7 @@ begin
Reset; Reset;
end; end;
class function TiPhoneProjectOptions.GetGroupCaption: string; class function TiPhoneProjectOptions.GetGroupCaption: String;
begin begin
Result:='iPhone'; Result:='iPhone';
end; end;
@ -380,12 +383,13 @@ begin
if fSpaceName='' then fSpaceName:=RandomSpaceName; if fSpaceName='' then fSpaceName:=RandomSpaceName;
if CustomData.Contains(optResourceDir) then fResourceDir:=CustomData.Values[optResourceDir]; if CustomData.Contains(optResourceDir) then fResourceDir:=CustomData.Values[optResourceDir];
if CustomData.Contains(optExcludeMask) then fExcludeMask:=CustomData.Values[optExcludeMask]; if CustomData.Contains(optExcludeMask) then fExcludeMask:=CustomData.Values[optExcludeMask];
if CustomData.Contains(optMainNib) then fMainNib:=CustomData.Values[optMainNib];
end; end;
end; end;
function TiPhoneProjectOptions.Save: Boolean; function TiPhoneProjectOptions.Save: Boolean;
const const
BoolStr : array[Boolean] of string = ('false', 'true'); BoolStr : array[Boolean] of String = ('false', 'true');
begin begin
Result:=True; Result:=True;
{do not write iPhone related info to non-iPhone projects} {do not write iPhone related info to non-iPhone projects}
@ -397,6 +401,7 @@ begin
CustomData.Values[optSpaceName]:=fSpaceName; CustomData.Values[optSpaceName]:=fSpaceName;
CustomData.Values[optResourceDir]:=fResourceDir; CustomData.Values[optResourceDir]:=fResourceDir;
CustomData.Values[optExcludeMask]:=fExcludeMask; CustomData.Values[optExcludeMask]:=fExcludeMask;
CustomData.Values[optMainNib]:=fMainNib;
end; end;
end; end;
@ -410,7 +415,7 @@ type
end; end;
// todo: implement reading .plist via OSX functions! (in case a .plist format changes) // 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 var
plist : TPListFile; plist : TPListFile;
begin begin
@ -426,7 +431,7 @@ end;
function isSDKDir(const SDKDir: String; var d: TSDKDescription): Boolean; function isSDKDir(const SDKDir: String; var d: TSDKDescription): Boolean;
var var
plist : string; plist : String;
begin begin
plist := IncludeTrailingPathDelimiter(SDKDir)+'SDKSettings.plist'; plist := IncludeTrailingPathDelimiter(SDKDir)+'SDKSettings.plist';
Result:=FileExists(plist); Result:=FileExists(plist);
@ -437,17 +442,17 @@ end;
function ScanForSDK(const PlatformDir: String; FoundProc: TSDKFoundEvent): Boolean; function ScanForSDK(const PlatformDir: String; FoundProc: TSDKFoundEvent): Boolean;
const 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; SDKSubDir = PathDelim+'Developer'+PathDelim+'SDKs'+PathDelim;
var var
isSim : Boolean; isSim : Boolean;
dir : string; dir : String;
sr : TSearchRec; sr : TSearchRec;
sdks : array of TSDKDescription; sdks : array of TSDKDescription;
descr : TSDKDescription; descr : TSDKDescription;
cnt : Integer; cnt : Integer;
simname : string; simname : String;
simpath : string; simpath : String;
i,j : Integer; i,j : Integer;
procedure AddDescription(const d: TSDKDescription); procedure AddDescription(const d: TSDKDescription);

View File

@ -35,6 +35,10 @@ resourcestring
strWNoSDKSelected = 'Warning: SDK is not selected using %s'; strWNoSDKSelected = 'Warning: SDK is not selected using %s';
strWNoSDK = 'Warning: No SDK available. Linking might fail.'; strWNoSDK = 'Warning: No SDK available. Linking might fail.';
strOpenXibAtIB = 'Open "%s" at Interface Builder';
strOpenAtIB = 'Open at Interface Builder';
implementation implementation
end. end.

View File

@ -15,10 +15,9 @@
<CompilerPath Value="$(CompPath)"/> <CompilerPath Value="$(CompPath)"/>
</Other> </Other>
</CompilerOptions> </CompilerOptions>
<Description Value="iPhone Development Lazarus extension <Description Value="iPhone Development Lazarus extension"/>
"/>
<License Value="LGPL"/> <License Value="LGPL"/>
<Version Minor="5"/> <Version Minor="6"/>
<Files Count="11"> <Files Count="11">
<Item1> <Item1>
<Filename Value="ideext.pas"/> <Filename Value="ideext.pas"/>

View File

@ -1,12 +1,11 @@
inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Height = 374 Height = 474
Width = 618 Width = 620
ClientHeight = 374 ClientHeight = 474
ClientWidth = 618 ClientWidth = 620
OnClick = FrameClick OnClick = FrameClick
TabOrder = 0 DesignLeft = 246
DesignLeft = 355 DesignTop = 121
DesignTop = 224
object chkisPhone: TCheckBox[0] object chkisPhone: TCheckBox[0]
Left = 16 Left = 16
Height = 18 Height = 18
@ -27,7 +26,7 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Left = 112 Left = 112
Height = 22 Height = 22
Top = 85 Top = 85
Width = 488 Width = 490
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
TabOrder = 1 TabOrder = 1
Text = 'com.mycompany.myapp' Text = 'com.mycompany.myapp'
@ -64,8 +63,10 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Left = 120 Left = 120
Height = 22 Height = 22
Top = 176 Top = 176
Width = 480 Width = 482
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
OnChange = edtResDirChange
OnExit = edtResDirExit
TabOrder = 3 TabOrder = 3
Text = 'Resources' Text = 'Resources'
end end
@ -81,7 +82,7 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
Left = 120 Left = 120
Height = 22 Height = 22
Top = 224 Top = 224
Width = 480 Width = 482
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
OnChange = edtExcludeChange OnChange = edtExcludeChange
TabOrder = 4 TabOrder = 4
@ -105,4 +106,47 @@ inherited iPhoneProjectOptionsEditor: TiPhoneProjectOptionsEditor
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
end 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 end

View File

@ -2,33 +2,47 @@
LazarusResources.Add('TiPhoneProjectOptionsEditor','FORMDATA',[ LazarusResources.Add('TiPhoneProjectOptionsEditor','FORMDATA',[
'TPF0'#241#27'TiPhoneProjectOptionsEditor'#26'iPhoneProjectOptionsEditor'#6'H' '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 +'eight'#3#218#1#5'Width'#3'l'#2#12'ClientHeight'#3#218#1#11'ClientWidth'#3'l'
+#7'OnClick'#7#10'FrameClick'#8'TabOrder'#2#0#10'DesignLeft'#3'c'#1#9'DesignT' +#2#7'OnClick'#7#10'FrameClick'#10'DesignLeft'#3#246#0#9'DesignTop'#2'y'#0#242
+'op'#3#224#0#0#242#2#0#9'TCheckBox'#10'chkisPhone'#4'Left'#2#16#6'Height'#2 +#2#0#9'TCheckBox'#10'chkisPhone'#4'Left'#2#16#6'Height'#2#18#3'Top'#2#16#5'W'
+#18#3'Top'#2#16#5'Width'#3#199#0#7'Caption'#6#29'is iPhone application proje' +'idth'#3#199#0#7'Caption'#6#29'is iPhone application project'#8'TabOrder'#2#0
+'ct'#8'TabOrder'#2#0#0#0#242#2#1#6'TLabel'#8'lblAppID'#4'Left'#2#16#6'Height' +#0#0#242#2#1#6'TLabel'#8'lblAppID'#4'Left'#2#16#6'Height'#2#18#3'Top'#2'X'#5
+#2#18#3'Top'#2'X'#5'Width'#2'W'#7'Caption'#6#14'Application ID'#11'ParentCol' +'Width'#2'W'#7'Caption'#6#14'Application ID'#11'ParentColor'#8#0#0#242#2#2#5
+'or'#8#0#0#242#2#2#5'TEdit'#8'edtAppID'#4'Left'#2'p'#6'Height'#2#22#3'Top'#2 +'TEdit'#8'edtAppID'#4'Left'#2'p'#6'Height'#2#22#3'Top'#2'U'#5'Width'#3#234#1
+'U'#5'Width'#3#232#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrde' +#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrder'#2#1#4'Text'#6#19
+'r'#2#1#4'Text'#6#19'com.mycompany.myapp'#0#0#242#2#3#6'TLabel'#12'lblAppIDH' +'com.mycompany.myapp'#0#0#242#2#3#6'TLabel'#12'lblAppIDHint'#4'Left'#2#16#6
+'int'#4'Left'#2#16#6'Height'#2#14#3'Top'#2'u'#5'Width'#3#237#1#7'Caption'#6 +'Height'#2#14#3'Top'#2'u'#5'Width'#3#237#1#7'Caption'#6'_It''s recommended b'
+'_It''s recommended by Apple to use domain-structured name, i.e. com.mycompa' +'y Apple to use domain-structured name, i.e. com.mycompany.myApplication as '
+'ny.myApplication as ID'#11'Font.Height'#2#246#11'ParentColor'#8#10'ParentFo' +'ID'#11'Font.Height'#2#246#11'ParentColor'#8#10'ParentFont'#8#0#0#242#2#4#6
+'nt'#8#0#0#242#2#4#6'TLabel'#9'lblSDKVer'#4'Left'#2#16#6'Height'#2#18#3'Top' +'TLabel'#9'lblSDKVer'#4'Left'#2#16#6'Height'#2#18#3'Top'#2'3'#5'Width'#2'P'#7
+#2'3'#5'Width'#2'P'#7'Caption'#6#12'SDK version:'#11'ParentColor'#8#0#0#242#2 +'Caption'#6#12'SDK version:'#11'ParentColor'#8#0#0#242#2#5#9'TComboBox'#7'cm'
+#5#9'TComboBox'#7'cmbSDKs'#4'Left'#2'p'#6'Height'#2#20#3'Top'#2'0'#5'Width'#3 +'bSDKs'#4'Left'#2'p'#6'Height'#2#20#3'Top'#2'0'#5'Width'#3#184#0#10'ItemHeig'
+#184#0#10'ItemHeight'#2#0#8'OnChange'#7#13'cmbSDKsChange'#5'Style'#7#14'csDr' +'ht'#2#0#8'OnChange'#7#13'cmbSDKsChange'#5'Style'#7#14'csDropDownList'#8'Tab'
+'opDownList'#8'TabOrder'#2#2#0#0#242#2#6#5'TEdit'#9'edtResDir'#4'Left'#2'x'#6 +'Order'#2#2#0#0#242#2#6#5'TEdit'#9'edtResDir'#4'Left'#2'x'#6'Height'#2#22#3
+'Height'#2#22#3'Top'#3#176#0#5'Width'#3#224#1#7'Anchors'#11#5'akTop'#6'akLef' +'Top'#3#176#0#5'Width'#3#226#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0
+'t'#7'akRight'#0#8'TabOrder'#2#3#4'Text'#6#9'Resources'#0#0#242#2#7#6'TLabel' +#8'OnChange'#7#15'edtResDirChange'#6'OnExit'#7#13'edtResDirExit'#8'TabOrder'
+#6'Label1'#4'Left'#2#16#6'Height'#2#18#3'Top'#3#176#0#5'Width'#2'Y'#7'Captio' +#2#3#4'Text'#6#9'Resources'#0#0#242#2#7#6'TLabel'#6'Label1'#4'Left'#2#16#6'H'
+'n'#6#14'Resources dir:'#11'ParentColor'#8#0#0#242#2#8#5'TEdit'#10'edtExclud' +'eight'#2#18#3'Top'#3#176#0#5'Width'#2'Y'#7'Caption'#6#14'Resources dir:'#11
+'e'#4'Left'#2'x'#6'Height'#2#22#3'Top'#3#224#0#5'Width'#3#224#1#7'Anchors'#11 +'ParentColor'#8#0#0#242#2#8#5'TEdit'#10'edtExclude'#4'Left'#2'x'#6'Height'#2
+#5'akTop'#6'akLeft'#7'akRight'#0#8'OnChange'#7#16'edtExcludeChange'#8'TabOrd' +#22#3'Top'#3#224#0#5'Width'#3#226#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRig'
+'er'#2#4#4'Text'#6#4'.svn'#0#0#242#2#9#6'TLabel'#6'Label2'#4'Left'#2#16#6'He' +'ht'#0#8'OnChange'#7#16'edtExcludeChange'#8'TabOrder'#2#4#4'Text'#6#4'.svn'#0
+'ight'#2#18#3'Top'#3#224#0#5'Width'#2'Q'#7'Caption'#6#12'Ignore mask:'#11'Pa' +#0#242#2#9#6'TLabel'#6'Label2'#4'Left'#2#16#6'Height'#2#18#3'Top'#3#224#0#5
+'rentColor'#8#0#0#242#2#10#6'TLabel'#6'Label3'#4'Left'#2#16#6'Height'#2#14#3 +'Width'#2'Q'#7'Caption'#6#12'Ignore mask:'#11'ParentColor'#8#0#0#242#2#10#6
+'Top'#3#200#0#5'Width'#3'l'#1#7'Caption'#6'NIt''s recommended to set resourc' +'TLabel'#6'Label3'#4'Left'#2#16#6'Height'#2#14#3'Top'#3#200#0#5'Width'#3'l'#1
+'e dir as a relative (to project .lpr file) path'#11'Font.Height'#2#246#11'P' +#7'Caption'#6'NIt''s recommended to set resource dir as a relative (to proje'
+'arentColor'#8#10'ParentFont'#8#0#0#0 +'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
]); ]);

View File

@ -19,15 +19,17 @@ unit project_iphone_options;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, StdCtrls, Classes,SysUtils,FileUtil,LResources,Forms,StdCtrls,Masks,CheckLst,Buttons,
IDEOPtionsIntf, ProjectIntf, Menus,IDEOptionsIntf,ProjectIntf,LazIDEIntf,iPhoneExtStr,iPhoneExtOptions, process, Controls;
iPhoneExtStr, iPhoneExtOptions;
type type
{ TiPhoneProjectOptionsEditor } { TiPhoneProjectOptionsEditor }
TiPhoneProjectOptionsEditor = class(TAbstractIDEOptionsEditor) TiPhoneProjectOptionsEditor = class(TAbstractIDEOptionsEditor)
Label5:TLabel;
mnuOpenIB:TMenuItem;
nibFilesBox:TCheckListBox;
chkisPhone: TCheckBox; chkisPhone: TCheckBox;
cmbSDKs: TComboBox; cmbSDKs: TComboBox;
edtResDir: TEdit; edtResDir: TEdit;
@ -36,16 +38,33 @@ type
Label1: TLabel; Label1: TLabel;
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
Label4:TLabel;
lblAppID: TLabel; lblAppID: TLabel;
lblAppIDHint: TLabel; lblAppIDHint: TLabel;
lblSDKVer: TLabel; lblSDKVer: TLabel;
nibsPopup:TPopupMenu;
procedure cmbSDKsChange(Sender: TObject); procedure cmbSDKsChange(Sender: TObject);
procedure edtExcludeChange(Sender: TObject); procedure edtExcludeChange(Sender: TObject);
procedure edtResDirChange(Sender:TObject);
procedure edtResDirExit(Sender:TObject);
procedure FrameClick(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
{ private declarations } { private declarations }
SelXibFile : String;
ResDirChanged : Boolean;
fOnChanged : TNotifyEvent; fOnChanged : TNotifyEvent;
procedure DoChanged; procedure DoChanged;
procedure RefreshXIBList;
public public
{ public declarations } { public declarations }
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
@ -58,6 +77,42 @@ type
implementation 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 } { TiPhoneProjectOptionsEditor }
procedure TiPhoneProjectOptionsEditor.cmbSDKsChange(Sender: TObject); procedure TiPhoneProjectOptionsEditor.cmbSDKsChange(Sender: TObject);
@ -70,16 +125,120 @@ begin
end; 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); procedure TiPhoneProjectOptionsEditor.FrameClick(Sender: TObject);
begin begin
end; 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; procedure TiPhoneProjectOptionsEditor.DoChanged;
begin begin
if Assigned(fOnChanged) then fOnChanged(Self); if Assigned(fOnChanged) then fOnChanged(Self);
end; 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; function TiPhoneProjectOptionsEditor.GetTitle: String;
begin begin
Result:=strPrjOptTitle; Result:=strPrjOptTitle;
@ -113,10 +272,25 @@ begin
edtExclude.Text:=ExcludeMask; edtExclude.Text:=ExcludeMask;
end; 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; end;
procedure TiPhoneProjectOptionsEditor.WriteSettings(AOptions: TAbstractIDEOptions); procedure TiPhoneProjectOptionsEditor.WriteSettings(AOptions: TAbstractIDEOptions);
var
amainnib : AnsiString;
i : integer;
begin 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 with TiPhoneProjectOptions(AOptions) do
begin begin
isIPhoneApp:=chkisPhone.Checked; isIPhoneApp:=chkisPhone.Checked;
@ -124,6 +298,7 @@ begin
AppID:=edtAppID.Text; AppID:=edtAppID.Text;
ResourceDir:=edtResDir.Text; ResourceDir:=edtResDir.Text;
ExcludeMask:=edtExclude.Text; ExcludeMask:=edtExclude.Text;
MainNib:=amainnib;
Save; Save;
DoChanged; DoChanged;
end; end;