cocoa: change TCocoaContext constructor to accept graphics context, implement GetDC for currently painting views

git-svn-id: trunk@38932 -
This commit is contained in:
paul 2012-10-01 08:16:01 +00:00
parent 5b87a81b7e
commit d07bc91aef
2 changed files with 10 additions and 14 deletions

View File

@ -359,7 +359,7 @@ type
procedure ClearClipping;
public
ctx: NSGraphicsContext;
constructor Create; virtual;
constructor Create(AGraphicsContext: NSGraphicsContext); virtual;
destructor Destroy; override;
function SaveDC: Integer;
@ -424,7 +424,7 @@ type
FBitmap : TCocoaBitmap;
procedure SetBitmap(const AValue: TCocoaBitmap);
public
constructor Create; override;
constructor Create;
destructor Destroy; override;
property Bitmap: TCocoaBitmap read FBitmap write SetBitmap;
@ -1137,7 +1137,7 @@ end;
constructor TCocoaBitmapContext.Create;
begin
inherited Create;
inherited Create(nil);
FBitmap := DefaultBitmap;
end;
@ -1324,10 +1324,12 @@ begin
FClipRegion.Shape := AData.ClipShape;
end;
constructor TCocoaContext.Create;
constructor TCocoaContext.Create(AGraphicsContext: NSGraphicsContext);
begin
inherited Create;
ctx := AGraphicsContext;
FBkBrush := TCocoaBrush.CreateDefault;
FBrush := DefaultBrush;
@ -2600,7 +2602,7 @@ initialization
DefaultPen := TCocoaPen.CreateDefault;
DefaultFont := TCocoaFont.CreateDefault;
DefaultBitmap := TCocoaBitmap.CreateDefault;
ScreenContext := TCocoaContext.Create;
ScreenContext := TCocoaContext.Create(nil);
finalization
ScreenContext.Free;

View File

@ -1310,16 +1310,10 @@ begin
// ToDo: Not finished yet
Result := 0;
{ if NSObject(hWnd) is TCocoaGroupBox then ctx := TCocoaGroupBox(hWnd).Context;
ctx := NSObject(hWnd).lclGetCallback.GetContext;
if ctx <> nil then
Result := HDC(ctx)
// use dummy context if we are outside paint event
else
begin}
ctx := TCocoaContext.Create({NSObject(HWnd)});
Result := HDC(ctx);
{ end;}
// todo: use dummy context if we are outside paint event
Result := HDC(ctx);
end;
{$IFDEF VerboseWinAPI}