looking for a solution, to show a font with a selected color on a contrast-background,
I used with a little change the Contrast-function from xBrowse.
Using different Fontcolors on Say on Get, the needed Background is automatically selected,
to show a visible text.
Because of fontcolor < RED >, the Say-background-color changed to white :
Sample :
- Code: Select all Expand view
...
...
REDEFINE SAY oTime PROMPT cTime ID 510 OF oDlg2 UPDATE
oTime:SetColor( nTimeColor, GET_CONTR(nTimeColor))
oTime:SetFont( oTimeFont )
REDEFINE BTNBMP oBtn1 OF oDlg2 ;
ID 130 PIXEL 2007 ;
NOBORDER ;
PROMPT "&Time-color" ;
FILENAME c_path + "\Images\Select.Bmp" ;
ACTION ( nTimeColor := ChooseColor(), ;
oTime:SetColor( nTimeColor, GET_CONTR(nTimeColor) ), ;
oTime:Refresh ) ;
FONT oBrwFont ;
LEFT
oBtn1:lTransparent := .t.
oBtn1:cToolTip = { "Time-" + CRLF + "Color","Color-Selection", 1, CLR_BLACK, 14089979 }
oBtn1:SetColor( 0, )
...
...
// ------------------
FUNCTION GET_CONTR(nFontClr)
LOCAL nClr, nLuma, nContrast
nContrast := nFontClr
// Fontcolor
nLuma := ( 0.299 * nRGBRed( nFontClr ) + 0.587 * nRGBGreen( nFontClr ) + 0.114 * nRGBBlue( nFontClr ) )
nContrast := IF( nLuma < 150, CLR_WHITE, CLR_BLACK )
RETURN nContrast
Best Regards
Uwe