#include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oFont1, oBrw2, n, cCol, oFont
local oBrush, cBrush := "C:\FWH1204\BITMAPS\BACKGRND\BEACH.BMP"
local nWd := 240, nHt := 600
local aArr := CreaMatrices(), aR := aArr[1], aM := aArr[2]
DEFINE FONT oFont NAME "ARIAL" SIZE 0,-24 BOLD ITALIC
DEFINE FONT oFont1 NAME "CONSOLAS" SIZE 0,-16 BOLD ITALIC
DEFINE DIALOG oDlg SIZE nWd,nHt PIXEL TRUEPIXEL
DEFINE BRUSH oBrush FILE cBrush RESIZE
oDlg:SetBrush( oBrush )
oBrush:End()
@ 1,1 XBROWSE oBrw2 SIZE -1,-1 PIXEL OF oDlg DATASOURCE aM ;
COLUMNS 1,2,3 HEADERS "Col1","Col2","Col3" ;
CELL LINES NOBORDER
FOR EACH cCol IN {"COL1", "COL2", "COL3"}
WITH OBJECT oBrw2:oCol( cCol )
:nWidth := (oBrw2:nWidth/3)-1
END
NEXT
WITH OBJECT oBrw2
:nMarqueeStyle := 0
:nRowHeight := 42
:lHeader := .f.
:lFooter := .f.
:lHScroll := .f.
:lVScroll := .f.
:lRecordSelector := .f.
:nDataStrAligns := AL_CENTER
:SetFont(oFont)
:lTransparent := .t.
:CreateFromCode()
END
ColorFondoCelda(oBrw2, aR)
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( CeldaTransparente(oBrw2) )
RELEASE oFont1, oFont
RELEASE BRUSH oBrush
return nil
//----------------------------------------------------------------------------//
Function CreaMatrices()
local n, aNms, aClr, aR, aM
aNms := {'00', '27', '10', '25', '29', '12', '8', '19', '31', '18', '6', '21', '33', '16', '4', '23', '35', '14', '2', '0', '28', '9', '26', '30', '11', '7', '20', '32', '17', '5', '22', '34', '15', '3', '24', '36', '13', '1'}
aClr := { 'V', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'V', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R', 'N', 'R'}
aR := {}
For n := 1 to Len(aNms)
aadd( aR, {,,,} )
aR[n,1] := n //Posicion
aR[n,2] := if(len(aNms[n])=1, aNms[n]+" ", aNms[n]) //Numero (debe ser long 2 char)
aR[n,3] := if(upper(aClr[n]) ="V","VERDE" ,; //Color
if(upper(aClr[n]) ="R","ROJO" ,;
if(upper(aClr[n]) ="N","NEGRO",)))
Next
aM := Array(14)
aM[1] := {'Rojo', 'Negro', 'Verde'}
aM[2] := {'0 ', '00', ' '}
aM[3] := {' ', '2 ', '3 '}
aM[4] := {' ', '5 ', '6 '}
aM[5] := {'7 ', ' ', ' '}
aM[6] := {'10', '11', '12'}
aM[7] := {' ', ' ', ' '}
aM[8] := {'16', '17', '18'}
aM[9] := {' ', '20', '21'}
aM[10]:= {' ', '23', '24'}
aM[11]:= {'25', '26', '27'}
aM[12]:= {'28', '29', '30'}
aM[13]:= {'31', ' ', '33'}
aM[14]:= {' ', ' ', '36'}
Return { aR, aM }
//-----------------------------------------------------//
Function ColorFondoCelda(oBrw2, aR)
local n
For n := 1 to len(oBrw2:aCols)
oBrw2:aCols[n]:bClrStd := ColorDeCelda( oBrw2, n, aR )
Next
Return nil
//-----------------------------------------------------//
function ColorDeCelda( oBrw, n, aR )
return {|| ElijeColor( oBrw:aRow[ n ], aR ) }
//-----------------------------------------------------//
function ElijeColor( uDato, aR )
local n, nClrBck, nClrTxt := RGB(255,255,255), cClr
cClr:=""
for n := 1 to len(aR)
if aR[n,2] == uDato
cClr := aR[n,3]
exit
endif
Next
if cClr == "VERDE" .or. uDato == "Verde" //Si dato es Verde,Rojo,Negro, es apuesta por color.
nClrBck := RGB(0, 200, 0)
elseif cClr == "ROJO" .or. uDato == "Rojo"
nClrBck := RGB(225, 0, 0)
elseif cClr == "NEGRO" .or. uDato == "Negro"
nClrBck := RGB(0, 0, 0)
else
nClrBck := NIL //GetSysColor( 5 )
endif
return { nClrTxt, nClrBck }
//Celdas sin valor serán transparentes. Para ello, oBrw2:lTransparent := .t., y ClrBck de celda debe ser NIL
//-----------------------------------------------------//
Function CeldaTransparente(oBrw2)
local n
For n := 1 to len(oBrw2:aCols)
oBrw2:aCols[n]:lColTransparent := if(Empty(oBrw2:aCols[n]:Value),.t.,.f.)
Next
Return nil