Page 1 of 2

XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Wed May 18, 2016 1:25 pm
by nageswaragunupudi
The DATAs bPaintHeader, bPaintFooter and bPaintRow offer more control to programmer to customize display of xbrowse where required.

Sample:
Image

Code:

Code: Select all

function XbUserDraw()

   local oDlg, oBrw, oFont, oBold, oLarge, oSmall
   local oHeadBrush
   local aData := {}
   local nOpgBal  := 25000.00

   FWNumFormat( 'A', .T. )

   aData    := GetData()

   DEFINE FONT oLarge NAME "TAHOMA" SIZE 0,-26
   DEFINE FONT oFont  NAME "TAHOMA" SIZE 0,-14
   DEFINE FONT oBold  NAME "TAHOMA" SIZE 0,-16 BOLD

   DEFINE BRUSH oHeadBrush FILE "..\bitmaps\backgrnd\stone.bmp"

   DEFINE DIALOG oDlg SIZE 800,650 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData ;
      COLUMNS 2,3,4,5,6, 7 ;
      HEADERS "DATE", "DETAILS", "QUANTITY", "RATE", "AMOUNT", Transform( nOpgBal, NumPict( 10, 2 ) ) ;
      PICTURES nil, nil, "9999.999", "$ 999.99", '$ ' + NumPict( 7, 2 ), '$ ' + NumPict( 7, 2 ) ;
      CELL FOOTERS NOBORDER STYLE FLAT

   WITH OBJECT oBrw

      :AddVar( "oFntLarge", oLarge )
      :AddVar( "oHeadBrush", oHeadBrush )

      :lRecordSelector  := .f.
      :lHScroll         := .f.
      :nRowDividerStyle := LINESTYLE_BLACK
      :nHeaderHeight    := 90
      :nFooterHeight    := 90
      :nRowHeight       := 25
      :nStretchCol      := 2
      :nHeadStrAligns   := { AL_RIGHT, AL_LEFT, AL_RIGHT, AL_RIGHT, AL_RIGHT, AL_RIGHT }
      :nFootStrAligns   := { AL_RIGHT, AL_LEFT, AL_RIGHT, AL_RIGHT, AL_RIGHT, AL_RIGHT }
      :lDisplayZeros    := .f.
      :lAllowColSwapping := .f.

      :oHeaderFonts     := oBold
      :oFooterFonts     := oBold

      :aCols[ 3 ]:bClrStd     := { || { CLR_BLACK, RGB( 240, 240, 240 ) } }
      :aCols[ 5 ]:bClrStd     := :aCols[ 3 ]:bClrStd

      :aCols[ 3 ]:nFooterType := AGGR_SUM
      :aCols[ 5 ]:nFooterType := AGGR_SUM
      :aCols[ 6 ]:nFooterType := AGGR_SUM
      :aCols[ 6 ]:bFooter  := { || oBrw:aCols[ 6 ]:nTotal + nOpgBal }

      :bPaintRow        := { | brw, nRow, nCol, nHeight, lHighLite, lSelect, nRowPos, nColSel, oColSel | PaintRow ;
                             ( brw, nRow, nCol, nHeight, lHighLite, lSelect, nRowPos, nColSel, oColSel ) }

      :bPaintHeader     := { | brw, hDC, aCols, nLast, hWhitePen, hGrayPen, hColPen | BrwHeader ;
                             ( brw, hDC, aCols, nLast, hWhitePen, hGrayPen, hColPen ) }

      :bPaintFooter     := { | brw, hDC, aCols, nLast, nGridWidth, nBrwHeight, hWhitePen, hGrayPen | BrwFooter ;
                             ( brw, hDC, aCols, nLast, nGridWidth, nBrwHeight, hWhitePen, hGrayPen ) }

      :lDrawBorder      := .t.
      //
      :MakeTotals()
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont, oLarge, oBold
   RELEASE BRUSH oHeadBrush

return nil

//----------------------------------------------------------------------------//

function BrwHeader( Self, hDC, aCols, nLast, hWhitePen, hGrayPen, hColPen )

   local aRect := { 1, 1, ::nHeaderHeight, ::BrwWidth() }
   local hPen
   local nRow, n, aBmp
   local cHeader := "Painted using oBrw:bPaintHeader"
   local oBrush

   FillRect( hDC, aRect, ::oHeadBrush:hBrush )

   hPen     := createPen( PS_SOLID, 1, CLR_BLACK )
   DrawHorz( hDC, 1, 0, ::BrwWidth(), hPen )
   nRow  := ::SayText( cHeader, aRect, "T", ::oFntLarge, CLR_HRED )

   aBmp  := ::ReadPalBmpEx( "..\bitmaps\pngs\image7.png" )
   ::SayPalBmp( aBmp, { 1, 1, ::nHeaderHeight - 24, 64 } )
   PalBmpFree( aBmp )

   for n := 1 to Len( ::aCols )
      ::aCols[ n ]:PaintHeader( ::nHeaderHeight - 30, nil, 26, .f., hDC )
   next

   ::SayText( "Opening" +  CRLF + "Balance", ;
      { 2, 1, ::nHeaderHeight - 23, ::BrwWidth() - 8 }, "R", ::aCols[ 6 ]:oHeaderFont, CLR_HRED )

   DrawHorz( hDC, ::nHeaderHeight - 3, 0, ::BrwWidth(), hPen )
   DrawHorz( hDC, ::nHeaderHeight - 1, 0, ::BrwWidth(), hPen )

   DeleteObject( hPen )

return nil

//----------------------------------------------------------------------------//

static function BrwFooter( Self, hDC, aCols, nLast, nGridWidth, nBrwHeight, hWhitePen, hGrayPen )

   local nRow     := nBrwHeight - ::nFooterHeight + 1
   local aRect    := { nRow, 1, nBrwHeight - 1, nGridWidth }
   local hPen     := CreatePen( PS_SOLID, 1, CLR_BLACK )
   local n, aBmp, nTotal, nTax

   FillRect( hDC, aRect, ::oHeadBrush:hBrush )
   DrawHorz( hDC, nRow, aRect[ 2 ], aRect[ 4 ], hPen )

   aBmp  := ::ReadPalBmpEx( "..\bitmaps\alphabmp\visa.bmp" )
   ::SayPalBmp( aBmp, { nRow, 1, nBrwHeight - 1, 96 } )
   PalBmpFree( aBmp )

   for n := 3 to 6
      ::aCols[ n ]:PaintFooter( nRow + 2, nil, 25 )
   next

   nRow  += 25
   ::SayText( "Tax calculated @ 20% :", { nRow, 1, nRow + 25, ::aCols[ 6 ]:nDisplayCol - 6 }, ;
            "R", ::aCols[ 1 ]:oFooterFont, CLR_HRED )

   nTotal   := Eval( ::aCols[ 6 ]:bFooter )
   nTax     := Round( nTotal * 0.2, 2 )

   ::SayText( Transform( nTax, ::aCols[ 6 ]:cEditPicture ), { nRow, ::aCols[ 6 ]:nDisplayCol, nRow + 25, ::BrwWidth() - 6 }, ;
            "R", ::aCols[ 1 ]:oFooterFont, CLR_GREEN )

   nRow  += 25
   ::SayText( "GRAND TOTAL :", { nRow, 1, nRow + 25, ::aCols[ 6 ]:nDisplayCol - 6 }, ;
            "R", ::aCols[ 1 ]:oFooterFont, CLR_HRED )

   nTotal   += nTax

   ::SayText( Transform( nTotal, ::aCols[ 6 ]:cEditPicture ), { nRow, ::aCols[ 6 ]:nDisplayCol, nRow + 25, ::BrwWidth() - 6 }, ;
            "R", ::aCols[ 1 ]:oFooterFont, CLR_HRED )

return nil

//----------------------------------------------------------------------------//

static function PaintRow( Self, nRow, nCol, nHeight, lHighLite, lSelect, nRowPos, nColSel, oColSel )

   local lPainted    := .f.
   local hDC, aColors

   if Empty( ::aRow[ 1 ] )
      return .t.
   endif

   if oColSel != nil .and. oColSel:nCreationOrder == 6
      return .t.
   endif

   hDC      := ::GetDC()

   if lSelect .and. ::nColSel < 6
      aColors  := Eval( ::bClrSelFocus )
   else
      aColors  := { CLR_BLACK, RGB( 255, 200, 160 ) }
   endif

   FillRectEx( hDC, { nRow, nCol, nRow + nHeight, ::aCols[ 6 ]:nDisplayCol }, aColors[ 2 ] )

   ::SayText( ::aRow[ 3 ] + " : Using bPaintRow", ;
            { nRow, nCol, nRow + nHeight, ::aCols[ 6 ]:nDisplayCol }, nil, ;
            ::aCols[ 1 ]:oHeaderFont )

   ::aCols[ 6 ]:PaintData( nRow, nil, nHeight, lHighLite, lSelect, 6, nRowPos )

   ::ReleaseDC()

return .f.

//----------------------------------------------------------------------------//

static function GetData()

   local aData    := {}
   local a, n
   local nTot     := 0

   for n := 1 to 15
      if n % 5 == 0
         a  := { 1, nil, RandomText( 20, 30 ), 0, 0, 0, nTot }
         nTot  := 0
      else
         a  := { 0, Date() - 20 + n, RandomText( 10, 30 ), HB_RandomInt( 100, 300 ), ;
               { 10,20,30 }[ HB_RandomInt( 1, 3 ) ], 0, 0 }
         a[ 6 ] := a[ 4 ] * a[ 5 ]

         nTot  += a[ 6 ]
      endif
      AAdd( aData, a )

   next


return aData

//----------------------------------------------------------------------------//
 

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Thu May 19, 2016 2:00 am
by joseluisysturiz
Simplemente ESPECTACULAR..!!!...esto le da una mejor estetica al xbrowse, ahora falta la buttonbar en footer, saludos... :shock:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Fri May 20, 2016 3:45 am
by RAMESHBABU
Hello Mr.Nageswara Rao

The Strength of XBrowse is demonstrated in this example.

May I request to you please provide a Printout feature of this Invoice Sample? .
A fully featured Invoicing software can be developed just using xBrowse itself.

In this context, I propose to assemble all xBrowse samples into a single sample for
the users to fully understand xBrowse and its strengths.

-Ramesh Babu P

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Fri May 20, 2016 3:51 am
by bpd2000
+1

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Sat May 21, 2016 2:42 pm
by ukoenig
Mr Rao,

this sample is very nice !!!.

I found a missing function in :

static function GetData()
local aData := {}
local a, n
local nTot := 0

for n := 1 to 15
if n % 5 == 0
a := { 1, nil, RandomText( 20, 30 ), 0, 0, 0, nTot }
...
...
Is it possible to add this function ?

best regards
Uwe :?:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Sun May 22, 2016 6:36 pm
by HunterEC
Rao:

Great example !!! You're a genius. I agree that we should have a complete xBrowse example to explore all its strengths and features. I suggest that this example should have also some sort of FULL documentation. It has received some many improvements / updates that I, at least myself, cannot find a single place to read all of its data and methods.

Antonio and yourself had done a MAGNIFICENT job !!! Keep it going !!!!

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Mon May 23, 2016 8:44 am
by Silvio.Falconi
Mr Nages,
then when it is printed also the header ? Do you thinked also to search a solution for print the multiheader?

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Mon May 23, 2016 10:08 am
by nageswaragunupudi
Silvio.Falconi wrote:Mr Nages,
then when it is printed also the header ? Do you thinked also to search a solution for print the multiheader?
No. Not yet.

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Mon May 23, 2016 7:08 pm
by Silvio.Falconi
:cry:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Tue Aug 23, 2016 11:17 pm
by rterraz
Sr.Rao
Lo felicito por el trabajo realizado, es muy bello.
Yo tengo FWH 16.02 y el xbrowse lamentablemente aun no tenia estas mejoras incorporadas.
Puedo agregar los codeblocks de la data y las funciones que ud. agrega a la clase xbrowse para que esto funcione o se necesita algo mas ?
Muchas gracias

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Fri Jul 28, 2017 2:58 am
by AIDA
No. Not yet

No RandomText :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Fri Jul 28, 2017 3:38 am
by nageswaragunupudi
nageswaragunupudi wrote:
Silvio.Falconi wrote:Mr Nages,
then when it is printed also the header ? Do you thinked also to search a solution for print the multiheader?
No. Not yet.
Implemented in 17.06

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Fri Jul 28, 2017 3:40 am
by nageswaragunupudi
Random text

Code: Select all

function RandomText( nMinLen, nMaxLen )

   local cText, nAt

   TEXT INTO cText
   Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
   ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis
   parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec,
   pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec
   pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo,
   rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu
   pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum
   semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor
   eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in,
   viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius
   laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue.
   Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas
   tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet
   adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar,
   hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec
   vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit
   amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris
   sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget
   bibendum sodales, augue velit cursus nunc,"
   ENDTEXT

   DEFAULT nMinLen := 10, nMaxLen := 50

   nAt      := HB_RandomInt( 1, Len( cText ) - nMaxLen )
   cText    := LTrim( SubStr( cText, nAt ) )
   cText    := Upper( Left( cText, 1 ) ) + ;
               SubStr( cText, 2, HB_RandomInt( nMinLen, nMaxLen - 1 ) )

return cText

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Mon Jul 31, 2017 4:10 am
by AIDA
OOOOH :shock:

Ya compile tu ejemplo esta genial :mrgreen:

muchas gracias :D

Saluditos :wink:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Posted: Tue Sep 18, 2018 1:21 pm
by miragerr
Good morning to all

Mr. Nages it is possible to highlight the summation of a determidado period.

For example, the BPaintRow, show the summation of a given year or month.

I don't know if I was very specific.

I'm waiting.