DCBROWSE highlight

This forum is for eXpress++ general support.
Message
Author
reganc
Posts: 258
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

DCBROWSE highlight

#1 Post by reganc »

Is there any way to get the highlight in a browse to show with both a row and a cell highlight at the same time?

The browse would use cell navigation as normal but the rest of the row would get highlighted in a different color.

I don't think it has been done yet but it seems like it might be a useful possibility as it would make reading the data in a browse easier. And it seems it might be possible due to ownerdraw being available.
Attachments
An example of what I mean...
An example of what I mean...
Browse Highlight with row and cell highlight at the same time.png (28.88 KiB) Viewed 13079 times
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

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

Re: DCBROWSE highlight

#2 Post by skiman »

Hi Regan,

I think this is the answer to your question:

Code: Select all

			DCBROWSECOL FIELD klant->naam HEADER fMessage(2101) PARENT oBrowse WIDTH 18 ;
				COLOR bCOlor;
				EVAL {|o|o:DataArea:DrawMode := XBP_DRAW_OWNER}
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4733
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSE highlight

#3 Post by rdonnay »

You should be able to do this without the use of owner drawing.
You need to use the ITEMMARKED callback:

@ DCBROWSE .. ITEMMARKED {|a,b,o|sethilitecolor(o)}


STATIC FUNCTION setHiliteColor( oBrowse )

LOCAL oColumn := oBrowse:GetColumn(1), i

oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_DARKRED,GRA_CLR_CYAN, .t. )
FOR i := 2 TO oBrowse:colCount
oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_DARKBLUE,GRA_CLR_YELLOW, .t. )
NEXT
The eXpress train is coming - and it has more cars.

richardc
Posts: 21
Joined: Sat May 11, 2013 3:46 pm

Re: DCBROWSE highlight

#4 Post by richardc »

This is an excellent, very clean solution and one I have been looking for. One minor change in the FOR loop made this work for me:

@ DCBROWSE .. ITEMMARKED {|a,b,o|sethilitecolor(o)}


STATIC FUNCTION setHiliteColor( oBrowse )

LOCAL oColumn := oBrowse:GetColumn(1), i

oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_DARKRED,GRA_CLR_CYAN, .t. )
FOR i := 2 TO oBrowse:colCount
oColumn := oBrowse:GetColumn(i) // add this line
oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_DARKBLUE,GRA_CLR_YELLOW, .t. )
NEXT

User avatar
rdonnay
Site Admin
Posts: 4733
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSE highlight

#5 Post by rdonnay »

One minor change in the FOR loop made this work for me:
Thanks for correcting my error.
The eXpress train is coming - and it has more cars.

reganc
Posts: 258
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: DCBROWSE highlight

#6 Post by reganc »

I'm afraid I just tried that code and it does not work for me.

It changes the highlight color of the first column but the cells in the other columns remain unhilited.
If I change the cursor mode to row, the 1st column is highighted in cyan and the rest are in yellow but then of course I lose the cell navigation.

I might come back to this later as I can understand what it should do but I think something is interfering with it's usage.

It couldn't be a manifest / visual styles issue again, could it?
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

User avatar
rdonnay
Site Admin
Posts: 4733
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSE highlight

#7 Post by rdonnay »

but then of course I lose the cell navigation.
It hadn't occurred to me that you were using XBPBRW_CURSOR_CELL.

Your question is framed in such a way that I thought you were using XBPBRW_CURSOR_ROW.

So then, it appears that I am answering the wrong question.

I need to see more of your code.
The eXpress train is coming - and it has more cars.

reganc
Posts: 258
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: DCBROWSE highlight

#8 Post by reganc »

Sorry, Roger,

I obviously didn't frame the question well at all. I should have mentioned XBPBRW_CURSOR_CELL specifically.

Could this be down to the fact that when XBPBRW_CURSOR_CELL is used, the change to the internal highlight coloring on the other columns is made but not repainted?
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

User avatar
rdonnay
Site Admin
Posts: 4733
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSE highlight

#9 Post by rdonnay »

After working with this a bit more, I think i found a solution for you.
The below sample shows solutions for both Row cursor and Cell cursor.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], aDir := Directory(), oBrowse1, oBrowse2, i

@ 0,0 DCBROWSE oBrowse1 DATA aDir SIZE 100, 15 ;
      FONT '10.Lucida Console' ;
      CURSORMODE XBPBRW_CURSOR_ROW ;
      ITEMMARKED {|a,b,o|SetHiliteColorRow(o,aDir), ;
                         DC_ClearEvents()}

FOR i := 1 TO 10
  DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) WIDTH 10 PARENT oBrowse1
NEXT

@ 17,0 DCBROWSE oBrowse2 DATA aDir SIZE 100, 15 ;
      FONT '10.Lucida Console' ;
      CURSORMODE XBPBRW_CURSOR_CELL ;
      ITEMMARKED {|a,b,o|SetHiliteColorCell(o,aDir), ;
                         DC_ClearEvents()} ;


FOR i := 1 TO 10
  DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) WIDTH 10 PARENT oBrowse2
NEXT


DCREAD GUI FIT TITLE 'Cursor Color Test' ;
   EVAL {||SetHiliteColorCell(oBrowse2,aDir)}

RETURN nil

* ---------

PROC appsys ; RETURN

* ---------

STATIC FUNCTION SetHiliteColorRow( oBrowse, aDir )

LOCAL i, oColumn, aData := aDir[oBrowse:arrayElement]

FOR i := 1 TO oBrowse:colCount
  oColumn := oBrowse:getColumn(i)
  IF aData[2] > 10000 // file size
    oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_WHITE,GRA_CLR_RED, .t. )
  ELSE
    oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_WHITE,GRA_CLR_BLUE, .t. )
  ENDIF
NEXT

RETURN nil

* ---------

STATIC FUNCTION SetHiliteColorCell( oBrowse, aDir )

STATIC snRow
LOCAL i, oColumn, aData := aDir[oBrowse:arrayElement]

IF !Empty(snRow)
  FOR i := 1 TO oBrowse:colCount
    oColumn := oBrowse:getColumn(i)
    oColumn:dataArea:setcellColor( snRow,GRA_CLR_BLACK,GRA_CLR_WHITE, .t. )
  NEXT
ENDIF

FOR i := 1 TO oBrowse:colCount
  oColumn := oBrowse:getColumn(i)
  oColumn:dataArea:setcellColor( oBrowse:rowPos-1,GRA_CLR_BLACK,GRA_CLR_WHITE, .t. )
  oColumn:dataArea:setcellColor( oBrowse:rowPos+1,GRA_CLR_BLACK,GRA_CLR_WHITE, .t. )
  IF oBrowse:colPos == i
    oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_BLACK,GRA_CLR_CYAN, .t. )
  ELSE
    oColumn:dataArea:setcellColor( oBrowse:rowPos,GRA_CLR_BLACK,GRA_CLR_YELLOW, .t. )
  ENDIF
NEXT

snRow := oBrowse:rowPos

RETURN nil
The eXpress train is coming - and it has more cars.

reganc
Posts: 258
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: DCBROWSE highlight

#10 Post by reganc »

rdonnay wrote:After working with this a bit more, I think i found a solution for you.
The below sample shows solutions for both Row cursor and Cell cursor.
Thanks Roger.

I will try it later today, hopefully.
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

Post Reply