Xbrowse advanced painting techniques

Xbrowse advanced painting techniques

Postby Antonio Linares » Thu Sep 29, 2011 9:49 am

This is a xbrowse using the power that bPaintText provides :-)

Image

The button corners are still to be fixed, but the overall look is very good :-)

xbrpaint.prg
Code: Select all  Expand view
// xbrowse advanced painting examples

#include "FiveWin.ch"
#include "xbrowse.ch"

#define CLR_BACK nRGB( 130, 201, 249 )

function Main()

   local oWnd, oFont, oBrw, aItems := { { "One", "Two" }, { "Three", "Four" }, { "Five", "Six" } }
   local hBmp := ReadBitmap( 0, "..\bitmaps\contact.bmp" )

   DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0, -16

   DEFINE WINDOW oWnd COLOR "BG/B" STYLE nOr( WS_POPUP, WS_VISIBLE )

   @ 9, 37 XBROWSE oBrw ARRAY aItems ;
      SIZE 800, 500 NOBORDER OF oWnd FONT oFont

   oBrw:nDataLines = 4  
   oBrw:lRecordSelector = .F.
   oBrw:lHeader   = .F.
   oBrw:lHScroll  = .F.
   oBrw:lVScroll  = .F.
   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLCELL // MARQSTYLE_NOMARQUEE
   oBrw:bClrStd = { || { 0, CLR_BACK } }  
   oBrw:bClrSelFocus = { || { CLR_WHITE, CLR_BACK } }
   oBrw:SetColor( 0, CLR_BACK )    
   
   oBrw:CreateFromCode()
   oBrw:SetFocus()  

   oBrw:aCols[ 1 ]:nWidth = 400
   oBrw:aCols[ 2 ]:nWidth = 400
   oBrw:aCols[ 1 ]:bPaintText = { | oCol, hDC, cText, aCoors, aColors, lHighlight | DrawRow( oCol, hDC, cText, aCoors, oFont, lHighlight, hBmp )  }
   oBrw:aCols[ 2 ]:bPaintText = { | oCol, hDC, cText, aCoors, aColors, lHighlight | DrawRow( oCol, hDC, cText, aCoors, oFont, lHighlight, hBmp )  }
     
   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON CLICK oWnd:End()

return nil

function DrawRow( oCol, hDC, cText, aCoors, oFont, lHighlight, hBmp )

   local hOldFont, nOldMode := SetBkMode( hDC, 0 )
   // local hRgn := CreateRoundRectRgn( { aCoors[ 1 ] +  10, aCoors[ 2 ] + 10, aCoors[ 3 ] - 10, aCoors[ 4 ] - 10 }, 10, 10 )

   // SetWindowRgn( oCol:oBrw:hWnd, hRgn, .F. )

   if lHighlight
      GradientFill( hDC, aCoors[ 1 ] +  10, aCoors[ 2 ] + 10, aCoors[ 3 ] - 10, aCoors[ 4 ] - 10, { ;
           { 2/5, nRGB( 253, 212, 168 ), nRGB( 251, 178, 99 ) },;
         { 3/5, nRGB( 250, 157, 52 ), nRGB( 252, 234, 163 ) } } )
      RoundBox( hDC, aCoors[ 2 ] +  10, aCoors[ 1 ] + 10, aCoors[ 4 ] - 10, aCoors[ 3 ] - 10, 20, 20, CLR_BLUE )
   else
      GradientFill( hDC, aCoors[ 1 ] +  10, aCoors[ 2 ] + 10, aCoors[ 3 ] - 10, aCoors[ 4 ] - 10, { ;
           { 2/5, nRGB( 223, 236, 255 ), nRGB( 197, 222, 255 ) },;
         { 3/5, nRGB( 173, 209, 255 ), nRGB( 189, 217, 255 ) } } )
      RoundBox( hDC, aCoors[ 2 ] +  10, aCoors[ 1 ] + 10, aCoors[ 4 ] - 10, aCoors[ 3 ] - 10, 20, 20, CLR_BLUE )
   endif

   // DeleteObject( hRgn )
   // SetWindowRgn( oCol:oBrw:hWnd, nil, .F. )
   
   DrawBitmap( hDC, hBmp, aCoors[ 1 ] +  18, aCoors[ 2 ] + 23 )
   
   aCoors[ 1 ] += 30
   aCoors[ 2 ] += 80
   DrawText( hDC, cText, aCoors )
   hOldFont = SelectObject( hDC, oFont:hFont )
   SetBkMode( hDC, nOldMode )

   // DrawText( hDC, aItems[ oCol:oBrw:KeyNo ], aCoors )
   // SelectObject( hDC, hOldFont )
   
return nil  
regards, saludos

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

Re: Xbrowse advanced painting techniques

Postby Otto » Sat Oct 01, 2011 7:52 am

Hello Antonio,

if this is to be used for WINDOWS 8 there seems to be no RoundBoxes.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 45 guests