The above sample shows usage of oCol:bPaintText.
This offers total flexibility to the programmer and he can paint any cell in his own way.
There is another feature where two or more columns can be painted in a single cell.
By specifying something like
oBrw:aCols[ 1 ]:SetColsAsRows( 1, 2, 3 ), contents of columns 1,2,3 are painted as 3 rows in column 1 and columns 2 and 3 are not displayed. We can specify different fonts, colors, alignment, etc to these columns as usual, except that they are painted under one another as subrows of the cell instead of showing in adjacent columns.
Here is an example. Please compile and run as it is.
- Code: Select all Expand view
function MultiLineCells
local oDlg, oBrw, aFont[ 3 ]
local aData := Array( 4, 12 )
local n,i,j
n := 1
for i := 1 to 4
for j := 1 to 10 step 3
aData[ i, j ] := NToCDOW( ( n - 1 ) % 7 + 1 )
aData[ i, j + 1 ] := n
aData[ i, j + 2 ] := "Some details that may take more than one line"
n++
next
next
DEFINE FONT aFont[ 1 ] NAME "TAHOMA" SIZE 0,-16 BOLD
DEFINE FONT aFont[ 2 ] NAME "IMPACT" SIZE 0,-34
DEFINE FONT aFont[ 3 ] NAME "TIMES ROMAN" SIZE 0,-12 ITALIC
DEFINE DIALOG oDlg SIZE 700,500 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg DATASOURCE aData AUTOCOLS ;
LINES NOBORDER
WITH OBJECT oBrw
:nWidths := 150
:nRowHeight := 100
for i := 1 to 10 STEP 3
WITH OBJECT :aCols[ i ]
:oDataFont := aFont[ 1 ]
:nDataStrAlign := AL_CENTER
END
WITH OBJECT :aCols[ i + 1 ]
:oDataFont := aFont[ 2 ]
:nDataStrAlign := AL_CENTER
:bClrStd := { || { CLR_HRED, CLR_WHITE } }
END
WITH OBJECT :aCols[ i + 2 ]
:oDataFont := aFont[ 3 ]
:nDataLines := 2
END
:aCols[ i ]:SetColsAsRows( i, i + 1, i + 2 )
next
//
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
AEval( aFont, { |o| o:End() } )
return nil
To understand the concept better, please insert this code just after preparing the array
- Code: Select all Expand view
XBROWSER aData
The raw array data looks like this.
Now let us apply formatting to the columns. Every 3rd columns has the same formatting.
For this just comment the line of code in the above sample
- Code: Select all Expand view
// :aCols[ i ]:SetColsAsRows( i, i + 1, i + 2 )
Without this line, each column is displayed side by side.
Now let us paint cols 2 and 3 under col-1. cols 5 and 6 under col 4 and so on.
This is done by restoring the line
- Code: Select all Expand view
:aCols[ i ]:SetColsAsRows( i, i + 1, i + 2 )
Now the final outcome is what we see in the first screen-shot