Zebra Stripes in Browse

This forum is for ideas and or code to be contributed for general use.
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Zebra Stripes in Browse

#1 Post by rdonnay »

This was sent to me by Jack Duijf. He has made many contributions to eXpress++ in the past.

Hello Roger,

The last few days i have been strugling to get reliable zebra stripes in a DC_browse.
The main problem was when i was browsing a database with deleted records.
The striping was not consitent.

I made some modifications in _dcxbrow.prg of build 254.
You can find the changes in the attached file if you look for "7-03-2010".

The express browse looks now as follows:

Code: Select all

@ nLine  , nCol1     DCBROWSE .... ;
                      COLOR {|o|Jd_BrowseZebraColor(o)}
And then the zebra function:

Code: Select all

Function Jd_BrowseZebraColor(oBrowse)

LOCAL aRet           := {GRA_CLR_BLACK,GRA_CLR_WHITE}                         // Default black/white
LOCAL oColumn        := oBrowse:GetColumn(1)                                  // First column (if any)
if ValType(oColumn) = "O"
    if oColumn:IsderivedFrom("DC_XbpColumn")  
       if oColumn:EvenRow
          aRet        := {GRA_CLR_BLACK,GraMakeRGBColor({255,255,170})}
       else
          aRet        := {GRA_CLR_BLACK,GraMakeRGBColor({159,231,176})}
       endif
    endif
endif
Return aRet
Tweaking the code could result in moving some lines into Dc_xbpColumn, so the function Jd_BrowseZebraColor() can be made even more simple.

Feel free to add this to Express, if this does not break any code.
The only thing i am not absolutely 100% sure of, is passing the Browse object as a parameter to the color block.

Please let me know what you make of this.

Well, I did my testing and it appears to work ok, so I'm planning to include this in the next release.
Here is the latest _DCXBROW.PRG with Jack's mods :

http://bb.donnay-software.com:8080/support/_dcxbrow.prg
The eXpress train is coming - and it has more cars.

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Zebra Stripes in Browse

#2 Post by skiman »

Hi,

Based on the modifications Jack Duijf made, and an idea I got from Tom Liehr in a recent topic, I made a little modification.

With Jack's code, there was a little problem when you also uses the COLOR block of dcbrowsecol. In that case the column didn't appear in the same 'zebra striping' as the other columns of the browse.

This was the sample of Jack.

Code: Select all

@ nLine  , nCol1     DCBROWSE .... ;
                      COLOR {|o|Jd_BrowseZebraColor(o)}
I added the following based on an idea of Tom

Code: Select all

@ nLine  , nCol1     DCBROWSE .... ;
                      COLOR {|o| if( yourColorselect(), {x,y},Zebra(o))}

DCBROWSECOL .... ;
                      COLOR {|o| if( anotherColorselect(), {x,y},Zebra(o))}
Normally you would have {nil,nil} instead of zebra(o).

And then the modified zebra function:

Code: Select all

Function Zebra(oBrowseOrCol)
****************************
LOCAL aRet           := {GRA_CLR_BLACK,GRA_CLR_WHITE}                         // Default black/white
LOCAL oColumn    

if valtype(oBrowseOrCol)=="O" .and. oBrowseOrCol:IsderivedFrom("DC_XbpColumn")     // is it a column
    oColumn := oBrowseOrCol
  else                                                            // it is a browse?
	oColumn    := oBrowseOrCol:GetColumn(1)                                  // First column (if any)
	if ValType(oColumn) # "O" .or. !oColumn:IsderivedFrom("DC_XbpColumn")  
		return aRet
	endif
endif
if oColumn:EvenRow
    aRet        := {GRA_CLR_BLACK,ABO_YELLOW}
   else
    aRet        := {GRA_CLR_BLACK,GRA_CLR_PALEGRAY }
endif
Return aRet
You also need the modified _dcbrowse.prg of Jack Duijf. All credits go to him.
Best regards,

Chris.
www.aboservice.be

Post Reply