FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Wed May 18, 2016 01:25 PM
The DATAs bPaintHeader, bPaintFooter and bPaintRow offer more control to programmer to customize display of xbrowse where required.

Sample:


Code:
Code (fw): Select all Collapse
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
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Thu May 19, 2016 02:00 AM

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!
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Fri May 20, 2016 03:45 AM

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

Posts: 153
Joined: Tue Aug 05, 2014 09:48 AM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Fri May 20, 2016 03:51 AM

+1

Regards, Greetings



Try FWH. You will enjoy it's simplicity and power.!
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Sat May 21, 2016 02:42 PM
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.
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Sun May 22, 2016 06:36 PM

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 !!!!

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Mon May 23, 2016 08:44 AM

Mr Nages,
then when it is printed also the header ? Do you thinked also to search a solution for print the multiheader?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Mon May 23, 2016 10:08 AM
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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Mon May 23, 2016 07:08 PM

:cry:

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 182
Joined: Wed Nov 08, 2006 11:44 PM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Tue Aug 23, 2016 11:17 PM

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

Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Fri Jul 28, 2017 02:58 AM

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ǝ
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Fri Jul 28, 2017 03:38 AM
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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Fri Jul 28, 2017 03:40 AM
Random text
Code (fw): Select all Collapse
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
Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Mon Jul 31, 2017 04:10 AM

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ǝ
Posts: 140
Joined: Tue Oct 11, 2005 02:36 AM
Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow
Posted: Tue Sep 18, 2018 01:21 PM

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