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

DATATypeDescription
aGradArrayBackground track gradient definition (array of {fraction, fromClr, toClr})
aGradMetArrayMeter fill gradient definition
bSetGetBlockCode block to get/set the current value
nTotalNumericMaximum value (100% fill)
nRefreshNumericLast painted pixel width (drives refresh logic)
lRoundLogicalEnable rounded corners
nRoundNumericCorner radius in pixels
lVerticalLogicalVertical orientation
lInvertedLogicalInvert fill direction
hBitmapHandleOptional overlay bitmap for the fill area
nClrBoxInNumericInner border color
nClrBoxOutNumericOuter border color

Methods

MethodDescription
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

See Also