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; inherited;
if not Assigned(callback) then Exit; if not Assigned(callback) then Exit;
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext); ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
ctx.InitDraw(round(clipRect.size.width), round(clipRect.size.height));
try try
ItemState := []; ItemState := [];
if isRowSelected(row) then Include(ItemState, odSelected); if isRowSelected(row) then Include(ItemState, odSelected);

View File

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