XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
joseluisysturiz
Posts: 2024
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela
Contact:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post by joseluisysturiz »

Simplemente ESPECTACULAR..!!!...esto le da una mejor estetica al xbrowse, ahora falta la buttonbar en footer, saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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
User avatar
bpd2000
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post by bpd2000 »

+1
Regards, Greetings

Try FWH. You will enjoy it's simplicity and power.!
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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 :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
HunterEC
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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 !!!!
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post by Silvio.Falconi »

:cry:
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
rterraz
Posts: 141
Joined: Wed Nov 08, 2006 11:44 pm
Location: Argentina

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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
User avatar
AIDA
Posts: 782
Joined: Fri Jan 12, 2007 8:35 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post by AIDA »

No. Not yet

No RandomText :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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
Regards

G. N. Rao.
Hyderabad, India
User avatar
AIDA
Posts: 782
Joined: Fri Jan 12, 2007 8:35 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post by AIDA »

OOOOH :shock:

Ya compile tu ejemplo esta genial :mrgreen:

muchas gracias :D

Saluditos :wink:
Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
User avatar
miragerr
Posts: 140
Joined: Tue Oct 11, 2005 2:36 am
Location: Brasil

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Post 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.
Jackson Douglas C. Brito
Boa Vista - RR - Brasil
FWH 12.09 Last Build
xHarbour Free
UESTUDIO
SQLRDD
Post Reply