You've already forked lazarus-ccr
iphonelazext: added HelloWorld example
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1131 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
BIN
components/iphonelazext/examples/HelloWorld/ihelloworld.ico
Normal file
BIN
components/iphonelazext/examples/HelloWorld/ihelloworld.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
99
components/iphonelazext/examples/HelloWorld/ihelloworld.lpi
Normal file
99
components/iphonelazext/examples/HelloWorld/ihelloworld.lpi
Normal file
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<UseDefaultCompilerOptions Value="True"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=""/>
|
||||
<Title Value="ihelloworld"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<CustomData Count="4">
|
||||
<Item0 Name="iPhone/AppID" Value="com.mycompany.myapplication"/>
|
||||
<Item1 Name="iPhone/SDK" Value="iPhone 2.0"/>
|
||||
<Item2 Name="iPhone/SimSpaceName" Value="AE7A4C5E-559A-1694-53EF-3683CFE2F32D"/>
|
||||
<Item3 Name="iPhone/isiPhoneApp" Value="true"/>
|
||||
</CustomData>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="ihelloworld.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ihelloworld"/>
|
||||
<CursorPos X="34" Y="12"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<SyntaxHighlighter Value="Delphi"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
<JumpHistory Count="0" HistoryIndex="-1"/>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)/"/>
|
||||
<Libraries Value="$Env(WNLIB)/../Music/oggvorbis/macosx/"/>
|
||||
<OtherUnitFiles Value="MacLauncher/;$Env(WNLIB)/;$Env(WNLIB)/MacOS/;$Env(WNLIB)/Application2/;$Env(WNLIB)/Composite/;$Env(WNLIB)/Graphics/;$Env(WNLIB)/VectorGraphics/;$Env(WNLIB)/TextOut/;$Env(PTELIB)/;$Env(PTELIB)/3DBasics/;$Env(PTELIB)/3DEngine/;$Env(PTELIB)/DeviceMenu/;$Env(PTELIB)/DrawController/;$Env(PTELIB)/GdiEngine/;$Env(PTELIB)/NavPanel/;$Env(PTELIB)/PteClasses/;$Env(PTELIB)/PteViewer/;$Env(PTELIB)/Shaders/;$Env(PTELIB)/ShadowSpreads/;$Env(PTELIB)/VirtualList/;$Env(PTELIB)/OpenGL/;$Env(PTELIB)/MacOS/;$Env(WNLIB)/../Music/;$Env(WNLIB)/../Music/oggvorbis/"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
<CStyleOperator Value="False"/>
|
||||
<IncludeAssertionCode Value="True"/>
|
||||
<CPPInline Value="False"/>
|
||||
<UseAnsiStrings Value="True"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<IgnoredMessages idx3018="True" idx3031="True" idx3189="True" idx4035="True" idx4036="True" idx4055="True" idx4079="True" idx4080="True" idx4081="True" idx5024="True" idx5057="True" idx5058="True" idx5060="True"/>
|
||||
</CompilerMessages>
|
||||
<CustomOptions Value="-XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
79
components/iphonelazext/examples/HelloWorld/ihelloworld.pas
Normal file
79
components/iphonelazext/examples/HelloWorld/ihelloworld.pas
Normal file
@ -0,0 +1,79 @@
|
||||
program ihelloworld;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$modeswitch objectivec1}
|
||||
{$linkframework UIKit}
|
||||
|
||||
uses
|
||||
iPhoneAll, CGContext, CGGeometry, CFString;
|
||||
|
||||
type
|
||||
TAppDelegate = objcclass(NSObject)
|
||||
procedure applicationDidFinishLaunching(application: UIApplication); message 'applicationDidFinishLaunching:';
|
||||
end;
|
||||
|
||||
TMyWindow = objcclass(UIWindow)
|
||||
public
|
||||
procedure drawRect(c: CGRect); override;
|
||||
end;
|
||||
|
||||
const
|
||||
helloworld = 'Hello world';
|
||||
|
||||
// window paint method
|
||||
procedure TMyWindow.drawRect(c: CGRect);
|
||||
var
|
||||
cg : CGContextRef;
|
||||
begin
|
||||
// getting current context
|
||||
cg:=UIGraphicsGetCurrentContext;
|
||||
// setting back ground color
|
||||
CGContextSetRGBFillColor(cg, 0, 0, 0.5, 1);
|
||||
CGContextFillRect(cg, c);
|
||||
|
||||
// rotating up-side down context
|
||||
CGContextTranslateCTM(cg, 0, c.size.height);
|
||||
CGContextScaleCTM(cg, 1, -1);
|
||||
|
||||
// setting text color
|
||||
CGContextSetRGBFillColor(cg, 1, 1, 0, 1);
|
||||
CGContextSetRGBStrokeColor(cg, 1, 1, 0, 1);
|
||||
// setting font (must set any)
|
||||
CGContextSelectFont(cg, 'Helvetica', 30, kCGEncodingMacRoman);
|
||||
// rendering text
|
||||
CGContextShowTextAtPoint(cg, 0, c.size.height-50, helloworld, length(helloworld));
|
||||
end;
|
||||
|
||||
var
|
||||
mainwindow : TMyWindow;
|
||||
|
||||
{ TAppDelegate }
|
||||
|
||||
procedure TAppDelegate.applicationDidFinishLaunching(application: UIApplication);
|
||||
begin
|
||||
// application has initialized, now we can create the main window
|
||||
mainwindow:=TMyWindow(TMyWindow.alloc);
|
||||
// initialize window in Objective-C style
|
||||
mainwindow := TMyWindow(mainwindow.initWithFrame (UIScreen.mainScreen.bounds));
|
||||
// activate and show the window
|
||||
mainwindow.makeKeyAndVisible;
|
||||
end;
|
||||
|
||||
function NSStr(const s: string): NSString;
|
||||
begin
|
||||
// converting string to NSString (CFStringRef and NSString are interchangable)
|
||||
Result:=NSString( CFStr(PChar(s)));
|
||||
end;
|
||||
|
||||
var
|
||||
pool : NSAutoreleasePool;
|
||||
|
||||
begin
|
||||
// initialize foundation memory manger (aka autorelease pool)
|
||||
pool := NSAutoreleasePool.alloc.init;
|
||||
// launching main application loop
|
||||
ExitCode:=UIApplicationMain(argc, argv, nil, NSSTR('TAppDelegate'));
|
||||
// according to docs the UIApplicationMain never returns,
|
||||
// but still the code present in the Obj-C main.m files
|
||||
pool.release;
|
||||
end.
|
Reference in New Issue
Block a user