Here is an example of using ownerdraw to highlight portions of text and to make selected row a much larger font. Also, notice the bitmap in the selected row.
Code: Select all
STATIC FUNCTION DrawCellHighlighted( oPS, aInfo, cHighLight, oBrowse, oFontLarge, oBitmap )
LOCAL xData, nPos, nRow, aRect, oCell := aInfo[5], oColumn
IF oCell:isDerivedFrom('DC_MultiLineCellGroup') // It's a header
RETURN .t.
ENDIF
xData := DC_XtoC(aInfo[ XBP_DRAWINFO_AREA ]:getCell( aInfo[ XBP_DRAWINFO_ITEM ] ))
nRow := aInfo[1]
oColumn := oCell:setParent()
IF nRow == oBrowse:rowPos
oPS:setFont(oFontLarge)
ENDIF
IF xData <> nil .AND. ( nPos:= At( cHighlight, xData ) ) > 0
oPS:setColor( IIF( aInfo[ XBP_DRAWINFO_STATE ] = XBP_DRAWSTATE_SELECTED, ;
XBPSYSCLR_MENUHILITE, XBPSYSCLR_WINDOWSTATICTEXT ) )
GraCaptionStr( oPS, aInfo[ XBP_DRAWINFO_RECT ], { aInfo[ XBP_DRAWINFO_RECT, 3 ], ;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }, xData )
IF nRow == oBrowse:rowPos
oPS:setColor( GRA_CLR_DARKPINK )
ELSE
oPS:setColor( GRA_CLR_RED )
ENDIF
IF nPos = 1
GraCaptionStr( oPS, aInfo[ XBP_DRAWINFO_RECT ], { aInfo[ XBP_DRAWINFO_RECT, 3 ], ;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }, cHighlight )
ELSE
aRect:= GraQueryTextBox( oPS, Left( xData, nPos - 1 ) )
GraCaptionStr( oPS, { aInfo[ XBP_DRAWINFO_RECT, 1 ] + aRect[ 3, 1 ], aInfo[ XBP_DRAWINFO_RECT, 2 ] }, ;
{ aInfo[ XBP_DRAWINFO_RECT, 3 ], aInfo[ XBP_DRAWINFO_RECT, 4 ] }, ;
cHighlight )
ENDIF
RETURN .F.
ELSE
oPS:setColor( IIF( aInfo[ XBP_DRAWINFO_STATE ] = XBP_DRAWSTATE_SELECTED, ;
XBPSYSCLR_MENUHILITE, XBPSYSCLR_WINDOWSTATICTEXT ) )
IF nRow == oBrowse:rowPos
oPS:setColor( GRA_CLR_YELLOW )
ENDIF
IF nRow == oBrowse:rowPos .AND. oColumn == oBrowse:getColumn(1)
aRect:= GraQueryTextBox( oPS, Left( xData, nPos - 1 ) )
oBitmap:draw(oPS, { aInfo[ XBP_DRAWINFO_RECT, 1 ] + aRect[ 3, 1 ], ;
aInfo[ XBP_DRAWINFO_RECT, 2 ] } )
GraCaptionStr( oPS,{ aInfo[ XBP_DRAWINFO_RECT, 1 ] + oBitmap:xSize + 2, ;
aInfo[ XBP_DRAWINFO_RECT, 2 ] }, ;
{ aInfo[ XBP_DRAWINFO_RECT, 3 ] + oBitmap:xSize + 2, ;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }, xData )
ELSE
GraCaptionStr( oPS, aInfo[ XBP_DRAWINFO_RECT ], ;
{ aInfo[ XBP_DRAWINFO_RECT, 3 ], ;
aInfo[ XBP_DRAWINFO_RECT, 4 ] }, xData )
ENDIF
RETURN .f.
ENDIF
RETURN .T.