[Demo] Editors in editors

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

[Demo] Editors in editors

Post by Sergey Tkachenko »

This demo shows how to insert TRichViewEdit in TRichViewEdit.
Documents with inserted RichViewEdits can be saved in RVF files.

http://www.trichview.com/support/files/subeditors.zip

Minimal required Delphi version: 6
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

If I save the TRichViewEdit to file as a RVF it should be able to up in another TRichView Editor correct?

RichViewEdit1.SaveRVF('InterlinearTest.rvf', False); or do I need to do something a bit different?
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demo] Editors in editors

Post by Sergey Tkachenko »

Yes, of course. Use SaveRVF to save and LoadRVF+Format to load.

RegisterClasses([TSubRichViewEdit]) must be called before loading, if RVF document can contain TSubRichViewEdit controls.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

Ah excellent I thought as much that I must be missing just a little something. Thanks for the info about Register class
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

I am working with these subEditors and it is going quite well. (I am needing to speed them up there can be a lot.)
I am having trouble with DocmentWidth (note I am on rvf17 on this project)
rvS.Width := rvS.RVData.DocumentWidth;
It is resizing but not fully always.

I've tried +/- [rvoClientTextWidth];
I've set this for the subEditors options: rvS.Options := rvP.Options - [rvoClientTextWidth];
Capture.JPG
Capture.JPG (27.99 KiB) Viewed 41573 times
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

If you could help me to get the leanest/quickest version of:
rvS.FormatTail;
rvPd.AddControlEx('subEditor|row:' + IntToStr(rowIdx) + '|grp:' + IntToStr(i),rvS, -1, rvvaAbsTop);

As in do I need to clean up styles, what options, for TRichViewEdit. etc can I use to get it there the fastest.
I have a bout a 11sec delay on load and I need to get this down to like 1 sec if possible.

I am adding roughly 100s of TRichViewEdits depending on the Chapter length. So that means I am calling Format/FormatTail that many times for each indvidual TRichViewEdit that is added. Also calling AddControlEx
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demo] Editors in editors

Post by Sergey Tkachenko »

1. As for rv.RVData.DocumentWidth, try assigning rv.WordWrap = False.

2. As for efficiency.
Do you need to add all this content by one function call, or do you add/delete subeditors one by one?
The most efficient method is adding all content (using AddControlEx method), and then call rv.Format only once.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

Code: Select all

  //Special for Interlinear
  ReadOnly := True;
  HScrollVisible := False;
  VScrollVisible := False;
  BorderStyle := bsNone;
  WordWrap := False;
  TopMargin := 0;
  BottomMargin := 0;
  LeftMargin := 0;
  RightMargin := 0;
WordWrap should be set to False hmms...

As to efficiency here is the process.

1. The RVF document is loaded with items.
2. I process a paragraph. Not there could be a 151 pagraphs I think max.
3. Then using the items in the pagraph. I add them to a subEditor if they are what I want I add them using AddNLW. Items not needed are added back into the paragraph not to the subEditor.
4. Then once the correct items are added to the new subEditor. The subEditor is formatted (not the main editor)
5. Then this new subEditor is added via AddControlEx.
6. Once the paragraph is compled I delete the original items DeleteItems. Since they are now stored in the subEditors. Could be 20 or more subEditors in a paragraph.

Format for the main TRichViewEdit is called after the whole document is built. With the exception of the subEditors they are formated before they are added or they seem not have the right heigth/width. Hmms maybe this Format for these subEditors is slowing it down and the main Format is all I need. But how can I get the right Width/Height? Do I need to go through all the subEditors and resize after the main format?


By the way once they are generated it works very nice.
interlinear.JPG
interlinear.JPG (58.1 KiB) Viewed 41307 times
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

It seems if I take away the subEditor format that almost halfs the time to 5-6 seconds.
Now I need to get back into the items and solve how to edit a control. I named them 'subEditor...' so if I can do this that helps. Now if there was a way to improve the speed of AddControlEx
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

Getting there on the resize but I am running into something odd:
This seems to do pretty good except for: intRVE.Height := intRVE.RVData.DocumentHeight;
Even though DocumentHeight is the right size intRVE.Height always stays at 0???

right now I am trying this right before the main rve.format; I have tried it after same result....

Code: Select all

procedure TfmBibleView.subEditorsResize;
var
  //Interlinear
  itemIdx: Integer;
  intName: TRVUnicodeString;
  intCtrl: TControl;
  intVAlign: TRVVAlign;
  intTag: TRVTag;
  intRVE: TCustomRichViewEdit;
begin
  if m_parsingHelper.Interlinear then begin
    for itemIdx := 0 to reader.ItemCount-1 do
      if reader.GetItemStyle(itemIdx) = rvsComponent then begin
         reader.GetControlInfo(itemIdx, intName, intCtrl, intVAlign, intTag);
         intRVE := TCustomRichViewEdit(inCtrl);
         intRVE.Height := intRVE.RVData.DocumentHeight;
         intRVE.Width :=  intRVE.RVData.DocumentWidth;
      end;
    end;
end;
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

I seem to get some 0 and other the subEditors height unless I set it like 200; The below is just letting it use
intRVE.Height := intRVE.RVData.DocumentHeight;
height-error.JPG
height-error.JPG (51.2 KiB) Viewed 41287 times
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demo] Editors in editors

Post by Sergey Tkachenko »

Can you send me a sample project, as simple as possible?
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

I am going to try to updated to RV22 (this project is Delphi7.1 with RV17) and see if the problem still exists. If so then I will try though it is very complex unfortunately.
I am afraid there are so many possibilities.
1. We load data converting into RTF then load that into RichView (no format yet)
2. Copy from that RTF now RVF data into subEditors (no format yet)
3. Build all the subEditors (trying to get DocumentHeight)
4. Add this verse and go to the next so loop through 1-4 over and over.
5. Now right before format try to get DocumenWidth

As you can see way too many places so hoping upgrading will help (plus I need to do it anyways at some point.)
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: [Demo] Editors in editors

Post by jgkoehn »

I tried reproducing this error in another project but I couldn't make it happen.
Today as I was trying different things I came across
TRichView.Format_ when I set OnlyResized to True in the subEditors it produced a similar error.
Is it possible that Format/FormatTail for my TRichViewEdit somehow has OnlyResized set to False?
Oh I see that is the normally set to False and perhaps these subEditors are messing it up somehow.

By the way the content is there somehow the height is just wrong is all.
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demo] Editors in editors

Post by Sergey Tkachenko »

Maybe you call Reformat instead of Format?
Post Reply