Hello
I would like to show different fonts in the same cell with xbrowse.
I remember seing something like this from Otto, i have searched but couldn't find it
If anyone knows how we can acheive this,
Thanks for the help,
Richard
Hello
I would like to show different fonts in the same cell with xbrowse.
I remember seing something like this from Otto, i have searched but couldn't find it
If anyone knows how we can acheive this,
Thanks for the help,
Richard
Ask to Otto
Hello Richard,
I changed METHOD PaintData. I send a # as a prefix in my data string.
Then in the paintData method I check if the first character is # if yes I us another font.
It is hardcoded but for my task ok.
Regards,
Otto
IF left(cdata,1)="#"
cLine = SubStr(ExtractLine( cData, @nFrom ),2)
oFont1 := ::oFntGross
oFont1:Activate( hDC )
SetTextColor( hDC, aColors[ 1 ] )
SetBkColor( hDC, aColors[ 2 ] )
DrawTextEx( hDC, cLine ,;
{nRow, nCol, nRow + oFont1:nHeight(), Min( nCol + nWidth, ::oBrw:BrwWidth() - 5 ) },;
::nDataStyle )
oFont1:Deactivate( hDC )
cLine = Alltrim(SubStr(cData, nFrom ))
oFont:Activate( hDC )
SetTextColor( hDC, aColors[ 1 ] )
SetBkColor( hDC, aColors[ 2 ] )
//msginfo(oFont:nHeight())
DrawTextEx( hDC, cLine,;
{nRow+oFont1:nHeight(), nCol, nRow +oFont1:nHeight() + (oFont:nHeight())*2 + 5 , Min( nCol + nWidth, ::oBrw:BrwWidth() - 5 ) },;
::nDataStyle )
oFont:Deactivate( hDC )
else
oFont:Activate( hDC )
SetTextColor( hDC, aColors[ 1 ] )
SetBkColor( hDC, aColors[ 2 ] )
DrawTextEx( hDC, cData,;
{nRow, nCol, nRow + nHeight, Min( nCol + nWidth, ::oBrw:BrwWidth() - 5 ) },;
::nDataStyle )
oFont:Deactivate( hDC )
ENDIF
Otto
Thank you
Richard ![]()
#include 'fivewin.ch'
#include 'xbrowse.ch'
function main()
local oDlg, oBrw
local oFont, oBold, oItalic
local aData := {}
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE FONT oBold NAME 'TAHOMA' SIZE 0,-12 BOLD
DEFINE FONT oItalic NAME 'TAHOMA' SIZE 0,-12 ITALIC
AAdd( aData, { 1, 'Otto ', ;
'Mr.Otto' + CRLF + ;
'deleveloped using multiple fonts in the same cell' } )
AAdd( aData, { 2, 'Richard', ;
"MR.OTTO'S" + CRLF + ;
'work is well appreciated' } )
AAdd( aData, { 3, 'Chidak ', ;
'Mr.Richard Chidak' + CRLF + ;
'also has similar requirement. But needs to change the library' } )
AAdd( aData, { 4, 'Antonio', ;
'FWH' + CRLF + ;
'Provides easier solution for owner drawing data without changing library code' } )
DEFINE DIALOG oDlg SIZE 440,440 PIXEL FONT oFont
@ 10, 10 XBROWSE oBrw ;
HEADERS 'No', 'Name', 'Text' ;
SIZE 200, 200 PIXEL ;
OF oDlg ;
ARRAY aData AUTOCOLS ;
LINES
oBrw:nStretchCol := STRETCHCOL_LAST
WITH OBJECT oBrw:aCols[3]
:nHeadStrAlign := AL_CENTER
:nWidth := 200
:bPaintText := { |oCol, hDC, cText, aCoord| DrawText( oCol, hDC, cText, aCoord, oBold, oItalic ) }
END
oBrw:nDataLines := 6
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
RELEASE FONT oBold
RELEASE FONT oItalic
return nil
static function DrawText( oCol, hDC, cText, aCoord, oBold, oItalic )
local nTop := aCoord[ 1 ], nLeft := aCoord[ 2 ]
local nBottom := aCoord[ 3 ], nRight := aCoord[ 4 ]
local nRow := nTop
local cLine, nFontHt, nAt
nAt := AT( CRLF, cText )
if nAt > 0
cLine := Left( cText, nAt - 1 )
oBold:Activate( hDC )
nFontHt := GetTextHeight( oCol:oBrw:hWnd, hDC )
DrawTextEx( hDC, cLine, { nRow, nLeft, nRow + nFontHt + 4, nRight }, 1 ) //oCol:nDataStyle )
oBold:DeActivate( hDC )
nRow += nFontHt + 4
cLine := SubStr( cText, nAt + 2 )
else
cLine := cText
endif
oItalic:Activate( hDC )
DrawTextEx( hDC, cLine, { nRow, nLeft, nBottom, nRight }, oCol:nDataStyle )
oItalic:DeActivate( hDC )
return nil
Antonio,
Very impressive!
James