What are the "Code..." properties for? (afsHype

  • There are new properties for the property collection InsertPointAttr,
    HyperlinkTextAttr, BookmarkTextAttr and SPANObjectTextAttr:

    CodeOpeningText
    CodeClosingText
    CodeSingularText
    CodeTextColor

    They change the way the embedded start/end marks (TWPTextObj) are displayed. In WPTools 5 hyperlinks are not marked with afsHyperlink as it was in WPTools 4. Instead embedded marks are used, similar to those used in HTML. The Insertpoints are now also this start/end marks.
    New is the support for SPAN objects which apply a certain character style to text, just like the HTML code <span style=""> does. It is even possible to use <span class"stylename">!

    All this objects are usually hidden but can be displayed using the FormatOptions.

    When the objects are displayed, text is created, such as <a> and </a> for the closing object. This text creation is controlled by the mentioned properties. It is possible to use a string which displays some of the properties of the object:

    %N displays the name (for hyperlinks this is the title!)
    %S displays the property "Source" - hyperlinks use this as URL
    %Y is the style name (from <span class="">)
    %P is the params property

    If you need more features to create the text to be displayed use the event OnCodeGetText.

    If you need even more possibilities use TextObjGetTextEx which in fact allows to draw the text object yourself - see the code from the bookmark demo:

    Assign an OnwerDraw event

    Code
    procedure TForm1.WPRichText1TextObjGetTextEx(RefCanvas: TCanvas;  TXTObject: TWPTextObj; var PrintString: WideString; var WidthInPix,  HeightInPix: Integer; var PaintObject: TWPTextObj; Xres, YRes: Integer);begin  if not ShowBookmarkCodes.Checked then exit;  if TXTObject.ObjType=wpobjBookmark then  begin     // simple test:     // PrintString := '<------------>';     //     // If you set PaintObject to anything <> nil PrintString will be ignored!     // Here you can initialize an event for an owner draw object     PaintObject := TXTObject;     PaintObject.OnPaint := OnPaintObject;     WidthInPix := RefCanvas.TextWidth(TXTObject.Name+'<'+#32);  end;end;


    The OnwerDraw procedure

    The embedded codes are one of the powerful new features of WPTools 5. If you have any follow up questions please post here.

    Julian Ziersch