mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:19:19 +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)
|
||||
procedure setImageInterpolation(interpolation: NSImageInterpolation); message 'setImageInterpolation:';
|
||||
procedure setShouldAntialias(antialias: Boolean); message 'setShouldAntialias:';
|
||||
// 10.10
|
||||
function CGContext: CGContextRef; message 'CGContext';
|
||||
end;
|
||||
|
||||
NSEventFix = objccategory external (NSEvent)
|
||||
|
@ -492,11 +492,30 @@ function CheckDC(dc: HDC; Str: string): Boolean;
|
||||
function CheckGDIOBJ(obj: HGDIOBJ): TCocoaGDIObject;
|
||||
function CheckBitmap(ABitmap: HBITMAP; AStr: string): Boolean;
|
||||
|
||||
type
|
||||
|
||||
{ LCLNSGraphicsContext }
|
||||
|
||||
LCLNSGraphicsContext = objccategory (NSGraphicsContext)
|
||||
function lclCGContext: CGContextRef; message 'lclCGContext';
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
CocoaInt;
|
||||
|
||||
|
||||
{ LCLNSGraphicsContext }
|
||||
|
||||
function LCLNSGraphicsContext.lclCGcontext: CGContextRef;
|
||||
begin
|
||||
if NSAppKitVersionNumber >= NSAppKitVersionNumber10_10 then
|
||||
Result := CGContext
|
||||
else
|
||||
Result := CGContextRef(graphicsPort);
|
||||
end;
|
||||
|
||||
//todo: a better check!
|
||||
|
||||
function CheckDC(dc: HDC): TCocoaContext;
|
||||
@ -1378,7 +1397,7 @@ end;
|
||||
|
||||
function TCocoaContext.CGContext: CGContextRef;
|
||||
begin
|
||||
Result := CGContextRef(ctx.graphicsPort);
|
||||
Result := CGContextRef(ctx.lclCGContext);
|
||||
end;
|
||||
|
||||
procedure TCocoaContext.SetAntialiasing(AValue: Boolean);
|
||||
|
@ -408,6 +408,7 @@ begin
|
||||
|
||||
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
|
||||
try
|
||||
ctx.InitDraw(Round(dirtyRect.size.width), Round(dirtyRect.size.height));
|
||||
combobox.callback.ComboBoxDrawItem(itemIndex, ctx, NSRectToRect(frame), false);
|
||||
finally
|
||||
ctx.Free;
|
||||
|
Loading…
Reference in New Issue
Block a user