You've already forked lazarus-ccr
LazClock: Adds bundle creator and path getting code, this allows it to run in Mac OS X
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2335 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -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.
|
||||
|
||||
|
101
applications/lazclock/createbundle.sh
Executable file
101
applications/lazclock/createbundle.sh
Executable file
@ -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 '<?xml version="1.0" encoding="UTF-8"?>' >$plistfile
|
||||
echo '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >>$plistfile
|
||||
echo '<plist version="1.0">' >>$plistfile
|
||||
echo '<dict>' >>$plistfile
|
||||
echo ' <key>CFBundleDevelopmentRegion</key>' >>$plistfile
|
||||
echo ' <string>English</string>' >>$plistfile
|
||||
echo ' <key>CFBundleExecutable</key>' >>$plistfile
|
||||
echo ' <string>'$appfile'</string>' >>$plistfile
|
||||
echo ' <key>CFBundleIconFile</key>' >>$plistfile
|
||||
echo ' <string>macicon.icns</string>' >>$plistfile
|
||||
echo ' <key>CFBundleIdentifier</key>' >>$plistfile
|
||||
echo ' <string>org.pascal.lazarusimageeditor</string>' >>$plistfile
|
||||
echo ' <key>CFBundleInfoDictionaryVersion</key>' >>$plistfile
|
||||
echo ' <string>6.0</string>' >>$plistfile
|
||||
echo ' <key>CFBundlePackageType</key>' >>$plistfile
|
||||
echo ' <string>APPL</string>' >>$plistfile
|
||||
echo ' <key>CFBundleSignature</key>' >>$plistfile
|
||||
echo ' <string>IMG#</string>' >>$plistfile
|
||||
echo ' <key>CFBundleVersion</key>' >>$plistfile
|
||||
echo ' <string>1.0</string>' >>$plistfile
|
||||
echo '</dict>' >>$plistfile
|
||||
echo '</plist>' >>$plistfile
|
||||
fi
|
@ -17,8 +17,37 @@
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
<Item2 Name="CustomDrawn">
|
||||
<MacroValues Count="1">
|
||||
<Macro1 Name="LCLWidgetType" Value="customdrawn"/>
|
||||
</MacroValues>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="lazclock"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
|
@ -13,6 +13,7 @@ uses
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Title:='project1';
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
|
Reference in New Issue
Block a user