diff --git a/.gitattributes b/.gitattributes
index 02433d2a91..6c9fd8ae7a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -14018,6 +14018,7 @@ utils/fpdoc/fpde/xpms.pp svneol=native#text/plain
 utils/fpdoc/fpdoc.css -text
 utils/fpdoc/fpdoc.lpi svneol=native#text/plain
 utils/fpdoc/fpdoc.pp svneol=native#text/plain
+utils/fpdoc/fpdocclasstree.pp svneol=native#text/plain
 utils/fpdoc/fpdocproj.pas svneol=native#text/plain
 utils/fpdoc/fpdocxmlopts.pas svneol=native#text/plain
 utils/fpdoc/fpmake.pp svneol=native#text/plain
@@ -14032,9 +14033,11 @@ utils/fpdoc/intl/makeskel.de.po svneol=native#text/plain
 utils/fpdoc/makeskel.lpi svneol=native#text/plain
 utils/fpdoc/makeskel.pp svneol=native#text/plain
 utils/fpdoc/mgrfpdocproj.pp svneol=native#text/plain
+utils/fpdoc/minusimage.inc svneol=native#text/plain
 utils/fpdoc/mkfpdoc.pp svneol=native#text/plain
 utils/fpdoc/mkfpdocproj.lpi svneol=native#text/plain
 utils/fpdoc/mkfpdocproj.pp svneol=native#text/plain
+utils/fpdoc/plusimage.inc svneol=native#text/plain
 utils/fpdoc/sample-project.xml svneol=native#text/plain
 utils/fpdoc/sh_pas.pp svneol=native#text/plain
 utils/fpdoc/testunit.pp svneol=native#text/plain
diff --git a/utils/fpdoc/Makefile b/utils/fpdoc/Makefile
index e2f8df7c3a..8552f9cfb5 100644
--- a/utils/fpdoc/Makefile
+++ b/utils/fpdoc/Makefile
@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2012/09/27]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2012/12/01]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii powerpc-aix sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-netbsd x86_64-solaris x86_64-openbsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded powerpc64-aix avr-embedded armeb-linux armeb-embedded mips-linux mipsel-linux jvm-java jvm-android
@@ -3500,6 +3500,96 @@ endif
 fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
 fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
 fpc_makefiles: fpc_makefile fpc_makefile_dirs
+ifdef TARGET_DIRS_TARGET_DIRS
+TARGET_DIRS_all:
+	$(MAKE) -C TARGET_DIRS all
+TARGET_DIRS_debug:
+	$(MAKE) -C TARGET_DIRS debug
+TARGET_DIRS_smart:
+	$(MAKE) -C TARGET_DIRS smart
+TARGET_DIRS_release:
+	$(MAKE) -C TARGET_DIRS release
+TARGET_DIRS_units:
+	$(MAKE) -C TARGET_DIRS units
+TARGET_DIRS_examples:
+	$(MAKE) -C TARGET_DIRS examples
+TARGET_DIRS_shared:
+	$(MAKE) -C TARGET_DIRS shared
+TARGET_DIRS_install:
+	$(MAKE) -C TARGET_DIRS install
+TARGET_DIRS_sourceinstall:
+	$(MAKE) -C TARGET_DIRS sourceinstall
+TARGET_DIRS_exampleinstall:
+	$(MAKE) -C TARGET_DIRS exampleinstall
+TARGET_DIRS_distinstall:
+	$(MAKE) -C TARGET_DIRS distinstall
+TARGET_DIRS_zipinstall:
+	$(MAKE) -C TARGET_DIRS zipinstall
+TARGET_DIRS_zipsourceinstall:
+	$(MAKE) -C TARGET_DIRS zipsourceinstall
+TARGET_DIRS_zipexampleinstall:
+	$(MAKE) -C TARGET_DIRS zipexampleinstall
+TARGET_DIRS_zipdistinstall:
+	$(MAKE) -C TARGET_DIRS zipdistinstall
+TARGET_DIRS_clean:
+	$(MAKE) -C TARGET_DIRS clean
+TARGET_DIRS_distclean:
+	$(MAKE) -C TARGET_DIRS distclean
+TARGET_DIRS_cleanall:
+	$(MAKE) -C TARGET_DIRS cleanall
+TARGET_DIRS_info:
+	$(MAKE) -C TARGET_DIRS info
+TARGET_DIRS_makefiles:
+	$(MAKE) -C TARGET_DIRS makefiles
+TARGET_DIRS:
+	$(MAKE) -C TARGET_DIRS all
+.PHONY: TARGET_DIRS_all TARGET_DIRS_debug TARGET_DIRS_smart TARGET_DIRS_release TARGET_DIRS_units TARGET_DIRS_examples TARGET_DIRS_shared TARGET_DIRS_install TARGET_DIRS_sourceinstall TARGET_DIRS_exampleinstall TARGET_DIRS_distinstall TARGET_DIRS_zipinstall TARGET_DIRS_zipsourceinstall TARGET_DIRS_zipexampleinstall TARGET_DIRS_zipdistinstall TARGET_DIRS_clean TARGET_DIRS_distclean TARGET_DIRS_cleanall TARGET_DIRS_info TARGET_DIRS_makefiles TARGET_DIRS
+endif
+ifdef TARGET_EXAMPLEDIRS_TARGET_EXAMPLEDIRS
+TARGET_EXAMPLEDIRS_all:
+	$(MAKE) -C TARGET_EXAMPLEDIRS all
+TARGET_EXAMPLEDIRS_debug:
+	$(MAKE) -C TARGET_EXAMPLEDIRS debug
+TARGET_EXAMPLEDIRS_smart:
+	$(MAKE) -C TARGET_EXAMPLEDIRS smart
+TARGET_EXAMPLEDIRS_release:
+	$(MAKE) -C TARGET_EXAMPLEDIRS release
+TARGET_EXAMPLEDIRS_units:
+	$(MAKE) -C TARGET_EXAMPLEDIRS units
+TARGET_EXAMPLEDIRS_examples:
+	$(MAKE) -C TARGET_EXAMPLEDIRS examples
+TARGET_EXAMPLEDIRS_shared:
+	$(MAKE) -C TARGET_EXAMPLEDIRS shared
+TARGET_EXAMPLEDIRS_install:
+	$(MAKE) -C TARGET_EXAMPLEDIRS install
+TARGET_EXAMPLEDIRS_sourceinstall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS sourceinstall
+TARGET_EXAMPLEDIRS_exampleinstall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS exampleinstall
+TARGET_EXAMPLEDIRS_distinstall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS distinstall
+TARGET_EXAMPLEDIRS_zipinstall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS zipinstall
+TARGET_EXAMPLEDIRS_zipsourceinstall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS zipsourceinstall
+TARGET_EXAMPLEDIRS_zipexampleinstall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS zipexampleinstall
+TARGET_EXAMPLEDIRS_zipdistinstall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS zipdistinstall
+TARGET_EXAMPLEDIRS_clean:
+	$(MAKE) -C TARGET_EXAMPLEDIRS clean
+TARGET_EXAMPLEDIRS_distclean:
+	$(MAKE) -C TARGET_EXAMPLEDIRS distclean
+TARGET_EXAMPLEDIRS_cleanall:
+	$(MAKE) -C TARGET_EXAMPLEDIRS cleanall
+TARGET_EXAMPLEDIRS_info:
+	$(MAKE) -C TARGET_EXAMPLEDIRS info
+TARGET_EXAMPLEDIRS_makefiles:
+	$(MAKE) -C TARGET_EXAMPLEDIRS makefiles
+TARGET_EXAMPLEDIRS:
+	$(MAKE) -C TARGET_EXAMPLEDIRS all
+.PHONY: TARGET_EXAMPLEDIRS_all TARGET_EXAMPLEDIRS_debug TARGET_EXAMPLEDIRS_smart TARGET_EXAMPLEDIRS_release TARGET_EXAMPLEDIRS_units TARGET_EXAMPLEDIRS_examples TARGET_EXAMPLEDIRS_shared TARGET_EXAMPLEDIRS_install TARGET_EXAMPLEDIRS_sourceinstall TARGET_EXAMPLEDIRS_exampleinstall TARGET_EXAMPLEDIRS_distinstall TARGET_EXAMPLEDIRS_zipinstall TARGET_EXAMPLEDIRS_zipsourceinstall TARGET_EXAMPLEDIRS_zipexampleinstall TARGET_EXAMPLEDIRS_zipdistinstall TARGET_EXAMPLEDIRS_clean TARGET_EXAMPLEDIRS_distclean TARGET_EXAMPLEDIRS_cleanall TARGET_EXAMPLEDIRS_info TARGET_EXAMPLEDIRS_makefiles TARGET_EXAMPLEDIRS
+endif
 all: fpc_all
 debug: fpc_debug
 smart: fpc_smart
@@ -3526,9 +3616,13 @@ include fpcmake.loc
 endif
 .NOTPARALLEL:
 fpdoc$(EXEEXT): fpdoc.pp dglobals.pp dwriter.pp dw_xml.pp sh_pas.pp dw_html.pp\
-  dw_latex.pp dwlinear.pp dw_txt.pp dw_linrtf.pp
+  dw_latex.pp dwlinear.pp dw_txt.pp dw_linrtf.pp css.inc plusimage.inc minusimage.inc
 makeskel$(EXEEXT): makeskel.pp dglobals.pp
 css.inc: fpdoc.css ../bin2obj$(EXEEXT)
 	../bin2obj$(EXEEXT) -o css.inc -c DefaultCSS fpdoc.css
+plusimage.inc: images/plus.png ../bin2obj$(EXEEXT)
+	../bin2obj$(EXEEXT) -o plusimage.inc -c PlusImageData images/plus.png
+minusimage.inc: images/minus.png ../bin2obj$(EXEEXT)
+	../bin2obj$(EXEEXT) -o minusimage.inc -c MinusImageData images/minus.png
 ../bin2obj$(EXEEXT):
 	$(MAKE) -C .. bin2obj$(EXEEXT)
diff --git a/utils/fpdoc/Makefile.fpc b/utils/fpdoc/Makefile.fpc
index 77d14dfdae..5209b8c1e1 100644
--- a/utils/fpdoc/Makefile.fpc
+++ b/utils/fpdoc/Makefile.fpc
@@ -34,12 +34,18 @@ files=dwriter.rst fpdoc.rst dglobals.rst makeskel.rst fpdocopts.rst
 [rules]
 .NOTPARALLEL:
 fpdoc$(EXEEXT): fpdoc.pp dglobals.pp dwriter.pp dw_xml.pp sh_pas.pp dw_html.pp\
-  dw_latex.pp dwlinear.pp dw_txt.pp dw_linrtf.pp
+  dw_latex.pp dwlinear.pp dw_txt.pp dw_linrtf.pp css.inc plusimage.inc minusimage.inc
 
 makeskel$(EXEEXT): makeskel.pp dglobals.pp
 
 css.inc: fpdoc.css ../bin2obj$(EXEEXT)
 	../bin2obj$(EXEEXT) -o css.inc -c DefaultCSS fpdoc.css
 
+plusimage.inc: images/plus.png ../bin2obj$(EXEEXT)
+	../bin2obj$(EXEEXT) -o plusimage.inc -c PlusImageData images/plus.png
+
+minusimage.inc: images/minus.png ../bin2obj$(EXEEXT)
+	../bin2obj$(EXEEXT) -o minusimage.inc -c MinusImageData images/minus.png
+
 ../bin2obj$(EXEEXT):
 	$(MAKE) -C .. bin2obj$(EXEEXT)
diff --git a/utils/fpdoc/css.inc b/utils/fpdoc/css.inc
index d0252e893c..03d7c95384 100644
--- a/utils/fpdoc/css.inc
+++ b/utils/fpdoc/css.inc
@@ -1,9 +1,9 @@
 
 Const
-  DefaultCSS : Array[0..2254] of byte = (
+  DefaultCSS : Array[0..2242] of byte = (
       47, 42, 10, 32, 32, 36, 73,100, 58, 32,102,112,100,111, 99, 46, 99,
-     115,115, 44,118, 32, 49, 46, 49, 32, 50, 48, 48, 51, 47, 48, 51, 47,
-      49, 55, 32, 50, 51, 58, 48, 51, 58, 50, 48, 32,109,105, 99,104, 97,
+     115,116, 44,118, 32, 49, 46, 49, 32, 50, 48, 48, 53, 47, 48, 49, 47,
+      48, 50, 32, 49, 54, 58, 50, 50, 58, 49, 54, 32,109,105, 99,104, 97,
      101,108, 32, 69,120,112, 32, 36, 10, 10, 32, 32, 68,101,102, 97,117,
      108,116, 32,115,116,121,108,101, 32,115,104,101,101,116, 32,102,111,
      114, 32, 70, 80, 68,111, 99, 32,114,101,102,101,114,101,110, 99,101,
@@ -53,84 +53,83 @@ Const
       32,105,110, 32,115,111,117,114, 99,101, 32,102,114, 97,103,109,101,
      110,116,115, 32, 42, 47, 10,115,112, 97,110, 46,115,121,109, 32,123,
       10, 32, 32, 99,111,108,111,114, 58, 32,100, 97,114,107,114,101,100,
-      10,125, 10, 10, 47, 42, 32,107,101,121,119,111,114,100,115, 32,105,
-     110, 32,115,111,117,114, 99,101, 32,102,114, 97,103,109,101,110,116,
-     115, 32, 42, 47, 10,115,112, 97,110, 46,107,119, 32,123, 10, 32, 32,
-     102,111,110,116, 45,119,101,105,103,104,116, 58, 32, 98,111,108,100,
-      10,125, 10, 10, 47, 42, 32, 99,111,109,109,101,110,116,115, 32,105,
-     110, 32,115,111,117,114, 99,101, 32,102,114, 97,103,109,101,110,116,
-     115, 32, 42, 47, 10,115,112, 97,110, 46, 99,109,116, 32,123, 10, 32,
-      32, 99,111,108,111,114, 58, 32,100, 97,114,107, 99,121, 97,110, 59,
-      10, 32, 32,102,111,110,116, 45,115,116,121,108,101, 58, 32,105,116,
-      97,108,105, 99, 10,125, 10, 10, 47, 42, 32,100,105,114,101, 99,116,
-     105,118,101,115, 32,105,110, 32,115,111,117,114, 99,101, 32,102,114,
-      97,103,109,101,110,116,115, 32, 42, 47, 10,115,112, 97,110, 46,100,
-     105,114, 32,123, 10, 32, 32, 99,111,108,111,114, 58, 32,100, 97,114,
-     107,121,101,108,108,111,119, 59, 10, 32, 32,102,111,110,116, 45,115,
-     116,121,108,101, 58, 32,105,116, 97,108,105, 99, 10,125, 10, 10, 47,
-      42, 32,110,117,109, 98,101,114,115, 32,105,110, 32,115,111,117,114,
+      10,125, 10, 47, 42, 32, 78,111, 32,119,111,114,100,119,114, 97,112,
+      32,105,110, 32, 99,111,100,101, 32,102,114, 97,103,109,101,110,116,
+     115, 32, 42, 47, 10,115,112, 97,110, 46, 99,111,100,101, 32,123, 10,
+      32, 32, 32,119,104,105,116,101, 45,115,112, 97, 99,101, 58, 32,110,
+     111,119,114, 97,112, 10,125, 10, 10, 47, 42, 32,107,101,121,119,111,
+     114,100,115, 32,105,110, 32,115,111,117,114, 99,101, 32,102,114, 97,
+     103,109,101,110,116,115, 32, 42, 47, 10,115,112, 97,110, 46,107,119,
+      32,123, 10, 32, 32,102,111,110,116, 45,119,101,105,103,104,116, 58,
+      32, 98,111,108,100, 10,125, 10, 10, 47, 42, 32, 99,111,109,109,101,
+     110,116,115, 32,105,110, 32,115,111,117,114, 99,101, 32,102,114, 97,
+     103,109,101,110,116,115, 32, 42, 47, 10,115,112, 97,110, 46, 99,109,
+     116, 32,123, 10, 32, 32, 99,111,108,111,114, 58, 32,100, 97,114,107,
+      99,121, 97,110, 59, 10, 32, 32,102,111,110,116, 45,115,116,121,108,
+     101, 58, 32,105,116, 97,108,105, 99, 10,125, 10, 10, 47, 42, 32,100,
+     105,114,101, 99,116,105,118,101,115, 32,105,110, 32,115,111,117,114,
       99,101, 32,102,114, 97,103,109,101,110,116,115, 32, 42, 47, 10,115,
-     112, 97,110, 46,110,117,109, 32,123, 10, 32, 32, 99,111,108,111,114,
-      58, 32,100, 97,114,107,109, 97,103,101,110,116, 97, 10,125, 10, 10,
-      47, 42, 32, 99,104, 97,114, 97, 99,116,101,114,115, 32, 40, 35, 46,
-      46, 46, 41, 32,105,110, 32,115,111,117,114, 99,101, 32,102,114, 97,
-     103,109,101,110,116,115, 32, 42, 47, 10,115,112, 97,110, 46, 99,104,
-     114, 32,123, 10, 32, 32, 99,111,108,111,114, 58, 32,100, 97,114,107,
-      99,121, 97,110, 10,125, 10, 10, 47, 42, 32,115,116,114,105,110,103,
-     115, 32,105,110, 32,115,111,117,114, 99,101, 32,102,114, 97,103,109,
-     101,110,116,115, 32, 42, 47, 10,115,112, 97,110, 46,115,116,114, 32,
-     123, 10, 32, 32, 99,111,108,111,114, 58, 32, 98,108,117,101, 10,125,
-      10, 10, 47, 42, 32, 97,115,115,101,109, 98,108,101,114, 32,112, 97,
-     115,115, 97,103,101,115, 32,105,110, 32,115,111,117,114, 99,101, 32,
-     102,114, 97,103,109,101,110,116,115, 32, 42, 47, 10,115,112, 97,110,
-      46, 97,115,109, 32,123, 10, 32, 32, 99,111,108,111,114, 58, 32,103,
-     114,101,101,110, 10,125, 10, 10, 10,116,100, 46,112,114,101, 32,123,
-      10, 32, 32,119,104,105,116,101, 45,115,112, 97, 99,101, 58, 32,112,
-     114,101, 10,125, 10, 10,112, 46, 99,109,116, 32,123, 10, 32, 32, 99,
-     111,108,111,114, 58, 32,103,114, 97,121, 10,125, 10, 10,115,112, 97,
-     110, 46,119, 97,114,110,105,110,103, 32,123, 10, 32, 32, 99,111,108,
-     111,114, 58, 32,114,101,100, 59, 10, 32, 32,102,111,110,116, 45,119,
-     101,105,103,104,116, 58, 32, 98,111,108,100, 10,125, 10, 10, 47, 42,
-      32, 33, 33, 33, 58, 32, 72,111,119, 32,115,104,111,117,108,100, 32,
-     119,101, 32,100,101,102,105,110,101, 32,116,104,105,115, 46, 46, 46,
-      63, 32, 42, 47, 10,115,112, 97,110, 46,102,105,108,101, 32,123, 10,
-      32, 32, 99,111,108,111,114, 58, 32,100, 97,114,107,103,114,101,101,
-     110, 10,125, 10, 10,116, 97, 98,108,101, 46,114,101,109, 97,114,107,
-      32,123, 10, 32, 32, 98, 97, 99,107,103,114,111,117,110,100, 45, 99,
-     111,108,111,114, 58, 32, 35,102,102,102,102, 99, 48, 59, 10,125, 10,
-      10,116, 97, 98,108,101, 46, 98, 97,114, 32,123, 10, 32, 32, 98, 97,
-      99,107,103,114,111,117,110,100, 45, 99,111,108,111,114, 58, 32, 35,
-      97, 48, 99, 48,102,102, 59, 10,125, 10, 10,115,112, 97,110, 46, 98,
-      97,114,116,105,116,108,101, 32,123, 10, 32, 32,102,111,110,116, 45,
-     119,101,105,103,104,116, 58, 32, 98,111,108,100, 59, 10, 32, 32,102,
+     112, 97,110, 46,100,105,114, 32,123, 10, 32, 32, 99,111,108,111,114,
+      58, 32,100, 97,114,107,121,101,108,108,111,119, 59, 10, 32, 32,102,
      111,110,116, 45,115,116,121,108,101, 58, 32,105,116, 97,108,105, 99,
-      59, 10, 32, 32, 99,111,108,111,114, 58, 32,100, 97,114,107, 98,108,
-     117,101, 10,125, 10, 10,115,112, 97,110, 46,102,111,111,116,101,114,
-      32,123, 10, 32, 32,102,111,110,116, 45,115,116,121,108,101, 58, 32,
-     105,116, 97,108,105, 99, 59, 10, 32, 32, 99,111,108,111,114, 58, 32,
-     100, 97,114,107, 98,108,117,101, 10,125, 10, 10, 47, 42, 32,100,101,
-     102,105,110,105,116,105,111,110, 32,108,105,115,116, 32, 42, 47, 10,
-     100,108, 32,123, 10, 32, 98,111,114,100,101,114, 58, 32, 51,112,120,
-      32,100,111,117, 98,108,101, 32, 35, 99, 99, 99, 59, 10, 32,112, 97,
-     100,100,105,110,103, 58, 32, 48, 46, 53,101,109, 59, 10,125, 10, 10,
-      47, 42, 32,100,101,102,105,110,105,116,105,111,110, 32,108,105,115,
-     116, 58, 32,116,101,114,109, 32, 42, 47, 10,100,116, 32,123, 10, 32,
-     102,108,111, 97,116, 58, 32,108,101,102,116, 59, 10, 32, 99,108,101,
-      97,114, 58, 32,108,101,102,116, 59, 10, 32,119,105,100,116,104, 58,
-      32, 97,117,116,111, 59, 32, 47, 42, 32,110,111,114,109, 97,108,108,
-     121, 32, 98,114,111,119,115,101,114,115, 32,100,101,102, 97,117,108,
-     116, 32,119,105,100,116,104, 32,111,102, 32,108, 97,114,103,101,115,
-     116, 32,105,116,101,109, 32, 42, 47, 10, 32,112, 97,100,100,105,110,
-     103, 45,114,105,103,104,116, 58, 32, 50, 48,112,120, 59, 10, 32,102,
-     111,110,116, 45,119,101,105,103,104,116, 58, 32, 98,111,108,100, 59,
-      10, 32, 99,111,108,111,114, 58, 32,100, 97,114,107,103,114,101,101,
-     110, 59, 10,125, 10, 10, 47, 42, 32,100,101,102,105,110,105,116,105,
-     111,110, 32,108,105,115,116, 58, 32,100,101,115, 99,114,105,112,116,
-     105,111,110, 32, 42, 47, 10,100,100, 32,123, 10, 32,109, 97,114,103,
-     105,110, 58, 32, 48, 32, 48, 32, 48, 32, 49, 49, 48,112,120, 59, 10,
-      32,112, 97,100,100,105,110,103, 58, 32, 48, 32, 48, 32, 48, 46, 53,
-     101,109, 32, 48, 59, 10,125, 10, 10, 47, 42, 32,102,111,114, 32, 98,
-     114,111,119,115,101,114,115, 32,105,110, 32,115,116, 97,110,100, 97,
-     114,100,115, 32, 99,111,109,112,108,105, 97,110, 99,101, 32,109,111,
-     100,101, 32, 42, 47, 10,116,100, 32,112, 32,123, 10, 32, 32,109, 97,
-     114,103,105,110, 58, 32, 48, 59, 10,125, 10);
+      10,125, 10, 10, 47, 42, 32,110,117,109, 98,101,114,115, 32,105,110,
+      32,115,111,117,114, 99,101, 32,102,114, 97,103,109,101,110,116,115,
+      32, 42, 47, 10,115,112, 97,110, 46,110,117,109, 32,123, 10, 32, 32,
+      99,111,108,111,114, 58, 32,100, 97,114,107,109, 97,103,101,110,116,
+      97, 10,125, 10, 10, 47, 42, 32, 99,104, 97,114, 97, 99,116,101,114,
+     115, 32, 40, 35, 46, 46, 46, 41, 32,105,110, 32,115,111,117,114, 99,
+     101, 32,102,114, 97,103,109,101,110,116,115, 32, 42, 47, 10,115,112,
+      97,110, 46, 99,104,114, 32,123, 10, 32, 32, 99,111,108,111,114, 58,
+      32,100, 97,114,107, 99,121, 97,110, 10,125, 10, 10, 47, 42, 32,115,
+     116,114,105,110,103,115, 32,105,110, 32,115,111,117,114, 99,101, 32,
+     102,114, 97,103,109,101,110,116,115, 32, 42, 47, 10,115,112, 97,110,
+      46,115,116,114, 32,123, 10, 32, 32, 99,111,108,111,114, 58, 32, 98,
+     108,117,101, 10,125, 10, 10, 47, 42, 32, 97,115,115,101,109, 98,108,
+     101,114, 32,112, 97,115,115, 97,103,101,115, 32,105,110, 32,115,111,
+     117,114, 99,101, 32,102,114, 97,103,109,101,110,116,115, 32, 42, 47,
+      10,115,112, 97,110, 46, 97,115,109, 32,123, 10, 32, 32, 99,111,108,
+     111,114, 58, 32,103,114,101,101,110, 10,125, 10, 10, 10,116,100, 46,
+     112,114,101, 32,123, 10, 32, 32,119,104,105,116,101, 45,115,112, 97,
+      99,101, 58, 32,112,114,101, 10,125, 10, 10,112, 46, 99,109,116, 32,
+     123, 10, 32, 32, 99,111,108,111,114, 58, 32,103,114, 97,121, 10,125,
+      10, 10,115,112, 97,110, 46,119, 97,114,110,105,110,103, 32,123, 10,
+      32, 32, 99,111,108,111,114, 58, 32,114,101,100, 59, 10, 32, 32,102,
+     111,110,116, 45,119,101,105,103,104,116, 58, 32, 98,111,108,100, 10,
+     125, 10, 10, 47, 42, 32, 33, 33, 33, 58, 32, 72,111,119, 32,115,104,
+     111,117,108,100, 32,119,101, 32,100,101,102,105,110,101, 32,116,104,
+     105,115, 46, 46, 46, 63, 32, 42, 47, 10,115,112, 97,110, 46,102,105,
+     108,101, 32,123, 10, 32, 32, 99,111,108,111,114, 58, 32,100, 97,114,
+     107,103,114,101,101,110, 10,125, 10, 10,116, 97, 98,108,101, 46,114,
+     101,109, 97,114,107, 32,123, 10, 32, 32, 98, 97, 99,107,103,114,111,
+     117,110,100, 45, 99,111,108,111,114, 58, 32, 35,102,102,102,102, 99,
+      48, 59, 10,125, 10, 10,116, 97, 98,108,101, 46, 98, 97,114, 32,123,
+      10, 32, 32, 98, 97, 99,107,103,114,111,117,110,100, 45, 99,111,108,
+     111,114, 58, 32, 35, 97, 48, 99, 48,102,102, 59, 10,125, 10, 10,116,
+     100, 32,112, 32,123, 10, 32,109, 97,114,103,105,110, 58, 32, 48, 59,
+      10,125, 10, 10,115,112, 97,110, 46, 98, 97,114,116,105,116,108,101,
+      32,123, 10, 32, 32,102,111,110,116, 45,119,101,105,103,104,116, 58,
+      32, 98,111,108,100, 59, 10, 32, 32,102,111,110,116, 45,115,116,121,
+     108,101, 58, 32,105,116, 97,108,105, 99, 59, 10, 32, 32, 99,111,108,
+     111,114, 58, 32,100, 97,114,107, 98,108,117,101, 10,125, 10, 10,115,
+     112, 97,110, 46,116,111,103,103,108,101,116,114,101,101, 99,108,111,
+     115,101, 32,123, 10, 32, 32, 32, 32, 98, 97, 99,107,103,114,111,117,
+     110,100, 58, 32,117,114,108, 40,109,105,110,117,115, 46,112,110,103,
+      41, 32, 99,101,110,116,101,114, 32,108,101,102,116, 32,110,111, 45,
+     114,101,112,101, 97,116, 59, 10, 32, 32, 32, 32,112, 97,100,100,105,
+     110,103, 45,108,101,102,116, 58, 32, 50, 48,112,120, 59, 32, 10,125,
+      10, 10,115,112, 97,110, 46,116,111,103,103,108,101,116,114,101,101,
+     111,112,101,110, 32,123, 10, 32, 32, 32, 32, 98, 97, 99,107,103,114,
+     111,117,110,100, 58, 32,117,114,108, 40,112,108,117,115, 46,112,110,
+     103, 41, 32, 99,101,110,116,101,114, 32,108,101,102,116, 32,110,111,
+      45,114,101,112,101, 97,116, 59, 10, 32, 32, 32, 32,112, 97,100,100,
+     105,110,103, 45,108,101,102,116, 58, 32, 50, 48,112,120, 59, 32, 10,
+     125, 10, 10,117,108, 46, 99,108, 97,115,115,116,114,101,101,108,105,
+     115,116, 32,108,105, 32,123, 32,112, 97,100,100,105,110,103, 45,108,
+     101,102,116, 58, 32, 48,112,120, 59, 32,125, 10, 10,117,108, 46, 99,
+     108, 97,115,115,116,114,101,101,108,105,115,116, 32,123, 32,108,105,
+     115,116, 45,115,116,121,108,101, 45,116,121,112,101, 58,110,111,110,
+     101, 59, 32,125, 10, 10,108,105, 46, 99,108, 97,115,115,116,114,101,
+     101, 32,117,108, 32,123, 32,100,105,115,112,108, 97,121, 58, 32, 98,
+     108,111, 99,107, 59, 32,125, 10, 10,108,105, 46, 99,108, 97,115,115,
+     116,114,101,101, 99,108,111,115,101,100, 32,117,108, 32,123, 32,100,
+     105,115,112,108, 97,121, 58, 32,110,111,110,101, 59, 32,125, 10);
diff --git a/utils/fpdoc/dglobals.pp b/utils/fpdoc/dglobals.pp
index 6bcadf8128..07a3918bbe 100644
--- a/utils/fpdoc/dglobals.pp
+++ b/utils/fpdoc/dglobals.pp
@@ -48,6 +48,7 @@ resourcestring
   SDocProceduresAndFunctions = 'Procedures and functions';
   SDocVariables              = 'Variables';
   SDocIdentifierIndex        = 'Index';
+  SDocPackageClassHierarchy  = 'Class hierarchy';
   SDocModuleIndex            = 'Index of all identifiers in unit ''%s''';
   SDocPackageIndex           = 'Index of all identifiers in package ''%s''';
   SDocUnitOverview           = 'Overview of unit ''%s''';
diff --git a/utils/fpdoc/dw_html.pp b/utils/fpdoc/dw_html.pp
index a743cb923f..1c90fa7d30 100644
--- a/utils/fpdoc/dw_html.pp
+++ b/utils/fpdoc/dw_html.pp
@@ -32,6 +32,7 @@ const
   // Maybe needed later for topic overview ??
   TopicsSubIndex = 7;
   IndexSubIndex = 8;
+  ClassHierarchySubIndex = 9;
 
   // Subpage indices for classes
   PropertiesByInheritanceSubindex = 1;
@@ -88,7 +89,10 @@ type
     FOnTest: TNotifyEvent;
     FPackage: TPasPackage;
     FCharSet : String;
+    procedure AddElementsFromList(L: TStrings; List: TFPList; UsePathName : Boolean = False);
     procedure AppendTypeDecl(AType: TPasType; TableEl, CodeEl: TDomElement);
+    procedure CreateMinusImage;
+    procedure CreatePlusImage;
     function GetPageCount: Integer;
     procedure SetOnTest(const AValue: TNotifyEvent);
   protected
@@ -99,6 +103,7 @@ type
     PageInfos: TObjectList;     // list of TPageInfo objects
 
     Doc: THTMLDocument;
+    HeadElement,
     BodyElement, TitleElement: TDOMElement;
 
     Module: TPasModule;
@@ -233,6 +238,8 @@ type
     procedure CreatePageBody(AElement: TPasElement; ASubpageIndex: Integer); virtual;
     procedure CreatePackagePageBody;
     procedure CreatePackageIndex;
+    procedure CreatePackageClassHierarchy;
+    procedure CreateClassHierarchyPage(AList: TStringList; AddUnit : Boolean);
     procedure AddModuleIdentifiers(AModule : TPasModule; L : TStrings);
     Procedure CreateTopicPageBody(AElement : TTopicElement);
     procedure CreateModulePageBody(AModule: TPasModule; ASubpageIndex: Integer);
@@ -286,9 +293,12 @@ type
 
 implementation
 
-uses SysUtils, XHTML, XMLRead, XMLWrite, HTMWrite, sh_pas,chmsitemap;
+uses SysUtils, XHTML, XMLRead, XMLWrite, HTMWrite, sh_pas, fpdocclasstree,
+  chmsitemap;
 
 {$i css.inc}
+{$i plusimage.inc}
+{$i minusimage.inc}
 
 Function FixHTMLpath(S : String) : STring;
 
@@ -525,6 +535,13 @@ constructor THTMLWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
     end;
   end;
 
+  Function HaveClasses(AModule: TPasModule) : Boolean;
+
+  begin
+    with AModule do
+      Result:=InterfaceSection.Classes.Count>0;
+  end;
+
   procedure ScanModule(AModule: TPasModule; LinkList : TObjectList);
   var
     i, j, k: Integer;
@@ -621,6 +638,7 @@ constructor THTMLWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
 var
   i: Integer;
   L : TObjectList;
+  H : Boolean;
 
 begin
   inherited ;
@@ -642,6 +660,15 @@ begin
     begin
     AddPage(Package, 0);
     AddPage(Package,IndexSubIndex);
+    I:=0;
+    H:=False;
+    While (I<Package.Modules.Count) and Not H do
+      begin
+      H:=HaveClasses(TPasModule(Package.Modules[i]));
+      Inc(I);
+      end;
+    if H then
+      AddPage(Package,ClassHierarchySubIndex);
     AddTopicPages(Package);
     end;
   L:=TObjectList.Create;
@@ -683,6 +710,7 @@ begin
   Doc.AppendChild(HTMLEl);
 
   HeadEl := Doc.CreateHeadElement;
+  HeadElement:=HeadEl;
   HTMLEl.AppendChild(HeadEl);
   El := Doc.CreateElement('meta');
   HeadEl.AppendChild(El);
@@ -762,6 +790,41 @@ begin
       end;
     end;
   CreateCSSFile;
+  CreatePlusImage;
+  CreateMinusImage;
+end;
+
+procedure THTMLWriter.CreatePlusImage;
+Var
+  TempStream: TMemoryStream;
+
+begin
+  TempStream := TMemoryStream.Create;
+  try
+    DoLog('Creating plus image',[]);
+    TempStream.WriteBuffer(PlusImageData,SizeOf(PlusImageData));
+    TempStream.Position := 0;
+    TempStream.SaveToFile(Engine.output+'plus.png');
+  finally
+    TempStream.Free;
+  end;
+end;
+
+procedure THTMLWriter.CreateMinusImage;
+
+Var
+  TempStream: TMemoryStream;
+
+begin
+  TempStream := TMemoryStream.Create;
+  try
+    DoLog('Creating minus image',[]);
+    TempStream.WriteBuffer(MinusImageData,SizeOf(MinusImageData));
+    TempStream.Position := 0;
+    TempStream.SaveToFile(Engine.output+'minus.png');
+  finally
+    TempStream.Free;
+  end;
 end;
 
 procedure THTMLWriter.CreateCSSFile;
@@ -2003,6 +2066,20 @@ var
       AppendText(ParaEl, ']');
   end;
 
+  procedure AddPackageLink(ALinkSubpageIndex: Integer; const AName: String);
+  begin
+    if FUseMenuBrackets then
+      AppendText(ParaEl, '[');
+    if ALinkSubpageIndex = ASubpageIndex then
+      AppendText(ParaEl, AName)
+    else
+      AppendText(
+        CreateLink(ParaEl, ResolveLinkWithinPackage(Package, ALinkSubpageIndex)),
+        AName);
+    if FUseMenuBrackets then
+      AppendText(ParaEl, ']');
+  end;
+
 begin
   TableEl := CreateEl(BodyElement, 'table');
   TableEl['cellpadding'] := '4';
@@ -2032,17 +2109,8 @@ begin
     end
   else
     begin
-    // Manually add link for package page
-    if FUseMenuBrackets then
-      AppendText(ParaEl, '[');
-    if (IndexSubIndex = ASubpageIndex) then
-      AppendText(ParaEl, SDocIdentifierIndex)
-    else
-      AppendText(
-        CreateLink(ParaEl, ResolveLinkWithinPackage(Package, IndexSubIndex)),
-        SDocIdentifierIndex);
-    if FUseMenuBrackets then
-      AppendText(ParaEl, ']');
+    AddPackageLink(IndexSubIndex, SDocIdentifierIndex);
+    AddPackageLink(ClassHierarchySubIndex, SDocPackageClassHierarchy);
     end;
 
   if Length(SearchPage) > 0 then
@@ -2269,6 +2337,162 @@ begin
     end;
 end;
 
+procedure THTMLWriter.CreateClassHierarchyPage(AList : TStringList; AddUnit : Boolean);
+  Procedure PushClassElement;
+
+  Var
+    H : THTMLElement;
+  begin
+    H:=CreateEl(CurOutputNode, 'li');
+    H['class']:='classtree';
+    PushOutputNode(H);
+    H:=CreateEl(CurOutputNode, 'span');
+    H['class']:='toggletreeclose';
+    H['onclick']:='expandorcollapse(this)';
+    PushOutputNode(h);
+    AppendNbSp(h,1);
+    PopOutputNode;
+  end;
+
+  Procedure PushClassList;
+
+  Var
+    H : THTMLElement;
+  begin
+    H:=CreateEl(CurOutputNode, 'ul');
+    H['class']:='classtreelist';
+    PushOutputNode(h);
+  end;
+
+  Procedure AppendClass(E : TDomElement);
+
+  Var
+    N : TDomNode;
+    P,PM : TPasElement;
+    NN : String;
+    EN : String;
+    LL : TstringList;
+    I,J : Integer;
+
+  begin
+    EN:=Package.Name+'.'+E['unit']+'.'+E.NodeName;
+    J:=AList.IndexOf(EN);
+    If J<>-1 then
+      P:=AList.Objects[J] as TPasElement
+    else
+      P:=Engine.FindElement(EN);
+    PushClassElement;
+    try
+      if (P<>Nil) then
+        begin
+        AppendHyperLink(CurOutputNode,P);
+        PM:=P.Getmodule;
+        if (PM<>Nil) then
+          begin
+          AppendText(CurOutputNode,' (');
+          AppendHyperLink(CurOutputNode,PM);
+          AppendText(CurOutputNode,')');
+          end
+        end
+      else
+        AppendText(CurOutputNode,P.Name);
+      LL:=TStringList.Create;
+      try
+        N:=E.FirstChild;
+        While (N<>Nil) do
+          begin
+          if (N.NodeType=ELEMENT_NODE) then
+            LL.AddObject(N.NodeName,N);
+          N:=N.NextSibling;
+          end;
+        if (LL.Count>0) then
+          begin
+          LL.Sorted:=true;
+          PushClassList;
+          try
+            For I:=0 to LL.Count-1 do
+              AppendClass(LL.Objects[i] as TDomElement);
+          finally
+            PopOutputNode;
+          end;
+          end;
+      finally
+        LL.Free;
+      end;
+    Finally
+      PopOutputNode;
+    end;
+  end;
+
+Var
+  B : TClassTreeBuilder;
+  E : TDomElement;
+  F : TFileStream;
+
+begin
+  PushOutputNode(BodyElement);
+  try
+    B:=TClassTreeBuilder.Create(Package,okClass);
+    try
+      B.BuildTree(AList);
+      // Classes
+      WriteXMLFile(B.ClassTree,'tree.xml');
+      // Dummy TObject
+      E:=B.ClassTree.DocumentElement;
+      PushClassList;
+      try
+        AppendClass(E);
+      finally
+        PopOutputNode;
+      end;
+    finally
+      B.Free;
+    end;
+  finally
+    PopOutputNode;
+  end;
+end;
+
+procedure THTMLWriter.CreatePackageClassHierarchy;
+
+Const
+  SFunc = 'function expandorcollapse (o) {'+sLineBreak+
+          '  o.className = (o.className=="toggletreeclose") ? "toggletreeopen" : "toggletreeclose";'+sLineBreak+
+          '  o.parentNode.className = (o.className=="toggletreeclose") ? "classtree" : "classtreeclosed";'+sLineBreak+
+          '  return false;'+sLineBreak+
+          '}';
+
+Var
+  L : TStringList;
+  I : Integer;
+  M : TPasModule;
+  E : TPasElement;
+  S : String;
+  SE : THTMLElement;
+
+begin
+  SE := Doc.CreateElement('script');
+  AppendText(SE,SFunc);
+  HeadElement.AppendChild(SE);
+  L:=TStringList.Create;
+  try
+    L.Capacity:=PageInfos.Count; // Too much, but that doesn't hurt.
+    For I:=0 to Package.Modules.Count-1 do
+      begin
+      M:=TPasModule(Package.Modules[i]);
+      Self.AddElementsFromList(L,M.InterfaceSection.Classes,True)
+      end;
+    AppendMenuBar(ClassHierarchySubIndex);
+    S:=Package.Name;
+    If Length(S)>0 then
+      Delete(S,1,1);
+    AppendTitle(Format(SDocPackageClassHierarchy, [S]));
+    CreateClassHierarchyPage(L,True);
+  Finally
+    L.Free;
+  end;
+end;
+
 procedure THTMLWriter.CreatePageBody(AElement: TPasElement;
   ASubpageIndex: Integer);
 var
@@ -2289,6 +2513,8 @@ begin
       CreatePackagePageBody
     else if ASubPageIndex=IndexSubIndex then
       CreatePackageIndex  
+    else if ASubPageIndex=ClassHierarchySubIndex then
+      CreatePackageClassHierarchy
     end
   else
     begin
@@ -2409,24 +2635,27 @@ begin
   end;  
 end;
 
+Procedure THTMLWriter.AddElementsFromList(L : TStrings; List : TFPList; UsePathName : Boolean = False);
+
+Var
+  I : Integer;
+  El : TPasElement;
+
+begin
+  For I:=0 to List.Count-1 do
+    begin
+    El:=TPasElement(List[I]);
+    if UsePathName then
+      L.AddObject(El.PathName,El)
+    else
+      L.AddObject(El.Name,El);
+    If el is TPasEnumType then
+      AddElementsFromList(L,TPasEnumType(el).Values);
+    end;
+end;
+
 procedure THTMLWriter.AddModuleIdentifiers(AModule : TPasModule; L : TStrings);
 
-  Procedure AddElementsFromList(L : TStrings; List : TFPList);
-  
-  Var
-    I : Integer;
-    El : TPasElement;
-    
-  begin
-    For I:=0 to List.Count-1 do
-      begin
-      El:=TPasElement(List[I]);
-      L.AddObject(El.Name,El);
-      If el is TPasEnumType then
-        AddElementsFromList(L,TPasEnumType(el).Values);
-      end;
-  end;
-  
 begin
   AddElementsFromList(L,AModule.InterfaceSection.Consts);
   AddElementsFromList(L,AModule.InterfaceSection.Types);
diff --git a/utils/fpdoc/fpclasschart.lpi b/utils/fpdoc/fpclasschart.lpi
index b071863a02..bf0b95eed5 100644
--- a/utils/fpdoc/fpclasschart.lpi
+++ b/utils/fpdoc/fpclasschart.lpi
@@ -1,22 +1,24 @@
 <?xml version="1.0"?>
 <CONFIG>
   <ProjectOptions>
-    <PathDelim Value="/"/>
-    <Version Value="6"/>
+    <Version Value="9"/>
     <General>
       <Flags>
         <SaveOnlyProjectUnits Value="True"/>
         <MainUnitHasUsesSectionForAllUnits Value="False"/>
         <MainUnitHasCreateFormStatements Value="False"/>
         <MainUnitHasTitleStatement Value="False"/>
+        <LRSInOutputDirectory Value="False"/>
       </Flags>
       <SessionStorage Value="InProjectDir"/>
       <MainUnit Value="0"/>
-      <TargetFileExt Value=""/>
     </General>
     <VersionInfo>
-      <ProjectVersion Value=""/>
+      <StringTable ProductVersion=""/>
     </VersionInfo>
+    <BuildModes Count="1">
+      <Item1 Name="default" Default="True"/>
+    </BuildModes>
     <PublishOptions>
       <Version Value="2"/>
       <IgnoreBinaries Value="False"/>
@@ -29,7 +31,7 @@
         <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
       </local>
     </RunParams>
-    <Units Count="2">
+    <Units Count="3">
       <Unit0>
         <Filename Value="fpclasschart.pp"/>
         <IsPartOfProject Value="True"/>
@@ -40,10 +42,20 @@
         <IsPartOfProject Value="True"/>
         <UnitName Value="dGlobals"/>
       </Unit1>
+      <Unit2>
+        <Filename Value="fpdocclasstree.pp"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="fpdocclasstree"/>
+      </Unit2>
     </Units>
   </ProjectOptions>
   <CompilerOptions>
-    <Version Value="8"/>
+    <Version Value="11"/>
+    <Parsing>
+      <SyntaxOptions>
+        <UseAnsiStrings Value="False"/>
+      </SyntaxOptions>
+    </Parsing>
     <Other>
       <CompilerPath Value="$(CompPath)"/>
     </Other>
diff --git a/utils/fpdoc/fpclasschart.pp b/utils/fpdoc/fpclasschart.pp
index 9203a5effc..3cb7bcd871 100644
--- a/utils/fpdoc/fpclasschart.pp
+++ b/utils/fpdoc/fpclasschart.pp
@@ -19,7 +19,7 @@ program fpclasschart;
 
 uses
   SysUtils, Classes, Typinfo, Gettext, dom, xmlread,
-  dGlobals, PasTree, PParser,PScanner, xmlwrite;
+  dGlobals, PasTree, PParser,PScanner, xmlwrite, fpdocclasstree;
 
 resourcestring
   STitle = 'fpClassTree - Create class tree from pascal sources';
@@ -37,20 +37,14 @@ type
 
   { TClassTreeEngine }
 
+
   TClassTreeEngine = class(TFPDocEngine)
   Private
-    FClassTree : TXMLDocument;
-    FTreeStart : TDomElement;
+    FTree : TClassTreeBuilder;
     FObjects : TStringList;
-    FObjectKind : TPasObjKind;
-    FParentObject : TPasClassType;
-    function LookForElement(PE: TDomElement; AElement: TPasElement): TDomNode;
-    function NodeMatch(N: TDomNode; AElement: TPasElement): Boolean;
-    Function AddToClassTree(AElement : TPasElement; Var ACount : Integer) : TDomElement;
   public
     Constructor Create(AClassTree : TXMLDocument; AObjectKind : TPasObjKind);
     Destructor Destroy; override;
-    Function BuildTree : Integer;
     function CreateElement(AClass: TPTreeElement; const AName: String;
       AParent: TPasElement; AVisibility :TPasMemberVisibility;
       const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement; override;
@@ -95,6 +89,11 @@ type
     Property MaxObjectsPerColumn : Integer Read FMaxObjectsPerColumn Write FMaxObjectsPerColumn;
   end;
 
+{ TClassTreeBuilder }
+
+
+
+
 { TChartFormatter }
 
 constructor TClassChartFormatter.Create(AXML: TXMLDocument);
@@ -450,21 +449,11 @@ end;
 
 Constructor TClassTreeEngine.Create(AClassTree : TXMLDocument; AObjectKind : TPasObjKind);
 
-Var
-  N : TDomNode;
 
 begin
-  FClassTree:=AClassTree;
-  FTreeStart:=FClassTree.DocumentElement;
   FPackage:=TPasPackage.Create('dummy',Nil);
-  FObjectKind:=AObjectKind;
+  FTree:=TClassTreeBuilder.Create(FPackage,AObjectKind);
   FObjects:=TStringList.Create;
-  Case FObjectkind of
-    okObject    : FParentObject:=TPasClassType.Create('TObject',FPackage);
-    okClass     : FParentObject:=TPasClassType.Create('TObject',FPackage);
-    okInterface : FParentObject:=TPasClassType.Create('IInterface',FPackage);
-  end;
-  FParentObject.ObjKind:=FObjectKind;
   Inherited Create;
 end;
 
@@ -474,89 +463,7 @@ begin
   inherited Destroy;
 end;
 
-Function TClassTreeEngine.BuildTree : Integer;
 
-Var
-  I : Integer;
-  PC : TPasClassType;
-
-begin
-  Result:=0;
-  FObjects.Sorted:=True;
-  For I:=0 to FObjects.Count-1 do
-    begin
-    PC:=TPasClassType(FObjects.Objects[i]);
-    If (PC.ObjKind=FObjectKind) and Not PC.IsForward then
-      AddToClassTree(PC as TPasElement,Result)
-    end;
-end;
-
-Function TClassTreeEngine.NodeMatch(N : TDomNode; AElement : TPasElement) : Boolean;
-
-begin
-  Result:=(N.NodeType=ELEMENT_NODE) and (CompareText(N.NodeName,AElement.Name)=0)
-end;
-
-Function TClassTreeEngine.LookForElement(PE : TDomElement; AElement : TPasElement) : TDomNode;
-
-Var
-  N : TDomNode;
-
-begin
-  Result:=PE.FirstChild;
-  While (Result<>Nil) and Not NodeMatch(Result,AElement) do
-    Result:=Result.NextSibling;
-  If (Result=Nil) then
-    begin
-    N:=PE.FirstChild;
-    While (Result=Nil) and (N<>Nil) do
-      begin
-      if (N.NodeType=ELEMENT_NODE) then
-        begin
-        Result:=LookForElement(N as TDomElement,AElement);
-        end;
-      N:=N.NextSibling;
-      end;
-    end
-end;
-
-Function TClassTreeEngine.AddToClassTree(AElement : TPasElement; Var ACount : Integer) : TDomElement;
-
-Var
-  PC : TPasClassType;
-  PE : TDomElement;
-  M : TPasModule;
-  N : TDomNode;
-
-begin
-  PE:=Nil;
-  If (AElement is TPasClassType) then
-    begin
-    PC:=AElement as TPasClassType;
-    If not Assigned(PC.AncestorType) and (CompareText(PC.Name,FParentObject.Name)<>0) then
-      PC.AncestorType:=FParentObject;
-    If Assigned(PC.AncestorType) then
-      PE:=AddToClassTree(PC.AncestorType,ACount);
-    end;
-  If (PE=Nil) then
-    PE:=FTreeStart;
-  N:=LookForElement(PE,AElement);
-  If (N<>Nil) then
-    Result:=N as TDomElement
-  else
-    begin
-    Inc(ACount);
-    Result:=FClassTree.CreateElement(AElement.Name);
-    If Not (AElement is TPasUnresolvedTypeRef) then
-      begin
-      M:=AElement.GetModule;
-      if Assigned(M) then
-        Result['unit']:=M.Name;
-      end;
-    PE.AppendChild(Result);
-    end;
-end;    
-    
 { ---------------------------------------------------------------------
   Main program. Document all units.    
   ---------------------------------------------------------------------}
@@ -636,7 +543,7 @@ begin
       Engine := TClassTreeEngine.Create(XML,AObjectKind);
       Try
         ParseSource(Engine,InputFiles[I],OSTarget,CPUTarget);
-        ACount:=ACount+Engine.BuildTree;
+        ACount:=ACount+Engine.Ftree.BuildTree(Engine.FObjects);
       Finally
         Engine.Free;
       end;
diff --git a/utils/fpdoc/fpdoc.css b/utils/fpdoc/fpdoc.css
index 09218e5384..169089a184 100644
--- a/utils/fpdoc/fpdoc.css
+++ b/utils/fpdoc/fpdoc.css
@@ -1,5 +1,5 @@
 /*
-  $Id: fpdoc.css,v 1.1 2003/03/17 23:03:20 michael Exp $
+  $Id: fpdoc.cst,v 1.1 2005/01/02 16:22:16 michael Exp $
 
   Default style sheet for FPDoc reference documentation
   by Sebastian Guenther, sg@freepascal.org
@@ -62,6 +62,10 @@ span.code {
 span.sym {
   color: darkred
 }
+/* No wordwrap in code fragments */
+span.code {
+   white-space: nowrap
+}
 
 /* keywords in source fragments */
 span.kw {
@@ -127,40 +131,30 @@ table.bar {
   background-color: #a0c0ff;
 }
 
+td p {
+ margin: 0;
+}
+
 span.bartitle {
   font-weight: bold;
   font-style: italic;
   color: darkblue
 }
 
-span.footer {
-  font-style: italic;
-  color: darkblue
+span.toggletreeclose {
+    background: url(minus.png) center left no-repeat;
+    padding-left: 20px; 
 }
 
-/* definition list */
-dl {
- border: 3px double #ccc;
- padding: 0.5em;
+span.toggletreeopen {
+    background: url(plus.png) center left no-repeat;
+    padding-left: 20px; 
 }
 
-/* definition list: term */
-dt {
- float: left;
- clear: left;
- width: auto; /* normally browsers default width of largest item */
- padding-right: 20px;
- font-weight: bold;
- color: darkgreen;
-}
+ul.classtreelist li { padding-left: 0px; }
 
-/* definition list: description */
-dd {
- margin: 0 0 0 110px;
- padding: 0 0 0.5em 0;
-}
+ul.classtreelist { list-style-type:none; }
 
-/* for browsers in standards compliance mode */
-td p {
-  margin: 0;
-}
+li.classtree ul { display: block; }
+
+li.classtreeclosed ul { display: none; }
diff --git a/utils/fpdoc/fpdoc.lpi b/utils/fpdoc/fpdoc.lpi
index 988963cecf..07fdce3d02 100644
--- a/utils/fpdoc/fpdoc.lpi
+++ b/utils/fpdoc/fpdoc.lpi
@@ -31,7 +31,7 @@
     <RunParams>
       <local>
         <FormatVersion Value="1"/>
-        <CommandLineParams Value="--project=fpdoc.xml"/>
+        <CommandLineParams Value="--package=me --output=me --input=ct.pp --format=html"/>
         <LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
       </local>
     </RunParams>
@@ -40,7 +40,7 @@
         <PackageName Value="FCL"/>
       </Item1>
     </RequiredPackages>
-    <Units Count="15">
+    <Units Count="16">
       <Unit0>
         <Filename Value="fpdoc.pp"/>
         <IsPartOfProject Value="True"/>
@@ -116,6 +116,11 @@
         <IsPartOfProject Value="True"/>
         <UnitName Value="mkfpdoc"/>
       </Unit14>
+      <Unit15>
+        <Filename Value="fpdocclasstree.pp"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="fpdocclasstree"/>
+      </Unit15>
     </Units>
   </ProjectOptions>
   <CompilerOptions>
diff --git a/utils/fpdoc/fpdoc.pp b/utils/fpdoc/fpdoc.pp
index d4db8e2e6d..122c55e81e 100644
--- a/utils/fpdoc/fpdoc.pp
+++ b/utils/fpdoc/fpdoc.pp
@@ -23,6 +23,7 @@ uses
 {$endif}
   SysUtils, Classes, Gettext, custapp,
   dGlobals,  // Global definitions, constants.
+  fpdocclasstree, // Class tree builder
   dwriter,   // TFPDocWriter definition.
   dwlinear,  // Linear (abstract) writer
   dw_LaTeX,  // TLaTex writer
diff --git a/utils/fpdoc/fpdocclasstree.pp b/utils/fpdoc/fpdocclasstree.pp
new file mode 100644
index 0000000000..4cd478c656
--- /dev/null
+++ b/utils/fpdoc/fpdocclasstree.pp
@@ -0,0 +1,160 @@
+unit fpdocclasstree;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, DOM, pastree;
+
+Type
+  TClassTreeBuilder = Class
+  Private
+    FClassTree : TXMLDocument;
+    FTreeStart : TDomElement;
+    FObjectKind : TPasObjKind;
+    FPackage: TPasPackage;
+    FParentObject : TPasClassType;
+  Protected
+    function LookForElement(PE: TDomElement; AElement: TPasElement): TDomNode;
+    function NodeMatch(N: TDomNode; AElement: TPasElement): Boolean;
+    Function AddToClassTree(AElement : TPasElement; Var ACount : Integer) : TDomElement;
+  Public
+    Constructor Create(APackage : TPasPackage; AObjectKind : TPasObjKind = okClass);
+    Destructor Destroy; override;
+    Function BuildTree(AObjects : TStringList) : Integer;
+    Property ClassTree : TXMLDocument Read FClassTree;
+  end;
+
+implementation
+
+constructor TClassTreeBuilder.Create(APackage : TPasPackage;
+  AObjectKind: TPasObjKind);
+Var
+  N : TDomNode;
+begin
+  FCLassTree:=TXMLDocument.Create;
+  FPackage:=APAckage;
+  FObjectKind:=AObjectKind;
+  Case FObjectkind of
+    okObject    : FParentObject:=TPasClassType.Create('System.TObject',FPackage);
+    okClass     : FParentObject:=TPasClassType.Create('System.TObject',FPackage);
+    okInterface : FParentObject:=TPasClassType.Create('System.IInterface',FPackage);
+  end;
+  FParentObject.ObjKind:=FObjectKind;
+  FTreeStart:=FClassTree.CreateElement('TObject');
+  FTreeStart['unit']:='System';
+  ClassTree.AppendChild(FTreeStart);
+end;
+
+destructor TClassTreeBuilder.Destroy;
+begin
+  FreeAndNil(FClassTree);
+  Inherited;
+end;
+Function TClassTreeBuilder.BuildTree(AObjects : TStringList) : Integer;
+
+Var
+  I : Integer;
+  PC : TPasClassType;
+
+begin
+  Result:=0;
+  AObjects.Sorted:=True;
+  For I:=0 to AObjects.Count-1 do
+    begin
+    PC:=TPasClassType(AObjects.Objects[i]);
+    If (PC.ObjKind=FObjectKind) and Not PC.IsForward then
+      begin
+      AddToClassTree(PC as TPasElement,Result)
+      end;
+    end;
+end;
+
+Function TClassTreeBuilder.NodeMatch(N : TDomNode; AElement : TPasElement) : Boolean;
+
+Var
+  S : String;
+
+begin
+  Result:=(N.NodeType=ELEMENT_NODE);
+  if Result then
+    begin
+    S:=N.NodeName;
+    S:=FPackage.Name+'.'+TDomElement(N)['unit']+'.'+S;
+    Result:= (CompareText(S,AElement.PathName)=0)
+    end;
+end;
+
+Function TClassTreeBuilder.LookForElement(PE : TDomElement; AElement : TPasElement) : TDomNode;
+
+Var
+  N : TDomNode;
+
+begin
+  Result:=PE;
+  While (Result<>Nil) and Not NodeMatch(Result,AElement) do
+    Result:=Result.NextSibling;
+  If (Result=Nil) then
+    begin
+    N:=PE.FirstChild;
+    While (Result=Nil) and (N<>Nil) do
+      begin
+      if (N.NodeType=ELEMENT_NODE) then
+        begin
+        Result:=LookForElement(N as TDomElement,AElement);
+        end;
+      N:=N.NextSibling;
+      end;
+    end
+end;
+
+Function TClassTreeBuilder.AddToClassTree(AElement : TPasElement; Var ACount : Integer) : TDomElement;
+
+Var
+  PC : TPasClassType;
+  PE : TDomElement;
+  M : TPasModule;
+  N : TDomNode;
+
+begin
+  Result:=Nil;
+  If (AElement=Nil) then
+    Result:=FTreeStart
+  else If (AElement is TPasClassType) then
+    begin
+    Writeln('Doing ',AElement.Name);
+    if (AElement=FParentObject) then
+      Result:=FTreeStart
+    else
+      begin
+      PC:=AElement as TPasClassType;
+      PE:=AddToClassTree(PC.AncestorType,ACount);
+      N:=LookForElement(PE,AElement);
+      If (N<>Nil) then
+        Result:=N as TDomElement
+      else
+        begin
+        Inc(ACount);
+        Result:=FClassTree.CreateElement(AElement.Name);
+        If Not (AElement is TPasUnresolvedTypeRef) then
+          begin
+          M:=AElement.GetModule;
+          if Assigned(M) then
+            Result['unit']:=M.Name;
+          end;
+        if (PE=FTreeStart) then
+          begin
+          Writeln('Adding to tree start :',AELement.Name);
+          Writeln('Have ancestor : ',PC.AncestorType<>Nil);
+          if (PC.AncestorType<>Nil) then
+            Writeln(PC.AncestorType.ClassName, ' : '+PC.AncestorType.Name);
+          end;
+        PE.AppendChild(Result);
+        end;
+     end;
+    end
+end;
+
+end.
+
diff --git a/utils/fpdoc/minusimage.inc b/utils/fpdoc/minusimage.inc
new file mode 100644
index 0000000000..4d076e51aa
--- /dev/null
+++ b/utils/fpdoc/minusimage.inc
@@ -0,0 +1,20 @@
+
+Const
+  MinusImageData : Array[0..273] of byte = (
+     137, 80, 78, 71, 13, 10, 26, 10,  0,  0,  0, 13, 73, 72, 68, 82,  0,
+       0,  0, 19,  0,  0,  0, 19,  8,  4,  0,  0,  0,216, 89,254, 71,  0,
+       0,  0,  2, 98, 75, 71, 68,  0,238,237, 63,236, 77,  0,  0,  0,  9,
+     112, 72, 89,115,  0,  0,  0, 72,  0,  0,  0, 72,  0, 70,201,107, 62,
+       0,  0,  0,  9,118,112, 65,103,  0,  0,  0, 19,  0,  0,  0, 19,  0,
+     241,127,140,174,  0,  0,  0, 63, 73, 68, 65, 84, 40,207, 99,124,199,
+      64, 12, 96, 34, 74,213,192, 40, 99, 65, 48, 39,253, 71,151,204, 99,
+     196,162,140,129,161, 30, 69, 81, 35, 61,220,198,192,192,192,  0,119,
+      12,195,127,124,202,254,227, 48,141,134,110,107,196,169,140,113,232,
+     167, 16,  0,229, 60,  7,139,203,229, 71,  3,  0,  0,  0, 37,116, 69,
+      88,116,100, 97,116,101, 58, 99,114,101, 97,116,101,  0, 50, 48, 49,
+      50, 45, 49, 50, 45, 50, 48, 84, 49, 53, 58, 48, 52, 58, 52, 48, 43,
+      48, 49, 58, 48, 48, 36,251,160,191,  0,  0,  0, 37,116, 69, 88,116,
+     100, 97,116,101, 58,109,111,100,105,102,121,  0, 50, 48, 49, 50, 45,
+      49, 50, 45, 50, 48, 84, 49, 53, 58, 48, 52, 58, 52, 48, 43, 48, 49,
+      58, 48, 48, 85,166, 24,  3,  0,  0,  0,  0, 73, 69, 78, 68,174, 66,
+      96,130);
diff --git a/utils/fpdoc/plusimage.inc b/utils/fpdoc/plusimage.inc
new file mode 100644
index 0000000000..98f9d74a0b
--- /dev/null
+++ b/utils/fpdoc/plusimage.inc
@@ -0,0 +1,21 @@
+
+Const
+  PlusImageData : Array[0..288] of byte = (
+     137, 80, 78, 71, 13, 10, 26, 10,  0,  0,  0, 13, 73, 72, 68, 82,  0,
+       0,  0, 19,  0,  0,  0, 19,  8,  4,  0,  0,  0,216, 89,254, 71,  0,
+       0,  0,  2, 98, 75, 71, 68,  0,238,237, 63,236, 77,  0,  0,  0,  9,
+     112, 72, 89,115,  0,  0,  0, 72,  0,  0,  0, 72,  0, 70,201,107, 62,
+       0,  0,  0,  9,118,112, 65,103,  0,  0,  0, 19,  0,  0,  0, 19,  0,
+     241,127,140,174,  0,  0,  0, 78, 73, 68, 65, 84, 40,207, 99,124,199,
+      64, 12, 96, 34, 74,213,192, 40, 99, 65, 48, 39,253, 71,151,204, 99,
+     196,162,140,129,161, 30, 69, 81, 35,126, 75, 25, 49,133,200,112, 27,
+     194, 36, 70,  6,  6,134,255,248,148,253,103, 96, 96, 96,100,192,240,
+      11,  5,225,246, 31,139, 50, 20, 75, 27, 25,112,  1,198,161,159, 66,
+       0, 47,159,  9,140, 36, 84,124, 38,  0,  0,  0, 37,116, 69, 88,116,
+     100, 97,116,101, 58, 99,114,101, 97,116,101,  0, 50, 48, 49, 50, 45,
+      49, 50, 45, 50, 48, 84, 49, 53, 58, 48, 52, 58, 50, 50, 43, 48, 49,
+      58, 48, 48,117, 11,184, 17,  0,  0,  0, 37,116, 69, 88,116,100, 97,
+     116,101, 58,109,111,100,105,102,121,  0, 50, 48, 49, 50, 45, 49, 50,
+      45, 50, 48, 84, 49, 53, 58, 48, 52, 58, 50, 50, 43, 48, 49, 58, 48,
+      48,  4, 86,  0,173,  0,  0,  0,  0, 73, 69, 78, 68,174, 66, 96,130
+     );