mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 08:09:22 +02:00
LCL: Add ShadowColor for TArrow. Issue #28228, patch from Alexey Torgashin.
git-svn-id: trunk@49261 -
This commit is contained in:
parent
aa88ae22b8
commit
cd60cd81ec
45
lcl/arrow.pp
45
lcl/arrow.pp
@ -24,7 +24,7 @@ uses
|
|||||||
type
|
type
|
||||||
|
|
||||||
TArrowType = (atUp, atDown, atLeft, atRight);
|
TArrowType = (atUp, atDown, atLeft, atRight);
|
||||||
TShadowType = (stNone, stIn, stOut, stEtchedIn, stEtchedOut);
|
TShadowType = (stNone, stIn, stOut, stEtchedIn, stEtchedOut, stFilledArrow);
|
||||||
TTriPts = (ptA, ptB, ptC);
|
TTriPts = (ptA, ptB, ptC);
|
||||||
TTrianglePoints = array[TTriPts] of TPoint;
|
TTrianglePoints = array[TTriPts] of TPoint;
|
||||||
|
|
||||||
@ -36,6 +36,7 @@ type
|
|||||||
FArrowType: TArrowType;
|
FArrowType: TArrowType;
|
||||||
FArrowAngle: integer;
|
FArrowAngle: integer;
|
||||||
FShadowType: TShadowType;
|
FShadowType: TShadowType;
|
||||||
|
FShadowColor: TColor;
|
||||||
FR: TRect;
|
FR: TRect;
|
||||||
FT: TTrianglePoints;
|
FT: TTrianglePoints;
|
||||||
procedure CalcTrianglePoints;
|
procedure CalcTrianglePoints;
|
||||||
@ -80,6 +81,7 @@ type
|
|||||||
property ParentShowHint;
|
property ParentShowHint;
|
||||||
property PopupMenu;
|
property PopupMenu;
|
||||||
property ShadowType: TShadowType read FShadowType write SetShadowType default stEtchedIn;
|
property ShadowType: TShadowType read FShadowType write SetShadowType default stEtchedIn;
|
||||||
|
property ShadowColor: TColor read FShadowColor write FShadowColor default cl3DShadow;
|
||||||
property ShowHint;
|
property ShowHint;
|
||||||
property Visible;
|
property Visible;
|
||||||
end;
|
end;
|
||||||
@ -94,6 +96,8 @@ const
|
|||||||
ArrowMinHeight = 8;
|
ArrowMinHeight = 8;
|
||||||
cMinAngle = 20;
|
cMinAngle = 20;
|
||||||
cMaxAngle = 160;
|
cMaxAngle = 160;
|
||||||
|
cShadowColors: array[TShadowType] of TColor =
|
||||||
|
(clWindow, cl3DShadow, cl3DShadow, cl3DHiLight, cl3DHiLight, clBlue{not used});
|
||||||
|
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
@ -208,10 +212,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TArrow.Paint;
|
procedure TArrow.Paint;
|
||||||
const
|
|
||||||
Colors: array[TShadowType] of TColor
|
|
||||||
=(clWindow, cl3DShadow, cl3DShadow, cl3DHiLight, cl3DHiLight);
|
|
||||||
|
|
||||||
procedure Offset(var ptA, ptB: TPoint);
|
procedure Offset(var ptA, ptB: TPoint);
|
||||||
begin
|
begin
|
||||||
case FArrowType of
|
case FArrowType of
|
||||||
@ -224,11 +224,11 @@ const
|
|||||||
|
|
||||||
procedure ShadowLine(p1, p2: TPoint);
|
procedure ShadowLine(p1, p2: TPoint);
|
||||||
begin
|
begin
|
||||||
Canvas.Pen.Color:= Colors[FShadowType];
|
Canvas.Pen.Color:= cShadowColors[FShadowType];
|
||||||
Canvas.MoveTo(p1);
|
Canvas.MoveTo(p1);
|
||||||
Canvas.LineTo(p2);
|
Canvas.LineTo(p2);
|
||||||
Offset(p1, p2);
|
Offset(p1, p2);
|
||||||
Canvas.Pen.Color:= cl3DShadow;
|
Canvas.Pen.Color:= FShadowColor;
|
||||||
Canvas.MoveTo(p1);
|
Canvas.MoveTo(p1);
|
||||||
Canvas.LineTo(p2);
|
Canvas.LineTo(p2);
|
||||||
if (Height>13) then
|
if (Height>13) then
|
||||||
@ -239,19 +239,43 @@ const
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure ShadowTriangle;
|
||||||
|
const
|
||||||
|
dx = 2;
|
||||||
|
var
|
||||||
|
Pts: TTrianglePoints;
|
||||||
|
begin
|
||||||
|
Pts:= FT;
|
||||||
|
Inc(Pts[ptA].x, dx);
|
||||||
|
Inc(Pts[ptA].y, dx);
|
||||||
|
Inc(Pts[ptB].x, dx);
|
||||||
|
Inc(Pts[ptB].y, dx);
|
||||||
|
Inc(Pts[ptC].x, dx);
|
||||||
|
Inc(Pts[ptC].y, dx);
|
||||||
|
Canvas.Pen.Color:= FShadowColor;
|
||||||
|
Canvas.Brush.Color:= FShadowColor;
|
||||||
|
Canvas.Polygon(Pts);
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
CalcTrianglePoints;
|
||||||
|
|
||||||
Canvas.AntialiasingMode := AntiAliasingMode;
|
Canvas.AntialiasingMode := AntiAliasingMode;
|
||||||
// Paint background
|
// Paint background
|
||||||
Canvas.Brush.Color := Color;
|
Canvas.Brush.Color := Color;
|
||||||
Canvas.FillRect(ClientRect);
|
Canvas.FillRect(ClientRect);
|
||||||
|
|
||||||
|
// Paint shadow area
|
||||||
|
if (FShadowType=stFilledArrow) then
|
||||||
|
ShadowTriangle;
|
||||||
|
|
||||||
// Paint arrow
|
// Paint arrow
|
||||||
Canvas.Pen.Color:= FArrowColor;
|
Canvas.Pen.Color:= FArrowColor;
|
||||||
Canvas.Brush.Color:= FArrowColor;
|
Canvas.Brush.Color:= FArrowColor;
|
||||||
CalcTrianglePoints;
|
|
||||||
Canvas.Polygon(FT);
|
Canvas.Polygon(FT);
|
||||||
|
|
||||||
if (FShadowType <> stNone)
|
if not (FShadowType in [stNone, stFilledArrow]) then
|
||||||
then ShadowLine(FT[ptB], FT[ptC]);
|
ShadowLine(FT[ptB], FT[ptC]);
|
||||||
|
|
||||||
inherited Paint;
|
inherited Paint;
|
||||||
end;
|
end;
|
||||||
@ -264,6 +288,7 @@ begin
|
|||||||
FArrowType:= atLeft; // set defaults to match TArrow component
|
FArrowType:= atLeft; // set defaults to match TArrow component
|
||||||
FArrowAngle:= 60; // angle of equal side triangle
|
FArrowAngle:= 60; // angle of equal side triangle
|
||||||
FShadowType:= stEtchedIn;
|
FShadowType:= stEtchedIn;
|
||||||
|
FShadowColor:= cl3DShadow;
|
||||||
FArrowColor:= clBlack;
|
FArrowColor:= clBlack;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user