You've already forked lazarus-ccr
aarre
applications
bindings
components
ZVDateTimeCtrls
aboutcomponent
acs
beepfp
chelper
cmdline
cmdlinecfg
colorpalette
csvdocument
epiktimer
fpsound
fpspreadsheet
fractions
freetypepascal
geckoport
gradcontrols
iosdesigner
iphonelazext
examples
HelloWorld
ihelloworld.ico
ihelloworld.lpi
ihelloworld.pas
iArkanoid
pbx
tests
environment_iphone_options.lfm
environment_iphone_options.lrs
environment_iphone_options.pas
ideext.pas
ioptionsdialog.lfm
ioptionsdialog.lrs
ioptionsdialog.pas
iphonebundle.pas
iphoneextoptions.pas
iphoneextstr.pas
iphonelazext.lpk
iphonelazext.pas
iphonelog_form.lfm
iphonelog_form.pas
iphonesimctrl.pas
lazfilesutils.pas
newxibdialog.lfm
newxibdialog.pas
plistfile.pas
project_iphone_options.lfm
project_iphone_options.lrs
project_iphone_options.pas
xcodetemplate.pas
xcodeutils.pas
xibfile.pas
jujiboutils
jvcllaz
kcontrols
lazbarcodes
lclextensions
longtimer
manualdock
mplayer
multithreadprocs
nvidia-widgets
onguard
orpheus
playsoundpackage
poweredby
powerpdf
rgbgraphics
richmemo
richview
rtfview
rx
scrolltext
smnetgradient
spktoolbar
svn
tdi
thtmlport
tparadoxdataset
tvplanit
virtualtreeview
virtualtreeview-new
xdev_toolkit
zlibar
examples
lclbindings
wst
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1131 8e941d3f-bd1b-0410-a28a-d453659cc2b4
80 lines
2.1 KiB
ObjectPascal
80 lines
2.1 KiB
ObjectPascal
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.
|