mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:59:08 +02:00
cocoa: using brush color for FrameRect. bug #36410
git-svn-id: trunk@62373 -
This commit is contained in:
parent
b0a06ab91f
commit
8535bb2ac4
@ -144,6 +144,7 @@ type
|
|||||||
AGlobal: Boolean = False);
|
AGlobal: Boolean = False);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Apply(ADC: TCocoaContext; UseROP2: Boolean = True);
|
procedure Apply(ADC: TCocoaContext; UseROP2: Boolean = True);
|
||||||
|
procedure ApplyAsPenColor(ADC: TCocoaContext; UseROP2: Boolean = True);
|
||||||
|
|
||||||
// for brushes created by NCColor
|
// for brushes created by NCColor
|
||||||
property Color: NSColor read FColor write SetColor;
|
property Color: NSColor read FColor write SetColor;
|
||||||
@ -448,6 +449,13 @@ type
|
|||||||
procedure SetPixel(X,Y:integer; AColor:TColor); virtual;
|
procedure SetPixel(X,Y:integer; AColor:TColor); virtual;
|
||||||
procedure Polygon(const Points: array of TPoint; NumPts: Integer; Winding: boolean);
|
procedure Polygon(const Points: array of TPoint; NumPts: Integer; Winding: boolean);
|
||||||
procedure Polyline(const Points: array of TPoint; NumPts: Integer);
|
procedure Polyline(const Points: array of TPoint; NumPts: Integer);
|
||||||
|
// draws a rectangle by given LCL coordinates.
|
||||||
|
// always outlines rectangle
|
||||||
|
// if FillRect is set to true, then fills with either Context brush
|
||||||
|
// OR with "UseBrush" brush, if provided
|
||||||
|
// if FillRect is set to false, draws outlines only.
|
||||||
|
// if "UseBrush" is not provided, uses the current pen
|
||||||
|
// if "useBrush" is provided, uses the color from the defined brush
|
||||||
procedure Rectangle(X1, Y1, X2, Y2: Integer; FillRect: Boolean; UseBrush: TCocoaBrush);
|
procedure Rectangle(X1, Y1, X2, Y2: Integer; FillRect: Boolean; UseBrush: TCocoaBrush);
|
||||||
procedure BackgroundFill(dirtyRect:NSRect);
|
procedure BackgroundFill(dirtyRect:NSRect);
|
||||||
procedure Ellipse(X1, Y1, X2, Y2: Integer);
|
procedure Ellipse(X1, Y1, X2, Y2: Integer);
|
||||||
@ -2062,12 +2070,14 @@ end;
|
|||||||
procedure TCocoaContext.Rectangle(X1, Y1, X2, Y2: Integer; FillRect: Boolean; UseBrush: TCocoaBrush);
|
procedure TCocoaContext.Rectangle(X1, Y1, X2, Y2: Integer; FillRect: Boolean; UseBrush: TCocoaBrush);
|
||||||
var
|
var
|
||||||
cg: CGContextRef;
|
cg: CGContextRef;
|
||||||
|
resetPen: Boolean;
|
||||||
begin
|
begin
|
||||||
if (X1=X2) or (Y1=Y2) then Exit;
|
if (X1=X2) or (Y1=Y2) then Exit;
|
||||||
|
|
||||||
cg := CGContext;
|
cg := CGContext;
|
||||||
if not Assigned(cg) then Exit;
|
if not Assigned(cg) then Exit;
|
||||||
|
|
||||||
|
resetPen := false;
|
||||||
CGContextBeginPath(cg);
|
CGContextBeginPath(cg);
|
||||||
|
|
||||||
if FillRect then
|
if FillRect then
|
||||||
@ -2082,11 +2092,25 @@ begin
|
|||||||
FBrush.Apply(Self);
|
FBrush.Apply(Self);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
CGContextAddLCLRect(cg, X1, Y1, X2, Y2, true);
|
CGContextAddLCLRect(cg, X1, Y1, X2, Y2, true);
|
||||||
|
// this is a "special" case, when UseBrush is provided
|
||||||
|
// but "FillRect" is set to false. Use for FrameRect() function
|
||||||
|
// (it deserves a redesign)
|
||||||
|
if Assigned(UseBrush) then
|
||||||
|
begin
|
||||||
|
UseBrush.Apply(Self);
|
||||||
|
UseBrush.ApplyAsPenColor(Self);
|
||||||
|
resetPen := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
CGContextStrokePath(cg);
|
CGContextStrokePath(cg);
|
||||||
|
|
||||||
AttachedBitmap_SetModified();
|
AttachedBitmap_SetModified();
|
||||||
|
|
||||||
|
if resetPen and Assigned(fPen) then // pen was modified by brush. Setting it back
|
||||||
|
fPen.Apply(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCocoaContext.BackgroundFill(dirtyRect:NSRect);
|
procedure TCocoaContext.BackgroundFill(dirtyRect:NSRect);
|
||||||
@ -3328,6 +3352,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaBrush.ApplyAsPenColor(ADC: TCocoaContext; UseROP2: Boolean);
|
||||||
|
var
|
||||||
|
AR, AG, AB, AA: CGFloat;
|
||||||
|
AROP2: Integer;
|
||||||
|
ADashes: array [0..15] of CGFloat;
|
||||||
|
ADashLen: Integer;
|
||||||
|
StatDash: PCocoaStatDashes;
|
||||||
|
isCosm : Boolean;
|
||||||
|
WidthMul : array [Boolean] of CGFloat;
|
||||||
|
begin
|
||||||
|
if ADC = nil then Exit;
|
||||||
|
if ADC.CGContext = nil then Exit;
|
||||||
|
|
||||||
|
if UseROP2 then
|
||||||
|
AROP2 := ADC.ROP2
|
||||||
|
else
|
||||||
|
AROP2 := R2_COPYPEN;
|
||||||
|
|
||||||
|
GetRGBA(AROP2, AR, AG, AB, AA);
|
||||||
|
|
||||||
|
CGContextSetRGBStrokeColor(ADC.CGContext, AR, AG, AB, AA);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaGDIObject }
|
{ TCocoaGDIObject }
|
||||||
|
|
||||||
constructor TCocoaGDIObject.Create(AGlobal: Boolean);
|
constructor TCocoaGDIObject.Create(AGlobal: Boolean);
|
||||||
|
Loading…
Reference in New Issue
Block a user