Compact coding

<< Click to Display Table of Contents >>

Navigation:  Programming > Create text under program control > Paragraphs > TParagraph API >

Compact coding

Please see the lit of API methods which return a reference to the TParagraph object which they are working on.

 

Since a reference is returned the call to this functions can be simply append after a '.'.

 

Example - create a footer with numbering:

 

WPRichText1.HeaderFooter.Get(wpIsFooter, wpraOnAllPages).Clear

    .SetProperty(WPAT_Alignment,Integer(paralCenter))

    .Append(wpoPageNumber)

    .Append('/')

    .Append(wpoNumPages);

WPRichText1.ReformatAll();

 

 

The initial reference to a TParagraph can be retrieved with, among others:

 

In TWPRTFDataBlock:

 

function Clear(Complete: Boolean = FALSE) : TParagraph;

function AppendPar(Par: TParagraph = nil; AfterPar: TParagraph = nil) : TParagraph;

property FirstPar: TParagraph;

property LastPar: TParagraph;

 

In TParagraph:

 

function AppendNewPar(DontCopyStyle: Boolean = FALSE): TParagraph;

function PrependNewPar(DontCopyStyle: Boolean = FALSE): TParagraph;

 

This functions set the text of a paragraph

 

  function SetText(const text: WideString; const A: TWPCharAttr) : TParagraph; overload;

  function SetText(const text: WideString; const aindex: Integer) : TParagraph; overload;

  function SetText(const text: WideString) : TParagraph; overload;

 

This functions append text and objects to a paragraph

 

  function Append(const s: string) : TParagraph; overload;

  function Append(SourcePar: TParagraph) : TParagraph; overload;

  function Append(obj: TWPTextObj; CharAttrIndex: Cardinal = 0) : TParagraph; overload;

  function Append(const s: string; const aindex: Integer) : TParagraph; overload;

 

  function Append(TextFieldType : TWPTextFieldType; CharAttrIndex: Cardinal = 0) : TParagraph; overload;

  function Append(SingleObjType : TWPTextObjType; ObjName : String; CharAttrIndex: Cardinal = 0) : TParagraph; overload;

  function Append(PairObjType : TWPTextObjType; IsClosing : Boolean; ObjName : String; ObjSource : String; CharAttrIndex: Cardinal = 0) : TParagraph; overload;

 

This functions change a property - they work like ASet()

 

  function SetProperty(WPAT_Code: Byte; Value: Integer) : TParagraph;

  function SetColorProperty(WPAT_Code: Byte; Value: TColor) : TParagraph;

  function SetStringProperty(WPAT_Code: Byte; const Value: String) : TParagraph;

 

This function protects the paragraph

 

  function IsParProtected(value : Integer = 1) : TParagraph;

 

 

Example

 

 WPRichText1.BodyText.LastPar

   .SetText('Line 1')

        .SetProperty(WPAT_CharStyleON,WPSTY_BOLD)

        .SetProperty(WPAT_CharStyleMASK,WPSTY_BOLD)

   .AppendNewPar(true).SetText('Line 2')

        .SetProperty(WPAT_IndentLeft, 720)

   .AppendNewPar(true).SetText('Line 3')

        .SetColorProperty(WPAT_FGColor, clRed)

        .SetProperty(WPAT_CharStyleON,WPSTY_UNDERLINE)

        .SetProperty(WPAT_CharStyleMASK,WPSTY_UNDERLINE);

 

clip0016