diff --git a/applications/lazclock/clock_control.pas b/applications/lazclock/clock_control.pas
index 379b5797a..a7295b41b 100644
--- a/applications/lazclock/clock_control.pas
+++ b/applications/lazclock/clock_control.pas
@@ -5,7 +5,7 @@ unit clock_control;
interface
uses
- Classes, SysUtils, Controls, Graphics, LCLType, DateUtils;
+ Classes, SysUtils, Controls, Graphics, LCLType, DateUtils, Types;
type
@@ -17,16 +17,22 @@ type
constructor Create(AOwner: TComponent); override;
procedure EraseBackground(DC: HDC); override;
procedure Paint; override;
+ function GetResourcesDir: string;
end;
implementation
+{$ifdef Darwin}
+uses
+ MacOSAll;
+{$endif}
+
constructor TLazClockControl.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BackgroundImage := TPortableNetworkGraphic.Create;
- BackgroundImage.LoadFromFile('skins\wallclock1.PNG');
+ BackgroundImage.LoadFromFile(GetResourcesDir() + 'skins' + PathDelim + 'wallclock1.PNG');
end;
procedure TLazClockControl.EraseBackground(DC: HDC);
@@ -46,7 +52,7 @@ begin
Canvas.Draw(0, 0, BackgroundImage);
lCurTime := Now();
SysUtils.DecodeTime(lCurTime, lHours, lMinutes, lSeconds, lMilliseconds);
- ClockCenter := Point(Width div 2, Height div 2);
+ ClockCenter := Types.Point(Width div 2, Height div 2);
// Seconds indicator
lPointerAngleMajor := - 2 * Pi * (lSeconds / 60);
@@ -86,5 +92,32 @@ begin
Canvas.Line(MinorPos, MajorPos);
end;
+function TLazClockControl.GetResourcesDir: string;
+{$ifdef Darwin}
+var
+ pathRef: CFURLRef;
+ pathCFStr: CFStringRef;
+ pathStr: shortstring;
+{$endif}
+begin
+{$ifdef UNIX}
+{$ifdef Darwin}
+ pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle);
+ CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding());
+ CFRelease(pathRef);
+ CFRelease(pathCFStr);
+
+ Result := pathStr + '/Contents/Resources/';
+{$else}
+ Result := '/usr/share/lazclock/';
+{$endif}
+{$endif}
+
+{$ifdef Windows}
+ Result := ExtractFilePath(Application.EXEName);
+{$endif}
+end;
+
end.
diff --git a/applications/lazclock/createbundle.sh b/applications/lazclock/createbundle.sh
new file mode 100755
index 000000000..5b6883e20
--- /dev/null
+++ b/applications/lazclock/createbundle.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+# Force Bourne shell in case tcsh is default.
+#
+
+#
+# Reads the bundle type
+#
+
+echo "========================================================"
+echo " Bundle creation script"
+echo "========================================================"
+echo ""
+echo " Please select which kind of bundle you would like to build:"
+echo ""
+echo " 1 > Debug bundle"
+echo " 2 > Release bundle"
+echo " 0 > Exit"
+
+read command
+
+case $command in
+
+ 1) ;;
+
+ 2) ;;
+
+ 0) exit 0;;
+
+ *) echo "Invalid command"
+ exit 0;;
+
+esac
+
+#
+# Creates the bundle
+#
+
+appname=LazClock
+appfolder=$appname.app
+macosfolder=$appfolder/Contents/MacOS
+plistfile=$appfolder/Contents/Info.plist
+appfile=lazclock
+
+PkgInfoContents="APPLCLO#"
+
+#
+if ! [ -e $appfile ]
+then
+ echo "$appfile does not exist"
+elif [ -e $appfolder ]
+then
+ echo "$appfolder already exists"
+else
+ echo "Creating $appfolder..."
+ mkdir $appfolder
+ mkdir $appfolder/Contents
+ mkdir $appfolder/Contents/MacOS
+ mkdir $appfolder/Contents/Resources
+ mkdir $appfolder/Contents/Resources/skins
+
+#
+# For a debug bundle,
+# Instead of copying executable into .app folder after each compile,
+# simply create a symbolic link to executable.
+#
+if [ $command = 1 ]; then
+ ln -s ../../../$appfile $macosfolder/$appfile
+else
+ cp $appfile $macosfolder/$appfile
+fi
+
+# Copy the resource files to the correct place
+cp skins/*.PNG $appfolder/Contents/Resources/skins
+#
+# Create PkgInfo file.
+ echo $PkgInfoContents >$appfolder/Contents/PkgInfo
+#
+# Create information property list file (Info.plist).
+ echo '' >$plistfile
+ echo '' >>$plistfile
+ echo '' >>$plistfile
+ echo '' >>$plistfile
+ echo ' CFBundleDevelopmentRegion' >>$plistfile
+ echo ' English' >>$plistfile
+ echo ' CFBundleExecutable' >>$plistfile
+ echo ' '$appfile'' >>$plistfile
+ echo ' CFBundleIconFile' >>$plistfile
+ echo ' macicon.icns' >>$plistfile
+ echo ' CFBundleIdentifier' >>$plistfile
+ echo ' org.pascal.lazarusimageeditor' >>$plistfile
+ echo ' CFBundleInfoDictionaryVersion' >>$plistfile
+ echo ' 6.0' >>$plistfile
+ echo ' CFBundlePackageType' >>$plistfile
+ echo ' APPL' >>$plistfile
+ echo ' CFBundleSignature' >>$plistfile
+ echo ' IMG#' >>$plistfile
+ echo ' CFBundleVersion' >>$plistfile
+ echo ' 1.0' >>$plistfile
+ echo '' >>$plistfile
+ echo '' >>$plistfile
+fi
diff --git a/applications/lazclock/lazclock.lpi b/applications/lazclock/lazclock.lpi
index 663beaebf..5692a1b71 100644
--- a/applications/lazclock/lazclock.lpi
+++ b/applications/lazclock/lazclock.lpi
@@ -17,8 +17,37 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/applications/lazclock/lazclock.lpr b/applications/lazclock/lazclock.lpr
index 58a428de7..3a7ea190e 100644
--- a/applications/lazclock/lazclock.lpr
+++ b/applications/lazclock/lazclock.lpr
@@ -13,6 +13,7 @@ uses
{$R *.res}
begin
+ Application.Title:='project1';
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);