From f49aedaf1f204887513b83acf7eefc868bd71866 Mon Sep 17 00:00:00 2001 From: rich2014 Date: Fri, 13 Oct 2023 18:25:13 +0800 Subject: [PATCH] Cocoa: both 3d style and box style supported in TCocoaWidgetSet.Frame3d() by csParentBackground --- lcl/interfaces/cocoa/cocoagdiobjects.pas | 3 +++ lcl/interfaces/cocoa/cocoawinapi.inc | 33 +++++++++++++++++++----- lcl/interfaces/cocoa/cocoawscommon.pas | 1 + 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoagdiobjects.pas b/lcl/interfaces/cocoa/cocoagdiobjects.pas index ae2b26767a..8a732a38b2 100644 --- a/lcl/interfaces/cocoa/cocoagdiobjects.pas +++ b/lcl/interfaces/cocoa/cocoagdiobjects.pas @@ -347,6 +347,7 @@ type TCocoaBitmapContext = class; TCocoaContext = class(TObject) private + FControl: TWinControl; FBkBrush: TCocoaBrush; FBkColor: TColor; FBkMode: Integer; @@ -448,6 +449,8 @@ type function SetClipRegion(AClipRegion: TCocoaRegion; Mode: TCocoaCombine): TCocoaRegionType; function CopyClipRegion(ADstRegion: TCocoaRegion): TCocoaRegionType; + property Control: TWinControl read FControl write FControl; + property Clipped: Boolean read FClipped; property Flipped: Boolean read FFlipped; property PenPos: TPoint read FPenPos write FPenPos; diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index aa71511e8e..442b875444 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -966,14 +966,35 @@ const var I: Integer; rect: TRect; + ctx: TCocoaContext; + control: TWinControl; + is3dStyle: Boolean; begin - Result := FrameWidth > 0; - if not Result then exit; - rect:= ARect; - for I := 0 to FrameWidth - 1 do + ctx := CheckDC(DC); + if not Assigned(ctx) then + exit; + + control := ctx.control; + if Assigned(control) then + is3dStyle := csParentBackground in control.ControlStyle + else + is3dStyle := true; + + if is3dStyle then begin - Result := Boolean(DrawEdge(DC, rect, Edge[Style], BF_RECT or BF_ADJUST)); - InflateRect(rect,-1,-1); + Result := FrameWidth > 0; + if not Result then exit; + rect:= ARect; + for I := 0 to FrameWidth - 1 do + begin + Result := Boolean(DrawEdge(DC, rect, Edge[Style], BF_RECT or BF_ADJUST)); + InflateRect(rect,-1,-1); + end; + end + else + begin + if FrameWidth > 0 then + ctx.Frame3d(ARect, FrameWidth, Style); end; end; diff --git a/lcl/interfaces/cocoa/cocoawscommon.pas b/lcl/interfaces/cocoa/cocoawscommon.pas index e5d7c53135..c64ba9956c 100644 --- a/lcl/interfaces/cocoa/cocoawscommon.pas +++ b/lcl/interfaces/cocoa/cocoawscommon.pas @@ -1563,6 +1563,7 @@ begin if Assigned(FContext) then Exit; FContext := TCocoaContext.Create(ControlContext); + FContext.Control := FTarget; FContext.isControlDC := True; try // debugln('Draw '+Target.name+' bounds='+Dbgs(NSRectToRect(bounds))+' dirty='+Dbgs(NSRectToRect(dirty)));