Delphi is 10.4, TMS VCL UI Pack is 10.7.9.1 JUL, 2022
Hello TMS,
When assigned the text on a TAdvGaugeCircle which is created in a run-time and place on TPanel on a TAdvStringGrid, text is positioned about 2 pixels high then from the center.
In the "TAdvGaugeCircle.Paint" method, adding +2 to y position then the text's is looks fine:
//Draw the position centered in the circle
PosText := FloatToStr(Position);
if FFormat <> '' then
PosText := SysUtils.Format(FFormat, [Position]);
g.MeasureString(PosText,Length(PosText), gpfont ,r, tr);
tr.X := cr.X + cr.Width / 2 - tr.Width / 2;
tr.Y := (cr.Y + cr.Height / 2 - tr.Height / 2) {+ 2}; // <-----------------------------------Here
We miss something or any suggestions?
Our create gauge code like a following:
function CreateGauge(AOwner: TPanel): TAdvGaugeCircle;
var
LGauge: TAdvGaugeCircle;
begin
LGauge := TAdvGaugeCircle.Create(AOwner);
LGauge.Parent := AOwner;
LGauge.CircleBackgroundColor := AColor;
LGauge.Background.Color := clNone;
LGauge.Background.ColorTo := clNone;
LGauge.Background.ColorMirror := clNone;
LGauge.Background.ColorMirrorTo := clNone;
LGauge.Font.Name := '나눔바른고딕';
LGauge.Font.Color := AFontColor;
LGauge.Font.Height := IfThen(Length(AText) >= 4, -11, -15);
LGauge.Font.Style := [fsBold];
LGauge.ArcWidth := 4;
LGauge.Minimum := AMinVal;
LGauge.Maximum := AMaxVal;
LGauge.Name := 'GridGauge' + ACol.ToString + ARow.ToString;
LGauge.Position := AVal;
LGauge.PenColor := AGaugeColor;
LGauge.InnerMargin := 2;
LGauge.Increment := 0;
LGauge.Cursor := crHandPoint;
LGauge.Align := alClient;
LGauge.Tag := ARow;
LGauge.OnClick := OnGaugeClick;
LGauge.OnMouseUp := OnGaugeMouseUp;
LGauge.Text := '';
LGauge.Format := AText;
if (AVal = 0) and (AMaxVal = 0) then
begin
LGauge.ArcWidth := (Convert96DPI(AOwner.Width) div 2) - LGauge.InnerMargin;
LGauge.Minimum := 0;
LGauge.Maximum := 100;
LGauge.Position := 100;
end
else
LGauge.ArcWidth := 4;
Result := LGauge;
end;
//...
LPanel := TPanel.Create(nil);
LPanel.Top := 0;
LPanel.Left := 0;
LPanel.Visible := True;
LPanel.Name := 'GridGaugePanel' + ACol.ToString + ARow.ToString;
LPanel.Caption := '';
LPanel.ParentDoubleBuffered := False;
LPanel.ParentBackground := False;
LPanel.ParentColor := False;
LPanel.Color := clNone;
LPanel.BevelOuter := bvNone;
LPanel.BevelInner := bvNone;
LPanel.BevelKind := bkNone;
LPanel.Font.Color := clWindow;
LPanel.Width := CellSize(ACol, ARow).X;
LPanel.Height := CellSize(ACol, ARow).Y;
LPanel.OnClick := OnGaugeClick;
LPanel.OnMouseUp := OnGaugeMouseUp;
LPanel.Tag := ARow;
LPanel.AlignWithMargins := True;
LPanel.Margins.SetBounds(0, 0, 0, 0);
LPanel.Padding.Bottom := 2;
LGauge := CreateGauge(LPanel);
LGauge.Repaint;
LGauge.Refresh;
LGauge.BringToFront;
CellControls[ACol, ARow] := LPanel;