Position of the bullet

General TRichView support forum. Please post your questions here
Post Reply
Roliat
Posts: 21
Joined: Wed Jul 27, 2011 4:12 pm

Position of the bullet

Post by Roliat »

Hello!

I'm trying to switch from Delphi's TRichEdit to your TRichView component. I've a lot of RTF-Files which are stored in a Database. Now I'm trying to add the bullets for (un)ordered lists.

The bullets should be in exactly the same position as the paragraph text is. I saw that I have to use the "markerindent". But I don't know how to read out the paragraph's left indent. It's always 0 (zero). Here is the way, I created the intendation of the lists using the delphi-component.

Code: Select all

procedure TextEinruecken(Editor: TJvRichEdit; Ebene: Integer);
var
  fmt, fmt_current: TPARAFORMAT2;
begin
  ZeroMemory(@fmt, sizeof(TParaformat2));
  fmt.cbSize:=SizeOf(TParaformat2);
  fmt.dwMask:=PFM_NUMBERING or PFM_NUMBERINGSTART or PFM_NUMBERINGSTYLE or
              PFM_NUMBERINGTAB or PFM_STARTINDENT or PFN_BULLET or PFM_OFFSETINDENT
              or PFM_OFFSET;

  ZeroMemory(@fmt_current, sizeof(TParaformat2));
  fmt_current.cbSize:=SizeOf(TParaformat2);
  fmt_current.dwMask:=PFM_NUMBERING or PFM_NUMBERINGSTART or PFM_NUMBERINGSTYLE or
              PFM_NUMBERINGTAB or PFM_STARTINDENT or PFN_BULLET or PFM_OFFSETINDENT
              or PFM_OFFSET;

  if (Ebene = 1) then
    fmt.dxStartIndent:=0
  else if (ebene = 2) then
    fmt.dxStartIndent:=200
  else if (ebene > 2) then
    fmt.dxStartIndent:=200*(ebene-1);

  Editor.Perform(EM_GETPARAFORMAT, 0, lParam(@fmt_current));

  uTextEditorUtils.letzterEinzug:=fmt_current.dxStartIndent;

  Editor.Perform(EM_SETPARAFORMAT, 0, lParam(@fmt));
end;
This worked correctly and the corresponding rtf-files are stored in DB. When the caret enters - e.g. level ("ebene") 4 - and I press enter, the caret still is indented to level 4. If I press the bulletlist-button (using the code from the example), the bulled sticks to the left border.

How can I get the correct "markerindent"?

Thanks in advance
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In TRichView, for bulleted paragraphs, LeftIndent of paragraphs are ignored. The following properties of list level are used instead: Level.MarkerIndent --- defines the position of the bullet;
Level.LeftIndent --- defines the indentation of the text on the second and subsequent lines;
Level.FirstIndent --- Level.FirstIndent+Level.LeftIndent defines the indentation of the text on the first line.
You can see a scheme in the help file: http://www.trichview.com/help/idh_trvli ... ndent.html
Image

Note that by default all values are measured in pixels. You can use twips, see http://www.trichview.com/help/idh_trvstyle_units.html
Roliat
Posts: 21
Joined: Wed Jul 27, 2011 4:12 pm

Post by Roliat »

Hello and thanks for your answer.

As mentioned above, I know that I have to use Markerindent and that LeftIndent of the Paragraph is being ignored.

But I must be possible to transfer the leftIndent from the paragraph to the MarkerIndent of the List. But the Left-Indent-Para-Info is always 0. Now I wanted to use the current tab position (which is <> 0). But I can't figure out in which the tab-position the caret stands. Heres my code I tried to get the leftindent.

Code: Select all

function TfrmEditor.CreateBullets: Integer;
var
  ListStyle: TRVListInfo;
  ParaInfo: TParaInfo;
  fIndent, lIndent, mIndent: Integer;
begin

  ParaInfo := TParaInfo.Create(nil);
  try
    ParaInfo.Assign(RVStyle1.ParaStyles[Editor2.CurParaStyleNo]);
    fIndent:=ParaInfo.FirstIndent;
    lIndent:=ParaInfo.LeftIndent;
  finally
    ParaInfo.Free;
  end;

  // 1. Creating desired list style
  ListStyle := TRVListInfo.Create(nil);
  with ListStyle.Levels.Add do begin
    ListType  := rvlstBullet;
    Font.Name := 'Symbol';
    {$IFDEF RICHVIEWCBDEF3}
    Font.Charset := SYMBOL_CHARSET;
    {$ENDIF}
    Font.Size := StrToInt(cbSize.Text);
    MarkerIndent:= lIndent;
    FirstIndent := fIndent;
    LeftIndent  := lIndent;
  end;
  // 2. Searching for existing style with these properties. Creating it, if not found
  Result := RVStyle1.ListStyles.FindSuchStyle(ListStyle, True);
  ListStyle.Free;
end;
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

ParaInfo.LeftIndent may be zero or non-zero, it depends on how this document is created. Since it is not used for bulleted paragraph, it may have any value.

If tab positions are explicitly defined for this paragraph, they are in ParaStyle.Tabs.
Note that in TRichView, there is no automatic tab after a bullet.
Post Reply