[RichViewActions][Demo] Tabbed Multiple Document Interface

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[RichViewActions][Demo] Tabbed Multiple Document Interface

Post 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 54921 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
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post 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.
Nostradamus
Posts: 67
Joined: Sat May 13, 2006 1:56 pm
Location: Australia

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

Post by Nostradamus »

Hi Sergey,
This Demo failed to compile in Delphi 11 Ent.

cheers
Richard
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post 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.
Post Reply