Tables Question

General TRichView support forum. Please post your questions here
Post Reply
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Tables Question

Post by standay »

Hi Sergey,

Here's a question not related to line numbers!

I use code in my main rve style to color the para background. Works fine and looks like what I want. However, when I pasted some tables in, the para bgnd is drawing in them and I don't want it in there (see screenshot below). How can I suppress the para bgnd color from drawing into my tables? I've tried everything I can think of and the only way I have gotten rid of the bgnds in the tables is to turn it off for everything!

Line 5 is a regular para and is fine. Lines 7 and 10 are the tables and I don't want the blue para bgnd bar to be drawn in those. If I decide to implement tables at all, it will be to add images like you see in the screenshot. So if the answer is to remove the image from the table that will be an issue.

Thanks Sergey

Stan
Image47.png
Image47.png (95.5 KiB) Viewed 9424 times
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Tables Question

Post by Sergey Tkachenko »

But if you draw paragraph backgrounds yourself, you can just check if a paragraph contains a table, and do not draw background in this case (?)
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Tables Question

Post by standay »

Sergey Tkachenko wrote: Sun Jan 02, 2022 8:46 pm But if you draw paragraph backgrounds yourself, you can just check if a paragraph contains a table, and do not draw background in this case (?)
Tried that first thing. No go. If I select a line above the table(s), it highlights. Here's the code. Right now I have several attempts commented out but you can get an idea of what I was doing...part of it is the tables have the same itemno's as the rve. I think it's trying to highlight the same item no but I can't seem to get it stopped...

Code: Select all

  if not EditorActiveLine1.Checked then exit;
  if ActiveRVE <> rve then exit;

  //if rve.GetItemStyle( rve.CurItemNo ) = rvsTable then exit;
  //if rve.GetItemStyle( Sender.ItemNo ) = rvsTable then exit;
  //if rve.GetCurrentItemEx(TRVTableItemInfo, rv, item) then exit;

  if not rve.Modified and (rve.GetTextLen = 0) and
    ( not FileExists( FileNameFromDate(CalendarView1.Date) + '.rvf' )) then exit;

  i := Sender.ItemNo;
  j := rve.CurItemNo;

  RVAlign := rvvaBaseline;
  if (rve.GetItemStyle(j) = rvsPicture) then
    rve.GetPictureInfo(j, s, gr, RVAlign, RVTag );
  if (rve.GetItemStyle(j) = rvsBreak) or
    ( RVAlign = rvvaLeft ) or
      ( RVAlign = rvvaRight ) then exit;

  if TCustomRVFormattedData(Sender.RVData) = rve.RVData then
    j := rve.CurItemNo;
  repeat
    DoLineHL := i=j;
    if DoLineHL then
      break;
    dec(i);
  //was IsFromNewLine but wasn't always working that way so I changed it to
  //IsParaStart 9/9/2021. SRD
  until TCustomRVFormattedData(Sender.RVData).IsParaStart(i+1);
  if DoLineHL then begin
    //ACanvas.Brush.Style := bsSolid;
    //ACanvas.Brush.Color := $CCCCFF;
    //ACanvas.FillRect(ARect);
    r := ARect;

    if ShowLinenumberIndicators1.Checked and ExtendEditorSel1.Checked then
      r.Left := 0;

    if rve.GetItemTextW(j) <> '' then
    r.Bottom := r.Bottom + 2;
    //if OfficeTextSel1.Checked then r.Left := 0;
    ColorBlend(ACanvas, r, SRDJournalThemes.EditorActiveLine , 225);
  end;
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Tables Question

Post by standay »

Hi Sergey,

FYI, I tried a plain table with no image, still does it, and in a simple test app and it's still doing it there.

Stan
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Tables Question

Post by Sergey Tkachenko »

Can you create a simple project reproducing this problem?
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Tables Question

Post by standay »

Hi Sergey,

I'll attach a simple test file and the project unit. I don't think I can do the whole thing as attachment size is limited here.

Let me know if this is sufficient.

Stan
Attachments
Project1.dproj
(31.73 KiB) Downloaded 856 times
Project1.dpr
(234 Bytes) Downloaded 822 times
Unit1.pas
(2.09 KiB) Downloaded 782 times
test.rvf
(4.09 KiB) Downloaded 822 times
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Tables Question

Post by Sergey Tkachenko »

Please attach DFM file

PS: you can attach ZIP files
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Tables Question

Post by standay »

Sergey Tkachenko wrote: Mon Jan 03, 2022 10:56 am Please attach DFM file

PS: you can attach ZIP files
OK, attached a zip. No DCUs or EXE in it but everything else its there.

Note that this was happening in version 19.5. I updated to version 20 this morning and still the same effect.

Stan
Attachments
rve test.zip
(64.01 KiB) Downloaded 850 times
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Tables Question

Post by Sergey Tkachenko »

Attached.

By default, the demo highlights the current paragraph, both in a table cells and not.

There are two checkboxes.
One turns off highlighting in table cells.
Another one turns off highlighting tables themselves.
Attachments
rve test app.zip
(6.83 KiB) Downloaded 827 times
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Tables Question

Post by standay »

Hi Sergey,

Yes, that all worked. THANKS. The key was this:

Code: Select all

  Edit := rve.TopLevelEditor;
  if TCustomRVFormattedData(Sender.RVData) <> Edit.RVData then
    exit;
I thought it was going to be something like that. And I actually tried things along those lines, but the closest I got was this:

Code: Select all

  if rve = rve.InPlaceEditor then exit;
and...

Code: Select all

  if rve = rve.TopLevelEditor then exit;
It never occurred to me to set up a separate var and then compare it the way you did. Sigh.

Well, thanks again.

Stan
Post Reply