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
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
procedure TForm1.OnPaintObject(Sender : TWPTextObj;
OutCanvas : TCanvas;
XRes, YRes : Integer;
X, Y, W, H, BASE: Integer );
var s : string;
begin
OutCanvas.Rectangle(x,y,x+w,y+h);
OutCanvas.MoveTo(x+w,y+1);
OutCanvas.LineTo(x+w,y+h);
OutCanvas.LineTo(x+1,y+h);
if wpobjIsClosing in Sender.Mode then
s := '>' + Sender.Name
else s := Sender.Name + '<';
OutCanvas.TextOut(x+2,y+BASE,s);
end;
Alles anzeigen
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