From d07bc91aef69801cde65ab627e41b6bfd0bd0602 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 1 Oct 2012 08:16:01 +0000 Subject: [PATCH] cocoa: change TCocoaContext constructor to accept graphics context, implement GetDC for currently painting views git-svn-id: trunk@38932 - --- lcl/interfaces/cocoa/cocoagdiobjects.pas | 12 +++++++----- lcl/interfaces/cocoa/cocoawinapi.inc | 12 +++--------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoagdiobjects.pas b/lcl/interfaces/cocoa/cocoagdiobjects.pas index f94fdd3ea1..2b5a65978a 100644 --- a/lcl/interfaces/cocoa/cocoagdiobjects.pas +++ b/lcl/interfaces/cocoa/cocoagdiobjects.pas @@ -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; diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index 0d31e34294..985ac8eafa 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -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}