mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 10:39:22 +02:00
cocoa: extend support of CGContextRef (for macOS 10.10 and later). Adding init of context for custom drawn dropdownlist
git-svn-id: trunk@59027 -
This commit is contained in:
parent
a1c48e5e97
commit
01c8eef539
@ -77,6 +77,8 @@ type
|
|||||||
NSGraphicsContextFix = objccategory external(NSGraphicsContext)
|
NSGraphicsContextFix = objccategory external(NSGraphicsContext)
|
||||||
procedure setImageInterpolation(interpolation: NSImageInterpolation); message 'setImageInterpolation:';
|
procedure setImageInterpolation(interpolation: NSImageInterpolation); message 'setImageInterpolation:';
|
||||||
procedure setShouldAntialias(antialias: Boolean); message 'setShouldAntialias:';
|
procedure setShouldAntialias(antialias: Boolean); message 'setShouldAntialias:';
|
||||||
|
// 10.10
|
||||||
|
function CGContext: CGContextRef; message 'CGContext';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
NSEventFix = objccategory external (NSEvent)
|
NSEventFix = objccategory external (NSEvent)
|
||||||
|
@ -492,11 +492,30 @@ function CheckDC(dc: HDC; Str: string): Boolean;
|
|||||||
function CheckGDIOBJ(obj: HGDIOBJ): TCocoaGDIObject;
|
function CheckGDIOBJ(obj: HGDIOBJ): TCocoaGDIObject;
|
||||||
function CheckBitmap(ABitmap: HBITMAP; AStr: string): Boolean;
|
function CheckBitmap(ABitmap: HBITMAP; AStr: string): Boolean;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ LCLNSGraphicsContext }
|
||||||
|
|
||||||
|
LCLNSGraphicsContext = objccategory (NSGraphicsContext)
|
||||||
|
function lclCGContext: CGContextRef; message 'lclCGContext';
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
CocoaInt;
|
CocoaInt;
|
||||||
|
|
||||||
|
|
||||||
|
{ LCLNSGraphicsContext }
|
||||||
|
|
||||||
|
function LCLNSGraphicsContext.lclCGcontext: CGContextRef;
|
||||||
|
begin
|
||||||
|
if NSAppKitVersionNumber >= NSAppKitVersionNumber10_10 then
|
||||||
|
Result := CGContext
|
||||||
|
else
|
||||||
|
Result := CGContextRef(graphicsPort);
|
||||||
|
end;
|
||||||
|
|
||||||
//todo: a better check!
|
//todo: a better check!
|
||||||
|
|
||||||
function CheckDC(dc: HDC): TCocoaContext;
|
function CheckDC(dc: HDC): TCocoaContext;
|
||||||
@ -1378,7 +1397,7 @@ end;
|
|||||||
|
|
||||||
function TCocoaContext.CGContext: CGContextRef;
|
function TCocoaContext.CGContext: CGContextRef;
|
||||||
begin
|
begin
|
||||||
Result := CGContextRef(ctx.graphicsPort);
|
Result := CGContextRef(ctx.lclCGContext);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaContext.SetAntialiasing(AValue: Boolean);
|
procedure TCocoaContext.SetAntialiasing(AValue: Boolean);
|
||||||
|
@ -408,6 +408,7 @@ begin
|
|||||||
|
|
||||||
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
|
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
|
||||||
try
|
try
|
||||||
|
ctx.InitDraw(Round(dirtyRect.size.width), Round(dirtyRect.size.height));
|
||||||
combobox.callback.ComboBoxDrawItem(itemIndex, ctx, NSRectToRect(frame), false);
|
combobox.callback.ComboBoxDrawItem(itemIndex, ctx, NSRectToRect(frame), false);
|
||||||
finally
|
finally
|
||||||
ctx.Free;
|
ctx.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user