mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 15:00:26 +02:00
cocoa: complete implementation of GetDC, ReleaseDC
git-svn-id: trunk@38955 -
This commit is contained in:
parent
8929340e01
commit
c48efd29bf
@ -435,6 +435,7 @@ var
|
||||
DefaultPen: TCocoaPen;
|
||||
DefaultFont: TCocoaFont;
|
||||
DefaultBitmap: TCocoaBitmap;
|
||||
DefaultContext: TCocoaBitmapContext;
|
||||
ScreenContext: TCocoaContext;
|
||||
|
||||
function CheckDC(dc: HDC): TCocoaContext;
|
||||
@ -1121,16 +1122,16 @@ end;
|
||||
|
||||
procedure TCocoaBitmapContext.SetBitmap(const AValue: TCocoaBitmap);
|
||||
begin
|
||||
if FBitmap <> AValue then
|
||||
if Assigned(ctx) then
|
||||
begin
|
||||
ctx.release;
|
||||
ctx := nil;
|
||||
end;
|
||||
|
||||
if FBitmap <> nil then
|
||||
begin
|
||||
FBitmap := AValue;
|
||||
if Assigned(ctx) then
|
||||
begin
|
||||
ctx.release;
|
||||
ctx := nil;
|
||||
end;
|
||||
|
||||
ctx := NSGraphicsContext.graphicsContextWithBitmapImageRep(AValue.ImageRep);
|
||||
ctx := NSGraphicsContext.graphicsContextWithBitmapImageRep(Bitmap.ImageRep);
|
||||
InitDraw(Bitmap.Width, Bitmap.Height);
|
||||
end;
|
||||
end;
|
||||
@ -2602,10 +2603,15 @@ initialization
|
||||
DefaultPen := TCocoaPen.CreateDefault;
|
||||
DefaultFont := TCocoaFont.CreateDefault;
|
||||
DefaultBitmap := TCocoaBitmap.CreateDefault;
|
||||
ScreenContext := TCocoaContext.Create(nil);
|
||||
DefaultContext := TCocoaBitmapContext.Create;
|
||||
DefaultContext.Bitmap := DefaultBitmap;
|
||||
|
||||
ScreenContext := TCocoaContext.Create(DefaultContext.ctx);
|
||||
|
||||
finalization
|
||||
ScreenContext.Free;
|
||||
DefaultContext.Free;
|
||||
|
||||
DefaultBrush.Free;
|
||||
DefaultPen.Free;
|
||||
DefaultFont.Free;
|
||||
|
@ -1307,13 +1307,15 @@ begin
|
||||
Result := HDC(ScreenContext)
|
||||
else
|
||||
begin
|
||||
// ToDo: Not finished yet
|
||||
Result := 0;
|
||||
|
||||
ctx := NSObject(hWnd).lclGetCallback.GetContext;
|
||||
|
||||
// todo: use dummy context if we are outside paint event
|
||||
Result := HDC(ctx);
|
||||
if ctx = nil then
|
||||
begin
|
||||
ctx := TCocoaContext.Create(DefaultContext.ctx);
|
||||
with DefaultContext.size do
|
||||
ctx.InitDraw(cx, cy);
|
||||
end;
|
||||
Result := HDC(ctx)
|
||||
end;
|
||||
|
||||
{$IFDEF VerboseWinAPI}
|
||||
@ -1588,6 +1590,19 @@ begin
|
||||
Result := IntersectRect(R, ARect, CGRectToRect(ClipBox));
|
||||
end;
|
||||
|
||||
function TCocoaWidgetSet.ReleaseDC(hWnd: HWND; DC: HDC): Integer;
|
||||
var
|
||||
ctx: TCocoaContext;
|
||||
begin
|
||||
Result := 0;
|
||||
ctx := CheckDC(DC);
|
||||
if not Assigned(ctx) then
|
||||
Exit;
|
||||
if (ctx <> DefaultContext) and (ctx.ctx <> DefaultContext.ctx) then
|
||||
ctx.Free;
|
||||
Result := 1;
|
||||
end;
|
||||
|
||||
function TCocoaWidgetSet.GetWindowOrgEx(dc: hdc; P: PPoint): Integer;
|
||||
var
|
||||
ctx: TCocoaContext;
|
||||
|
@ -152,8 +152,8 @@ function PostMessage(Handle: HWND; Msg: Cardinal; wParam: WParam; lParam: LParam
|
||||
|
||||
function Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; override;
|
||||
function RectVisible(dc : hdc; const ARect: TRect) : Boolean; override;
|
||||
{function ReleaseCapture : Boolean; override;
|
||||
function ReleaseDC(hWnd: HWND; DC: HDC): Integer; override;}
|
||||
{function ReleaseCapture : Boolean; override;}
|
||||
function ReleaseDC(hWnd: HWND; DC: HDC): Integer; override;
|
||||
function RestoreDC(DC: HDC; SavedDC: Integer): Boolean; override;
|
||||
function RoundRect(DC: HDC; X1, Y1, X2, Y2: Integer; RX, RY : Integer): Boolean; override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user