Multilevel numbering

General TRichView support forum. Please post your questions here
Post Reply
rvp
Posts: 3
Joined: Tue Nov 07, 2006 12:00 pm

Multilevel numbering

Post by rvp »

Hi,

I can't get the following to work:

Custom numbering

Code: Select all

A. 1st Level Text 1
  (1) 2nd Level Text 1
  (2) 2nd Level Text 2
     1. 3rd Level Text 1
     2. 3rd Level Text 2
        - 4th Level Text 1
   Additional text which is 1st Level Text 1 too
B. 1st Level Text 2
  Additional 1st Level Text 2
C. 1st Level Text 3
  - unordered List Item 1
  - unordered List Item 2
Any sample code available?
Many thanks in advance.
rvp
Posts: 3
Joined: Tue Nov 07, 2006 12:00 pm

Ups: Formatting lost

Post by rvp »

When switching the levels, the text schould be moved to right. The board software deletes spaces and tabs.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

const Indent = 24;
begin
  RVStyle1.ListStyles.Clear;
  // adding ListStyle[0] with 4 levels
  with RVStyle1.ListStyles.Add do begin
    with Levels.Add do begin
      ListType := rvlstUpperAlpha;
      FormatString := '%0:s.';
      LeftIndent := Indent*1;
      MarkerIndent := Indent*0;
      FirstIndent := 0;
      Font.Assign(RVStyle1.TextStyles[0]);
    end;
    with Levels.Add do begin
      ListType := rvlstDecimal;
      FormatString := '(%1:s)';
      LeftIndent := Indent*2;
      MarkerIndent := Indent*1;
      FirstIndent := 0;
      Font.Assign(RVStyle1.TextStyles[0]);
    end;
    with Levels.Add do begin
      ListType := rvlstDecimal;
      FormatString := '%2:s.';
      LeftIndent := Indent*3;
      MarkerIndent := Indent*2;
      FirstIndent := 0;
      Font.Assign(RVStyle1.TextStyles[0]);
    end;
    with Levels.Add do begin
      ListType := rvlstBullet;
      FormatString := '-';
      LeftIndent := Indent*4;
      MarkerIndent := Indent*3;
      FirstIndent := 0;
      Font.Assign(RVStyle1.TextStyles[0]);
    end;
  end;
  // adding ListStyle[1] with 1 level
  with RVStyle1.ListStyles.Add do begin
    with Levels.Add do begin
      ListType := rvlstBullet;
      FormatString := '-';
      LeftIndent := Indent*2;
      MarkerIndent := Indent*1;
      FirstIndent := 0;
      Font.Assign(RVStyle1.TextStyles[0]);      
    end;
  end;
  // Building doc
  with RichViewEdit1 do begin
    Clear;
    SetListMarkerInfo(-1, 0, 0, 1, 0, False);
    Add('1st Level Text 1', 0);
      SetListMarkerInfo(-1, 0, 1, 1, 0, False);
      Add('2nd Level Text 1', 0);
      SetListMarkerInfo(-1, 0, 1, 1, 0, False);
      Add('2nd Level Text 2', 0);
        SetListMarkerInfo(-1, 0, 2, 1, 0, False);
        Add('3rd Level Text 1', 0);
        SetListMarkerInfo(-1, 0, 2, 1, 0, False);
        Add('3rd Level Text 2', 0);
          SetListMarkerInfo(-1, 0, 3, 1, 0, False);
          Add('4th Level Text 1', 0);
    AddNL('"Additional text which is 1st Level Text 1 too"'+
     ' - not possible, this paragraph does not have numbering, '+
     'but the numbering below will be continued', 0, 0);
    SetListMarkerInfo(-1, 0, 0, 1, 0, False);
    Add('1st Level Text 2', 0);
    AddNL('"Additional 1st Level Text 2"'+
     ' - not possible, this paragraph does not have numbering, '+
     'but the numbering below will be continued', 0, 0);
    SetListMarkerInfo(-1, 0, 0, 1, 0, False);
    Add('1st Level Text 3', 0);
    SetListMarkerInfo(-1, 1, 0, 1, 0, False);
    Add('unordered List Item 1', 0);
    SetListMarkerInfo(-1, 1, 0, 1, 0, False);
    Add('unordered List Item 2', 0);
    Format;
  end;
end;
It's not necessary to create list styles in code, they can be created at designtime in the Object Inspector
rvp
Posts: 3
Joined: Tue Nov 07, 2006 12:00 pm

Works fine

Post by rvp »

Many Thanks for the fast response. :D :D
ianh
Posts: 4
Joined: Wed Apr 16, 2008 10:01 pm

Post by ianh »

I've used this example to get started using auto numbered headings. I'm also trying to find all of the top level headings and list them in a TMemo component.

The code I'm using is here:

Code: Select all

var
  n: Integer;
  AListNo, AListLevel, AStartFrom: Integer; AUseStartFrom: Boolean;

begin
  Memo1.Lines.Clear;

  for n := 1 to RichViewEdit1.ItemCount - 1 do
  begin

    if RichViewEdit1.GetItemStyle(n-1) = rvsListMarker then
    begin
      if RichViewEdit1.GetListMarkerInfo(n,AListNo,AListLevel, AStartFrom, AUseStartFrom) <> -1 then
      begin
        if AListLevel = 0 then
          Memo1.Lines.Add(RichViewEdit1.GetItemText(n));
      end;
    end;
  end;

GetItemText only fetches the text of the heading, how do get the level numbers as well?

Many thanks.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

uses RVMarker;
...
Counter := TRVMarkerItemInfo(RichViewEdit1.GetItem(n-1)).Counter
...
Post Reply