Cocoa: fix drawing issue for custom-drawn listbox (issue #36714)

This commit is contained in:
rich2014 2024-06-06 00:57:53 +08:00
parent b7183648e0
commit df77d2766e
2 changed files with 11 additions and 6 deletions

View File

@ -521,6 +521,7 @@ begin
inherited;
if not Assigned(callback) then Exit;
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
ctx.InitDraw(round(clipRect.size.width), round(clipRect.size.height));
try
ItemState := [];
if isRowSelected(row) then Include(ItemState, odSelected);

View File

@ -945,11 +945,17 @@ procedure TCocoaThemeServices.CellDrawStart(dst: TCocoaContext; const r: Trect;
var
acc : TCocoaContextAccess absolute dst;
begin
NSGraphicsContext.classSaveGraphicsState;
cur := NSGraphicsContext.currentContext;
NSGraphicsContext.setCurrentContext( acc.ctx );
acc.SetCGFillping(acc.CGContext, 0, -acc.Size.cy);
LCLToNSRect( R, acc.size.cy, dstRect);
if NOT acc.ctx.isFlipped then begin
CGContextTranslateCTM(acc.ctx.CGContext, 0, acc.Size.cy);
CGContextScaleCTM(acc.ctx.CGContext, 1, -1);
LCLToNSRect( R, acc.size.cy, dstRect);
end else begin
dstRect:= RectTONSRect(R);
end;
end;
procedure TCocoaThemeServices.CellDrawFrame(cell: NSCell; const dst: NSRect);
@ -958,11 +964,9 @@ begin
end;
procedure TCocoaThemeServices.CellDrawEnd(dst: TCocoaContext; cur: NSGraphicsContext);
var
acc : TCocoaContextAccess absolute dst;
begin
acc.SetCGFillping(acc.CGContext, 0, -acc.Size.cy);
NSGraphicsContext.setCurrentContext( cur );
NSGraphicsContext.setCurrentContext(cur);
NSGraphicsContext.classRestoreGraphicsState;
end;
{ TCocoaThemeCallback }