XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby nageswaragunupudi » Wed May 18, 2016 1:25 pm

The DATAs bPaintHeader, bPaintFooter and bPaintRow offer more control to programmer to customize display of xbrowse where required.

Sample:
Image

Code:
Code: Select all  Expand view
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
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby joseluisysturiz » Thu May 19, 2016 2: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!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby RAMESHBABU » Fri May 20, 2016 3: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
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby bpd2000 » Fri May 20, 2016 3:51 am

+1
Regards, Greetings

Try FWH. You will enjoy it's simplicity and power.!
User avatar
bpd2000
 
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby ukoenig » Sat May 21, 2016 2: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby HunterEC » Sun May 22, 2016 6: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 !!!!
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby Silvio.Falconi » Mon May 23, 2016 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby Silvio.Falconi » Mon May 23, 2016 7:08 pm

:cry:
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby rterraz » 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
User avatar
rterraz
 
Posts: 182
Joined: Wed Nov 08, 2006 11:44 pm
Location: Argentina

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby AIDA » Fri Jul 28, 2017 2: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ǝ
User avatar
AIDA
 
Posts: 879
Joined: Fri Jan 12, 2007 8:35 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby nageswaragunupudi » Fri Jul 28, 2017 3: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby nageswaragunupudi » Fri Jul 28, 2017 3:40 am

Random text
Code: Select all  Expand view
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
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby AIDA » Mon Jul 31, 2017 4: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ǝ
User avatar
AIDA
 
Posts: 879
Joined: Fri Jan 12, 2007 8:35 pm

Re: XBrowse 16.04 : bPaintHeader, bPaintFooter, bPaintRow

Postby miragerr » Tue Sep 18, 2018 1: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
User avatar
miragerr
 
Posts: 140
Joined: Tue Oct 11, 2005 2:36 am
Location: Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 44 guests