mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 05:13:09 +02:00
Improves carbon trayicon
git-svn-id: trunk@15326 -
This commit is contained in:
parent
f8f5d4f4bf
commit
57660dab8c
@ -29,7 +29,7 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="wndtray.dpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -44,11 +44,6 @@
|
||||
<ResourceFilename Value="frmtest.lrs"/>
|
||||
<UnitName Value="frmtest"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="wscommontrayicon.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="wscommontrayicon"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -28,6 +28,11 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
{
|
||||
Documentation for converting a CGImageRef to a NSImage can be found here:
|
||||
|
||||
http://www.cocoadev.com/index.pl?CGImageRef
|
||||
}
|
||||
class function TCarbonWSCustomTrayIcon.Show(const ATrayIcon: TCustomTrayIcon): Boolean;
|
||||
var
|
||||
APrivateTrayIcon: TPrivateCocoaCarbonTrayIcon;
|
||||
@ -51,12 +56,6 @@ begin
|
||||
|
||||
{ Convert our CFImageRef to a NSImage }
|
||||
|
||||
{ NSImage* image = [[NSImage alloc] initWithSize:rect.size];
|
||||
[image lockFocus];
|
||||
CGContextDrawImage([[NSGraphicsContext currentContext]
|
||||
graphicsPort], *(CGRect*)&rect, imageRef);
|
||||
[image unlockFocus];}
|
||||
|
||||
ASize.width := TCarbonBitmap(ATrayIcon.Icon.Handle).Width;
|
||||
ASize.height := TCarbonBitmap(ATrayIcon.Icon.Handle).Height;
|
||||
ACGRect.size.width := ASize.width;
|
||||
@ -79,11 +78,18 @@ begin
|
||||
{$endif VerboseCarbonTrayIcon}
|
||||
APrivateTrayIcon.image.unlockFocus;
|
||||
|
||||
{ Inserts the menu }
|
||||
|
||||
if ATrayIcon.PopUpMenu <> nil then
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
{ Shows the icon }
|
||||
|
||||
if APrivateTrayIcon.item <> nil then Exit(True);
|
||||
|
||||
APrivateTrayIcon.item := APrivateTrayIcon.bar.statusItemWithLength(NSSquareStatusItemLength);
|
||||
APrivateTrayIcon.item := NSStatusItem.CreateWithHandle(APrivateTrayIcon.bar.statusItemWithLength(NSSquareStatusItemLength));
|
||||
APrivateTrayIcon.item.retain();
|
||||
APrivateTrayIcon.item.setImage(APrivateTrayIcon.image);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user