home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
news
/
4611
/
fw16d.ins
/
SOURCE
/
CLASSES
/
SAY.PRG
< prev
next >
Wrap
Text File
|
1994-06-11
|
5KB
|
188 lines
#include "FiveWin.ch"
#include "Constant.ch"
#define LTGRAY_BRUSH 1
#define TRANSPARENT 1
#define SS_CENTER 1
#define DLGC_BUTTON 8192 // 0x2000
#define COLOR_WINDOW 5
#define COLOR_WINDOWTEXT 8
#define WM_NCHITTEST 132 // 0x84
//----------------------------------------------------------------------------//
CLASS TSay FROM TControl
DATA lBorder, lCenter
DATA cPicture
DATA bGet
METHOD New( nRow, nCol, bText, oWnd, cPicture, oFont,;
lCentered, lBorder, lPixels, nClrText, nClrBack,;
nWidth, nHeight, lDesign, lUpdate ) CONSTRUCTOR
METHOD ReDefine( nId, bText, oWnd, lCentered, lBorder, nClrText,;
nClrBack, lUpdate, oFont ) CONSTRUCTOR
METHOD cToChar() INLINE Super:cToChar( "STATIC" )
METHOD Default()
METHOD cGenPrg()
METHOD HandleEvent( nMsg, nWParam, nLParam )
METHOD Init( hDlg )
METHOD Refresh() INLINE If( ::bGet != nil, ::SetText( Eval( ::bGet ) ),)
METHOD SetText( cText ) INLINE ;
::cCaption := If( ::cPicture != nil,;
Transform( cText, ::cPicture ),;
cValToChar( cText ) ),;
SetWindowText( ::hWnd, ::cCaption )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nRow, nCol, bText, oWnd, cPicture, oFont,;
lCentered, lBorder, lPixels, nClrText, nClrBack,;
nWidth, nHeight, lDesign, lUpdate ) CLASS TSay
DEFAULT lBorder := .f., lCentered := .f., lPixels := .f.,;
oWnd := GetWndDefault(),;
nClrText := oWnd:nClrText, nClrBack := oWnd:nClrPane,;
nHeight := If( oFont != nil, Abs( oFont:nHeight ), SAY_CHARPIX_H ),;
lDesign := .f., bText := { || "" },;
lUpdate := .f.
::bGet = bText
::cPicture = cPicture
::cCaption = If( Empty( cPicture ), cValToChar( Eval( bText ) ),;
Transform( Eval( bText ), cPicture ) )
DEFAULT nWidth := ( If( oFont != nil, Abs( oFont:nWidth ), SAY_CHARPIX_W ) * Len( ::cCaption ) ) - 4 // 8
::lBorder = lBorder
::lCenter = lCentered
if ! lPixels
::nTop = nRow * If( oFont != nil, Abs( oFont:nHeight ), SAY_CHARPIX_H ) + 2 // 13
::nLeft = nCol * If( oFont != nil, Abs( oFont:nWidth ), SAY_CHARPIX_W ) // 8
else
::nTop = nRow
::nLeft = nCol
endif
::nBottom = ::nTop + nHeight - 1
::nRight = ::nLeft + nWidth - 1
::oWnd = oWnd
::oFont = oFont
::nId = ::GetNewId()
::nStyle = nOR( WS_CHILD, WS_VISIBLE ,;
If( ::lCenter , SS_CENTER, SS_LEFT ),;
If( ::lBorder, WS_BORDER, 0 ),;
If( lDesign, WS_THICKFRAME, 0 ) )
::lDrag = lDesign
::lCaptured = .f.
::lUpdate = lUpdate
::SetColor( nClrText, nClrBack )
if oWnd:lVisible
::Create( "STATIC" )
::Default()
oWnd:AddControl( Self )
else
oWnd:DefControl( Self )
endif
return nil
//----------------------------------------------------------------------------//
METHOD ReDefine( nId, bText, oWnd, cPicture, lCentered, lBorder,;
nClrText, nClrBack, lUpdate, oFont ) CLASS TSay
DEFAULT lCentered := .f., lBorder := .f.,;
nClrText := oWnd:nClrText, nClrBack := oWnd:nClrPane,;
lUpdate := .f.
::nId = nId
::bGet = bText
::cPicture = cPicture
::oFont = oFont
if bText != nil
::cCaption = If( Empty( cPicture ), cValToChar( Eval( bText ) ),;
Transform( Eval( bText ), cPicture ) )
endif
::oWnd = oWnd
::hWnd = 0
::lBorder = lBorder
::lCenter = lCentered
::lDrag = .f.
::lCaptured = .f.
::lUpdate = lUpdate
::SetColor( nClrText, nClrBack )
oWnd:DefControl( Self )
return nil
//----------------------------------------------------------------------------//
METHOD Init( hDlg ) CLASS TSay
Super:Init( hDlg )
if ! Empty( ::cCaption )
SetWindowText( ::hWnd, ::cCaption )
else
::cCaption = GetWindowText( ::hWnd )
endif
return nil
//----------------------------------------------------------------------------//
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TSay
if ::lDrag .and. nMsg == WM_NCHITTEST // To have a standard behavior on Clicks
return DefWindowProc( ::hWnd, nMsg, nWParam, nLParam )
endif
return Super:HandleEvent( nMsg, nWParam, nLParam )
//----------------------------------------------------------------------------//
METHOD Default() CLASS TSay
if ::oFont != nil
::SetFont( ::oFont )
else
::SetFont( ::oWnd:oFont )
endif
return nil
//----------------------------------------------------------------------------//
METHOD cGenPrg() CLASS TSay
local cCode := CRLF + " @ " + Str( ::nTop, 3 ) + ", " + ;
Str( ::nLeft, 3 ) + ' SAY "' + ::cCaption + ;
'" SIZE ' + Str( ::nRight - ::nTop, 3 ) + ", " + ;
Str( ::nBottom - ::nTop, 3 ) + " PIXEL OF oWnd" + CRLF
return cCode
//----------------------------------------------------------------------------//