Code: Select all
#include "FiveWin.ch"
#ifdef __XPP__
#define New _New
#endif
//----------------------------------------------------------------------------//
// MODIFIED BY FALCONI SILVIO & Nageswaragunupudi
// NOT remove this
CLASS TMsgItem
DATA oMsgBar
DATA cMsg
DATA nWidth, nClrText, nClrPane, nClrDisabled
DATA bMsg, bAction
DATA oFont
DATA lActive, lTimer AS LOGICAL
DATA lWasActive
DATA hBitmap1, hPalette1
DATA hBitmap2, hPalette2
DATA cToolTip
METHOD New( oMsgBar, cMsg, nWidth, oFont, nClrText, nClrBack, lAdd,;
bAction, cBmp1, cBmp2, cToolTip ) CONSTRUCTOR
METHOD Refresh()
METHOD SetFont( oFont ) INLINE ::oFont:End(), ::oFont := oFont
METHOD Paint()
METHOD SetText( cMsg ) INLINE ::cMsg := cValToChar( cMsg ), ::Paint()
METHOD Click( nRow, nCol ) INLINE If( ::bAction != nil, Eval( ::bAction, nRow, nCol ),)
METHOD IsOver( nRow, nCol )
METHOD nLeft()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( oMsgBar, cMsg, nWidth, oFont, nClrText, nClrBack, lAdd, bAction,;
cBmp1, cBmp2, cToolTip ) CLASS TMsgItem
#ifdef __XPP__
#undef New
#endif
DEFAULT nClrText := oMsgBar:nClrText,;
nClrBack := oMsgBar:nClrPane,;
lAdd := .f., cMsg := "", cToolTip := ""
::oMsgBar = oMsgBar
::cMsg = cMsg
::oFont = If( oFont != nil, oFont, ::oMsgBar:oFont )
::bAction = bAction
::lActive = .t.
::lWasActive = .t.
::lTimer = .f.
::cToolTip = cToolTip
if Valtype( nClrText ) == "C"
::nClrText := nGetForeRGB( nClrText )
::nClrPane := nGetBackRGB( nClrText )
else
::nClrText := nClrText
::nClrPane := nClrBack
endif
if cBmp1 != nil
if File( cBmp1 )
::hBitmap1 = ReadBitmap( 0, cBmp1 )
::hPalette1 = 0
else
::hBitmap1 = LoadBitmap( GetResources(), cBmp1 )
::hPalette1 = 0
endif
if ::hBitmap1 == 0
::hBitmap1 := nil
else
DEFAULT nWidth := nBmpWidth( ::hBitmap1 ) + 7
endif
endif
if cBmp2 != nil
if File( cBmp2 )
::hBitmap2 = ReadBitmap( 0, cBmp2 )
::hPalette2 = 0
else
::hBitmap2 = LoadBitmap( GetResources(), cBmp2 )
::hPalette2 = 0
endif
if ::hBitmap2 == 0
::hBitmap2 := nil
else
DEFAULT nWidth := nBmpWidth( ::hBitmap2 ) + 7
endif
endif
DEFAULT nWidth := 40
::nWidth = nWidth
if ! Empty( ::cToolTip )
::oMsgBar:cToolTip := ""
endif
if lAdd
oMsgBar:AddItem( Self )
endif
return Self
//----------------------------------------------------------------------------//
#ifdef __CLIPPER__
static function IsAppThemed()
return .f.
#endif
//----------------------------------------------------------------------------//
METHOD nLeft() CLASS TMsgItem
local n := Len( ::oMsgBar:aItem ), nPos := ::oMsgBar:nRight - ;
If( IsAppThemed(), 13, ;
If( IsZoomed( ::oMsgBar:oWnd:hWnd ), 3, 13 ) )
while n > 0 .and. ! ::oMsgBar:aItem[ n ] == Self
nPos -= ( ::oMsgBar:aItem[ n ]:nWidth + 4 )
n--
end
nPos -= ( ::nWidth - 2 )
return nPos
//----------------------------------------------------------------------------//
METHOD IsOver( nRow, nCol ) CLASS TMsgItem
local nLeft := ::nLeft()
return nCol >= ( nLeft - 1 ) .and. ( nCol <= nLeft + ( ::nWidth - 7 ) ) .and. ;
nRow > 5
//----------------------------------------------------------------------------//
METHOD Paint() CLASS TMsgItem
local nCount, nClrBack
local nLeft := ::nLeft()
local hBmp, nBmpWidth := 0
local hDC
hDC := ::oMsgBar:GetDC()
if ::omsgbar:l2007
Gradient( hDC, { 0, nLeft, ::omsgbar:nHeight / 3, nLeft + ::nWidth },;
nRGB( 227, 239, 255 ), nRGB( 201, 224, 255 ), .T. )
Gradient( hDC, { ( ::omsgbar:nHeight / 3 ) + 1, nLeft, ::omsgbar:nHeight, nLeft + ::nWidth },;
nRGB( 174, 209, 255 ), nRGB( 186, 216, 255 ), .T. )
endif
if ::hBitmap1 != nil
hBmp = If( ::lActive, ::hBitmap1, ;
If( ::hBitmap2 != nil, ::hBitmap2, ::hBitmap1 ) )
nBmpWidth = nBmpWidth( hBmp )
DrawMasked( hDC, hBmp, 4, nLeft + 1 )
endif
if ::omsgbar:l2007
::oMsgBar:Say( ::oMsgBar:nHeight / 4 - 2,;
nLeft + (::nWidth - GetTextWidth( hDC,::cMsg ))/2, ::cMsg, ;
iif( ::lActive, ::nClrText, ::nClrDisabled ), ::nClrPane, ;
::oFont, .T., .T. )
wndboxin( hDc, 0, nLeft-1, ::oMsgBar:nHeight, nLeft ) // present test values
else
DrawMsgItem( hDC, ::cMsg,;
{ 5, nLeft + nBmpWidth, ::oMsgBar:nHeight-6, nLeft + ( ::nWidth - 7 ) },;
If( ::lActive, ::nClrText, ::nClrDisabled ),;
::nClrPane, ::oFont:hFont )
WndBoxIn( hDC, 3, nLeft - 2, ::oMsgBar:nHeight-5, nLeft + ::nWidth - 6 ) // fwh
endif
::oMsgBar:ReleaseDC()
return nil
//----------------------------------------------------------------------------//
METHOD Refresh() CLASS TMsgItem
local cMsg
if ::bMsg != nil
cMsg = cValToChar( Eval( ::bMsg ) )
if cMsg != ::cMsg .or. ::lActive != ::lWasActive
::cMsg = cMsg
::Paint()
::lWasActive = ::lActive
endif
endif
return nil
//----------------------------------------------------------------------------//