TMeterEx
Source: source/classes/tmeterex.prg
Inherits from: TControl
TMeterEx is an extended progress meter control with dual-gradient rendering. It displays a filled progress bar over a background track, supporting custom gradient definitions, rounded corners, optional bitmap overlay, vertical orientation, and inverted fill direction. The meter value is managed through a bSetGet code block.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aGrad | Array | Background track gradient definition (array of {fraction, fromClr, toClr}) |
aGradMet | Array | Meter fill gradient definition |
bSetGet | Block | Code block to get/set the current value |
nTotal | Numeric | Maximum value (100% fill) |
nRefresh | Numeric | Last painted pixel width (drives refresh logic) |
lRound | Logical | Enable rounded corners |
nRound | Numeric | Corner radius in pixels |
lVertical | Logical | Vertical orientation |
lInverted | Logical | Invert fill direction |
hBitmap | Handle | Optional overlay bitmap for the fill area |
nClrBoxIn | Numeric | Inner border color |
nClrBoxOut | Numeric | Outer border color |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, oWnd, nWidth, nHeight, cBitmap, bSetGet, nTotal, lPixel, lDesign, lRound, nRound, aGrad, aGradMet, nClrBoxIn, nClrBoxOut, lVertical, lInverted, bPainted, lUpdate ) | Create a new meter control |
Redefine( nId, bSetGet, nTotal, oWnd, cBitmap, lRound, nRound, aGrad, aGradMet, nClrBoxIn, nClrBoxOut, lVertical, lInverted, bPainted, lUpdate ) | Redefine from a dialog resource |
Set( nActual ) | Set the current value and refresh the display |
SetTotal( nTotal ) | Set a new maximum value and refresh |
Paint() | Render the meter with gradients and borders |
Default() | Initialize the bSetGet value to 0 if undefined |
LoadBitmaps( cBitmap ) | Load a bitmap resource or file for the overlay |
Display() | Begin/end paint wrapper |
Example: Dual-Value Meter
#include "FiveWin.ch"
function Main()
local oWnd, oMeter, nVal := 50
DEFINE WINDOW oWnd TITLE "TMeterEx Demo" SIZE 400, 150
@ 30, 30 METEREX oMeter VAR nVal TOTAL 100 ;
SIZE 340, 28 OF oWnd ;
GRADIENTS { { 1, CLR_GRAY, CLR_WHITE } }, ;
{ { 1, CLR_GREEN, CLR_YELLOW } } ;
ROUND
@ 80, 30 BUTTON "Update" SIZE 60, 25 ;
ACTION ( nVal += 10, oMeter:Set( nVal ) )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- Use
GRADIENTSclause to setaGrad(track background) andaGradMet(progress fill). Each is an array of{ fraction, fromColor, toColor }entries. - The
ROUNDclause enables rounded corners with default radius 3; passnRoundfor a custom radius. lVerticaldraws the meter bottom-to-top;lInvertedreverses the fill direction (right-to-left or top-to-bottom).- A bitmap overlay can be specified via
cBitmap-- the bitmap is resized and drawn over the filled area.