mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-21 18:42:34 +02:00
cocoa: (de)allocate PaintStruct dinamically, cleanup
git-svn-id: trunk@38933 -
This commit is contained in:
parent
d07bc91aef
commit
cbfa6091d1
@ -101,7 +101,6 @@ const
|
|||||||
|
|
||||||
// Utility WS functions
|
// Utility WS functions
|
||||||
|
|
||||||
function AllocCustomControl(const AWinControl: TWinControl): TCocoaCustomControl;
|
|
||||||
function EmbedInScrollView(AView: NSView): TCocoaScrollView;
|
function EmbedInScrollView(AView: NSView): TCocoaScrollView;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -111,14 +110,6 @@ uses
|
|||||||
|
|
||||||
{$I mackeycodes.inc}
|
{$I mackeycodes.inc}
|
||||||
|
|
||||||
function AllocCustomControl(const AWinControl: TWinControl): TCocoaCustomControl;
|
|
||||||
begin
|
|
||||||
if not Assigned(AWinControl) then
|
|
||||||
Exit(nil);
|
|
||||||
Result := TCocoaCustomControl(TCocoaCustomControl.alloc).init;
|
|
||||||
Result.callback := TLCLCommonCallback.Create(Result, AWinControl);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function EmbedInScrollView(AView: NSView): TCocoaScrollView;
|
function EmbedInScrollView(AView: NSView): TCocoaScrollView;
|
||||||
var
|
var
|
||||||
r: TRect;
|
r: TRect;
|
||||||
@ -804,22 +795,26 @@ end;
|
|||||||
procedure TLCLCommonCallback.Draw(ControlContext: NSGraphicsContext;
|
procedure TLCLCommonCallback.Draw(ControlContext: NSGraphicsContext;
|
||||||
const bounds, dirty: NSRect);
|
const bounds, dirty: NSRect);
|
||||||
var
|
var
|
||||||
struct: TPaintStruct;
|
PS: PPaintStruct;
|
||||||
begin
|
begin
|
||||||
// todo: think more about draw call while previous draw still active
|
// todo: think more about draw call while previous draw still active
|
||||||
if Assigned(FContext) then
|
if Assigned(FContext) then
|
||||||
Exit;
|
Exit;
|
||||||
FContext := TCocoaContext.Create;
|
FContext := TCocoaContext.Create(ControlContext);
|
||||||
try
|
try
|
||||||
FContext.ctx := ControlContext;
|
|
||||||
if FContext.InitDraw(Round(bounds.size.width), Round(bounds.size.height)) then
|
if FContext.InitDraw(Round(bounds.size.width), Round(bounds.size.height)) then
|
||||||
begin
|
begin
|
||||||
FillChar(struct, SizeOf(TPaintStruct), 0);
|
New(PS);
|
||||||
struct.hdc := HDC(FContext);
|
try
|
||||||
struct.rcPaint := NSRectToRect(dirty);
|
FillChar(PS^, SizeOf(TPaintStruct), 0);
|
||||||
LCLSendPaintMsg(Target, HDC(FContext), @struct);
|
PS^.hdc := HDC(FContext);
|
||||||
|
PS^.rcPaint := NSRectToRect(dirty);
|
||||||
|
LCLSendPaintMsg(Target, HDC(FContext), PS);
|
||||||
if FHasCaret then
|
if FHasCaret then
|
||||||
DrawCaret;
|
DrawCaret;
|
||||||
|
finally
|
||||||
|
Dispose(PS);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeAndNil(FContext);
|
FreeAndNil(FContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user