FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) richtext
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
richtext
Posted: Tue Apr 19, 2016 08: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: richtext
Posted: Wed Apr 20, 2016 06:10 AM
René,

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

This is an example:

Code (fw): Select all Collapse
#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




regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: richtext
Posted: Wed Apr 20, 2016 09: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
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: richtext
Posted: Thu Apr 21, 2016 06: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
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: richtext
Posted: Thu Apr 21, 2016 06:30 PM
Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: richtext
Posted: Thu Apr 21, 2016 07: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: richtext
Posted: Sun Apr 24, 2016 07: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 (fw): Select all Collapse
#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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: richtext
Posted: Sun Apr 24, 2016 07: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: richtext
Posted: Sun Apr 24, 2016 07: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

Continue the discussion