Page 1 of 1

Table.Cells[j,i].AddNL

Posted: Sat Jun 24, 2023 4:36 pm
by fara2000
Hello everyone
First question:
When I try to add 'v=-2m/s' to a cell in my table by using the following:
Table.Cells[0,0].AddNL('v=-2m/s' ,GetTextStyle(Table.GetRVStyle,[fsBold],clRed,rvsssNormal,60),1);
I get the inversed string: 'v=m/s 2-' inside the cell.
I believe the problem will be solved if execute by code the srvActionsResource.rvActionParaLTR1 ??? How doing that?
Second Question:
I would like to know the Bottom coordination of the last item in a richView page... How Can I Do that By Code.
Please Help!

Re: Table.Cells[j,i].AddNL

Posted: Mon Jun 26, 2023 10:06 am
by Sergey Tkachenko
1. It's not necessary to use actions to change BiDiMode of text. Just change your GetTextStyle function to return an index of text style that have BiDiMode = rvbdLeftToRight. If you need text of different directions (LRT / RTL / default direction), you can add a parameter to GetTextStyle.
If you post code of GetTextStyle here, I can tell how to modify it.

2. The bottom coordinate of TRichView document is returned by RichView.DocumentHeight. It includes RichView.BottomMargin.
If you use ScaleRichView, you can use SRichViewEdit.ConvertRVToSRV method to convert it to client coordinates.

Re: Table.Cells[j,i].AddNL

Posted: Mon Jun 26, 2023 1:01 pm
by fara2000
Thank you for your reply
for my First question. here is the function I use:

function GetTextStyle(RVStyle:TRvStyle;Style: TFontStyles; Color: TColor;
SScript: TRVSubSuperScriptType; SizeDouble: Integer): Integer;
var
TextStyle: TFontInfo;
begin
TextStyle := TFontInfo.Create(nil);
TextStyle.Assign(RVStyle.TextStyles[0]);
TextStyle.Color := Color;
TextStyle.Style := Style;
TextStyle.SubSuperScriptType := SScript;
TextStyle.SizeDouble := SizeDouble;
Result := RVStyle.FindTextStyle(TextStyle);
TextStyle.Free;
end;
how Can I make it include BiDiMode = rvbdLeftToRight Action?
Thanks for your assistance!

Re: Table.Cells[j,i].AddNL

Posted: Mon Jun 26, 2023 1:07 pm
by Sergey Tkachenko

Code: Select all

function GetTextStyle(RVStyle:TRvStyle;Style: TFontStyles; Color: TColor; 
  SScript: TRVSubSuperScriptType; SizeDouble: Integer;
  BiDiMode: TRVBiDiMode = rvbdUnspecified): Integer;
var
  TextStyle: TFontInfo;
begin
  TextStyle := TFontInfo.Create(nil);
  TextStyle.Assign(RVStyle.TextStyles[0]);
  TextStyle.Color := Color;
  TextStyle.Style := Style;
  TextStyle.SubSuperScriptType := SScript;
  TextStyle.SizeDouble := SizeDouble;
  TextStyle.BiDiMode := BiDiMode;
  Result := RVStyle.FindTextStyle(TextStyle);
  TextStyle.Free;
end;
Now you can call it with additional parameter:
GetTextStyle(Table.GetRVStyle,[fsBold],clRed,rvsssNormal,60, rvbdLeftToRight)

Re: Table.Cells[j,i].AddNL

Posted: Mon Jun 26, 2023 1:09 pm
by Sergey Tkachenko
If you want the whole paragraph to be LTR or RTL, you need to assign BiDiMode of this paragraph's style.

Re: Table.Cells[j,i].AddNL

Posted: Mon Jun 26, 2023 1:19 pm
by fara2000
It works!!!
Than you. You are wonderful as always :D

Re: Table.Cells[j,i].AddNL

Posted: Mon Jun 26, 2023 2:04 pm
by fara2000
Please I still have a problem with my second question. As a matter of fact I need to read the Bottom Coordination of the document
not including empty area. Which Means I need to read the Bottom Coordination of the last Item in the document!!!!

It seems that Rich.RichViewEdit.DocumentHeight gives the whole Height page
Please Help

Re: Table.Cells[j,i].AddNL

Posted: Tue Jun 27, 2023 2:26 pm
by Sergey Tkachenko
Just subtract the bottom margin:

RV.DocumentHeight - RV.Style.StandardPixelsToPixels(RV.BottomMargin, RV.GetRealDocumentPixelsPerInch);

Re: Table.Cells[j,i].AddNL

Posted: Wed Jun 28, 2023 10:34 am
by fara2000
Hello
I attached a screenshot to explain my self.
As you can see, the last Line of the table(in SRichViewedit document) jumped to a new page. I don't want this to happen!
I could solve this problem by dragging down the sclruler at the left side, however What I really need is to do it by code so the SclRuler is adjusted exactly (without empty area) to include the escaping cells, or other Items which may come after.
I believe that knowing the physical height of the document (containing items without empty areas) is necessary for adjusting the BottomMargin of the page. I tried hard with no success
Please Help!!


Screenshot.jpg
Screenshot.jpg (84.36 KiB) Viewed 34489 times

Re: Table.Cells[j,i].AddNL

Posted: Wed Jun 28, 2023 12:08 pm
by Sergey Tkachenko
ScaleRichView ruler was designed to work only with cells for the active page (a page that contains the caret), like in Microsoft Word.
If you want to change it to allow resizing cells on all pages, it's a lot of work.