Fix for UBSan build
[platform/upstream/doxygen.git] / src / ftvhelp.cpp
1 /******************************************************************************
2  * ftvhelp.cpp,v 1.0 2000/09/06 16:09:00
3  *
4  * Copyright (C) 1997-2012 by Dimitri van Heesch.
5  *
6  * Permission to use, copy, modify, and distribute this software and its
7  * documentation under the terms of the GNU General Public License is hereby 
8  * granted. No representations are made about the suitability of this software 
9  * for any purpose. It is provided "as is" without express or implied warranty.
10  * See the GNU General Public License for more details.
11  *
12  * Documents produced by Doxygen are derivative works derived from the
13  * input used in their production; they are not affected by this license.
14  *
15  * Original version contributed by Kenney Wong <kwong@ea.com>
16  * Modified by Dimitri van Heesch
17  *
18  * Folder Tree View for offline help on browsers that do not support HTML Help.
19  */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <qlist.h>
24 #include <qdict.h>
25 #include <qfileinfo.h>
26
27 #include "ftvhelp.h"
28 #include "config.h"
29 #include "message.h"
30 #include "doxygen.h"
31 #include "language.h"
32 #include "htmlgen.h"
33 #include "layout.h"
34 #include "pagedef.h"
35 #include "docparser.h"
36 #include "htmldocvisitor.h"
37
38 #define MAX_INDENT 1024
39
40
41 static const char navtree_script[]=
42 #include "navtree_js.h"
43 ;
44
45 static const char resize_script[]=
46 #include "resize_js.h"
47 ;
48
49 static const char navtree_css[]=
50 #include "navtree_css.h"
51 ;
52
53 static unsigned char blank_png[352] =
54 {
55     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
56     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
57     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
58     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
59     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
60     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
61     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
62     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
63     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
64     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
65     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
66     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
67     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
68     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
69     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
70     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
71     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
72     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
73     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
74     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
75     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
76     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
77 };
78
79 static unsigned char folderopen_png[528] =
80 {
81   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
82   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
83   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
84   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
85   255,255,255,255,255,255,228,195,193,190,187,218,255,255,255,255,255,255,255,255,255,255,255,255,
86   255,255,255,255,255,255,195,215,221,225,225,178,176,176,175,176,178,180,255,255,255,255,255,255,
87   255,255,255,255,255,255,189,206,215,219,226,220,214,212,207,204,200,176,255,255,255,255,255,255,
88   255,255,255,255,168,154,153,153,152,152,151,149,150,150,149,147,146,145,145,167,255,255,255,255,
89   255,255,255,255,146,187,187,188,187,187,185,183,183,182,179,178,175,173,174,145,255,255,255,255,
90   255,255,255,255,146,180,182,182,181,181,179,178,176,174,173,171,169,170,168,144,255,255,255,255,
91   255,255,255,255,144,173,176,176,177,175,175,174,171,170,168,168,166,166,164,143,255,255,255,255,
92   255,255,255,255,142,168,170,171,170,170,169,168,166,166,165,163,163,164,162,142,255,255,255,255,
93   255,255,255,255,141,162,166,164,164,165,163,163,161,161,161,161,161,160,159,141,255,255,255,255,
94   255,255,255,255,138,157,159,159,158,158,158,157,157,157,157,156,157,157,155,138,255,255,255,255,
95   255,255,255,255,137,154,153,154,154,153,154,154,154,153,154,154,154,154,154,137,255,255,255,255,
96   255,255,255,255,137,154,154,154,154,154,154,154,153,154,154,153,153,153,154,137,255,255,255,255,
97   255,255,255,255,137,125,125,125,125,124,125,124,124,125,124,124,125,124,125,138,255,255,255,255,
98   255,255,255,255,212,209,204,199,193,190,186,183,180,181,185,188,192,197,202,203,255,255,255,255,
99   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
100   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
101   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
102   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
103 };
104
105 static unsigned char folderopen_a_png[528] =
106 {
107     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
108     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
109     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
110     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
111     0,  0,  0,  0,  0,  0,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
112     0,  0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,
113     0,  0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,
114     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
115     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
116     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
117     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
118     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
119     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
120     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
121     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
122     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
123     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
124     0,  0,  0,  0,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,  0,  0,  0,  0,
125     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
126     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
127     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
128     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
129 };
130
131 static unsigned char folderclosed_png[528] =
132 {
133   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
134   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
135   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
136   255,255,255,255,255,197,155,155,155,155,196,255,255,255,255,255,255,255,255,255,255,255,255,255,
137   255,255,255,255,255,155,191,191,191,192,155,255,255,255,255,255,255,255,255,255,255,255,255,255,
138   255,255,255,255,168,144,180,180,181,180,145,145,146,145,146,146,146,146,145,167,255,255,255,255,
139   255,255,255,255,147,225,226,226,225,226,225,221,221,219,215,214,212,211,213,145,255,255,255,255,
140   255,255,255,255,147,212,211,211,210,211,210,205,206,205,201,201,199,196,201,145,255,255,255,255,
141   255,255,255,255,146,204,203,204,203,203,202,200,200,197,197,196,195,194,196,145,255,255,255,255,
142   255,255,255,255,146,202,200,201,201,200,199,198,198,195,194,194,193,192,194,145,255,255,255,255,
143   255,255,255,255,145,200,196,196,196,195,195,193,192,192,190,189,189,189,191,143,255,255,255,255,
144   255,255,255,255,143,192,191,190,190,189,189,188,186,187,186,185,185,185,187,142,255,255,255,255,
145   255,255,255,255,142,186,184,183,182,183,182,183,180,181,181,181,181,181,182,141,255,255,255,255,
146   255,255,255,255,138,177,175,176,176,177,177,176,175,174,175,175,175,174,176,138,255,255,255,255,
147   255,255,255,255,138,173,169,170,168,170,169,170,170,169,171,171,171,171,174,137,255,255,255,255,
148   255,255,255,255,138,166,163,163,162,162,162,162,162,162,164,163,163,163,166,137,255,255,255,255,
149   255,255,255,255,137,124,124,124,125,124,124,124,125,125,124,124,125,124,125,138,255,255,255,255,
150   255,255,255,255,231,231,228,225,222,220,218,216,214,215,217,219,221,224,227,226,255,255,255,255,
151   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
152   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
153   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
154   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
155 };
156
157 static unsigned char folderclosed_a_png[528] =
158 {
159     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
160     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
161     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
162     0,  0,  0,  0,  0,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
163     0,  0,  0,  0,  0,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
164     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
165     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
166     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
167     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
168     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
169     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
170     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
171     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
172     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
173     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
174     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
175     0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,
176     0,  0,  0,  0,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,  0,  0,  0,  0,
177     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
178     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
179     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
180     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
181 };
182
183 static unsigned char doc_png[528] =
184 {
185   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
186   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
187   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
188   255,255,255,255,255,218,214,208,208,204,191,179,190,197,209,231,255,255,255,255,255,255,255,255,
189   255,255,255,255,255,195,224,226,226,222,214,204,181,203,229,188,225,255,255,255,255,255,255,255,
190   255,255,255,255,255,198,226,228,227,227,224,215,203,180,252,229,184,224,255,255,255,255,255,255,
191   255,255,255,255,255,198,229,230,229,229,228,224,214,154,252,252,229,187,235,255,255,255,255,255,
192   255,255,255,255,255,198,232,233,233,232,231,230,223,176,154,144,165,177,216,255,255,255,255,255,
193   255,255,255,255,255,198,236,236,216,226,238,219,232,225,209,190,189,166,193,255,255,255,255,255,
194   255,255,255,255,255,198,239,240,178,177,230,175,169,184,188,219,208,189,187,255,255,255,255,255,
195   255,255,255,255,255,198,241,242,240,218,237,236,240,235,241,244,221,208,182,255,255,255,255,255,
196   255,255,255,255,255,198,243,243,188,154,183,158,166,140,185,198,231,219,177,255,255,255,255,255,
197   255,255,255,255,255,198,243,245,248,228,241,241,226,249,237,227,239,232,177,255,255,255,255,255,
198   255,255,255,255,255,198,244,246,213,172,163,149,171,200,167,149,242,239,177,255,255,255,255,255,
199   255,255,255,255,255,198,249,248,240,218,237,236,240,235,241,244,244,242,177,255,255,255,255,255,
200   255,255,255,255,255,198,249,251,188,155,184,158,166,140,185,198,246,244,177,255,255,255,255,255,
201   255,255,255,255,255,198,251,253,248,228,241,241,226,249,237,227,249,246,177,255,255,255,255,255,
202   255,255,255,255,255,196,253,252,252,252,252,251,251,250,250,249,249,248,175,255,255,255,255,255,
203   255,255,255,255,255,194, 64, 30, 37, 37, 37, 37, 37, 37, 37, 37, 30, 64,188,255,255,255,255,255,
204   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
205   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
206   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
207 };
208
209 static unsigned char doc_a_png[528] =
210 {
211     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
212     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
213     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
214     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,  0,  0,
215     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,  0,
216     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,  0,
217     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
218     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
219     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
220     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
221     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
222     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
223     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
224     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
225     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
226     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
227     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
228     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
229     0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  0,  0,  0,  0,  0,
230     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
231     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
232     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
233 };
234
235 static unsigned char module_png[528] =
236 {
237   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
238   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
239   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
240   255,255,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,255,
241   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
242   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
243   255,128,128,255,255,255,193,128,136,255,255,255,217,128,128,255,255,255,255,255,255,255,255,255,
244   255,128,128,255,255,255,213,128,170,255,255,255,217,128,128,255,255,255,255,255,255,255,255,255,
245   255,128,128,255,255,247,247,128,196,255,247,255,217,128,128,255,255,255,255,255,255,255,255,255,
246   255,128,128,255,255,213,255,153,230,255,213,255,217,128,128,255,255,255,255,255,255,255,255,255,
247   255,128,128,255,255,187,255,187,255,230,204,255,217,128,128,255,255,255,255,255,255,255,255,255,
248   255,128,128,255,255,153,255,247,255,196,204,255,217,128,128,255,255,255,255,255,255,255,255,255,
249   255,128,128,255,255,128,247,255,255,170,204,255,217,128,128,255,255,255,255,255,255,255,255,255,
250   255,128,128,255,255,128,213,255,255,136,204,255,217,128,128,255,255,255,255,255,255,255,255,255,
251   255,128,128,255,255,128,187,255,230,138,204,255,217,128,128,255,255,255,255,255,255,255,255,255,
252   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
253   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
254   255,255,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,255,
255   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
256   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
257   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
258   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
259 };
260
261 static unsigned char namespace_png[528] =
262 {
263   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
264   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
265   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
266   255,255,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,255,
267   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
268   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
269   255,128,128,157,255,255,226,128,128,198,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
270   255,128,128,157,255,255,255,189,128,198,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
271   255,128,128,157,255,255,255,244,141,198,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
272   255,128,128,157,255,255,255,255,220,198,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
273   255,128,128,157,255,255,226,255,255,220,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
274   255,128,128,157,255,255,198,220,255,255,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
275   255,128,128,157,255,255,198,141,250,255,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
276   255,128,128,157,255,255,198,128,198,255,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
277   255,128,128,157,255,255,198,128,128,226,255,255,157,128,128,255,255,255,255,255,255,255,255,255,
278   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
279   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
280   255,255,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,255,
281   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
282   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
283   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
284   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
285 };
286
287 static unsigned char class_png[528] =
288 {
289   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
290   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
291   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
292   255,255,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,255,
293   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
294   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
295   255,128,128,128,128,187,247,255,255,230,170,128,128,128,128,255,255,255,255,255,255,255,255,255,
296   255,128,128,128,196,255,255,255,255,255,255,170,128,128,128,255,255,255,255,255,255,255,255,255,
297   255,128,128,145,255,255,230,128,136,230,247,179,128,128,128,255,255,255,255,255,255,255,255,255,
298   255,128,128,179,255,255,170,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
299   255,128,128,179,255,255,162,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
300   255,128,128,179,255,255,170,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
301   255,128,128,145,255,255,221,128,128,221,255,179,128,128,128,255,255,255,255,255,255,255,255,255,
302   255,128,128,128,196,255,255,255,255,255,255,187,128,128,128,255,255,255,255,255,255,255,255,255,
303   255,128,128,128,128,187,247,255,255,240,179,128,128,128,128,255,255,255,255,255,255,255,255,255,
304   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
305   255,128,128,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,
306   255,255,128,128,128,128,128,128,128,128,128,128,128,128,255,255,255,255,255,255,255,255,255,255,
307   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
308   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
309   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
310   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
311 };
312
313
314 static unsigned char letter_a_png[528] =
315 {
316     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
317     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
318     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
319     0,  0, 60,156,204,204,204,204,204,204,204,204,156, 51,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
320     0, 78,255,255,255,255,255,255,255,255,255,255,255,252, 72,  0,  0,  0,  0,  0,  0,  0,  0,  0,
321     0,210,255,255,255,255,255,255,255,255,255,255,255,255,207,  0,  0,  0,  0,  0,  0,  0,  0,  0,
322     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
323     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
324     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
325     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
326     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
327     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
328     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
329     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
330     0,240,255,255,255,255,255,255,255,255,255,255,255,255,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,
331     0,222,255,255,255,255,255,255,255,255,255,255,255,255,219,  0,  0,  0,  0,  0,  0,  0,  0,  0,
332     0,111,255,255,255,255,255,255,255,255,255,255,255,255, 99,  0,  0,  0,  0,  0,  0,  0,  0,  0,
333     0,  0, 99,198,204,204,204,204,204,204,204,204,195, 90,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
334     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
335     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
336     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
337     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
338 };
339
340
341 static unsigned char arrow_right_png[352] =
342 {
343   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
344   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
345   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
346   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
347   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
348   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
349   255,255,255,152,152,255,255,255,255,255,255,255,255,255,255,255,
350   255,255,255,152,152,152,152,255,255,255,255,255,255,255,255,255,
351   255,255,255,152,152,152,152,152,255,255,255,255,255,255,255,255,
352   255,255,255,152,152,152,152,152,152,152,255,255,255,255,255,255,
353   255,255,255,152,152,152,152,152,152,152,152,255,255,255,255,255,
354   255,255,255,152,152,152,152,152,152,152,255,255,255,255,255,255,
355   255,255,255,152,152,152,152,152,255,255,255,255,255,255,255,255,
356   255,255,255,152,152,152,152,255,255,255,255,255,255,255,255,255,
357   255,255,255,152,152,255,255,255,255,255,255,255,255,255,255,255,
358   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
359   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
360   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
361   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
362   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
363   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
364   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
365 };
366
367 static unsigned char arrow_right_a_png[352] =
368 {
369     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
370     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
371     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
372     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
373     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
374     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
375     0,  0,  0,223, 75,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
376     0,  0,  0,255,255,176, 33,  0,  0,  0,  0,  0,  0,  0,  0,  0,
377     0,  0,  0,255,255,255,248,117,  0,  0,  0,  0,  0,  0,  0,  0,
378     0,  0,  0,255,255,255,255,255,211, 60,  0,  0,  0,  0,  0,  0,
379     0,  0,  0,255,255,255,255,255,255,255, 77,  0,  0,  0,  0,  0,
380     0,  0,  0,255,255,255,255,255,211, 60,  0,  0,  0,  0,  0,  0,
381     0,  0,  0,255,255,255,248,117,  0,  0,  0,  0,  0,  0,  0,  0,
382     0,  0,  0,255,255,176, 33,  0,  0,  0,  0,  0,  0,  0,  0,  0,
383     0,  0,  0,223, 75,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
384     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
385     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
386     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
387     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
388     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
389     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
390     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
391 };
392
393 static unsigned char arrow_down_png[352] =
394 {
395   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
396   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
397   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
398   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
399   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
400   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
401   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
402   255,255,255,152,152,152,152,152,152,152,152,152,255,255,255,255,
403   255,255,255,152,152,152,152,152,152,152,152,152,255,255,255,255,
404   255,255,255,255,152,152,152,152,152,152,152,255,255,255,255,255,
405   255,255,255,255,152,152,152,152,152,152,152,255,255,255,255,255,
406   255,255,255,255,255,152,152,152,152,152,255,255,255,255,255,255,
407   255,255,255,255,255,255,152,152,152,255,255,255,255,255,255,255,
408   255,255,255,255,255,255,152,152,152,255,255,255,255,255,255,255,
409   255,255,255,255,255,255,255,152,255,255,255,255,255,255,255,255,
410   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
411   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
412   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
413   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
414   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
415   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
416   255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
417 };
418
419 static unsigned char arrow_down_a_png[352] =
420 {
421     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
422     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
423     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
424     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
425     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
426     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
427     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
428     0,  0,  0,231,255,255,255,255,255,255,255,216,  0,  0,  0,  0,
429     0,  0,  0, 87,255,255,255,255,255,255,255, 65,  0,  0,  0,  0,
430     0,  0,  0,  0,186,255,255,255,255,255,164,  0,  0,  0,  0,  0,
431     0,  0,  0,  0, 38,251,255,255,255,241, 25,  0,  0,  0,  0,  0,
432     0,  0,  0,  0,  0,127,255,255,255,107,  0,  0,  0,  0,  0,  0,
433     0,  0,  0,  0,  0,  0,221,255,204,  0,  0,  0,  0,  0,  0,  0,
434     0,  0,  0,  0,  0,  0, 72,253, 52,  0,  0,  0,  0,  0,  0,  0,
435     0,  0,  0,  0,  0,  0,  0, 77,  0,  0,  0,  0,  0,  0,  0,  0,
436     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
437     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
438     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
439     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
440     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
441     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
442     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
443 };
444
445 #define SPLITBAR_LINE 170,242,224,202,183,170
446 #define SPLITBAR_BLOCK2  SPLITBAR_LINE    , SPLITBAR_LINE 
447 #define SPLITBAR_BLOCK4  SPLITBAR_BLOCK2  , SPLITBAR_BLOCK2 
448 #define SPLITBAR_BLOCK8  SPLITBAR_BLOCK4  , SPLITBAR_BLOCK4 
449 #define SPLITBAR_BLOCK16 SPLITBAR_BLOCK8  , SPLITBAR_BLOCK8 
450 #define SPLITBAR_BLOCK32 SPLITBAR_BLOCK16 , SPLITBAR_BLOCK16
451
452 #define SPLITBAR_ALTLINE1 170,242,170,202,170,170
453 #define SPLITBAR_ALTLINE2 170,243,224,255,183,255
454 #define SPLITBAR_ALTBLOCK2 SPLITBAR_ALTLINE1  , SPLITBAR_ALTLINE2 
455 #define SPLITBAR_ALTBLOCK4 SPLITBAR_ALTBLOCK2 , SPLITBAR_ALTBLOCK2 
456 #define SPLITBAR_ALTBLOCK8 SPLITBAR_ALTBLOCK4 , SPLITBAR_ALTBLOCK4
457
458 static unsigned char splitbar_png[32*32*6] =
459 {
460   SPLITBAR_BLOCK32,
461   SPLITBAR_BLOCK32,
462   SPLITBAR_BLOCK32,
463   SPLITBAR_BLOCK32,
464   SPLITBAR_BLOCK32,
465   SPLITBAR_BLOCK32,
466   SPLITBAR_BLOCK32,
467   SPLITBAR_BLOCK32,
468   SPLITBAR_BLOCK32,
469   SPLITBAR_BLOCK32,
470   SPLITBAR_BLOCK32,
471   SPLITBAR_BLOCK32,
472   SPLITBAR_BLOCK32,
473   SPLITBAR_BLOCK32,
474   SPLITBAR_BLOCK32,
475   SPLITBAR_BLOCK8,
476   SPLITBAR_BLOCK8,
477   SPLITBAR_ALTBLOCK8,
478   SPLITBAR_BLOCK8,
479   SPLITBAR_BLOCK32,
480   SPLITBAR_BLOCK32,
481   SPLITBAR_BLOCK32,
482   SPLITBAR_BLOCK32,
483   SPLITBAR_BLOCK32,
484   SPLITBAR_BLOCK32,
485   SPLITBAR_BLOCK32,
486   SPLITBAR_BLOCK32,
487   SPLITBAR_BLOCK32,
488   SPLITBAR_BLOCK32,
489   SPLITBAR_BLOCK32,
490   SPLITBAR_BLOCK32,
491   SPLITBAR_BLOCK32,
492   SPLITBAR_BLOCK32,
493   SPLITBAR_BLOCK32,
494   SPLITBAR_BLOCK32
495 };
496
497 struct FTVImageInfo
498 {
499   const char *alt;
500   const char *name;
501   const unsigned char *data;
502   //unsigned int len;
503   unsigned short width, height;
504 };
505
506 //extern FTVImageInfo image_info[];
507
508 #define FTVIMG_blank        0
509 #define FTVIMG_doc          1
510 #define FTVIMG_folderclosed 2
511 #define FTVIMG_folderopen   3
512 #define FTVIMG_lastnode     4
513 #define FTVIMG_link         5
514 #define FTVIMG_mlastnode    6
515 #define FTVIMG_mnode        7
516 #define FTVIMG_node         8
517 #define FTVIMG_plastnode    9
518 #define FTVIMG_pnode       10
519 #define FTVIMG_vertline    11
520 #define FTVIMG_ns          12
521 #define FTVIMG_cl          13
522 #define FTVIMG_mo          14
523
524 #define FTV_S(name) #name
525 #define FTV_ICON_FILE(name) "ftv2" FTV_S(name) ".png"
526 #define FTVIMG_INDEX(name) FTVIMG_ ## name
527 #define FTV_INFO(name) ( image_info[FTVIMG_INDEX(name)] )
528 #define FTV_IMGATTRIBS(name) \
529     "src=\"" FTV_ICON_FILE(name) "\" " \
530     "alt=\"" << FTV_INFO(name).alt << "\" " \
531     "width=\"" << FTV_INFO(name).width << "\" " \
532     "height=\"" << FTV_INFO(name).height << "\" "
533
534
535 static FTVImageInfo image_info[] =
536 {
537   { "&#160;", "ftv2blank.png",    0 /*ftv2blank_png*/        /*,174*/,16,22 },
538   { "*",  "ftv2doc.png",          0 /*ftv2doc_png*/          /*,255*/,24,22 },
539   { "+",  "ftv2folderclosed.png", 0 /*ftv2folderclosed_png*/ /*,259*/,24,22 },
540   { "-",  "ftv2folderopen.png",   0 /*ftv2folderopen_png*/   /*,261*/,24,22 },
541   { "\\", "ftv2lastnode.png",     0 /*ftv2lastnode_png*/     /*,233*/,16,22 },
542   { "-",  "ftv2link.png",         0 /*ftv2link_png*/         /*,358*/,24,22 },
543   { "\\", "ftv2mlastnode.png",    0 /*ftv2mlastnode_png*/    /*,160*/,16,22 },
544   { "o",  "ftv2mnode.png",        0 /*ftv2mnode_png*/        /*,194*/,16,22 },
545   { "o",  "ftv2node.png",         0 /*ftv2node_png*/         /*,235*/,16,22 },
546   { "\\", "ftv2plastnode.png",    0 /*ftv2plastnode_png*/    /*,165*/,16,22 },
547   { "o",  "ftv2pnode.png",        0 /*ftv2pnode_png*/        /*,200*/,16,22 },
548   { "|",  "ftv2vertline.png",     0 /*ftv2vertline_png*/     /*,229*/,16,22 },
549   { "N",  "ftv2ns.png",           0 /*ftv2vertline_png*/     /*,352*/,24,22 },
550   { "C",  "ftv2cl.png",           0 /*ftv2vertline_png*/     /*,352*/,24,22 },
551   { "M",  "ftv2mo.png",           0 /*ftv2vertline_png*/     /*,352*/,24,22 },
552   {   0,  0,                      0                          /*,  0*/, 0, 0 }
553 };
554
555 static ColoredImgDataItem ftv_image_data[] =
556 {
557   { "ftv2blank.png",        16,  22, blank_png,        blank_png          },
558   { "ftv2doc.png",          24,  22, doc_png,          doc_a_png          },
559   { "ftv2folderclosed.png", 24,  22, folderclosed_png, folderclosed_a_png },
560   { "ftv2folderopen.png",   24,  22, folderopen_png,   folderopen_a_png   },
561   { "ftv2ns.png",           24,  22, namespace_png,    letter_a_png       },
562   { "ftv2mo.png",           24,  22, module_png,       letter_a_png       },
563   { "ftv2cl.png",           24,  22, class_png,        letter_a_png       },
564   { "ftv2lastnode.png",     16,  22, blank_png,        blank_png          },
565   { "ftv2link.png",         24,  22, doc_png,          doc_a_png          },
566   { "ftv2mlastnode.png",    16,  22, arrow_down_png,   arrow_down_a_png   },
567   { "ftv2mnode.png",        16,  22, arrow_down_png,   arrow_down_a_png   },
568   { "ftv2node.png",         16,  22, blank_png,        blank_png          },
569   { "ftv2plastnode.png",    16,  22, arrow_right_png,  arrow_right_a_png  },
570   { "ftv2pnode.png",        16,  22, arrow_right_png,  arrow_right_a_png  },
571   { "ftv2vertline.png",     16,  22, blank_png,        blank_png          },
572   { "ftv2splitbar.png",      6,1024, splitbar_png,     0                  },
573   { 0,                       0,   0, 0,                0                  }
574 };
575
576 static int folderId=1;
577
578 struct FTVNode
579 {
580   FTVNode(bool dir,const char *r,const char *f,const char *a,
581           const char *n,bool sepIndex,bool navIndex,Definition *df)
582     : isLast(TRUE), isDir(dir),ref(r),file(f),anchor(a),name(n), index(0),
583       parent(0), separateIndex(sepIndex), addToNavIndex(navIndex),
584       def(df) { children.setAutoDelete(TRUE); }
585   int computeTreeDepth(int level) const;
586   int numNodesAtLevel(int level,int maxLevel) const;
587   bool isLast;
588   bool isDir;
589   QCString ref;
590   QCString file;
591   QCString anchor;
592   QCString name;
593   int index;
594   QList<FTVNode> children;
595   FTVNode *parent;
596   bool separateIndex;
597   bool addToNavIndex;
598   Definition *def;
599 };
600
601 int FTVNode::computeTreeDepth(int level) const
602 {
603   int maxDepth=level;
604   QListIterator<FTVNode> li(children);
605   FTVNode *n;
606   for (;(n=li.current());++li)
607   {
608     if (n->children.count()>0)
609     {
610       int d = n->computeTreeDepth(level+1);
611       if (d>maxDepth) maxDepth=d;
612     }
613   }
614   return maxDepth;
615 }
616
617 int FTVNode::numNodesAtLevel(int level,int maxLevel) const
618 {
619   int num=0;
620   if (level<maxLevel)
621   {
622     num++; // this node
623     QListIterator<FTVNode> li(children);
624     FTVNode *n;
625     for (;(n=li.current());++li)
626     {
627       num+=n->numNodesAtLevel(level+1,maxLevel);
628     }
629   }
630   return num;
631 }
632
633 //----------------------------------------------------------------------------
634
635 /*! Constructs an ftv help object. 
636  *  The object has to be \link initialize() initialized\endlink before it can 
637  *  be used.
638  */
639 FTVHelp::FTVHelp(bool TLI) 
640 {
641   /* initial depth */
642   m_indentNodes = new QList<FTVNode>[MAX_INDENT];
643   m_indentNodes[0].setAutoDelete(TRUE);
644   m_indent=0;
645   m_topLevelIndex = TLI;
646 }
647
648 /*! Destroys the ftv help object. */
649 FTVHelp::~FTVHelp()
650 {
651   delete[] m_indentNodes;
652 }
653
654 /*! This will create a folder tree view table of contents file (tree.js).
655  *  \sa finalize()
656  */
657 void FTVHelp::initialize()
658 {
659 }
660
661 /*! Finalizes the FTV help. This will finish and close the
662  *  contents file (index.js).
663  *  \sa initialize()
664  */
665 void FTVHelp::finalize()
666 {
667   generateTreeView();
668 }
669
670 /*! Increase the level of the contents hierarchy. 
671  *  This will start a new sublist in contents file.
672  *  \sa decContentsDepth()
673  */
674 void FTVHelp::incContentsDepth()
675 {
676   //printf("incContentsDepth() indent=%d\n",m_indent);
677   m_indent++;
678   ASSERT(m_indent<MAX_INDENT);
679 }
680
681 /*! Decrease the level of the contents hierarchy.
682  *  This will end the current sublist.
683  *  \sa incContentsDepth()
684  */
685 void FTVHelp::decContentsDepth()
686 {
687   //printf("decContentsDepth() indent=%d\n",m_indent);
688   ASSERT(m_indent>0);
689   if (m_indent>0)
690   {
691     m_indent--;
692     QList<FTVNode> *nl = &m_indentNodes[m_indent];
693     FTVNode *parent = nl->getLast();
694     if (parent)
695     {
696       QList<FTVNode> *children = &m_indentNodes[m_indent+1];
697       while (!children->isEmpty())
698       {
699         parent->children.append(children->take(0));
700       }
701     }
702   }
703 }
704
705 /*! Add a list item to the contents file.
706  *  \param isDir TRUE if the item is a directory, FALSE if it is a text
707  *  \param ref  the URL of to the item.
708  *  \param file the file containing the definition of the item
709  *  \param anchor the anchor within the file.
710  *  \param name the name of the item.
711  *  \param separateIndex put the entries in a separate index file
712  *  \param addToNavIndex add this entry to the quick navigation index
713  *  \param def Definition corresponding to this entry
714  */
715 void FTVHelp::addContentsItem(bool isDir,
716                               const char *name,
717                               const char *ref,
718                               const char *file,
719                               const char *anchor,
720                               bool separateIndex,
721                               bool addToNavIndex,
722                               Definition *def
723                               )
724 {
725   //printf("%p: m_indent=%d addContentsItem(%s,%s,%s,%s)\n",this,m_indent,name,ref,file,anchor);
726   QList<FTVNode> *nl = &m_indentNodes[m_indent];
727   FTVNode *newNode = new FTVNode(isDir,ref,file,anchor,name,separateIndex,addToNavIndex,def);
728   if (!nl->isEmpty())
729   {
730     nl->getLast()->isLast=FALSE;
731   }
732   nl->append(newNode);
733   newNode->index = nl->count()-1;
734   if (m_indent>0)
735   {
736     QList<FTVNode> *pnl = &m_indentNodes[m_indent-1];
737     newNode->parent = pnl->getLast();
738   }
739   
740 }
741
742 static QCString node2URL(FTVNode *n,bool overruleFile=FALSE,bool srcLink=FALSE)
743 {
744   QCString url = n->file;
745   if (!url.isEmpty() && url.at(0)=='!')  // relative URL
746   {
747     // remove leading !
748     url = url.mid(1);
749   }
750   else if (!url.isEmpty() && url.at(0)=='^') // absolute URL
751   {
752     // skip, keep ^ in the output
753   }
754   else // local file (with optional anchor)
755   {
756     if (overruleFile && n->def && n->def->definitionType()==Definition::TypeFile)
757     {
758       FileDef *fd = (FileDef*)n->def;
759       if (srcLink)
760       {
761         url = fd->getSourceFileBase();
762       }
763       else
764       {
765         url = fd->getOutputFileBase();
766       }
767     }
768     url+=Doxygen::htmlFileExtension;
769     if (!n->anchor.isEmpty()) url+="#"+n->anchor;
770   }
771   return url;
772 }
773
774 QCString FTVHelp::generateIndentLabel(FTVNode *n,int level)
775 {
776   QCString result;
777   if (n->parent)
778   {
779     result=generateIndentLabel(n->parent,level+1);
780   }
781   result+=QCString().sprintf("%d_",n->index);
782   return result;
783 }
784
785 void FTVHelp::generateIndent(FTextStream &t, FTVNode *n,int level, bool opened)
786 {
787   if (n->parent)
788   {
789     generateIndent(t,n->parent,level+1,opened);
790   }
791   // from the root up to node n do...
792   if (level==0) // item before a dir or document
793   {
794     if (n->isLast)
795     {
796       if (n->isDir)
797       {
798         t << "<img id=\"arr_" << generateIndentLabel(n,0) 
799           << "\" ";
800         if (opened)
801           t << FTV_IMGATTRIBS(mlastnode);
802         else 
803           t << FTV_IMGATTRIBS(plastnode);
804         t << "onclick=\"toggleFolder('" 
805           << generateIndentLabel(n,0) 
806           << "')\"/>";
807       }
808       else
809       {
810         t << "<img " << FTV_IMGATTRIBS(lastnode) << "/>";
811       }
812     }
813     else
814     {
815       if (n->isDir)
816       {
817         t << "<img id=\"arr_" << generateIndentLabel(n,0)
818           << "\" ";
819         if (opened)
820           t << FTV_IMGATTRIBS(mnode);
821         else
822           t << FTV_IMGATTRIBS(pnode);
823         t << "onclick=\"toggleFolder('" 
824           << generateIndentLabel(n,0)
825           << "')\"/>";
826       }
827       else
828       {
829         t << "<img " << FTV_IMGATTRIBS(node) << "/>";
830       }
831     }
832   }
833   else // item at another level
834   {
835     if (n->isLast)
836     {
837       t << "<img " << FTV_IMGATTRIBS(blank) << "/>";
838     }
839     else
840     {
841       t << "<img " << FTV_IMGATTRIBS(vertline) << "/>";
842     }
843   }
844 }
845
846 void FTVHelp::generateLink(FTextStream &t,FTVNode *n)
847 {
848   //printf("FTVHelp::generateLink(ref=%s,file=%s,anchor=%s\n",
849   //    n->ref.data(),n->file.data(),n->anchor.data());
850   if (n->file.isEmpty()) // no link
851   {
852     t << "<b>" << convertToHtml(n->name) << "</b>";
853   }
854   else // link into other frame
855   {
856     if (!n->ref.isEmpty()) // link to entity imported via tag file
857     {
858       t << "<a class=\"elRef\" ";
859       t << externalLinkTarget() << externalRef("",n->ref,FALSE);
860     }
861     else // local link
862     {
863       t << "<a class=\"el\" ";
864     }
865     t << "href=\"";
866     t << externalRef("",n->ref,TRUE);
867     t << node2URL(n);
868     if (m_topLevelIndex)
869       t << "\" target=\"basefrm\">";
870     else
871       t << "\" target=\"_self\">";
872     t << convertToHtml(n->name);
873     t << "</a>";
874     if (!n->ref.isEmpty())
875     {
876       t << "&#160;[external]";
877     }
878   }
879 }
880
881 static void generateBriefDoc(FTextStream &t,Definition *def)
882 {
883   QCString brief = def->briefDescription(TRUE);
884   if (!brief.isEmpty())
885   {
886     DocNode *root = validatingParseDoc(def->briefFile(),def->briefLine(),
887         def,0,brief,FALSE,FALSE,0,TRUE,TRUE);
888     QCString relPath = relativePathToRoot(def->getOutputFileBase());
889     HtmlCodeGenerator htmlGen(t,relPath);
890     HtmlDocVisitor *visitor = new HtmlDocVisitor(t,htmlGen,def,0);
891     root->accept(visitor);
892     delete visitor;
893     delete root;
894   }
895 }
896
897 void FTVHelp::generateTree(FTextStream &t, const QList<FTVNode> &nl,int level,int maxLevel,int &index)
898 {
899   QListIterator<FTVNode> nli(nl);
900   FTVNode *n;
901   for (nli.toFirst();(n=nli.current());++nli)
902   {
903     t << "<tr id=\"row_" << generateIndentLabel(n,0) << "\"";
904     if ((index&1)==0) // even row
905       t << " class=\"even\"";
906     if (level>=maxLevel) // item invisible by default
907       t << " style=\"display:none;\"";
908     else // item visible by default
909       index++;
910     t << "><td class=\"entry\">";
911     bool nodeOpened = level+1<maxLevel;
912     generateIndent(t,n,0,nodeOpened);
913     if (n->isDir)
914     {
915       if (n->def && n->def->definitionType()==Definition::TypeGroup)
916       {
917         // no icon
918       }
919       else if (n->def && n->def->definitionType()==Definition::TypePage)
920       {
921         // no icon
922       }
923       else if (n->def && n->def->definitionType()==Definition::TypeNamespace)
924       {
925         t << "<img ";
926         t << FTV_IMGATTRIBS(ns);
927         t << "/>";
928       }
929       else if (n->def && n->def->definitionType()==Definition::TypeClass)
930       {
931         t << "<img ";
932         t << FTV_IMGATTRIBS(cl);
933         t << "/>";
934       }
935       else
936       {
937         t << "<img ";
938         t << "id=\"img_" << generateIndentLabel(n,0) 
939           << "\" ";
940         if (nodeOpened)
941           t << FTV_IMGATTRIBS(folderopen);
942         else
943           t << FTV_IMGATTRIBS(folderclosed);
944         t << "onclick=\"toggleFolder('"
945           << generateIndentLabel(n,0)
946           << "')\"";
947         t << "/>";
948       }
949       generateLink(t,n);
950       t << "</td><td class=\"desc\">";
951       if (n->def)
952       {
953         generateBriefDoc(t,n->def);
954       }
955       t << "</td></tr>" << endl;
956       folderId++;
957       generateTree(t,n->children,level+1,maxLevel,index);
958     }
959     else // leaf node
960     {
961       FileDef *srcRef=0;
962       if (n->def && n->def->definitionType()==Definition::TypeFile &&
963           ((FileDef*)n->def)->generateSourceFile())
964       {
965         srcRef = (FileDef*)n->def;
966       }
967       if (srcRef)
968       {
969         t << "<a href=\"" << srcRef->getSourceFileBase()
970           << Doxygen::htmlFileExtension 
971           << "\">";
972       }
973       if (n->def && n->def->definitionType()==Definition::TypeGroup)
974       {
975         // no icon
976       }
977       else if (n->def && n->def->definitionType()==Definition::TypePage)
978       {
979         // no icon
980       }
981       else if (n->def && n->def->definitionType()==Definition::TypeNamespace)
982       {
983         t << "<img ";
984         t << FTV_IMGATTRIBS(ns);
985         t << "/>";
986       }
987       else if (n->def && n->def->definitionType()==Definition::TypeClass)
988       {
989         t << "<img ";
990         t << FTV_IMGATTRIBS(cl);
991         t << "/>";
992       }
993       else
994       {
995         t << "<img ";
996         t << FTV_IMGATTRIBS(doc);
997         t << "/>";
998       }
999       if (srcRef)
1000       {
1001         t << "</a>";
1002       }
1003       generateLink(t,n);
1004       t << "</td><td class=\"desc\">";
1005       if (n->def)
1006       {
1007         generateBriefDoc(t,n->def);
1008       }
1009       t << "</td></tr>" << endl;
1010     }
1011   }
1012 }
1013
1014 //-----------------------------------------------------------
1015
1016 struct NavIndexEntry
1017 {
1018   NavIndexEntry(const QCString &u,const QCString &p) : url(u), path(p) {}
1019   QCString url;
1020   QCString path;
1021 };
1022
1023 class NavIndexEntryList : public QList<NavIndexEntry> 
1024 {
1025   public:
1026     NavIndexEntryList() : QList<NavIndexEntry>() { setAutoDelete(TRUE); }
1027    ~NavIndexEntryList() {}
1028     int compareItems(GCI item1,GCI item2)
1029     {
1030       // sort list based on url
1031       return qstrcmp(((NavIndexEntry*)item1)->url,((NavIndexEntry*)item2)->url);
1032     }
1033 };
1034
1035 static QCString pathToNode(FTVNode *leaf,FTVNode *n)
1036 {
1037   QCString result;
1038   if (n->parent)
1039   {
1040     result+=pathToNode(leaf,n->parent);
1041   }
1042   result+=QCString().setNum(n->index);
1043   if (leaf!=n) result+=",";
1044   return result;
1045 }
1046
1047 static bool dupOfParent(const FTVNode *n)
1048 {
1049   if (n->parent==0) return FALSE;
1050   if (n->file==n->parent->file) return TRUE;
1051   return FALSE;
1052 }
1053
1054 static void generateJSLink(FTextStream &t,FTVNode *n)
1055 {
1056   if (n->file.isEmpty()) // no link
1057   {
1058     t << "\"" << convertToJSString(n->name) << "\", null, ";
1059   }
1060   else // link into other page
1061   {
1062     t << "\"" << convertToJSString(n->name) << "\", \"";
1063     t << externalRef("",n->ref,TRUE);
1064     t << node2URL(n);
1065     t << "\", ";
1066   }
1067 }
1068
1069 static QCString convertFileId2Var(const QCString &fileId)
1070 {
1071   QCString varId = fileId;
1072   int i=varId.findRev('/');
1073   if (i>=0) varId = varId.mid(i+1);
1074   return substitute(varId,"-","_");
1075 }
1076
1077 static bool generateJSTree(NavIndexEntryList &navIndex,FTextStream &t, 
1078                            const QList<FTVNode> &nl,int level,bool &first)
1079 {
1080   static QCString htmlOutput = Config_getString("HTML_OUTPUT");
1081   QCString indentStr;
1082   indentStr.fill(' ',level*2);
1083   bool found=FALSE;
1084   QListIterator<FTVNode> nli(nl);
1085   FTVNode *n;
1086   for (nli.toFirst();(n=nli.current());++nli)
1087   {
1088     // terminate previous entry
1089     if (!first) t << "," << endl;
1090     first=FALSE;
1091
1092     // start entry
1093     if (!found)
1094     {
1095       t << "[" << endl;
1096     }
1097     found=TRUE;
1098
1099     if (n->addToNavIndex) // add entry to the navigation index
1100     {
1101       if (n->def && n->def->definitionType()==Definition::TypeFile)
1102       {
1103         FileDef *fd = (FileDef*)n->def;
1104         bool doc,src;
1105         doc = fileVisibleInIndex(fd,src);
1106         if (doc)
1107         {
1108           navIndex.append(new NavIndexEntry(node2URL(n,TRUE,FALSE),pathToNode(n,n)));
1109         }
1110         if (src)
1111         {
1112           navIndex.append(new NavIndexEntry(node2URL(n,TRUE,TRUE),pathToNode(n,n)));
1113         }
1114       }
1115       else
1116       {
1117         navIndex.append(new NavIndexEntry(node2URL(n),pathToNode(n,n)));
1118       }
1119     }
1120
1121     if (n->separateIndex) // store items in a separate file for dynamic loading
1122     {
1123       bool firstChild=TRUE;
1124       t << indentStr << "  [ ";
1125       generateJSLink(t,n);
1126       if (n->children.count()>0) // write children to separate file for dynamic loading
1127       {
1128         QCString fileId = n->file;
1129         if (dupOfParent(n)) fileId+="_dup";
1130         QFile f(htmlOutput+"/"+fileId+".js");
1131         if (f.open(IO_WriteOnly))
1132         {
1133           FTextStream tt(&f);
1134           tt << "var " << convertFileId2Var(fileId) << " =" << endl;
1135           generateJSTree(navIndex,tt,n->children,1,firstChild);
1136           tt << endl << "];"; 
1137         }
1138         t << "\"" << fileId << "\" ]";
1139       }
1140       else // no children
1141       {
1142         t << "null ]";
1143       }
1144     }
1145     else // show items in this file
1146     {
1147       bool firstChild=TRUE;
1148       t << indentStr << "  [ ";
1149       generateJSLink(t,n);
1150       bool emptySection = !generateJSTree(navIndex,t,n->children,level+1,firstChild);
1151       if (emptySection)
1152         t << "null ]";
1153       else
1154         t << endl << indentStr << "  ] ]"; 
1155     }
1156   }
1157   return found;
1158 }
1159
1160 static void generateJSNavTree(const QList<FTVNode> &nodeList)
1161 {
1162   QCString htmlOutput = Config_getString("HTML_OUTPUT");
1163   QFile f(htmlOutput+"/navtree.js");
1164   NavIndexEntryList navIndex;
1165   if (f.open(IO_WriteOnly) /*&& fidx.open(IO_WriteOnly)*/)
1166   {
1167     //FTextStream tidx(&fidx);
1168     //tidx << "var NAVTREEINDEX =" << endl;
1169     //tidx << "{" << endl;
1170     FTextStream t(&f);
1171     t << "var NAVTREE =" << endl;
1172     t << "[" << endl;
1173     t << "  [ ";
1174     QCString &projName = Config_getString("PROJECT_NAME");
1175     if (projName.isEmpty())
1176     {
1177       if (Doxygen::mainPage && !Doxygen::mainPage->title().isEmpty()) // Use title of main page as root
1178       {
1179         t << "\"" << convertToJSString(Doxygen::mainPage->title()) << "\", ";
1180       }
1181       else // Use default section title as root
1182       {
1183         LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::MainPage);
1184         t << "\"" << convertToJSString(lne->title()) << "\", ";
1185       }
1186     }
1187     else // use PROJECT_NAME as root tree element
1188     {
1189       t << "\"" << convertToJSString(projName) << "\", ";
1190     }
1191     t << "\"index" << Doxygen::htmlFileExtension << "\", ";
1192
1193     // add special entry for index page
1194     navIndex.append(new NavIndexEntry("index"+Doxygen::htmlFileExtension,""));
1195     // related page index is written as a child of index.html, so add this as well
1196     navIndex.append(new NavIndexEntry("pages"+Doxygen::htmlFileExtension,""));
1197
1198     bool first=TRUE;
1199     generateJSTree(navIndex,t,nodeList,1,first);
1200
1201     if (first) 
1202       t << "]" << endl;
1203     else 
1204       t << endl << "  ] ]" << endl;
1205     t << "];" << endl << endl;
1206
1207     // write the navigation index (and sub-indices)
1208     navIndex.sort();
1209     int subIndex=0;
1210     int elemCount=0;
1211     const int maxElemCount=250;
1212     //QFile fidx(htmlOutput+"/navtreeindex.js");
1213     QFile fsidx(htmlOutput+"/navtreeindex0.js");
1214     if (/*fidx.open(IO_WriteOnly) &&*/ fsidx.open(IO_WriteOnly))
1215     {
1216       //FTextStream tidx(&fidx);
1217       FTextStream tsidx(&fsidx);
1218       t << "var NAVTREEINDEX =" << endl;
1219       t << "[" << endl;
1220       tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
1221       tsidx << "{" << endl;
1222       QListIterator<NavIndexEntry> li(navIndex);
1223       NavIndexEntry *e;
1224       bool first=TRUE;
1225       for (li.toFirst();(e=li.current());) // for each entry
1226       {
1227         if (elemCount==0)
1228         {
1229           if (!first)
1230           {
1231             t << "," << endl;
1232           }
1233           else
1234           {
1235             first=FALSE;
1236           }
1237           t << "\"" << e->url << "\"";
1238         }
1239         tsidx << "\"" << e->url << "\":[" << e->path << "]";
1240         ++li;
1241         if (li.current() && elemCount<maxElemCount-1) tsidx << ","; // not last entry
1242         tsidx << endl;
1243   
1244         elemCount++;
1245         if (li.current() && elemCount>=maxElemCount) // switch to new sub-index
1246         {
1247           tsidx << "};" << endl;
1248           elemCount=0;
1249           fsidx.close();
1250           subIndex++;
1251           fsidx.setName(htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js");
1252           if (!fsidx.open(IO_WriteOnly)) break;
1253           tsidx.setDevice(&fsidx);
1254           tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl;
1255           tsidx << "{" << endl;
1256         }
1257       }
1258       tsidx << "};" << endl;
1259       t << endl << "];" << endl;
1260     }
1261     t << endl << "var SYNCONMSG = '"  << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';"; 
1262     t << endl << "var SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE)  << "';"; 
1263     t << endl << navtree_script;
1264   }
1265 }
1266
1267 //-----------------------------------------------------------
1268
1269 // new style images
1270 void FTVHelp::generateTreeViewImages()
1271 {
1272   QCString dname=Config_getString("HTML_OUTPUT");
1273   writeColoredImgData(dname,ftv_image_data);
1274 }
1275
1276 // new style scripts
1277 void FTVHelp::generateTreeViewScripts()
1278 {
1279   QCString htmlOutput = Config_getString("HTML_OUTPUT");
1280
1281   // generate navtree.js & navtreeindex.js
1282   generateJSNavTree(m_indentNodes[0]);
1283
1284   // generate resize.js
1285   {
1286     QFile f(htmlOutput+"/resize.js");
1287     if (f.open(IO_WriteOnly))
1288     {
1289       FTextStream t(&f);
1290       t << resize_script;
1291     }
1292   }
1293   // generate navtree.css
1294   {
1295     QFile f(htmlOutput+"/navtree.css");
1296     if (f.open(IO_WriteOnly))
1297     {
1298       FTextStream t(&f);
1299       t << replaceColorMarkers(navtree_css);
1300     }
1301   }
1302 }
1303
1304 // write tree inside page
1305 void FTVHelp::generateTreeViewInline(FTextStream &t)
1306 {
1307   int preferredNumEntries = Config_getInt("HTML_INDEX_NUM_ENTRIES");
1308   t << "<div class=\"directory\">\n";
1309   QListIterator<FTVNode> li(m_indentNodes[0]);
1310   FTVNode *n;
1311   int d=1, depth=1;
1312   for (;(n=li.current());++li)
1313   {
1314     if (n->children.count()>0)
1315     {
1316       d = n->computeTreeDepth(2);
1317       if (d>depth) depth=d;
1318     }
1319   }
1320   int preferredDepth = depth;
1321   // write level selector
1322   if (depth>1)
1323   {
1324     t << "<div class=\"levels\">[";
1325     t << theTranslator->trDetailLevel(); 
1326     t << " ";
1327     int i;
1328     for (i=1;i<=depth;i++)
1329     {
1330       t << "<span onclick=\"javascript:toggleLevel(" << i << ");\">" << i << "</span>";
1331     }
1332     t << "]</div>";
1333
1334     if (preferredNumEntries>0)
1335     {
1336       preferredDepth=1;
1337       for (int i=1;i<=depth;i++)
1338       {
1339         int num=0;
1340         QListIterator<FTVNode> li(m_indentNodes[0]);
1341         FTVNode *n;
1342         for (;(n=li.current());++li)
1343         {
1344           num+=n->numNodesAtLevel(0,i);
1345         }
1346         if (num<=preferredNumEntries)
1347         {
1348           preferredDepth=i;
1349         }
1350         else
1351         {
1352           break;
1353         }
1354       }
1355     }
1356   }
1357   //printf("preferred depth=%d\n",preferredDepth);
1358
1359   t << "<table class=\"directory\">\n";
1360   int index=0;
1361   generateTree(t,m_indentNodes[0],0,preferredDepth,index);
1362   t << "</table>\n";
1363
1364   t << "</div><!-- directory -->\n";
1365 }
1366
1367 // write old style index.html and tree.html
1368 void FTVHelp::generateTreeView()
1369 {
1370   generateTreeViewImages();
1371   generateTreeViewScripts();
1372 }
1373