Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » RichEdit and styles questions
RichEdit and styles questions [message #21514] Sun, 24 May 2009 00:36 Go to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello all

First question
Using UWord demo it is not possible to set one line with more than one style, but if I change the QTF file by hand, UWord opens the file properly:

index.php?t=getfile&id=1736&private=0

Do you know if it is possible to do this directly in UWord or by adding something?


Second question
I would like to parse the RichEdit text but focusing in the styles. For example text with "Default" style would be copied unchanged but text with "Formula" style would be converted into a mathematical formula, like converting:

Quote:

integral(sqrt(cos(phi_ini^2)) + i^2 + 6, i = 1, 10)*dx = cos((27+x^2)^3.25)/(PI*R_0^2)


in the equivalent formula:

index.php?t=getfile&id=1737&private=0

Do you know how to do this "the simple way" instead of parsing directly the QTF bytes?.

Best regards
Koldo
  • Attachment: window.JPG
    (Size: 49.02KB, Downloaded 718 times)
  • Attachment: math.JPG
    (Size: 4.56KB, Downloaded 724 times)


Best regards
Iñaki
Re: RichEdit and styles questions [message #21537 is a reply to message #21514] Mon, 25 May 2009 17:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
koldo wrote on Sat, 23 May 2009 18:36

Hello all

First question
Using UWord demo it is not possible to set one line with more than one style, but if I change the QTF file by hand, UWord opens the file properly:



I am afraid not really.

The problem is that it is PARAGRAPH style...

Quote:


Second question
I would like to parse the RichEdit text but focusing in the styles. For example text with "Default" style would be copied unchanged but text with "Formula" style would be converted into a mathematical formula, like converting:

Quote:

integral(sqrt(cos(phi_ini^2)) + i^2 + 6, i = 1, 10)*dx = cos((27+x^2)^3.25)/(PI*R_0^2)


in the equivalent formula:

index.php?t=getfile&id=1737&private=0

Do you know how to do this "the simple way" instead of parsing directly the QTF bytes?.



Simple (and I believe correct) way is to do is as RichObject. Do not mix with text...

BTW, nice formula renderer Wink

Mirek
Re: RichEdit and styles questions [message #21538 is a reply to message #21537] Mon, 25 May 2009 18:44 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello luzr

Sorry, I am going to explain it better.

The idea I had is to insert equations in Qtf text using a "poor man" approach. Instead of creating a full featured equation editor (perhaps some day) I thought to insert the text and equations in text following certain format, but selecting with a "Formula" style the formulas.

This way the text could look like this.

index.php?t=getfile&id=1741&private=0

After pushing a buttom the user could choose the view mode, so the equation and text before could look like this:

index.php?t=getfile&id=1743&private=0


There is no problem to view the equation as I did a QtfRichObject for equations so a program to show a prompt with that equation would be like this:

GUI_APP_MAIN
{
	QtfRichObject drw = QtfEquation("integral(sqrt(cos(phi_ini^2)) + i^2 + 6, i = 1, 10)*dx");
	String text;
	text << "[R3 This is some formula in QTF:&" << drw;
	PromptOK(text);
}


Code is here: http://www.ultimatepp.org/forum/index.php?t=msg&&th= 4214&goto=20264

But for doing that I need to parse the Qtf text looking for "Formula" style and changing that text with the QtfRichObject representing the equations.

The question was about how to parse the Qtf the smart way.

Ah, the parser in QtfEquation was borrowed from U++ Smile.

Sorry again. I do not understand what do you mean:

Quote:

The problem is that it is PARAGRAPH style...


(I have done the first bitmap Before.jpg by modifying the Qtf file by hand)

Best regards
Koldo
  • Attachment: Before.JPG
    (Size: 12.46KB, Downloaded 654 times)
  • Attachment: After.JPG
    (Size: 10.14KB, Downloaded 656 times)


Best regards
Iñaki
Re: RichEdit and styles questions [message #21539 is a reply to message #21538] Mon, 25 May 2009 22:02 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 25 May 2009 12:44

Hello luzr

Sorry, I am going to explain it better.

The idea I had is to insert equations in Qtf text using a "poor man" approach. Instead of creating a full featured equation editor (perhaps some day) I thought to insert the text and equations in text following certain format, but selecting with a "Formula" style the formulas.



Well, the equation of text can be the content of your RichObject. I believe that is the most simple approach.

RichObjects can be edited and you can add "Insert equation" button. Both will lead to "editor" where you just edit the text and perhaps see the preview.

Quote:


Quote:

The problem is that it is PARAGRAPH style...


(I have done the first bitmap Before.jpg by modifying the Qtf file by hand)



Yes, but it is sort of bug (it is "undefined" to use style for just part of paragraph). In any case, RichText would not work with such thing correctly no matter what (because style is remembered only one per whole paragraph).

Mirek
Re: RichEdit and styles questions [message #21544 is a reply to message #21539] Tue, 26 May 2009 08:59 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello luzr

luzr wrote on Mon, 25 May 2009 22:02

koldo wrote on Mon, 25 May 2009 12:44

Hello luzr

Sorry, I am going to explain it better.

The idea I had is to insert equations in Qtf text using a "poor man" approach. Instead of creating a full featured equation editor (perhaps some day) I thought to insert the text and equations in text following certain format, but selecting with a "Formula" style the formulas.



Well, the equation of text can be the content of your RichObject. I believe that is the most simple approach.

RichObjects can be edited and you can add "Insert equation" button. Both will lead to "editor" where you just edit the text and perhaps see the preview.




Sorry. I do not understand you Embarassed

One thing I liked was to parse Qtf, so to parse this:

index.php?t=getfile&id=1744&private=0

that is this in Qtf format:

[ $$0,0#00000000000000000000000000000000:Default]
[$(255.255.192) $$1,1#705B135C58F979E6FF526087DA632601:Formula]
[{_}%EN-US 
[s0; This is the explanation around the formula&]
[s0; &]
[s1; integral(sqrt(cos(phi`_ini`^2)) `+ i`^2 `+ 6, i `= 1, 10)`*dx&]
[s0; &]


I have two options:
1. Parse this Qtf string looking for "Formula" style paragraphs and substitute them with the rendered formulas (if the user has pressed preview button)
2. Other smarter option

Do you know if there is an option like the smarter option?

Best regards
Koldo
  • Attachment: Formula.JPG
    (Size: 11.13KB, Downloaded 643 times)


Best regards
Iñaki
Re: RichEdit and styles questions [message #21545 is a reply to message #21544] Tue, 26 May 2009 10:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 26 May 2009 02:59

Hello luzr

luzr wrote on Mon, 25 May 2009 22:02

koldo wrote on Mon, 25 May 2009 12:44

Hello luzr

Sorry, I am going to explain it better.

The idea I had is to insert equations in Qtf text using a "poor man" approach. Instead of creating a full featured equation editor (perhaps some day) I thought to insert the text and equations in text following certain format, but selecting with a "Formula" style the formulas.



Well, the equation of text can be the content of your RichObject. I believe that is the most simple approach.

RichObjects can be edited and you can add "Insert equation" button. Both will lead to "editor" where you just edit the text and perhaps see the preview.




Sorry. I do not understand you Embarassed

One thing I liked was to parse Qtf, so to parse this:

index.php?t=getfile&id=1744&private=0

that is this in Qtf format:

[ $$0,0#00000000000000000000000000000000:Default]
[$(255.255.192) $$1,1#705B135C58F979E6FF526087DA632601:Formula]
[{_}%EN-US 
[s0; This is the explanation around the formula&]
[s0; &]
[s1; integral(sqrt(cos(phi`_ini`^2)) `+ i`^2 `+ 6, i `= 1, 10)`*dx&]
[s0; &]


I have two options:
1. Parse this Qtf string looking for "Formula" style paragraphs and substitute them with the rendered formulas (if the user has pressed preview button)
2. Other smarter option

Do you know if there is an option like the smarter option?

Best regards
Koldo


Ah, I see, you not only want to enter formulas in RichEdit, but also in "manual" QTF, right?

Well, I agree, this would be a bit harder because RichObjects are usually quite "compressed".

Anyway, quite easier fix would be to introduce "text based RichObject" format in QTF, what do you thing?

Say

[ $$0,0#00000000000000000000000000000000:Default]
[$(255.255.192) $$1,1#705B135C58F979E6FF526087DA632601:Formula]
[{_}%EN-US 
[s0; This is the explanation around the formula&]
[s0; &]
[s1; @formula integral(sqrt(cos(phi`_ini`^2)) `+ i`^2 `+ 6, i `= 1, 10)`*dx@&]
[s0; &]


(would need more tuning I suspect...)

Mirek
Re: RichEdit and styles questions [message #21547 is a reply to message #21545] Tue, 26 May 2009 10:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello luzr

Quote:

Anyway, quite easier fix would be to introduce "text based RichObject" format in QTF, what do you thing?

[ $$0,0#00000000000000000000000000000000:Default]
[{_}%EN-US 
[s0; This is the explanation around the formula&]
[s0; &]
[s0; @formula integral(sqrt(cos(phi`_ini`^2)) `+ i`^2 `+ 6, i `= 1, 10)`*dx@&]
[s0; &]



For me it would be a very good solution.

I think it would be needed for the user:
- A way to define a new object
- A way to give RichEdit a renderer for that object
- A way to give Richedit a callback function so that if somebody does a double-click on the object this function can open an equation editor in this case (or a picture editor in case of a picture)
- A way to update that object text so that after being edited by the callback function, it can be updated in the RichEdit.

In the sample I have removed "Formula" style as with "formula" object it would be enough.

Best regards
Koldo


Best regards
Iñaki
Re: RichEdit and styles questions [message #21647 is a reply to message #21547] Sun, 31 May 2009 00:28 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Sorry Mirek

What is your opinion about this?

Best regards
Koldo


Best regards
Iñaki
Re: RichEdit and styles questions [message #21677 is a reply to message #21647] Sun, 31 May 2009 23:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
koldo wrote on Sat, 30 May 2009 18:28

Sorry Mirek

What is your opinion about this?

Best regards
Koldo


I agree, but I have not implemented this yet....

Mirek
Re: RichEdit and styles questions [message #21737 is a reply to message #21677] Wed, 03 June 2009 00:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
Implemented and documented as "RichTextObject" example.
Re: RichEdit and styles questions [message #21755 is a reply to message #21737] Thu, 04 June 2009 08:57 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello luzr

Very good Smile

With this it is easy to expand RichText to include and manage any new object.

One question: Once the Qtf text is saved

Quote:

[ $$0,0#00000000000000000000000000000000:Default]
[{_}
[s0; Some line&]
[s0; Here comes the RichObject:
@@mytype:1200*200`Hello world!`
&]
[s0; Next line]


, I would like to parse through it to get the normal text and the text inside the objects.

Is there a smart way through an implemented interface or I shold have to do a parser for it?.

Best regards
Koldo


Best regards
Iñaki
Re: RichEdit and styles questions [message #21779 is a reply to message #21755] Thu, 04 June 2009 21:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 04 June 2009 02:57

Hello luzr

Very good Smile

With this it is easy to expand RichText to include and manage any new object.

One question: Once the Qtf text is saved

Quote:

[ $$0,0#00000000000000000000000000000000:Default]
[{_}
[s0; Some line&]
[s0; Here comes the RichObject:
@@mytype:1200*200`Hello world!`
&]
[s0; Next line]


, I would like to parse through it to get the normal text and the text inside the objects.

Is there a smart way through an implemented interface or I shold have to do a parser for it?.

Best regards
Koldo


I guess you could consider RichText interfaces... Maybe Iterator?

Mirek
Re: RichEdit and styles questions [message #21782 is a reply to message #21779] Thu, 04 June 2009 23:24 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Sorry Mirek

Quote:

I guess you could consider RichText interfaces... Maybe Iterator?


I have never used them and I do not have any idea to do it. Sad

Best regards
Koldo


Best regards
Iñaki
Re: RichEdit and styles questions [message #21792 is a reply to message #21782] Fri, 05 June 2009 10:02 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
Well, it is probably the least documented part Smile

Anyway, it is nothing too complicated. There is RichText type that contains the, well, uhm, RichText. You can access individual RichPara paragraphs and RichTable tables. The only complications is that RichTables have RichTxt (base class of RichText) as cells (hierarchic structure).

Anyway, most of hierarchy caused complexity is avoided if you use "RichTxt::Iterator" (or UpdateIterator). In that case you will recieve just a series of paragraphs, which are quite easy to get in (they are just array of text strings with font and RichObjects).

Mirek
Re: RichEdit and styles questions [message #21799 is a reply to message #21792] Fri, 05 June 2009 13:31 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Sorry Mirek

I do not know where to begin.

I have checked Upp source and Forum and I did not find use or samples of Iterator.

Could you please give me any idea?

MyRichEdit editor;

... editing ...

RichText text = editor.Get();

-->To include here


Best regards
Koldo


Best regards
Iñaki
Re: RichEdit and styles questions [message #21800 is a reply to message #21799] Fri, 05 June 2009 13:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
Search for

RichFindIterator

(in RichEdit sources)

Mirek
Re: RichEdit and styles questions [message #21808 is a reply to message #21800] Fri, 05 June 2009 22:24 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3004
Registered: August 2008
Ultimate Member
Hello Mirek

Well, it seems RichFindIterator is a way to implement a parser but not a RichEdit/Qtf parser itself.

So I will do it by myself. Much less difficult than doing a Svg Painter Razz

Best regards
Koldo


Best regards
Iñaki
Re: RichEdit and styles questions [message #21829 is a reply to message #21808] Sun, 07 June 2009 21:56 Go to previous message
mirek is currently offline  mirek
Messages: 12050
Registered: November 2005
Ultimate Member
koldo wrote on Fri, 05 June 2009 16:24

Hello Mirek

Well, it seems RichFindIterator is a way to implement a parser but not a RichEdit/Qtf parser itself.

So I will do it by myself. Much less difficult than doing a Svg Painter Razz

Best regards
Koldo



Use ParseQTF to convert QTF->RichText. Then use either direct code or iterators to go through it.

Mirek
Previous Topic: viewing html
Next Topic: Editor Toolbar
Goto Forum:
  


Current Time: Sat Oct 19 17:23:12 CEST 2019

Total time taken to generate the page: 0.01439 seconds