home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
news
/
4611
/
fw16d.ins
/
SOURCE
/
CLASSES
/
METER.PRG
< prev
next >
Wrap
Text File
|
1994-06-10
|
3KB
|
139 lines
#include "FiveWin.ch"
#include "Constant.ch"
#define LTGRAY_BRUSH 1
static lRegistered := .f.
//----------------------------------------------------------------------------//
CLASS TMeter FROM TControl
DATA nTotal
METHOD New( nRow, nCol, bSetGet, nTotal, oWnd, nWidth, nHeight,;
lUpdate ) CONSTRUCTOR
METHOD ReDefine( nId, bSetGet, nTotal, oWnd, lUpdate ) CONSTRUCTOR
METHOD Default()
METHOD Init( hDlg ) INLINE Super:Init( hDlg ), ::Default()
METHOD HandleEvent( nMsg, nWParam, nLParam )
METHOD Paint() BLOCK ;
{ | Self, nActual | MeterPaint( ::hWnd, ::hDC,;
nActual := Eval( ::bSetGet ), ::nTotal,;
nActual * 100 / ::nTotal ) }
METHOD Set( nActual )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nRow, nCol, bSetGet, nTotal, oWnd, nWidth, nHeight,;
lUpdate ) CLASS TMeter
DEFAULT nTotal := 10, nWidth := 300, nHeight := 20,;
lUpdate := .f.
::nTop = nRow * MTR_CHARPIX_H //14
::nLeft = nCol * MTR_CHARPIX_W //8
::nBottom = ::nTop + nHeight
::nRight = ::nLeft + nWidth
::oWnd = oWnd
::nStyle = nOR( WS_CHILD, WS_VISIBLE, WS_BORDER )
::nId = ::GetNewId()
::bSetGet = bSetGet
::nTotal = nTotal
::lDrag = .f.
::lCaptured = .f.
::lUpdate = .f.
if ! lRegistered
::Register( nOR( CS_VREDRAW, CS_HREDRAW, CS_GLOBALCLASS ) )
lRegistered = .t.
endif
if oWnd:lVisible
::Create()
::Default()
oWnd:AddControl( Self )
else
oWnd:DefControl( Self )
endif
return nil
//----------------------------------------------------------------------------//
METHOD ReDefine( nId, bSetGet, nTotal, oWnd, lUpdate ) CLASS TMeter
DEFAULT nTotal := 10, lUpdate := .f.
::nId = nId
::bSetGet = bSetGet
::nTotal = nTotal
::oWnd = oWnd
::lDrag = .f.
::lCaptured = .f.
::lUpdate = lUpdate
if ! lRegistered
::Register( nOR( CS_VREDRAW, CS_HREDRAW, CS_GLOBALCLASS ) )
lRegistered = .t.
endif
if oWnd != nil
oWnd:DefControl( Self )
endif
return nil
//----------------------------------------------------------------------------//
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMeter
if nMsg == WM_PAINT
::BeginPaint()
::Paint()
::EndPaint()
return 0
endif
return Super:HandleEvent( nMsg, nWParam, nLParam )
//----------------------------------------------------------------------------//
METHOD Set( nActual ) CLASS TMeter
DEFAULT nActual := Eval( ::bSetGet )
if nActual > ::nTotal
nActual = ::nTotal
endif
if nActual < 0
nActual = 0
endif
Eval( ::bSetGet, nActual )
::Refresh( .f. )
return nil
//----------------------------------------------------------------------------//
METHOD Default() CLASS TMeter
if ValType( Eval( ::bSetGet ) ) == "U"
Eval( ::bSetGet, 0 )
endif
return nil
//----------------------------------------------------------------------------//