TRichView demo projects for FireMonkey

TRichView 19.3 – rich text editor for FireMonkey

TRichView is updated to version 19.3.

The new release includes the first version for FireMonkey (Windows platform, see the notes below).

New in VCL/LCL version: HTML de-encapsulation from RTF, new components for DevExpress ribbon (will be described later in a separate post). Lazarus 2.0.12 support.

Trial versions are available: https://www.trichview.com/download/
A full version can be found in the protected section of this forum (or old setups can check for updates and download new versions).

Licensing

FireMonkey version is available for VCL+LCL customers without additional payments.

FireMonkey version is available free of charge for customers who ordered in 2020 and 2021, and for customers who have active TRichView subscription.

Customers who ordered in 2019 can download the new VCL version (a paid update will be released later in this year), but FMX version is a paid update.
For all older customers this is a paid update, including customers who have free lifetime updates of VCL version.

Renewal prices and links can be found on the private support forum, or contact me (email richviewgmailcom, or a private message in this forum)

After ordering or renewing, you will receive VCL+LCL+FMX versions. Updates will be free in 2021, 2022, and maybe partially in 2023.

Time limited offer: 15% license on all our components and renewals (except for subscriptions).
To apply, enter the coupon code FireMonkey
The offer is valid till August, 1st.

Ordering new components: https://www.trichview.com/order/

What has been ported

The following components have been ported:

  • TRichView – rich text viewer
  • TRichViewEdit – rich text editor
  • TRVStyle – additional component that provides settings and formatting options for TRichView and TRichViewEdit

These are core components in the package.

TRVPrint and TRVReportHelper will be ported in the next update.
(all their code has been ported but not tested; most probably, it will work after minor modifications)

TRVOfficeConverter uses an obsolete Windows-only technology and will not be ported.

Supported Delphi/C++Builder versions: XE6, XE7, XE8, 10, 10.1, 10.2, 10.3, 10.4.

All types of document objects have been ported (except for equation item, it is available only in VCL version):

  • text
  • all types of bullets and numbering (including text and images)
  • pictures
  • images from TImageList
  • controls
  • tables
  • horizontal lines
  • text labels
  • numbered sequences (counters)
  • footnotes, endnotes, text boxes, page number, page count (although, the full functionality of these items requires printing)
  • tabulations

All paragraph attributes have been ported, except for justified and distributed alignments (they are displayed as left alignment).
All text attributes have been ported, except for character spacing, character scaling and font quality. Bi-directional text (Arabic and Hebrew), UTF-32 characters are supported.
All item properties have been ported (except for transparent color and mode for TBitmap).

All editing operations have been ported, including Clipboard and drag&drop.

“Smart popups” (a button next to the edited object) have been ported.

The following features were not ported yet: animations, live spelling check. They will be ported in the next update.

40 TRichView demo projects have been ported (all projects except for demo projects related to printing (they will be included in the next update), animation, VCL-specific features (custom hints)).

The help file is updated. The same help file is used for VCL, Lazarus and FireMonkey version. The online version is here: https://www.trichview.com/help/

Platforms

All the code is written as cross-platform. There are some special improvements for Windows (like special Clipboard support, optimizations for Direct2D and GDI+ canvases; but they are used only when compiling for Windows target).

However, only Windows version is tested, so the current version is announced as Windows only. After testing on (and optimizing for) other platforms, they will be added.
But if you try it on other platforms, please let me know about results (for mobile platforms, make sure that string indexes are started from 1).
At least I know it can be compiled for non-Windows platform on Delphi 10.4.

What’s next

Next I plan to port remaining features, starting from printing and spelling checking. I plan to port some additional components (RichViewXML, RvHtmlImporter, TRVASpell, TRVHunSpell).
Next I plan to add platforms, starting from Mac.
After platforms, I’ll start converting RichViewActions.

FireMonkey vs VCL

Can FMX and VCL versions be installed in the same Delphi/C++Builder IDE?

Yes, but the both of them must have version 19.3 or newer.
The FMX version uses similar unit names with “fmx” prefix. For example, fmxRichView.pas instead of RichView.pas. There are some units that exist only in VCL/LCL and only in FireMonkey version. FireMonkey-only units have “FM” postfix, for example fmxRVClipboardFM.pas.

Can RVF files saved by VCL version be opened in FMX version and vice versa?

Yes.

Maybe, except for controls (if you insert controls in documents), because controls are different in VCL and FMX.
The following RVF Options may help: rvfoIgnoreUnknownCtrls, rvfoIgnoreUnknownCtrlProperties.

Moreover, collections of text, paragraphs and list styles (properties of TRVStyle) are saved in DFM/FMX identically. Because of this, you can copy-paste TRVStyle objects between VCL and FMX projects.

In VCL and FMX, some properties have different types: font sizes (integer/single), colors (TColor/TAlphaColor), pictures (TPicture/TRVPicture). However, they are saved in RVF and DFM/FMX files in a compatible way. When FMX version saves TAlphaColor, it saves it as TColor and Opacity properties (Opacity is stored only for semitransparent colors). VCL version reads TColor and ignores Opacity. This ignoring works for styles. However, for tables it works only in v19.3+.
More about differences:
https://www.trichview.com/help/firemonkey.html

About color transparency

In FMX version, TAplaColor is used instead of TColor, so all lines and fills can be semitransparent.
In VCL version, you can specify opacities for some fills (like paragraph, table and cell backgrounds) in separate properties. In FMX version, both these opacities and color opacities are applied (multiplied).

About scrollbars

In VCL version:
– a horizontal scrollbar can be completely hidden or shown when needed.
– in TRichView, vertical scrollbar can be completely hidden or shown when needed.
– in TRichViewEdit, vertical scrollbar can be completely hidden or always shown (it has disable-no-scroll option).

In FMX version:
– you can define scrollbars in FMX style; by default, TRichView and TRichViewEdit use TMemo’s style
– TRichView and TRichViewEdit are inherited from TScrollBox and use its properties, including ShowScrollBars and AutoHide. As a consequence, you cannot define different hide and show options for a horizontal and a vertical scrollbars.
To-do: now it will not be difficult to use an auto-show option for a vertical scrollbar in VCL/LCL TRichViewEdit. It will be implemented in one of next updates.

About scrolling

In VCL version, when you insert controls in documents, they are inserted directly in TRichView. On scrolling, coordinates of controls are changed accordingly. Due to some technical limitations, TRichView has to use tags of these controls. Vertical scrolling is possible to positions that are multiple of value of VSmallStep property.

In FireMonkey version, all controls are inserted in a special internal control that represents a document area. On scrolling, this internal control is moved, and all its child controls are moved together with it. Tags are not used, scrolling is possible to any position.

In VCL version, scrolling can be smooth (optionally). This feature is not implemented in FMX version (if you know how to implement it using FMX animations, let me know).

Clipboard and Drag&Drop

Clipboard in FireMonkey version

In FireMonkey, you can copy only a single format to the Clipboard (in older versions of Delphi, FireMonkey allows copying only a plain text; newer version allows copying text, bitmap, or a custom format).

This is a very serious limitation for a rich text editor, so I implemented a special support for Windows clipboard. It is used only when compiling for Windows platform. So VCL and FMX versions support the Clipboard identically in Windows.

For all other platforms, the most appropriate format is copied:
– if an image is selected, this image is copied
– otherwise, the best format is chosen from Options: RVF, RTF or text.

Drag&drop in FireMonkey version

There is no way to override the standard drag&drop behavior in FireMonkey, so TRichView and TRichViewEdit use FMX drag&drop.

When dragging between editors within the same application (or dragging within the same editor), data are transferred in the most appropriate format listed in AcceptDragDropFormats property. Otherwise, data are provided as an image or as a plain text, depending on the selection.

When accepting dragged data from another source, TRichViewEdit supports: a plain text, an image, a list of files.
You can use events to insert data in your own formats.

Graphics in documents

Graphic

In VCL/LCL version, you can insert any image inherited from TGraphic, including TBitmap, TMetafile, TJPEGImage, TPngImage, etc., and third-party graphic classes (like TSVGImage).

In FireMonkey version, a special class TRVGraphic is used instead. Currently, it is a wrapper around TBitmap and supports all formats supported by FMX TBitmap (including bitmaps, windows icons, PNG, Jpeg). In future, I plan to add support for SVG images in FMX.
FireMonkey version does not support Windows metafiles (if you know a third-party metafile implementation for FireMonkey, please let me know).

Images from TImageList

Some items (bullets, hotspots, list markers) may display images from TImageList.
TImageList is available in FireMonkey starting from RAD Studio XE8. But it is different from VCL TImageList: for each image, it may contain multiple versions of arbitrary sizes (usually used for different resolutions).
FireMonkey version of TRichView supports TImageList. The items that use TImageList have two additional properties in FireMonkey: ImageWidth and ImageHeight. The component chooses the best image that fits the specified size.

Demo projects

Demo projects for FireMonkey

As I said before, all appropriate TRichView demo projects have been ported.
You can find them in <TRichView FMX Dir>\TRichView\Demos\Delphi.FMX\ folder.

Demo projects can be opened in all Delphi versions starting from XE7.

Some demos were ported one-to-one.
Some demos have changes. For example, in “Search and Replace” demo, a “search and replace” dialog is implemented by the application (instead of TFindDialog and TReplaceDialog, because they do not have analogs in FireMonkey), and so on.

The most important changes are in the following demo projects:

1) Editors\Editor 2\, Editors\StyleTemplates\

Rvedit.jpg

These demos show how to implement simple text editors with commands for changing text and paragraph attributes (like “make bold”, “apply font name”, “change paragraph alignment”).
FMX version have improvements:
– it is based on actions
– it has modern toolbar glyphs
– it supports image insertion
– it supports multiple file formats (RVF, DocX, RTF, Markdown)
(the last change was added to VCL and LCL versions of these demo projects as well)

2) Assorted\Graphics\DragImg\

FMXDrag.png

In VCL/LCL version, the editor uses system (OLE) drag&drop, and this demo shows how you can use VCL/LCL drag&drop in addition to it.
In FireMonkey version, this demo uses FMX drag&drop, but shows how to use events to accept dragged controls differently: as an image, as a text, or as a control.

Changes in VCL and Lazarus versions

Changes in VCL/LCL version

Lazarus: this version supports/needs Lazarus 2.0.12 (the previous version was for Lazarus 2.0.10).

There are no new features in TRichView (except for HTML-RTF deencapsulation)
There are some small fixes and optimizations + major refactoring inside, but without changing documented properties and methods.

Some functions were moved from RVFuncs.pas to RVColorFuncs.pas and RVCoordFuncs.pas.
Some undocumented properties were renamed (since this version, we avoid using parameters and properties that have the same names as units). For example, TRichViewRVData.RichView was renamed to TRichViewRVData.OwnerRichView.

Changes in VCL/LCL demo projects

The editors in “Editor 1” and “Editor 2” folder now support multiple formats (RVF, DocX, RTF, Markdown).
Images for tabs are changed for ScaleRichView ActionTestTabs demos. Now they include images for all formats (RVF, DocX, RTF, Markdown, text, other) and are the same for Unicode and non-Unicode versions of demos.
Some cosmetic changes in several demos.
Obsolete code is fixed in ScaleRichView\Demos\Delphi\RVDemos\Assorted\Printing\Headers.

Extracting encapsulated HTML from RTF

xtracting encapsulated HTML from RTF

HTML-in-RTF encapsulation is made by Microsoft Outlook/Exchange.
This is an RTF file created from HTML. It looks close to the original HTML file (i.e. it contains RTF code that mimics the original HTML document), but also contains data allowing to extract the original HTML document unchanged.

A new unit is added: RVRTFDeEncapsulation.pas (fmxRVRTFDeEncapsulation.pas in FireMonkey version).

It contains two functions:

function GetRTFEncapsulationType(RTFStream: TStream): TRVRTFEncapsulationType;
function ExtractEncapsulatedHTMLFromRTF(RTFStream, HTMLStream: TStream;
  OnAttachmentPosition: TRVAttachmentPositionEvent = nil): Boolean;

where

type
   TRVRTFEncapsulationType = (rvrtfetNone, rvrtfetHTML, rvrtfetText, rvrtfetError);

GetRTFEncapsulationType checks if the specified stream contains HTML or a plain text encapsulated in RTF. Possible result values:

  • rvrtfetNone – RTF without encapsulation
  • rvrtfetHTML – RTF containing encapsulated HTML
  • rvrtfetText – RTF containing encapsulated plain text
  • rvrtfetError – not RTF

ExtractEncapsulatedHTMLFromRTF performs extraction of encapsulated HTML or plain text from RTF (from RTFStream to HTMLStream).
Also, if the callback function OnAttachmentPosition is provided, it calls it when it finds an attachment position (you can store the position of HTMLStream where this attachment is located, and/or insert some text in resulting HTML/text in this position).

More info about HTML-in-RTF encapsulation and attachments:
https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxrtfex/afb1b1d7-e2a4-4c97-b4fe-ff8b794079e7

User interface translations

The following UI translations were updated in RichViewActions and ScaleRichView:

  • Portuguese (Br), thanks to Alexandre Garcia
  • Slovenian, thanks to Goran Brumen

Top

Share this article

Leave a Comment

Your email address will not be published. Required fields are marked *