xBrowser + RTF
xBrowser + RTF
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.
I would like to have the same outlook in xBrowser as the sample.
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
- 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
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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.
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.
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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.
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.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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
> 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
Last edited by Antonio Linares on Tue Mar 25, 2008 11:04 pm, edited 1 time in total.
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Mr. NageswaraRao,
I uploaded a small video.
Regards,
Otto
http://www.atzwanger.com/flexGrid//flexGrid.html
I uploaded a small video.
Regards,
Otto
http://www.atzwanger.com/flexGrid//flexGrid.html
Last edited by Otto on Tue Mar 25, 2008 11:29 pm, edited 1 time in total.
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact: