Page 1 of 1

Ident Bullet and Numbering

Posted: Sat Mar 22, 2008 1:43 pm
by AutoCorect
Hi,
I try to ident Bullet and Numbering, I see it's not posible direct with TSclRVRuler.

I set TSclRVRuler at OnRulerItemRelease event to do this:

Code: Select all

procedure TfrmMainChild.SclRVRuler1RulerItemRelease(Sender: TObject);
begin
if srvEditor.RichViewEdit.GetItemStyle(ItemCurr-1) = rvsListMarker then begin
   if srvEditor.RichViewEdit.Style.ListStyles[ItemCurr-1].Levels.Count>=0 then begin
      srvEditor.RichViewEdit.Style.ListStyles[ItemCurr-1].Levels[0].MarkerIndent:=Trunc(SclRVRuler1.FirstIndent) ;
      srvEditor.RichViewEdit.GetRootEditor.Reformat ;
   end ;
end ;
end ;
I set ItemCurr in the TSRichEviewEdit.OnCaretMove event to get the curent Item (where it's carret)

Code: Select all

procedure TfrmMainChild.srvEditorCaretMove(Sender: TObject);
begin
ItemCurr:=srvEditor.RichViewEdit.GetItemNo(srvEditor.RichViewEdit.GetCurrentItem) ;
end;
Code work ok if I put the bullet at the first line, end the next, but if at the first line a put the text the application give error "List Index Out of Bounds"

Have you some solutions for this problem.

Tanks.

Posted: Tue Mar 25, 2008 8:29 pm
by Sergey Tkachenko
Sorry for delay, I'll answer this question tomorrow.

Posted: Thu Mar 27, 2008 8:11 pm
by Sergey Tkachenko
Your code has several problems, the most important - you use incorrect value as an index of ListStyles.
The correct code is:

Code: Select all

procedure TForm3.SclRVRuler1RulerItemRelease(Sender: TObject);
var ItemNo, ListNo, LevelNo, StartFrom: Integer;
    UseStartFrom: Boolean;
    rve: TCustomRichViewEdit;
begin
  rve := SRichViewEdit1.RichViewEdit.TopLevelEditor;
  ItemNo := rve.CurItemNo;
  while not rve.IsParaStart(ItemNo) do
    dec(ItemNo);
  if rve.GetItemStyle(ItemNo) = rvsListMarker then begin
    rve.GetListMarkerInfo(ItemNo, ListNo, LevelNo, StartFrom, UseStartFrom);
   if (ListNo>=0) and (LevelNo>=0) then begin
      rve.Style.ListStyles[ListNo].Levels[LevelNo].MarkerIndent := Trunc(SclRVRuler1.FirstIndent) ;
      SRichViewEdit1.RichViewEdit.Reformat ;
   end;
  end;
end;
Note: this operation cannot be undone by undo command, but it does not do harm to undo buffer, so it is ok.

Posted: Thu Mar 27, 2008 8:29 pm
by AutoCorect
Tanks, work ok.

Question :

Code: Select all

var
rve: TCustomRichViewEdit; 
begin
rve := SRichViewEdit1.RichViewEdit.TopLevelEditor;
  ItemNo := rve.CurItemNo; 
If I assing my SRichViewEdit1 to rve the memory incres with a new document ?

Posted: Thu Mar 27, 2008 8:32 pm
by Sergey Tkachenko
No, rve becomes a pointer to the object, nothing is copied.
I added this variable only because writing "rve" in the subsequent code is shorter than "SRichViewEdit1.RichViewEdit.TopLevelEditor".