Page 1 of 2
DCBROWSE highlight
Posted: Tue May 10, 2016 2:25 am
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.
Re: DCBROWSE highlight
Posted: Tue May 10, 2016 5:14 am
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}
Re: DCBROWSE highlight
Posted: Wed May 11, 2016 4:58 am
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
Re: DCBROWSE highlight
Posted: Thu May 12, 2016 8:32 am
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
Re: DCBROWSE highlight
Posted: Thu May 12, 2016 8:33 am
by rdonnay
One minor change in the FOR loop made this work for me:
Thanks for correcting my error.
Re: DCBROWSE highlight
Posted: Thu May 12, 2016 9:46 am
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?
Re: DCBROWSE highlight
Posted: Thu May 12, 2016 11:03 am
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.
Re: DCBROWSE highlight
Posted: Fri May 13, 2016 1:42 am
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?
Re: DCBROWSE highlight
Posted: Sun May 15, 2016 4:10 pm
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
Re: DCBROWSE highlight
Posted: Mon May 16, 2016 2:12 am
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.