mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 08:58:15 +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"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="3">
|
<Units Count="2">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="wndtray.dpr"/>
|
<Filename Value="wndtray.dpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@ -44,11 +44,6 @@
|
|||||||
<ResourceFilename Value="frmtest.lrs"/>
|
<ResourceFilename Value="frmtest.lrs"/>
|
||||||
<UnitName Value="frmtest"/>
|
<UnitName Value="frmtest"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
|
||||||
<Filename Value="wscommontrayicon.pas"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<UnitName Value="wscommontrayicon"/>
|
|
||||||
</Unit2>
|
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@ -28,6 +28,11 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
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;
|
class function TCarbonWSCustomTrayIcon.Show(const ATrayIcon: TCustomTrayIcon): Boolean;
|
||||||
var
|
var
|
||||||
APrivateTrayIcon: TPrivateCocoaCarbonTrayIcon;
|
APrivateTrayIcon: TPrivateCocoaCarbonTrayIcon;
|
||||||
@ -51,12 +56,6 @@ begin
|
|||||||
|
|
||||||
{ Convert our CFImageRef to a NSImage }
|
{ 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.width := TCarbonBitmap(ATrayIcon.Icon.Handle).Width;
|
||||||
ASize.height := TCarbonBitmap(ATrayIcon.Icon.Handle).Height;
|
ASize.height := TCarbonBitmap(ATrayIcon.Icon.Handle).Height;
|
||||||
ACGRect.size.width := ASize.width;
|
ACGRect.size.width := ASize.width;
|
||||||
@ -79,11 +78,18 @@ begin
|
|||||||
{$endif VerboseCarbonTrayIcon}
|
{$endif VerboseCarbonTrayIcon}
|
||||||
APrivateTrayIcon.image.unlockFocus;
|
APrivateTrayIcon.image.unlockFocus;
|
||||||
|
|
||||||
|
{ Inserts the menu }
|
||||||
|
|
||||||
|
if ATrayIcon.PopUpMenu <> nil then
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
{ Shows the icon }
|
{ Shows the icon }
|
||||||
|
|
||||||
if APrivateTrayIcon.item <> nil then Exit(True);
|
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.retain();
|
||||||
APrivateTrayIcon.item.setImage(APrivateTrayIcon.image);
|
APrivateTrayIcon.item.setImage(APrivateTrayIcon.image);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user