mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 18:59:21 +02:00
Cocoa: #41309 fix the issue in TCocoaWSCustomForm for TCustomForm.PaintTo()
This commit is contained in:
parent
b855e211b6
commit
94951a82fd
@ -121,6 +121,7 @@ type
|
|||||||
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||||
|
|
||||||
class procedure CloseModal(const ACustomForm: TCustomForm); override;
|
class procedure CloseModal(const ACustomForm: TCustomForm); override;
|
||||||
|
class procedure PaintTo(const AWinControl: TWinControl; ADC: HDC; X, Y: Integer); override;
|
||||||
class procedure ShowModal(const ACustomForm: TCustomForm); override;
|
class procedure ShowModal(const ACustomForm: TCustomForm); override;
|
||||||
class procedure SetModalResult(const ACustomForm: TCustomForm; ANewValue: TModalResult); override;
|
class procedure SetModalResult(const ACustomForm: TCustomForm; ANewValue: TModalResult); override;
|
||||||
|
|
||||||
@ -1061,6 +1062,39 @@ begin
|
|||||||
CocoaWidgetSet.EndModal(NSView(ACustomForm.Handle).window);
|
CocoaWidgetSet.EndModal(NSView(ACustomForm.Handle).window);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function createWindowImageRep(win: NSWindow): NSBitmapImageRep;
|
||||||
|
var
|
||||||
|
rect: NSRect;
|
||||||
|
imageRef: CGImageRef;
|
||||||
|
begin
|
||||||
|
rect:= win.contentRectForFrameRect( win.frame );
|
||||||
|
rect:= RectToNSRect( ScreenRectFromNSToLCL(rect) );
|
||||||
|
imageRef:= CGWindowListCreateImage(
|
||||||
|
rect,
|
||||||
|
kCGWindowListOptionIncludingWindow,
|
||||||
|
win.windowNumber,
|
||||||
|
kCGWindowImageDefault );
|
||||||
|
Result:= NSBitmapImageRep.alloc.initWithCGImage( imageRef );
|
||||||
|
CGImageRelease( imageRef );
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TCocoaWSCustomForm.PaintTo(const AWinControl: TWinControl; ADC: HDC; X, Y: Integer);
|
||||||
|
var
|
||||||
|
bc : TCocoaBitmapContext;
|
||||||
|
win: NSWindow;
|
||||||
|
imageRep: NSBitmapImageRep;
|
||||||
|
begin
|
||||||
|
if not (TObject(ADC) is TCocoaBitmapContext) then Exit;
|
||||||
|
bc := TCocoaBitmapContext(ADC);
|
||||||
|
win:= NSView(AWinControl.Handle).window;
|
||||||
|
imageRep:= createWindowImageRep(win);
|
||||||
|
bc.DrawImageRep(
|
||||||
|
NSMakeRect(0,0, bc.size.Width, bc.size.Height),
|
||||||
|
NSMakeRect(0,0, imageRep.size.width, imageRep.size.height),
|
||||||
|
imageRep );
|
||||||
|
imageRep.release;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
|
class procedure TCocoaWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
|
||||||
var
|
var
|
||||||
lWinContent: TCocoaWindowContent;
|
lWinContent: TCocoaWindowContent;
|
||||||
|
Loading…
Reference in New Issue
Block a user