Page 1 of 1

[RichViewActions][Demo] Tabbed Multiple Document Interface

Posted: Tue Jun 05, 2018 1:05 pm
by Sergey Tkachenko
This demo is based on the demo from RichViewActions\Demo\DelphiUnicode\ActionTest, but implements a tabbed multiple document interface: it allows editing several files in the same application.

https://www.trichview.com/support/files ... sttabs.zip

actiontesttabs.png
actiontesttabs.png (47.94 KiB) Viewed 54489 times
It uses TPageControl. Each page contains TRichViewEdit and TRVRuler.

A new command is added in the menu "File": "Close" (Ctrl+F4). It closes the active editor.
It allows closing all editors except for the last one. This way of implementation is just simpler than allowing closing all editors (it's simpler to copy properties to a new editor from the active editor; not necessary to disable combo boxes when all editors are closed, etc.)

This demo is similar to the multiple-document ScaleRichView demo.
Main differences: This demo uses TPageControl, with TRichViewEdit and TRVRuler on each page. The ScaleRichView demo uses TSRVTabSet, hides all inactive editors, uses the same 2 rulers for all editors (assign them to the active editor)
[+] History of updates
2021-12-07: Updated for compatibility with TRichView 19.x

Re: [RichViewActions][Demo] Tabbed Multiple Document Interface

Posted: Tue Jun 05, 2018 1:09 pm
by Sergey Tkachenko
Notes about implementation.

Creating and destroying editors
Initially, the form has RichViewEdit1, RVRuler1, RVStyle1 - components for the first page. When creating a new document, a new page is added to PageControl1, and new TRichViewEdit, TRVRuler and TRVStyle controls are created on this page.
When closing a page, controls on this page are destroyed. The user can close the first page (containing RichViewEdit1, RVRuler1, RVStyle1) as well, so the program cannot use variables RichViewEdit1, RVRuler1, RVStyle1!

How to make actions to work with the active editor.
Initially, RVAControlPanel1.DefaultControl = RichViewEdit1. When another page becomes active, we assign the active editor to RVAControlPanel1.DefaultControl. Because of this, all RichViewActions work with the active editor.

Events of TRichViewEdit
Code in events is changed to work with Sender instead of RichViewEdit1.
If the code must change user interface (for example, selection in combo boxes), it is executed only if Sender is the active editor.

Note editing form
A form for editing text of footnote/endnote/sidenote/textbox is closed before switching tabs.

Re: [RichViewActions][Demo] Tabbed Multiple Document Interface

Posted: Tue Dec 07, 2021 8:41 am
by Nostradamus
Hi Sergey,
This Demo failed to compile in Delphi 11 Ent.

cheers
Richard

Re: [RichViewActions][Demo] Tabbed Multiple Document Interface

Posted: Tue Dec 07, 2021 9:44 am
by Sergey Tkachenko
I updated this demo for compatibility with new versions of TRichView and RichViewActions.

The functions that convert internal measure units to pixels/twips now require an additional parameter (TRVStyle), and it's recommended to use EMU instead of twips.