Page 1 of 5

XBrowse Win7 Bar New Sample

PostPosted: Wed Dec 29, 2010 7:52 am
by nageswaragunupudi
Here is a new derived class for Win7 bars.

Image

Sample program
Code: Select all  Expand view
// Using Windows 7 row selection colors in xbrowse

#include 'fivewin.ch'
#include 'xbrowse.ch'

#define MARQSTYLE_HIGHLWIN7  7

function Main()

   local oDlg, oBrw, oFont

   USE CUSTOMER ALIAS CUST

   DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14

   DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
      FONT oFont TITLE 'XBrowse Gradient Rows'

   @ 10, 10 XBROWSE oBrw OF oDlg ;
      SIZE 300, 200 PIXEL ;
      COLUMNS 'First', 'Last', 'Married', 'City' ;
      ALIAS 'CUST' NOBORDER CLASS TXbrWin7()

   WITH OBJECT oBrw
      //
      :nMarqueeStyle    = MARQSTYLE_HIGHLWIN7  // for Windows 7 style
      //
      :Married:SetCheck()
      WITH OBJECT :First
         :AddBitmap( "c:\fwh\bitmaps\16x16\zoom2.bmp" )
         :bBmpData         := { || 1 }
      END
      WITH OBJECT :Last
         :AddBitmap( "c:\fwh\bitmaps\16x16\open.bmp" )
         :bBmpData         := { || 1 }
      END
   END

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

   oFont:End()

return nil

//----------------------------------------------------------------------------//

CLASS TXbrWin7 FROM TXBrowse

   CLASSDATA lRegistered AS LOGICAL // This is compulsory for derived classes

   METHOD Adjust()
   METHOD FullPaint() INLINE ( ::lTransparent .or. ::lMergeVert .or. ::nMarqueeStyle == MARQSTYLE_HIGHLWIN7 )
   METHOD DrawLine( lSelected, nRowSel )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD Adjust() CLASS TXBrWin7

   if ::nMarqueeStyle == MARQSTYLE_HIGHLWIN7
      ::nRowDividerStyle   := LINESTYLE_NOLINES
      ::nColDividerStyle   := LINESTYLE_NOLINES
      ::bClrSelFocus       := ;
      ::bClrSel            := { || { CLR_BLACK, ;
                                 { { 1, RGB( 220, 235, 252 ), ;
                                 RGB( 193, 219, 252 ) } } } }

   endif

return Super:Adjust()

//----------------------------------------------------------------------------//

METHOD DrawLine( lSelected, nRowSel ) CLASS TXBrWin7

   local hDC, nRow, nBrwWidth, nDataHeight

   Super:DrawLine( lSelected, nRowSel )

   DEFAULT lSelected := .f.

   if lSelected
      if ::nMarqueeStyle == MARQSTYLE_HIGHLWIN7

         hDC         := ::GetDC()
         nRow        := ( ( ::nRowSel - 1 ) * ::nRowHeight ) + ::HeaderHeight()
         nBrwWidth   := ::BrwWidth()
         nDataHeight := ::DataHeight()

         RoundBox( hDC, 2, nRow - 1, nBrwWidth - 1, nRow + nDataHeight,     2, 2,;
                   RGB( 235, 244, 253 ), 1 )
         RoundBox( hDC, 1, nRow - 2, nBrwWidth,     nRow + nDataHeight + 1, 2, 2,;
                   RGB( 125, 162, 206 ), 1 )
      endif
   endif

return Self

//------------------------------------------------------------------//
 


If you like, you can keep this class in your library.

What all required is :

1) Add the clause "CLASS TXBrWin7()" while creating XBrowse
and
2) set oBrw:nMarqueeStyle := 7

Nothing more is to be done in the application program.

Re: XBrowse Win7 Bar New Sample

PostPosted: Wed Dec 29, 2010 5:08 pm
by mgsoft
Master Rao,

Why this beatiful look is not the normal xBrowse behaviour?.

Thanks

Re: XBrowse Win7 Bar New Sample

PostPosted: Wed Dec 29, 2010 5:19 pm
by nageswaragunupudi
mgsoft wrote:Master Rao,

Why this beatiful look is not the normal xBrowse behaviour?.

Thanks

If our friends test this code and are satisfied, this can become part of the main class and a feature of future versions.
The derived class I have provided can be used with all earlier versions of fwh.

Re: XBrowse Win7 Bar New Sample

PostPosted: Wed Dec 29, 2010 6:13 pm
by James Bott
Rao,

This looks great!

Is there a way to define a column that only contains a graphic (and the header has a graphic also). We can do this with TWBrowse.

Thanks,
James

Re: XBrowse Win7 Bar New Sample

PostPosted: Wed Dec 29, 2010 10:16 pm
by jll-fwh
Hola Nages:

Yo acabo de compilar tu ejemplo con la version 8.12 y da error de compilacion cuando detecta CLASS.


.\JMEDIA.PRG(328) Error E0030 Syntax error: "syntax error at '{'"



un saludo
JLL

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Dec 30, 2010 3:40 am
by nageswaragunupudi
James Bott wrote:Rao,

This looks great!

Is there a way to define a column that only contains a graphic (and the header has a graphic also). We can do this with TWBrowse.

Thanks,
James

To show bitmap in header, after adding bitmaps to the column, with oCol:AddBitmap( <file/resource> ),
oCol:nHeadBmp := <nBmp> // nBmp is the serial number of bitmaps added to the column.
if you want to show only bitmap and not text in header, you can set oCol:cHeader := ''

You have already seen how to show bitmaps in the cells. If you want to show bitmaps only the cells without any data, make oCol:bStrData := { || '' }

For example, in the above sample, add these two lines:
oBrw:Married:nHeadBmp := 1
oBrw:Married:cHeader := ''

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Dec 30, 2010 5:47 pm
by mgsoft
Mr. Rao,

I think it will be very interesting that native xBrowse class (without the modification as all xbrowses must be changed) can detect Windows 7 grid by putting MARQSTYLE_HIGHLWIN7.

Thanks a lot ;)

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Dec 30, 2010 9:00 pm
by Adolfo
Rao


How can I add the CLASS TXbrWin7() clause to my code...

I create all my xBrowse in this way

oBrw:=TxBrowse():New(oWnSql)
oBrw:nTop:=95
oBrw:nLeft:=0
oBrw:...

Thanks in advance

From Chile
Adolfo

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Dec 30, 2010 9:28 pm
by nageswaragunupudi
Instead of
Code: Select all  Expand view

oBrw:=TxBrowse():New(oWnSql)
 

Code: Select all  Expand view
oBrw:=TxBrWin7():New(oWnSql)

While you are free to choose any method of creating XBrowse, you are not aware that by this way of creating XBrowse and the columns, you have firmly decided NOT to use any of the capabilities of xbrowse. Probably you will never know what you are missing till you change your style to the new command syntax. You are using xbrowse as a dumb browse.
But it is totally your choice.

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Dec 30, 2010 9:34 pm
by Adolfo
Rao

While you are free to choose any method of creating XBrowse, you are not aware that by this way of creating XBrowse and the columns, you have firmly decided NOT to use any of the capabilities of xbrowse. Probably you will never know what you are missing till you change your style to the new command syntax. You are using xbrowse as a dumb browse.
But it is totally your choice.


I totally agree with you... but.. this is part of a data driven module, which has worked for some time with no problemas at all, with a great control over the data and functions to control it, and... is the same for DBF and MYSQL.

So if it works... :-)


Thanks for your answer.. will try it rigth away..

From Chile
Adolfo

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Dec 30, 2010 10:38 pm
by nageswaragunupudi
Please do what you are comfortable with.
I only said you never know what you are missing. :)

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Dec 30, 2010 11:11 pm
by mgsoft
Master Rao,

Why donĀ“t you incorporate the changes to xbrowse.prg?

Thank you

Re: XBrowse Win7 Bar New Sample

PostPosted: Fri Dec 31, 2010 7:21 am
by James Bott
Mgsoft,

Rao did answer that question in a previous message above.

James

Re: XBrowse Win7 Bar New Sample

PostPosted: Fri Dec 31, 2010 2:10 pm
by Silvio
THANKS MR RAO...

two questions...
the bitmaps I use must have the background color on white or another color ?

AND IF I WISH TOINSERT a BACKGROUND ( a bitmap on a center of xbrowse) INTO XBROWSE .....are there problems ?
can insert here a sample pls ?

Re: XBrowse Win7 Bar New Sample

PostPosted: Fri Dec 31, 2010 3:46 pm
by nageswaragunupudi
Mr. Silvio

You can use any bitmaps just like in a normal browse.

You can also use a background like any other browse.

But recently I found that bitmaps we define in columns are not being painted correctly, when we also define a background (on some backgrounds only). I found this problem with both normal xbrowse as well as win7style. We need to find a solution for this in general. For the time being, you may not use bitmaps in columns when you use backgrounds, till we solve this problem