* ============================================================================
* METHOD TSBrowse:Report() Version 9.0 Nov/30/2009
* ============================================================================
METHOD Report( cTitle, lPreview, oFont, cCaption, lModal, aCols, cHeader, cFooter, lGrid, oDevice ) CLASS TSBrowse
Local oRpt, oColumn, nRecNo, nI, nAt, cType, nSize, ;
nVPos := If( ::oVScroll != Nil, ::oVScroll:GetPos(), Nil ), ;
nRPos := ::nRowPos, ;
aAlig := { "LEFT", "CENTER", "RIGHT" }
Default cTitle := ::oWnd:GetText(), ;
lPreview := .T., ;
cCaption := ::oWnd:GetText(), ;
oFont := ::oFont, ;
lGrid := .F.
Default lModal := lPreview
::lNoPaint := .F.
cHeader := If( cHeader != Nil, cHeader + Space( 1 ), "" )
cFooter := If( cFooter != Nil, cFooter + Space( 1 ), "" )
cCaption += If( lPreview, Space( 1 ) + ::aMsg[ 23 ], "" )
If aCols == Nil
aCols := {}
For nI := 1 To Len( ::aColumns )
AAdd( aCols, nI )
Next
EndIf
If ::lIsDbf
If ::lDbfObj
nRecNo := ::oDbf:RecNo()
Else
nRecNo := ( ::cAlias )->( RecNo() )
EndIf
EndIf
nAt := ::nAt
Eval( ::bGoTop )
oRpt := RptBegin( {{||cTitle}}, { {||cHeader + ::aMsg[ 20 ] + Space( 1 ) + DToC( Date() ) + " - " + ;
::aMsg[ 22 ] + Space( 1 ) + Time() } }, ;
{ {|| cFooter + ::aMsg[ 21 ] + Str( oRpt:nPage, 3 ) } }, ;
If( oFont == Nil, Nil, {oFont} ),,,,,, lPreview,, oDevice, cCaption,,, "CENTER" )
oRpt:oDevice:lPrvModal := lModal
oRpt:bPostEnd := {|| If( ::lIsDbf, ( ::cAlias )->( DbGoTo( nRecNo ) ), Nil ), ::nAt := nAt, ::SetFocus() }
oRpt:cCharPattern := "b"
For nI := If( ::lSelector, 2, 1 ) To Len( aCols )
If ! ::aColumns[ aCols[ nI ] ]:lBitMap
cType := ValType( Eval( ::aColumns[ aCols[ nI ] ]:bData ) )
nSize := Max( 1, Round( ::aColSizes[ aCols[ nI ] ] / ;
GetTextWidth( 0, "b", If( oFont != Nil, oFont:hFont, 0 ) ), 0 ) )
oRpt:AddColumn( TrColumn():New( GenHead( ::aColumns, aCols[ nI ] ),, ;
GenData( ::aColumns, aCols[ nI ] ), nSize, ;
{ If( ! Empty( ::aColumns[ aCols[ nI ] ]:cPicture), ;
::aColumns[ aCols[ nI ] ]:cPicture, "" ) },, ;
( ::aColumns[ aCols[ nI ] ]:cFooting != Nil .and. ;
cType == "N"),, ; // prints footings if the column has one (numeric only)
aAlig[ nLoWord( ::aColumns[ aCols[ nI ] ]:nAlign ) + 1 ],,,, oRpt ) )
EndIf
Next
If lGrid
oRpt:CellView()
EndIf
RptEnd()
oRpt:bSkip := { || oRpt:Cargo := ::Skip( 1 ) }
oRpt:Cargo := 1
oRpt:Activate( , { || If( ::lIsArr, oRpt:nCounter <= Max( ( Eval( ::bLogicLen ) ) - 1, 1 ), oRpt:Cargo == 1 ) } )
::lHitTop := .F.
::SetFocus()
Return Self