Table.Cells[j,i].AddNL

General TRichView support forum. Please post your questions here
Post Reply
fara2000
Posts: 39
Joined: Mon Sep 07, 2015 5:59 pm

Table.Cells[j,i].AddNL

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

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

Post 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.
fara2000
Posts: 39
Joined: Mon Sep 07, 2015 5:59 pm

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

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

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

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

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

Post by Sergey Tkachenko »

If you want the whole paragraph to be LTR or RTL, you need to assign BiDiMode of this paragraph's style.
fara2000
Posts: 39
Joined: Mon Sep 07, 2015 5:59 pm

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

Post by fara2000 »

It works!!!
Than you. You are wonderful as always :D
fara2000
Posts: 39
Joined: Mon Sep 07, 2015 5:59 pm

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

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

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

Post by Sergey Tkachenko »

Just subtract the bottom margin:

RV.DocumentHeight - RV.Style.StandardPixelsToPixels(RV.BottomMargin, RV.GetRealDocumentPixelsPerInch);
fara2000
Posts: 39
Joined: Mon Sep 07, 2015 5:59 pm

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

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

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

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