Page 1 of 1

xBrowser + RTF

Posted: Sat Feb 02, 2008 11:15 am
by Otto
Has someone tried to use a RICHEDIT in the datapaint method of xBrowser.

I would like to have the same outlook in xBrowser as the sample.

Image

Posted: Sat Feb 02, 2008 4:47 pm
by Otto
Maybe someone can help

- Does "IsRTF()" work? I saw the function in fget class.
- What does TRichEdit need as a container?
Regards,
Otto


method paintdata
...

if IsRTF( cdata )

??? define a window without frame from {nRow, nCol, nRow + nHeight, Min( nCol + nWidth, ::oBrw:BrwWidth() - 5 ) }
cRtf:= cdata
oRTF := TRichEdit():New( nRow, 0, { | u | If( PCount()==0, cRTF, cRTF:= u ) },oWndTest ,,,, .F.,, .F., .F.,,,, .F., .F., "TestRTF.RTF",, .F., .F., )
ACTIVATE WINDOW oWndRTF




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

endif

Posted: Tue Mar 25, 2008 6:30 pm
by Otto
Antonio, is there some news about RTF support for xBrowser?
Regards,
Otto

Posted: Tue Mar 25, 2008 10:12 pm
by nageswaragunupudi
The function IsRTF() works.
Seems you have already done displaying RTF in xbrowse cell. Is it the same code you are using? Can you post your full code for display of rtf ?

Posted: Tue Mar 25, 2008 10:47 pm
by Otto
NageswaraRao,
no I am sorry. I used ComponentOne’s FlexGrid with VB.NET for the demo screen.
But I think it is very similar what we have in our xBrowser.

Regards,
Otto

Dim _rtf As New RTF
Private Sub _flex_OwnerDrawCell(ByVal sender As Object, ByVal e As C1.Win.C1FlexGrid.OwnerDrawCellEventArgs) Handles _flex.OwnerDrawCell

' check whether the cell contains RTF
Dim rtfText As String = _flex.GetDataDisplay(e.Row, e.Col)

If (rtfText.StartsWith("{\rtf")) Then

' _flex.Rows(e.Row).Height = GetDisplayHeight(_flex(e.Row, 3), _flex.Cols(3).WidthDisplay)
' it does, so draw background
e.DrawCell(DrawCellFlags.Background)

' draw the RTF text
_rtf.Rtf = rtfText
_rtf.ForeColor = e.Style.ForeColor
_rtf.BackColor = e.Style.BackColor
_rtf.RenderTo(e.Graphics, e.Bounds)

' and draw border last
e.DrawCell(DrawCellFlags.Border)

' we're done with this cell
e.Handled = True
Else

End If


End Sub

Posted: Tue Mar 25, 2008 10:51 pm
by Antonio Linares
Otto,

It is not a simple task:

The richedit control has to paint "itself" so we need to have a richedit control for each visible cell that wants to show formatted text.

So if you have a column that shows 20 rows and each cell shows RTF text, then we need to have 20 richedit controls, childs of the xbrowse.

We can not create a richedit control everytime we paint a cell, as you tried in your code, or the application will collapse. We need to create a certain amount of richedit controls only, and change their contents as the browse scrolls up or down.

Posted: Tue Mar 25, 2008 10:55 pm
by nageswaragunupudi
I agree with you Mr Antonio, if we create Richedit controls in each cell.

> _rtf.RenderTo(e.Graphics, e.Bounds)

But there seems to be a way of just rendering richtext content within a rectangle.

Posted: Tue Mar 25, 2008 10:59 pm
by Antonio Linares
We could start defining a new DATA in the Class TXBrwColumn:

DATA aRichEdits

that will hold an array of richedit controls, one by each visible cell of that column. When the browse is resized, then we have to redimension the array with more or less richedit controls.

When we scroll up or down, then we should change the richedits text with the next cell text. We should test how fast (or slow) this will be.

Posted: Tue Mar 25, 2008 11:01 pm
by Otto
Antonio,

I think ComponentOne’s FlexGrid does create every time you address a
column a new
Dim _rtf As New RTF.
I don’t have the working code on my HomePC.
But in real use I think you don’t have more than 20 RTF-cells opened at the same time.

Regards,
Otto

Posted: Tue Mar 25, 2008 11:03 pm
by Antonio Linares
Nageswararao,

> But there seems to be a way of just rendering richtext content within a rectangle.

That would be the perfect solution, but we need to find how to do that.

Thinking about it... if we provide a different hDC to the richedit when it is going to be painted, that could do the trick

Posted: Tue Mar 25, 2008 11:04 pm
by nageswaragunupudi
Otto

I haven't used flex grid. Please tell me does this flex grid scrolls up and down like our browses or does it paint in pages and should we flip the pages

Posted: Tue Mar 25, 2008 11:26 pm
by Otto
Mr. NageswaraRao,
I uploaded a small video.
Regards,
Otto
http://www.atzwanger.com/flexGrid//flexGrid.html

Posted: Tue Mar 25, 2008 11:28 pm
by nageswaragunupudi
The link is not working please

Posted: Tue Mar 25, 2008 11:30 pm
by Otto
Now it is.

First you see the mdb-database then the grid. There are only 3 rows in it.
Regards,
Otto