Table of Contents

Showing a value

TTMSFNCWidgetGauge is a circular dial gauge: a needle points to a value on a scale you define, with a labelled dial and an optional digital readout. You set the range and value, label the dial, and the gauge draws the needle and scale. This chapter covers the range and value, the dial label, and the value readout.

Range and value

Define the scale with MinimumValue and MaximumValue, then set Value to position the needle. Unlike the progress and arrow widgets, the gauge has a real range, so Value is in your own units (temperature, speed, load), not a fixed 0..100. The demo measures temperature from -40 to 60.

procedure TForm1.SetupGauge;
begin
  FGauge := TTMSFNCWidgetGauge.Create(Self);
  FGauge.Parent := Self;
  FGauge.SetBounds(20, 20, 260, 260);

  FGauge.MinimumValue := -40; // scale lower bound
  FGauge.MaximumValue := 60;  // scale upper bound
  FGauge.Value := 20;         // needle position within the range
  FGauge.DialText := 'Temperature';
end;
A temperature gauge with green/amber/red sections and a needle at 20 A temperature gauge with green/amber/red sections and a needle at 20

Labelling the dial

DialText prints a label on the face (the demo shows "Temperature"), and Font styles it. Use it to name the measured quantity or its unit.

The digital readout

ShowValues toggles the numeric readout, ValueFormat formats it (a standard Delphi format string), and ValuePosition (for example vpBottom) places it. GaugeValuesFormat formats the numbers printed around the scale. Hide the readout for a purely visual gauge, or show it when the exact figure matters.

Pitfalls

  • Value is in your scale's units. It is clamped to MinimumValue..MaximumValue, so set the range before the value.
  • ValueFormat is a Delphi format string. Double a literal % ('%.0f%%').
  • Set the range before sections and needles. Their values are read against the current MinimumValue/MaximumValue (see Sections and needles).

See also