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

actiontesttabs.png (47.94 KiB) Viewed 9142 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)

The demo requires TRichView 17.4+

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.