mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 07:00:31 +02:00
cocoa: Now the image code and the tray icon work more, although not yet fully
git-svn-id: trunk@31461 -
This commit is contained in:
parent
444d9eb06f
commit
9b30b68fdc
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -5342,6 +5342,7 @@ lcl/interfaces/cocoa/cocoalclintf.inc svneol=native#text/pascal
|
||||
lcl/interfaces/cocoa/cocoalclintfh.inc svneol=native#text/pascal
|
||||
lcl/interfaces/cocoa/cocoaobject.inc svneol=native#text/pascal
|
||||
lcl/interfaces/cocoa/cocoaprivate.pp svneol=native#text/plain
|
||||
lcl/interfaces/cocoa/cocoaproc.pas svneol=native#text/pascal
|
||||
lcl/interfaces/cocoa/cocoatextlayout.pas svneol=native#text/plain
|
||||
lcl/interfaces/cocoa/cocoatrayicon.inc svneol=native#text/pascal
|
||||
lcl/interfaces/cocoa/cocoautils.pas svneol=native#text/plain
|
||||
|
@ -167,9 +167,8 @@ type
|
||||
procedure SetFont(const AValue: TCocoaFont);
|
||||
procedure SetPen(const AValue: TCocoaPen);
|
||||
procedure SetRegion(const AValue: TCocoaRegion);
|
||||
protected
|
||||
ContextSize : TSize;
|
||||
public
|
||||
ContextSize : TSize;
|
||||
ctx : NSGraphicsContext;
|
||||
PenPos : TPoint;
|
||||
Stack : Integer;
|
||||
@ -200,6 +199,7 @@ var
|
||||
TextLayoutClass : TCocoaTextLayoutClass = nil;
|
||||
|
||||
function CheckDC(dc: HDC): TCocoaContext;
|
||||
function CheckDC(dc: HDC; Str: string): Boolean;
|
||||
function CheckGDIOBJ(obj: HGDIOBJ): TCocoaGDIObject;
|
||||
function CheckBitmap(ABitmap: HBITMAP; AStr: string): Boolean;
|
||||
|
||||
@ -212,6 +212,11 @@ begin
|
||||
Result:=TCocoaContext(dc);
|
||||
end;
|
||||
|
||||
function CheckDC(dc: HDC; Str: string): Boolean;
|
||||
begin
|
||||
Result:=dc<>0;
|
||||
end;
|
||||
|
||||
function CheckGDIOBJ(obj: HGDIOBJ): TCocoaGDIObject;
|
||||
begin
|
||||
Result:=TCocoaGDIObject(obj);
|
||||
@ -231,8 +236,8 @@ type
|
||||
// http://wiki.freepascal.org/FPC_PasCocoa/Differences#Sending_messages_to_id
|
||||
// http://wiki.lazarus.freepascal.org/FPC_PasCocoa#Category_declaration
|
||||
NSBitmapImageRepFix = objccategory external(NSBitmapImageRep)
|
||||
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bytesPerRow_bitsPerPixel(planes: PChar; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:';
|
||||
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel(planes: PChar; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; bitmapFormat_: NSBitmapFormat; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:';
|
||||
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bytesPerRow_bitsPerPixel(planes: PPByte; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:';
|
||||
function initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel(planes: PPByte; width: NSInteger; height: NSInteger; bps: NSInteger; spp: NSInteger; alpha: Boolean; isPlanar_: Boolean; colorSpaceName_: NSString; bitmapFormat_: NSBitmapFormat; rBytes: NSInteger; pBits: NSInteger): id; message 'initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:';
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -279,8 +284,8 @@ begin
|
||||
False, // hasAlpha
|
||||
False, // isPlanar
|
||||
NSCalibratedRGBColorSpace, // colorSpaceName
|
||||
0, // bitmapFormat
|
||||
0, // bytesPerRow
|
||||
NSAlphaNonpremultipliedBitmapFormat, // bitmapFormat
|
||||
FBytesPerRow, // bytesPerRow
|
||||
FBitsPerPixel //bitsPerPixel
|
||||
));
|
||||
|
||||
|
@ -38,6 +38,7 @@ uses
|
||||
InterfaceBase, GraphType,
|
||||
// private
|
||||
CocoaAll, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaTextLayout,
|
||||
CocoaProc,
|
||||
// LCL
|
||||
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
|
||||
IntfGraphics, Graphics, CocoaWSFactory;
|
||||
|
@ -398,7 +398,7 @@ begin
|
||||
then Result := RawImage_DescriptionFromCarbonBitmap(ADesc, TCarbonBitmap(ABitmap))
|
||||
else Result := False;
|
||||
end;
|
||||
|
||||
*)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: RawImage_DescriptionFromDevice
|
||||
@ -408,7 +408,7 @@ end;
|
||||
|
||||
Retrieves the standard image format utilized by Carbon
|
||||
------------------------------------------------------------------------------}
|
||||
function TCarbonWidgetSet.RawImage_DescriptionFromDevice(ADC: HDC; out ADesc: TRawImageDescription): Boolean;
|
||||
function TCocoaWidgetSet.RawImage_DescriptionFromDevice(ADC: HDC; out ADesc: TRawImageDescription): Boolean;
|
||||
var
|
||||
P: TPoint;
|
||||
begin
|
||||
@ -417,13 +417,14 @@ begin
|
||||
FillStandardDescription(ADesc);
|
||||
if (ADC <> 0) and CheckDC(ADC, 'RawImage_DescriptionFromDevice')
|
||||
then begin
|
||||
P := TCarbonDeviceContext(ADC).Size;
|
||||
P.X := TCocoaContext(ADC).ContextSize.cx;
|
||||
P.Y := TCocoaContext(ADC).ContextSize.cy;
|
||||
ADesc.Width := P.X;
|
||||
ADesc.Height := P.Y
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
end;*)
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: RawImage_FromBitmap
|
||||
|
@ -51,8 +51,8 @@ function PromptUser(const DialogCaption : string;
|
||||
EscapeResult : LongInt) : LongInt; override;}
|
||||
|
||||
function RawImage_CreateBitmaps(const ARawImage: TRawImage; out ABitmap, AMask: HBitmap; ASkipMask: Boolean = False): Boolean; override;
|
||||
{function RawImage_DescriptionFromBitmap(ABitmap: HBITMAP; out ADesc: TRawImageDescription): Boolean; override;
|
||||
function RawImage_DescriptionFromDevice(ADC: HDC; out ADesc: TRawImageDescription): Boolean; override;}
|
||||
{function RawImage_DescriptionFromBitmap(ABitmap: HBITMAP; out ADesc: TRawImageDescription): Boolean; override;}
|
||||
function RawImage_DescriptionFromDevice(ADC: HDC; out ADesc: TRawImageDescription): Boolean; override;
|
||||
function RawImage_FromBitmap(out ARawImage: TRawImage; ABitmap, AMask: HBITMAP; ARect: PRect = nil): Boolean; override;
|
||||
{function RawImage_FromDevice(out ARawImage: TRawImage; ADC: HDC; const ARect: TRect): Boolean; override;
|
||||
// override only when queried formats are different from screen description
|
||||
|
1384
lcl/interfaces/cocoa/cocoaproc.pas
Normal file
1384
lcl/interfaces/cocoa/cocoaproc.pas
Normal file
File diff suppressed because it is too large
Load Diff
@ -69,29 +69,10 @@ begin
|
||||
image := TCocoaBitmap(ATrayIcon.icon.Handle).image;
|
||||
if image <> nil then statusitem.setImage(image);
|
||||
end;
|
||||
//Result:=TLCLIntfHandle(box);
|
||||
// APrivateTrayIcon := TPrivateCocoaCocoaTrayIcon(ATrayIcon.Handle);
|
||||
|
||||
{ if APrivateTrayIcon.item <> nil then
|
||||
begin
|
||||
APrivateTrayIcon.item.Free;
|
||||
APrivateTrayIcon.item := nil;
|
||||
end;}
|
||||
|
||||
|
||||
{ if APrivateTrayIcon.item <> nil then Exit(True);
|
||||
|
||||
APrivateTrayIcon.item := NSStatusItem.CreateWithHandle(APrivateTrayIcon.bar.statusItemWithLength(NSSquareStatusItemLength));
|
||||
APrivateTrayIcon.item.retain();
|
||||
APrivateTrayIcon.item.setImage(APrivateTrayIcon.image.Handle);}
|
||||
|
||||
{ Inserts the menu }
|
||||
|
||||
{ if ATrayIcon.PopUpMenu <> nil then
|
||||
begin
|
||||
APrivateTrayIcon.menu := APrivateTrayIcon.CreateMenu(ATrayIcon.PopUpMenu);
|
||||
APrivateTrayIcon.item.setMenu(APrivateTrayIcon.menu.Handle);
|
||||
end;}
|
||||
// statusitem.setTitle('Menu');
|
||||
statusitem.setHighlightMode(True);
|
||||
statusitem.setEnabled(True);
|
||||
|
||||
Result := True;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user