Gradient Rows with XBrowse 9.11

Gradient Rows with XBrowse 9.11

Postby nageswaragunupudi » Fri Dec 04, 2009 4:28 am

Example to paint gradient rows with XBrowse 9.11 using oCol:bPaintText method.

Image

Code: Select all  Expand view
#include 'fivewin.ch'
#include 'xbrowse.ch'

function Main()

   local oDlg, oBrw, oFont

   USE \FWH\SAMPLES\CUSTOMER ALIAS CUST

   DEFINE FONT oFont NAME 'Tahoma' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
      FONT oFont TITLE 'XBrowse Gradient Rows'

   @ 10,10 XBROWSE oBrw OF oDlg ;
      SIZE 300,200 PIXEL ;
      AUTOCOLS ALIAS 'CUST' LINES NOBORDER


   WITH OBJECT oBrw
      :nMarqueeStyle := 4
      :bClrRowFocus  := { || { CLR_BLACK, RGB( 0, 251, 220 ) } }
   END

   AEval( oBrw:aCols, { |oCol| ;
      oCol:bClrSelFocus  := { || { CLR_BLACK, RGB( 255, 224, 126) } }, ;
      oCol:bPaintText := { |oCol, hDC, cData, aRect, aColors| ;
                           PaintCol( oCol, hDC, cData, aRect, aColors ) } ;
      } )

   oBrw:CreateFromCode()
   ACTIVATE DIALOG oDlg CENTERED
   CLOSE CUST
   RELEASE FONT oFont

return nil

static function PaintCol( oCol, hDC, cData, aRect, aColors )

   local aGrad

   if aColors[ 2 ] ==  RGB( 255, 224, 126 )
      aGrad := { { .5, RGB( 255, 224, 126 ), RGB( 255, 255, 193 ) }, ;
                 { .5, RGB( 255, 255, 193 ), RGB( 255, 224, 126 ) } }
   elseif aColors[ 2 ] == RGB(   0, 251, 220 )
      aGrad := { { .5, RGB(   0, 251, 220 ), RGB( 221, 255, 251 ) }, ;
                 { .5, RGB( 221, 255, 251 ), RGB(   0, 251, 220 ) } }
   endif

   if aGrad != nil
      GradientFill( hDC, aRect[ 1 ], aRect[ 2 ], aRect[ 3 ] - 1, aRect[ 4 ], aGrad, .t.)
      SetBkMode( hDC, 1 )
   endif

   DrawTextEx( hDC, cData, aRect, oCol:nDataStyle )


return nil
 
Regards

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

Re: Gradient Rows with XBrowse 9.11

Postby nageswaragunupudi » Fri Dec 04, 2009 5:08 am

This example works with versions 9.10 and before
Code: Select all  Expand view
#include 'fivewin.ch'
#include 'xbrowse.ch'

function Main()

   local oDlg, oBrw, oFont
   local nRecSel

   USE \FWH\SAMPLES\CUSTOMER ALIAS CUST
   nRecSel  := CUST->( RecNo() )

   DEFINE FONT oFont NAME 'Tahoma' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
      FONT oFont TITLE 'XBrowse Gradient Rows'

   @ 10,10 XBROWSE oBrw OF oDlg ;
      SIZE 300,200 PIXEL ;
      AUTOCOLS ALIAS 'CUST' LINES ;
      BACKGROUND '\fwh\bitmaps\fiveback.bmp'

   WITH OBJECT oBrw
      :bChange       := { || nRecSel := oBrw:BookMark }
      :nMarqueeStyle := 4
      :bClrRowFocus  := { || { CLR_BLACK, RGB( 0, 251, 220 ) } }
   END

   AEval( oBrw:aCols, { |oCol| ;
      oCol:bClrSelFocus  := { || { CLR_BLACK, RGB( 255, 224, 126) } }, ;
      oCol:bPaintText := { |oCol, hDC, cData, aRect | ;
                           PaintCol( oCol, hDC, cData, aRect, nRecSel ) } ;
      } )

   oBrw:CreateFromCode()
   ACTIVATE DIALOG oDlg CENTERED
   CLOSE CUST
   RELEASE FONT oFont

return nil

static function PaintCol( oCol, hDC, cData, aRect, nRecSel )

   local aGrad

   if nRecSel == CUST->( RecNo() )
      if oCol:nCreationOrder == oCol:oBrw:SelectedCol():nCreationOrder
         aGrad := { { .5, RGB( 255, 224, 126 ), RGB( 255, 255, 193 ) }, ;
                    { .5, RGB( 255, 255, 193 ), RGB( 255, 224, 126 ) } }
      else
         aGrad := { { .5, RGB(   0, 251, 220 ), RGB( 221, 255, 251 ) }, ;
                    { .5, RGB( 221, 255, 251 ), RGB(   0, 251, 220 ) } }
      endif
   endif

   if aGrad != nil
      GradientFill( hDC, aRect[ 1 ], aRect[ 2 ], aRect[ 3 ] - 1, aRect[ 4 ], aGrad, .t.)
      SetBkMode( hDC, 1 )
   endif

   DrawTextEx( hDC, cData, aRect, oCol:nDataStyle )

return nil
 
Regards

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

Re: Gradient Rows with XBrowse 9.11

Postby Antonio Linares » Fri Dec 04, 2009 9:53 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41898
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

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