TMeter
Source: source/classes/meter.prg
Inherits from: TControl
TMeter is a progress meter control that displays the completion status of a long-running operation. It supports three rendering styles: standard rectangular bar, circular gauge, and bitmap array. The meter can display a text label and percentage, with customizable foreground and background colors.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
nTotal | Numeric | Maximum value (100% completion) |
cText | Character | Label text displayed on or beside the meter |
lPercentage | Logical | Show percentage text on the meter |
nClrBar | Numeric | Bar fill color (default CLR_HBLUE) |
nClrBText | Numeric | Bar text color (default CLR_WHITE) |
nClrBlank | Numeric | Unfilled portion color |
cStyle | Character | Rendering style: "CIRCULAR", "BMPARRAY", "BRUSH", or NIL for standard bar |
nInnerDia | Numeric | Inner diameter for circular meter (donut style) |
nClrFill | Numeric | Fill color for circular meter |
nClrBorder | Numeric | Border color for circular meter |
Methods
| Method | Description |
|---|---|
New( nRow, nCol, bSetGet, nTotal, oWnd, nW, nH, lUpdate, lPixel, oFont, cText, lNoPercentage, nClrPane, nClrText, nClrBar, nClrBText, lDesign, lCircular, nInnerDia, nClrFill, nClrBorder, lBmpArray ) | Create a new meter control |
ReDefine( nId, bSetGet, nTotal, oWnd, lUpdate, oFont, cText, lNoPercentage, nClrPane, nClrText, nClrBar, nClrBText, lCircular, nInnerDia, nClrFill, nClrBorder, lBmpArray ) | Redefine from dialog resource |
Set( nActual ) | Set the current progress value and refresh the display |
SetTotal( nTotal ) | Change the maximum value |
Paint() | Render the standard rectangular bar |
PaintCircular() | Render the circular gauge style |
PaintBmpArray() | Render using a bitmap strip array |
PaintBrushed() | Render using a brush fill pattern |
Default() | Apply default font and colors |
Example: Circular Progress
#include "FiveWin.ch"
function Main()
local oWnd, oMeter, nVal := 0
DEFINE WINDOW oWnd TITLE "Circular Meter Demo" SIZE 400, 300
@ 10, 10 METER oMeter VAR nVal TOTAL 100 ;
OF oWnd SIZE 120, 120 CIRCULAR ;
COLORS CLR_HGREEN, CLR_WHITE, CLR_GRAY
DEFINE TIMER oTimer OF oWnd INTERVAL 100 ;
ACTION ( nVal++,;
oMeter:Set( nVal ),;
If( nVal >= 100, oTimer:End(), ) )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The
bSetGetcodeblock provides a two-way binding to a numeric variable. It is evaluated to read the current value and assigned to when the value changes. - Circular style is enabled by passing
.T.forlCircularinNew(), which setscStyleto"CIRCULAR". - Bitmap array style is enabled by
lBmpArray := .T., which setscStyleto"BMPARRAY". - Use
Set()to update the progress position; the meter redraws automatically. - For circular meters,
nInnerDiacontrols the hole size for a donut-style gauge.