Industrial/LCDDisplay: Refactor repeating code (Updatesize).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8306 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-06-15 20:56:35 +00:00
parent 7df4e35f13
commit 5573accbef

View File

@ -158,6 +158,8 @@ type
const AXProportion, AYProportion: double); override;
// inherited painting routine
procedure Paint; override;
// Recalculates the geometry if a related property has been changed.
procedure UpdateSize;
public
constructor Create(AOwner: TComponent); override;
@ -1137,12 +1139,7 @@ begin
if Value = DotSize then
Exit;
FDotSize := Value;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetDotsSpace(const Value: integer);
@ -1150,12 +1147,7 @@ begin
if Value = DotsSpace then
Exit;
FDotsSpace := Value;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetDotShape(const Value: TDotShape);
@ -1187,12 +1179,7 @@ begin
if Value = FrameHeight then
Exit;
FFrameHeight := Value;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetFrameSize(const Value: integer);
@ -1200,12 +1187,7 @@ begin
if Value = FrameSize then
Exit;
FFrameSize := Value;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetFrameStyle(const Value: TFrameStyle);
@ -1213,12 +1195,7 @@ begin
if Value = FrameStyle then
Exit;
FFrameStyle := Value;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetCharSpace(const Value: boolean);
@ -1226,7 +1203,8 @@ begin
if Value = CharSpace then
Exit;
FCharSpace := Value;
Invalidate;
UpdateSize; // wp: this should not be necessary because it only paints the cells between chars/rows in the board color.
// Invalidate; // wp: Invalidate should be enough.
end;
procedure TLCDDisplay.SetColorScheme(const Value: TColorScheme);
@ -1260,12 +1238,7 @@ begin
if Value = FDisplayLineCount then
Exit;
FDisplayLineCount := Value;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetDisplayCharCount(const Value: integer);
@ -1273,12 +1246,7 @@ begin
if Value = FDisplayCharCount then
Exit;
FDisplayCharCount := Value;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetLines(const Value: TStringList);
@ -1293,12 +1261,7 @@ begin
else
FLines.Add(' ');
end;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
function TLCDDisplay.GetCharCount: longint;
@ -1328,12 +1291,7 @@ begin
if AValue = DotColCount then
exit;
FCharDefs.ColCount := AValue;
if AutoSize then
begin
InvalidatePreferredSize;
AdjustSize;
end;
Invalidate;
UpdateSize;
end;
procedure TLCDDisplay.SetDotRowCount(AValue: Integer);
@ -1341,6 +1299,11 @@ begin
if AValue = DotRowCount then
exit;
FCharDefs.RowCount := AValue;
UpdateSize;
end;
procedure TLCDDisplay.UpdateSize;
begin
if AutoSize then
begin
InvalidatePreferredSize;