Page 1 of 1

richtext

Posted: Tue Apr 19, 2016 8:33 pm
by plantenkennis
I have a memofield with richtext value like this:
{\rtf1\ansi\ansicpg1200\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 TIMES NEW ROMAN;}}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs24 Bij deze fraaie plant is het jonge blad roze gekleurt. Later verkleurt dit blad naar groen met een cr\'e8mewitte rand. De jonge takken zijn opvallend rood gekleurt, wat goed contrasteerd met het fris gekleurde blad.\par
}
Now I want to show this text in a textblock. I use this code:

@ 0, 0 GET oGetAanteken VAR cText MEMO OF oFld:aDialogs[ 3 ] SIZE 680, 350

oGetAanteken:SetRichText(.T.)
oGetAanteken:SetImportGraf(.t.)
oGetAanteken:AddHRuler()
oGetAanteken:SetUndo(.T.)
However, all the RichText code is also shown. How can I make it show only the real text: Bij deze fraaie plant is het jonge blad roze gekleurt. Later verkleurt dit blad naar groen met een cr\'e8mewitte rand. De jonge takken zijn opvallend rood gekleurt, wat goed contrasteerd met het fris gekleurde blad.

Re: richtext

Posted: Wed Apr 20, 2016 6:10 am
by Antonio Linares
René,

You have to use FiveMac modified libs that I am emailing you.

This is an example:

Code: Select all

#include "FiveMac.ch"

function Main()

   local oDlg, oFld, oGet, cText := ""

   DEFINE DIALOG oDlg SIZE 600, 400

   @ 0, 0 FOLDER oFld OF oDlg PAGES "Test" SIZE 600, 350 

   @ 0, 0 GET oGet VAR cText MEMO OF oFld:aDialogs[ 1 ] SIZE 580, 300

   oGet:SetRichText( .T. )
   oGet:SetImportGraf( .T. )
   oGet:AddHRuler()
   oGet:SetUndo( .T. )
   oGet:SetFocus()

   cText = "{\rtf1\ansi\ansicpg1200\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 TIMES NEW ROMAN;}}" + ;
           "{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs24 Bij deze fraaie plant " + ;
           "is het jonge blad roze gekleurt. Later verkleurt dit blad naar groen met een cr\'e8mewitte rand." + ;
           "De jonge takken zijn opvallend rood gekleurt, wat goed contrasteerd met het fris gekleurde blad.\par}"

   oGet:SetAttributedString( cText )
   oGet:GoTop()

   ACTIVATE DIALOG oDlg CENTERED

return nil
Image

Image

Re: richtext

Posted: Wed Apr 20, 2016 9:28 pm
by plantenkennis
Hello Antonio,

Thanks again for the quick reply and the new libs. It has been a long day for me (6.00- 22.00 work), so tomorrow i will test this.

Re: richtext

Posted: Thu Apr 21, 2016 6:27 pm
by plantenkennis
Hello Antonio,

It works great if I have one tab or the richedit on the first tab, but if I use more tabs and the richedit is on the third tab I get to see the ruler, but not the buttons with outline ...

Also, is it possible to translate the buttons above the rulers.

And can I set the richedit on readonly

Last, if I use two richedits on two tabs, the program crashes (I need a richedit on the fith tab also.

I don't know how I insert an image in this forum

Re: richtext

Posted: Thu Apr 21, 2016 6:30 pm
by plantenkennis
Image

Re: richtext

Posted: Thu Apr 21, 2016 7:56 pm
by Antonio Linares
René,

> but if I use more tabs and the richedit is on the third tab I get to see the ruler, but not the buttons with outline ...

You have to do oGet:SetFocus() to each of them. Thats seems to paint it properly

I don't know if we can translate those buttons. We need to google about it

I am going to modify my example to check if it supports several richedits

Re: richtext

Posted: Sun Apr 24, 2016 7:10 pm
by Antonio Linares
René,

Here you have an example with two richedit controls. Notice that I had to increase a little the dimensions of the second one. Not sure why.

testrich.prg

Code: Select all

#include "FiveMac.ch"

function Main()

   local oDlg, oFld, oGet1, cText1 := "", oGet2, cText2 := ""

   DEFINE DIALOG oDlg SIZE 600, 400

   @ 0, 0 FOLDER oFld OF oDlg PAGES "First", "Second" SIZE 600, 350 

   @ 0, 0 GET oGet1 VAR cText1 MEMO OF oFld:aDialogs[ 1 ] SIZE 580, 300

   oGet1:SetRichText( .T. )
   oGet1:SetImportGraf( .T. )
   oGet1:AddHRuler()
   oGet1:SetUndo( .T. )
   oGet1:SetFocus()

   cText1 = "{\rtf1\ansi\ansicpg1200\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 TIMES NEW ROMAN;}}" + ;
           "{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs24 FIRST Bij deze fraaie plant " + ;
           "is het jonge blad roze gekleurt. Later verkleurt dit blad naar groen met een cr'e8mewitte rand." + ;
           "De jonge takken zijn opvallend rood gekleurt, wat goed contrasteerd met het fris gekleurde blad.\par}"

   oGet1:SetAttributedString( cText1 )
   oGet1:GoTop()

   @ 0, 0 GET oGet2 VAR cText2 MEMO OF oFld:aDialogs[ 2 ] SIZE 600, 346

   oGet2:SetRichText( .T. )
   oGet2:SetImportGraf( .T. )
   oGet2:AddHRuler()
   oGet2:SetUndo( .T. )
   oGet2:SetFocus()

   cText2 = "{\rtf1\ansi\ansicpg1200\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 TIMES NEW ROMAN;}}" + ;
           "{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\f0\fs24 SECOND Bij deze fraaie plant " + ;
           "is het jonge blad roze gekleurt. Later verkleurt dit blad naar groen met een cr'e8mewitte rand." + ;
           "De jonge takken zijn opvallend rood gekleurt, wat goed contrasteerd met het fris gekleurde blad.\par}"

   oGet2:SetAttributedString( cText2 )
   oGet2:GoTop()

   ACTIVATE DIALOG oDlg CENTERED

return nil

Re: richtext

Posted: Sun Apr 24, 2016 7:44 pm
by Antonio Linares
René,

Googling for NSRulerView translation did not provided any results so I have posted a tech question in stackoverflow to figure out how to translate the controls texts above the richedit:

http://stackoverflow.com/questions/3682 ... nstextview

Re: richtext

Posted: Sun Apr 24, 2016 7:53 pm
by Antonio Linares
René,

I have implemented a new Class TMultiGet method SetEditable( lOnOff )

https://developer.apple.com/library/mac ... index.html

I am emailing you the modified libs