richtext

richtext

Postby plantenkennis » Tue Apr 19, 2016 8:33 pm

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.
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: richtext

Postby Antonio Linares » Wed Apr 20, 2016 6:10 am

René,

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

This is an example:

Code: Select all  Expand view  RUN
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: richtext

Postby plantenkennis » Wed Apr 20, 2016 9:28 pm

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.
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: richtext

Postby plantenkennis » Thu Apr 21, 2016 6:27 pm

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
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: richtext

Postby plantenkennis » Thu Apr 21, 2016 6:30 pm

Image
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: richtext

Postby Antonio Linares » Thu Apr 21, 2016 7:56 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: richtext

Postby Antonio Linares » Sun Apr 24, 2016 7:10 pm

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  Expand view  RUN
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: richtext

Postby Antonio Linares » Sun Apr 24, 2016 7:44 pm

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/36828027/how-to-change-the-language-of-the-nsrulerview-controls-of-a-nstextview
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: richtext

Postby Antonio Linares » Sun Apr 24, 2016 7:53 pm

René,

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

https://developer.apple.com/library/mac/qa/qa1461/_index.html

I am emailing you the modified libs
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 15 guests