[fpc-pascal] Directory Tree
Jean SUZINEAU
jean.suzineau at wanadoo.fr
Sat Apr 17 00:22:50 CEST 2021
Le 15/04/2021 à 20:16, James Richters via fpc-pascal a écrit :
> It doesn't have to be a PDF, it could be an image file, or even a text
> file...maybe I can just make a text file of the output and use box
> characters to draw the tree. It seems like I should be able to get the
> branches of the treedata somehow and just do a writeln to a file with
> the right formatting.
I have added a text rendering of the tree, it's saved in a text file
Result.txt.
The rendering code is in unit uFileVirtualTree, function
ThVirtualStringTree.render_as_text. It's called in ufFileVirtualTree in
procedure TfFileVirtualTree.bGetCheckedClick:
m.Lines .Text:= slResult.Text+#13#10+hvstResult.render_as_text;
m.Lines .SaveToFile('Result.txt');
In function ThVirtualStringTree.render_as_text I used 3 constants for
the chars used for drawing the tree outline:
vertical_line_char='|';
horizontal_line_char='-';
angle_char='*';
crossing_char='L';
You can tune this to your needs.
I have added to a rendering as numbered list in an odt file, the text
file format for Libre Office and Open Office. The "template"
FileTree.odt is duplicated with a temp name in the user temp directory,
and opened in the software register in windows for opening odt files by
the function OpenDocument() of Lazarus. Depending on your installation
it can be open in Libre Office/OpenOffice or in MS Word (sometimes the
rendering is not perfect in Word).
Before recompiling the project, you will need to open first in Lazarus
the package pascal_o_r_mapping\02_Units\OD_DelphiReportEngine_Units.lpk
in order to make Lazarus know where it is.
If for some reason you can't load this package, you can remove it from
the dependency panel of the project inspector, and in unit
ufFileVirtualTree, comment out in the use clause the unit
uFileVirtualTree_odt, and comment out in procedure
TfFileVirtualTree.bGetCheckedClick the line:
OpenDocument( FileVirtualTree_odt( 'FileTree.odt', hvstResult));
I've considered making a screenshot of virtual tree component but if the
whole opened tree doesn't fit in the screen it will not work.
More information about the fpc-pascal
mailing list