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:
sekelsenmat 2011-06-29 20:45:12 +00:00
parent 444d9eb06f
commit 9b30b68fdc
7 changed files with 1407 additions and 34 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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
));

View File

@ -38,6 +38,7 @@ uses
InterfaceBase, GraphType,
// private
CocoaAll, CocoaPrivate, CocoaUtils, CocoaGDIObjects, CocoaTextLayout,
CocoaProc,
// LCL
LCLStrConsts, LMessages, LCLMessageGlue, LCLProc, LCLIntf, LCLType,
IntfGraphics, Graphics, CocoaWSFactory;

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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;