mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 09:01:34 +02:00
lcl: formatting
git-svn-id: trunk@18815 -
This commit is contained in:
parent
b95e622129
commit
a4a728b2a4
@ -17,7 +17,7 @@
|
|||||||
constructor TShape.Create(TheOwner: TComponent);
|
constructor TShape.Create(TheOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
|
SetInitialBounds(0, 0, GetControlClassDefaultSize.X, GetControlClassDefaultSize.Y);
|
||||||
ControlStyle := ControlStyle + [csReplicatable];
|
ControlStyle := ControlStyle + [csReplicatable];
|
||||||
FPen := TPen.Create;
|
FPen := TPen.Create;
|
||||||
FPen.OnChange := @StyleChanged;
|
FPen.OnChange := @StyleChanged;
|
||||||
@ -34,8 +34,8 @@ end;
|
|||||||
|
|
||||||
procedure TShape.Paint;
|
procedure TShape.Paint;
|
||||||
var
|
var
|
||||||
PaintRect : TRect;
|
PaintRect: TRect;
|
||||||
MinSize : Longint;
|
MinSize: Longint;
|
||||||
P: array[0..3] of TPoint;
|
P: array[0..3] of TPoint;
|
||||||
begin
|
begin
|
||||||
with Canvas do
|
with Canvas do
|
||||||
@ -43,9 +43,10 @@ begin
|
|||||||
Pen := FPen;
|
Pen := FPen;
|
||||||
Brush := FBrush;
|
Brush := FBrush;
|
||||||
|
|
||||||
PaintRect := Rect(0,0,Self.Width - 1, Self.Height - 1);
|
PaintRect := Rect(0, 0, Self.Width - 1, Self.Height - 1);
|
||||||
InflateRect(PaintRect, -(Pen.Width div 2), -(Pen.Width div 2));
|
InflateRect(PaintRect, -(Pen.Width div 2), -(Pen.Width div 2));
|
||||||
With PaintRect do begin
|
with PaintRect do
|
||||||
|
begin
|
||||||
MinSize := Min(Right - Left, Bottom - Top);
|
MinSize := Min(Right - Left, Bottom - Top);
|
||||||
if FShape in [stSquare, stRoundSquare, stCircle, stSquaredDiamond] then
|
if FShape in [stSquare, stRoundSquare, stCircle, stSquaredDiamond] then
|
||||||
begin
|
begin
|
||||||
@ -64,36 +65,42 @@ begin
|
|||||||
stCircle, stEllipse:
|
stCircle, stEllipse:
|
||||||
Ellipse(PaintRect);
|
Ellipse(PaintRect);
|
||||||
stSquaredDiamond, stDiamond:
|
stSquaredDiamond, stDiamond:
|
||||||
with PaintRect do begin
|
begin
|
||||||
P[0].x:=Left; P[0].y:=Top + (Bottom - Top) div 2;
|
with PaintRect do
|
||||||
P[1].x:=Left+ (Right - Left) div 2; P[1].y:=Bottom;
|
begin
|
||||||
P[2].x:=Right; P[2].y:= P[0].y;
|
P[0].x := Left;
|
||||||
P[3].x:=P[1].x; P[3].y:=Top;
|
P[0].y := Top + (Bottom - Top) div 2;
|
||||||
|
P[1].x := Left + (Right - Left) div 2;
|
||||||
|
P[1].y := Bottom;
|
||||||
|
P[2].x := Right;
|
||||||
|
P[2].y := P[0].y;
|
||||||
|
P[3].x := P[1].x;
|
||||||
|
P[3].y := Top;
|
||||||
Polygon(P);
|
Polygon(P);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
// to fire OnPaint event
|
// to fire OnPaint event
|
||||||
inherited Paint;
|
inherited Paint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TShape.StyleChanged(Sender: TObject);
|
procedure TShape.StyleChanged(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
If (Parent <> nil) and (Visible or (csDesigning in ComponentState))
|
if (Parent <> nil) and (Visible or (csDesigning in ComponentState)) and
|
||||||
and Parent.HandleAllocated
|
Parent.HandleAllocated then
|
||||||
then
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TShape.SetBrush(Value: TBrush);
|
procedure TShape.SetBrush(Value: TBrush);
|
||||||
begin
|
begin
|
||||||
If Value <> Brush then
|
if Value <> Brush then
|
||||||
FBrush.Assign(Value);
|
FBrush.Assign(Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TShape.SetPen(Value: TPen);
|
procedure TShape.SetPen(Value: TPen);
|
||||||
begin
|
begin
|
||||||
If Value <> Pen then
|
if Value <> Pen then
|
||||||
FPen.Assign(Value);
|
FPen.Assign(Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -108,7 +115,7 @@ end;
|
|||||||
|
|
||||||
class function TShape.GetControlClassDefaultSize: TPoint;
|
class function TShape.GetControlClassDefaultSize: TPoint;
|
||||||
begin
|
begin
|
||||||
Result.X:=65;
|
Result.X := 65;
|
||||||
Result.Y:=65;
|
Result.Y := 65;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user