|
<< Click to display table of contents >> Functions from RVSVGPath Unit |
Unit [VCL / FMX] RVSVGPath / fmxRVSVGPath.
This unit contains function that work with TRVSVGPathsDocObject object in rv.DocObjects.
These objects are not used in TRichView. They are used in ReportWorkshop.
function GetSVGPathDocObject(rv: TCustomRichView;
AllowCreate: Boolean): TRVSVGPathsDocObject;
function GetSVGCollectionFromDocObject(
rv: TCustomRichView): TRVSVGPathCollection;
GetSVGPathDocObject returns the object of type TRVSVGPathsDocObject from rv.DocObjects.
If rv.DocObjects has several TRVSVGPathsDocObject items, the function returns the first of them. Normally, the collection must have no more than one GetSVGPathDocObject item. If the object is not found then: if AllowCreate = True, a new object is added to rv.DocObjects and returned; otherwise, the function returns nil.
GetSVGCollectionFromDocObject returns the path property from object of type TRVSVGPathsDocObject from rv.DocObjects.
If rv.DocObjects has several TRVSVGPathsDocObject items, the function returns the property of first of them. If the object is not found, the function returns nil.
This example adds two SVG images (named 'lamp' and 'sailing') to the collection for storing in MyRichView.DocObject.
If you use RichViewActions, the best place for this code is TrvActionNew.OnNew event (it occurs when creating a new empty document).
const
LampStr = 'M480-80q-26 0-47-12.5T400-126q-33 0-56.5-23.5T320-206v-142q-59-39-'+
'94.5-103T190-590q0-121 84.5-205.5T480-880q121 0 205.5 84.5T770-590q0 77-35.5'+
' 140T640-348v142q0 33-23.5 56.5T560-126q-12 21-33 33.5T480-80Zm-80-126h160v-'+
'36H400v36Zm0-76h160v-38H400v38Zm110-118v-108l88-88-42-42-76 76-76-76-42 42 88 '+
'88v108h60Z';
SailStr = 'm120-420 320-460v460H120Zm380 0q12-28 26-98t14-142q0-72-13.5-148T500-'+
'920q61 18 121.5 67t109 117q48.5 68 79 149.5T840-420H500ZM360-200q-36 0-67-'+
'17t-53-43q-14 15-30.5 28T173-211q-35-26-59.5-64.5T80-360h800q-9 46-33.5 84.'+
'5T787-211q-20-8-36.5-21T720-260q-23 26-53.5 43T600-200q-36 0-67-17t-53-43q-'+
'22 26-53 43t-67 17ZM80-40v-80h40q32 0 62.5-10t57.5-30q27 20 57.5 29.5T360-'+
'121q32 0 62-9.5t58-29.5q27 20 57.5 29.5T600-121q32 0 62-9.5t58-29.5q28 20 58'+
' 30t62 10h40v80h-40q-31 0-61-7.5T720-70q-29 15-59 22.5T600-40q-31 0-61-7.5T480-'+
'70q-29 15-59 22.5T360-40q-31 0-61-7.5T240-70q-29 15-59 22.5T120-40H80Z';
var
DocObject: TRVSVGPathsDocObject;
begin
DocObject := GetSVGPathDocObject(MyRichView, True);
with DocObject.Paths.Add do
begin
Path := LampStr;
Name := 'lamp';
ViewBox.SetValues(0, -960, 960, 0);
end;
with DocObject.Paths.Add do
begin
Path := SailStr;
Name := 'sailing';
ViewBox.SetValues(0, -960, 960, 0);
end;
end;
end;