Hi,
To display lines in different colors in the xbrowse cell, I specify aCols [1]: aClrText: = {CLR _ BLACK, CLR_RED}.
Is it possible to make this setting not for all xBrose lines, but according to a certain condition ?
Color of rows in the cell
- leandro
- Posts: 1744
- Joined: Wed Oct 26, 2005 2:49 pm
- Location: Colombia
- Has thanked: 34 times
- Been thanked: 10 times
- Contact:
Re: Color of rows in the cell
Code: Select all | Expand
....
....
:bClrStd := {|| if(Len( aDeta ) > 0 , ;
{ CLR_BLACK,clrEstFondo(aDeta[oBrw:nArrayAt]["estado"]) } ,;
{ CLR_BLACK,clrEstFondo("S") } ) }
:bClrSelFocus := {|| if(Len( aDeta ) > 0 , ;
{ CLR_WHITE,clrEstSelec(aDeta[oBrw:nArrayAt]["estado"]) } ,;
{ CLR_WHITE,clrEstSelec("S") }) }
....
....
****************************
*CAMBIA EL COLOR DE LA CELDA
****************************
Function clrEstFondo(valor)
If valor=="S"
Return nRGB(255,255,255) //Blanco
ElseIf valor=="N"
Return nRGB(187,255,187) //Verde Claro
ElseIf valor=="M"
Return nRGB(187,187,255) //Azul Claro
ElseIf valor=="B"
Return nRGB(255,187,187) //Rojo Claro
Else
Return nRGB(255,255,255) //Blanco
Endif
*****************************************
*CAMBIA EL COLOR DE LA CELDA SELECCIONADO
*****************************************
Function clrEstSelec(valor)
If valor=="S"
Return RGB( 117, 186, 255 )
ElseIf valor=="N"
Return nRGB(0,210,0) //Verde Oscuro
ElseIf valor=="M"
Return nRGB(119,119,255) //Azul Oscuro
ElseIf valor=="B"
Return nRGB(255,117,117) //Rojo Oscuro
Else
Return RGB( 117, 186, 255 )
Endif
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com
[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 24.09 ] [ xHarbour 64 bits) ]
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com
[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 24.09 ] [ xHarbour 64 bits) ]
Re: Color of rows in the cell
This is an example for the whole cell, but I asked about coloring the lines in the cell with different colors.
tex1+CRLF+text2+CRLF+text3
tex1+CRLF+text2+CRLF+text3
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Color of rows in the cell
Natter wrote:Hi,
To display lines in different colors in the xbrowse cell, I specify aCols [1]: aClrText: = {CLR _ BLACK, CLR_RED}.
Is it possible to make this setting not for all xBrose lines, but according to a certain condition ?
Code: Select all | Expand
#include "fivewin.ch"
function Main()
local oDlg, oBrw, oCol, oFont, oBold, oItalic, oImpact
local aClr1 := { CLR_HRED,CLR_GREEN,CLR_HBLUE }
local aClr2 := { CLR_HBLUE,CLR_HRED,CLR_GREEN }
local aData := { { "123", "ONE" + CRLF + "JANUARY" + CRLF + "MONDAY" }, ;
{ "234", "TWO" + CRLF + "FEBRUARY" + CRLF + "TUESDAY" }, ;
{ "345", "THREE" + CRLF + "MARCH" + CRLF + "WEDNESDAY" } }
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE FONT oImpact NAME "IMPACT" SIZE 0,-35
DEFINE FONT oBold NAME "VERDANA" SIZE 0,-18 BOLD
DEFINE FONT oItalic NAME "Times New Roman" SIZE 0,-16 BOLD ITALIC
DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL FONT oFont
@ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE aData AUTOCOLS CELL LINES NOBORDER
WITH OBJECT oBrw
:nDataStrAligns := AL_CENTER
:aCols[ 1 ]:oDataFont := oImpact
WITH OBJECT ( oCol := oBrw:aCols[ 2 ] )
:aDataFont := { oBold, oFont, oItalic }
:bClrStd := { || oCol:aClrText := If( oBrw:KeyNo % 2 == 0, aClr1, aClr2 ), ;
{ 0, CLR_WHITE } }
END
:nRowHeight := 100
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont, oBold, oItalic, oImpact
return nil

Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Color of rows in the cell
Simplification in the next version:
1) aDataFont and aClrText can also be codeblocks. These codeblocks are evaluated with two params, viz, the column object and lHiLite.
The above code can be written like this:
2) We know bClrStd returns a color pair { nClrText, nClrBack }
If instead of returning a single color as nClrText, if we return an array of colors, those colors are used in the place of aClrText.
This example code also works like the above sample:
1) aDataFont and aClrText can also be codeblocks. These codeblocks are evaluated with two params, viz, the column object and lHiLite.
The above code can be written like this:
Code: Select all | Expand
WITH OBJECT oBrw:aCols[ 2 ]
:aClrText := { |oCol,lHilite| If( lHilite, { CLR_WHITE, CLR_WHITE, CLR_WHITE }, ;
If( oCol:oBrw:KeyNo % 2 == 0, aClr1, aClr2 ) ) }
END
If instead of returning a single color as nClrText, if we return an array of colors, those colors are used in the place of aClrText.
This example code also works like the above sample:
Code: Select all | Expand
WITH OBJECT oBrw:aCols[ 2 ]
:bClrStd := { || If( oBrw:KeyNo % 2 == 0, { aClr1, CLR_WHITE }, { aClr2, CLR_WHITE } ) }
END
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India