I tried 
           vertical_line_char=#179;
           horizontal_line_char=#196;
           angle_char=#192;
           crossing_char=#195;

which are the appropriate ASCII box characters... 

but it produces:
M: = 32:34
????Project1 = 18:30
?   ????File1 = 8:32
?   ????File2 = 7:43
?   ????File3 = 2:15
????Project2 = 14:04
    ????Component1 = 14:04
        ????Part1 = 5:32
        ????Part2 = 8:32

I also tried 
           vertical_line_char=chr(179);
           horizontal_line_char=chr(196);
           angle_char=chr(192);
           crossing_char=chr(195);

then I thought they must be Unicode.. so I tried the Unicode box characters:
           vertical_line_char=$2502;
           horizontal_line_char=$2500;
           angle_char=$2514;
           crossing_char=$251C;
but that gave me errors saying my constants were out of range and must be 
between 0 and 255... so if they have to be between 0 and 255, then they should 
be ACSII characters.. .so my original characters should have worked... so maybe 
it's just my text editor that's the problem...

is there a way we can maybe make it rich text format so the font can be 
specified?  Then I could specify Consolas which is a fixed width font and get 
the box characters from that... or maybe there is a way to do this with the ODT 
file.   

The ODT file opens in MS Word, but it doesn't draw the tree, it has text Like:
1
 1.1 M: 32:34
    1.1.1   Project1 18:30
     1.1.1.1     File1 8:32
     1.1.1.2     File2 7:43

Any ideas how to get box characters to work?

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Jean 
SUZINEAU via fpc-pascal
Sent: Friday, April 16, 2021 6:23 PM
To: fpc-pascal@lists.freepascal.org
Cc: Jean SUZINEAU <jean.suzin...@wanadoo.fr>
Subject: Re: [fpc-pascal] Directory Tree

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.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to