LazReport, use the corner set property instead of corner set items to control new mixed round/squared corners functionality

git-svn-id: trunk@33907 -
This commit is contained in:
jesus 2011-12-02 16:21:39 +00:00
parent bbf9512a32
commit 367f5ec871

View File

@ -44,6 +44,9 @@ type
Constructor Create(aOwner : TComponent); override;
end;
TCorner = (ctTopLeft,ctBottomLeft,ctBottomRight,ctTopRight);
TCornerSet = set of TCorner;
// Pour enregistrer les paramètres
TfrRoundRect = packed record
SGradian : Boolean; //ShowGradian
@ -53,15 +56,9 @@ type
wShadow : Integer; // Width of shadow
sCurve : Boolean; // RoundRect On/Off
wCurve : Integer; // Curve size
SqrTL : Boolean; // Squared top left corner
SqrBL : Boolean; // Squared bottom left corner
SqrBR : Boolean; // Squared bottom right corner
SqrTR : Boolean; // Squared top rigth corner
Corners : TCornerSet; // Set of squared corners
end;
TCorner = (ctTL,ctTR,ctBL,ctBR);
TCornerSet = set of TCorner;
{ TfrRoundRectView }
TfrRoundRectView = class(TfrMemoView)
@ -74,20 +71,13 @@ type
function GetShadowColor: TColor;
function GetShadowWidth: Integer;
function GetShowGrad: Boolean;
function GetSqrBottomLeft: boolean;
function GetSqrBottomRight: boolean;
function GetSqrTopLeft: boolean;
function GetSqrTopRight: boolean;
procedure SetCorners(AValue: TCornerSet);
procedure SetGradStyle(const AValue: TGradientStyle);
procedure SetRoundRect(const AValue: boolean);
procedure SetRoundRectCurve(const AValue: Integer);
procedure SetShadowColor(const AValue: TColor);
procedure SetShadowWidth(const AValue: Integer);
procedure SetShowGrad(const AValue: Boolean);
procedure SetSqrBottomLeft(AValue: boolean);
procedure SetSqrBottomRight(AValue: boolean);
procedure SetSqrTopLeft(AValue: boolean);
procedure SetSqrTopRight(AValue: boolean);
function GetCorners: TCornerSet;
public
constructor Create; override;
@ -107,10 +97,7 @@ type
property ShadowWidth : Integer read GetShadowWidth write SetShadowWidth;
property RoundRect : boolean read GetRoundRect write SetRoundRect;
property RoundRectCurve : Integer read GetRoundRectCurve write SetRoundRectCurve;
property SquaredTopLeft: boolean read GetSqrTopLeft write SetSqrTopLeft;
property SquaredBottomLeft: boolean read GetSqrBottomLeft write SetSqrBottomLeft;
property SquaredBottomRight: boolean read GetSqrBottomRight write SetSqrBottomRight;
property SquaredTopRight: boolean read GetSqrTopRight write SetSqrTopRight;
property SquaredCorners: TCornerSet read GetCorners write SetCorners;
end;
// Editeur de propriétés
@ -169,11 +156,13 @@ type
fNormalColor: TColor;
procedure ChgColorButton(S: TObject; C: TColor);
procedure SetCorners(AValue: TCornerSet);
procedure UpdateSample;
function GetCorners: TCornerSet;
public
{ Déclarations publiques }
procedure ShowEditor(t: TfrView); override;
property Corners: TCornerSet read GetCorners write SetCorners;
end;
implementation
@ -447,19 +436,19 @@ begin
c := 0;
Pts := nil;
if ctTL in SqrCorners then
if ctTopLeft in SqrCorners then
Corner(X1+MX,Y1, X1,Y1, X1,Y1+MY)
else
BezierArcPoints(X1,Y1,RX,RY, 90*16, 90*16, 0, Pts, c);
if ctBL in SqrCorners then
if ctBottomLeft in SqrCorners then
Corner(X1,Y2-MY,X1,Y2,X1+MX,Y2)
else
BezierArcPoints(X1,Y2-RY,RX,RY, 180*16, 90*16, 0, Pts, c);
if ctBR in SqrCorners then
if ctBottomRight in SqrCorners then
Corner(X2-MX,Y2, X2,Y2, X2, Y2-MY)
else
BezierArcPoints(X2-RX,Y2-RY,RX,RY, 270*16, 90*16, 0, Pts, c);
if ctTR in SqrCorners then
if ctTopRight in SqrCorners then
Corner(X2,Y1+MY, X2,Y1, X2-MX,Y1)
else
BezierArcPoints(X2-RX,Y1,RX,RY, 0, 90*16, 0, Pts, c);
@ -498,24 +487,11 @@ begin
Result:=fCadre.SGradian;
end;
function TfrRoundRectView.GetSqrBottomLeft: boolean;
procedure TfrRoundRectView.SetCorners(AValue: TCornerSet);
begin
result := fCadre.SqrBL;
end;
function TfrRoundRectView.GetSqrBottomRight: boolean;
begin
result := fCadre.SqrBR;
end;
function TfrRoundRectView.GetSqrTopLeft: boolean;
begin
result := fCadre.SqrTL;
end;
function TfrRoundRectView.GetSqrTopRight: boolean;
begin
result := fCadre.SqrTR;
BeforeChange;
fCadre.Corners := Avalue;
AfterChange;
end;
procedure TfrRoundRectView.SetGradStyle(const AValue: TGradientStyle);
@ -560,41 +536,9 @@ begin
AfterChange;
end;
procedure TfrRoundRectView.SetSqrBottomLeft(AValue: boolean);
begin
BeforeChange;
fCadre.SqrBL:=AValue;
AfterChange;
end;
procedure TfrRoundRectView.SetSqrBottomRight(AValue: boolean);
begin
BeforeChange;
fCadre.SqrBR:=AValue;
AfterChange;
end;
procedure TfrRoundRectView.SetSqrTopLeft(AValue: boolean);
begin
BeforeChange;
fCadre.SqrTL:=AValue;
AfterChange;
end;
procedure TfrRoundRectView.SetSqrTopRight(AValue: boolean);
begin
BeforeChange;
fCadre.SqrTR:=AValue;
AfterChange;
end;
function TfrRoundRectView.GetCorners: TCornerSet;
begin
result := [];
if fCadre.SqrTL then Include(result, ctTL);
if fCadre.SqrBL then Include(result, ctBL);
if fCadre.SqrBR then Include(result, ctBR);
if fCadre.SqrTR then Include(result, ctTR);
result := fCadre.Corners;
end;
(********************************************************)
@ -614,10 +558,7 @@ begin
fCadre.wShadow := 6;
fCadre.sCurve := True;
fCadre.wCurve := 10;
fCadre.SqrTL := false;
fCadre.SqrBL := false;
fCadre.SqrBR := false;
fCadre.SqrTR := false;
fCadre.Corners := [];
finally
Endupdate;
end;
@ -651,10 +592,7 @@ begin
RestoreProperty('ShadowWidth',XML.GetValue(Path+'Data/ShadowWidth/Value',''));
RestoreProperty('RoundRect',XML.GetValue(Path+'Data/RoundRect/Value',''));
RestoreProperty('RoundRectCurve',XML.GetValue(Path+'Data/RoundRectCurve/Value',''));
RestoreProperty('SquaredTopLeft',XML.GetValue(Path+'Data/SquaredTopLeft/Value',''));
RestoreProperty('SquaredBottomLeft',XML.GetValue(Path+'Data/SquaredBottomLeft/Value',''));
RestoreProperty('SquaredBottomRight',XML.GetValue(Path+'Data/SquaredBottomRight/Value',''));
RestoreProperty('SquaredTopRight',XML.GetValue(Path+'Data/SquaredTopRight/Value',''));
RestoreProperty('SquaredCorners',XML.GetValue(Path+'Data/SquaredCorners/Value',''));
end;
procedure TfrRoundRectView.SaveToXML(XML: TLrXMLConfig; const Path: String);
@ -667,10 +605,7 @@ begin
XML.SetValue(Path+'Data/ShadowWidth/Value', GetSaveProperty('ShadowWidth'));
XML.SetValue(Path+'Data/RoundRect/Value', GetSaveProperty('RoundRect'));
XML.SetValue(Path+'Data/RoundRectCurve/Value', GetSaveProperty('RoundRectCurve'));
XML.SetValue(Path+'Data/SquaredTopLeft/Value', GetSaveProperty('SquaredTopLeft'));
XML.SetValue(Path+'Data/SquaredBottomLeft/Value',GetSaveProperty('SquaredBottomLeft'));
XML.SetValue(Path+'Data/SquaredBottomRight/Value', GetSaveProperty('SquaredBottomRight'));
XML.SetValue(Path+'Data/SquaredTopRight/Value',GetSaveProperty('SquaredTopRight'));
XML.SetValue(Path+'Data/SquaredCorners/Value', GetSaveProperty('SquaredCorners'));
end;
procedure TfrRoundRectView.CalcGaps;
@ -888,6 +823,14 @@ begin
BM.Free;
end;
procedure TfrRoundRectForm.SetCorners(AValue: TCornerSet);
begin
chkTL.Checked := ctTopLeft in AValue;
chkBL.Checked := ctBottomLeft in AValue;
chkBR.Checked := ctBottomRight in AValue;
chkTR.Checked := ctTopRight in AValue;
end;
procedure TfrRoundRectForm.UpdateSample;
var
CC: TCanvas;
@ -958,10 +901,10 @@ end;
function TfrRoundRectForm.GetCorners: TCornerSet;
begin
result := [];
if chkTL.Checked then Include(result, ctTL);
if chkBL.Checked then Include(result, ctBL);
if chkBR.Checked then Include(result, ctBR);
if chkTR.Checked then Include(result, ctTR);
if chkTL.Checked then Include(result, ctTopLeft);
if chkBL.Checked then Include(result, ctBottomLeft);
if chkBR.Checked then Include(result, ctBottomRight);
if chkTR.Checked then Include(result, ctTopRight);
end;
procedure TfrRoundRectForm.bColorClick(Sender: TObject);
@ -1052,10 +995,7 @@ begin
cbCadre.Checked := (t.Frames<>[]);
cmShadow.Checked := fCadre.sCurve;
sCurve.Text := IntToStr(fCadre.wCurve);
chkTL.Checked := fCadre.SqrTL;
chkBL.Checked := fCadre.SqrBL;
chkBR.Checked := fCadre.SqrBR;
chkTR.Checked := fCadre.SqrTR;
Corners := fCadre.Corners;
end
else
begin //Gradian
@ -1083,10 +1023,7 @@ begin
fCadre.wShadow := 6;
end;
fCadre.SqrTL := chkTL.Checked;
fCadre.SqrBL := chkBL.Checked;
fCadre.SqrBR := chkBR.Checked;
fCadre.SqrTR := chkTR.Checked;
fCadre.Corners := Corners;
fCadre.SGradian:=cbGradian.checked;