Bladeren bron

Merged revisions 10435,10582,10604,10607,10815-10816,10825,10827,10849,10854-10855,10869,10878,10883,10896,10947 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r10435 | marco | 2008-03-03 09:28:26 +0100 (Mon, 03 Mar 2008) | 1 line

* comment fix #10781
........
r10582 | marco | 2008-03-29 12:24:02 +0100 (Sat, 29 Mar 2008) | 1 line

* comment fix for vincent
........
r10604 | marco | 2008-04-06 11:46:01 +0200 (Sun, 06 Apr 2008) | 1 line

* Parameter renames for some much used functions from Graeme (#11034)
........
r10607 | marco | 2008-04-06 14:28:18 +0200 (Sun, 06 Apr 2008) | 2 lines

* fix for 10766
........
r10815 | florian | 2008-04-27 15:18:40 +0200 (Sun, 27 Apr 2008) | 1 line

+ variant functions of oleaut32.dll added
........
r10816 | marco | 2008-04-27 17:22:44 +0200 (Sun, 27 Apr 2008) | 2 lines

* partial fix for 11156
........
r10825 | marco | 2008-04-27 22:33:33 +0200 (Sun, 27 Apr 2008) | 2 lines

* SharedSuffix
........
r10827 | marco | 2008-04-27 22:49:31 +0200 (Sun, 27 Apr 2008) | 1 line

* fix for 12225
........
r10849 | marco | 2008-05-01 13:23:04 +0200 (Thu, 01 May 2008) | 2 lines

* fix for 11238
........
r10854 | marco | 2008-05-01 17:24:06 +0200 (Thu, 01 May 2008) | 2 lines

* Updated header translations from Luiz. Now should work for win32 too
........
r10855 | marco | 2008-05-01 17:41:36 +0200 (Thu, 01 May 2008) | 2 lines

* patch for #11110, unc drives and forcedirectories from Bart.
........
r10869 | marco | 2008-05-02 22:13:19 +0200 (Fri, 02 May 2008) | 2 lines

* patch for gtk_file_chooser do_overwrite_confirmation getter and setter (#11246)
........
r10878 | marco | 2008-05-04 17:51:26 +0200 (Sun, 04 May 2008) | 2 lines

* Examples from 10820. Russian one needs testing. Makefile will follow
........
r10883 | marco | 2008-05-04 20:51:42 +0200 (Sun, 04 May 2008) | 2 lines

* some minor cleanup + removal of possibly non endian safe formal param getyx functions from ncurses, closes 11012
........
r10896 | marco | 2008-05-07 00:12:06 +0200 (Wed, 07 May 2008) | 2 lines

* bug #10571, getcompletionstatus was already added, postcompletionstatus in this commit
........
r10947 | marco | 2008-05-11 15:04:18 +0200 (Sun, 11 May 2008) | 2 lines

* tboolresult for xinerama, fixes 11147
........

git-svn-id: branches/fixes_2_2@10952 -

marco 17 jaren geleden
bovenliggende
commit
8d5f0ee6a8
50 gewijzigde bestanden met toevoegingen van 4012 en 723 verwijderingen
  1. 19 0
      .gitattributes
  2. 187 137
      packages/cairo/Makefile
  3. 16 2
      packages/cairo/Makefile.fpc
  4. 21 4
      packages/cairo/fpmake.pp
  5. 395 260
      packages/cairo/src/cairo.pp
  6. 57 0
      packages/cairo/src/cairoft.pp
  7. 46 0
      packages/cairo/src/cairowin32.pp
  8. 47 0
      packages/cairo/src/cairoxlib.pp
  9. 3 0
      packages/fcl-registry/src/registry.pp
  10. 4 2
      packages/fcl-registry/src/xregreg.inc
  11. 4 0
      packages/gtk2/src/gtk+/gtk/gtkfilechooser.inc
  12. 6 6
      packages/mysql/src/mysql.inc
  13. 1 1
      packages/mysql/src/mysql3_comdyn.pp
  14. 1 1
      packages/mysql/src/mysql3dyn.pp
  15. 2 2
      packages/mysql/src/mysql4.pp
  16. 2 2
      packages/mysql/src/mysql4_com.pp
  17. 1 1
      packages/mysql/src/mysql4_comdyn.pp
  18. 1 1
      packages/mysql/src/mysql4dyn.pp
  19. 115 59
      packages/ncurses/Makefile
  20. 1 1
      packages/ncurses/Makefile.fpc
  21. BIN
      packages/ncurses/examples/ru/messages.mo
  22. 83 0
      packages/ncurses/examples/t1form.pp
  23. 65 0
      packages/ncurses/examples/t1menu.pp
  24. 190 0
      packages/ncurses/examples/t1panel.pp
  25. 186 0
      packages/ncurses/examples/t2form.pp
  26. 433 0
      packages/ncurses/examples/t2menu.pp
  27. 169 0
      packages/ncurses/examples/t2panel.pp
  28. 241 0
      packages/ncurses/examples/t3form.pp
  29. 67 0
      packages/ncurses/examples/tbackground.pp
  30. 267 0
      packages/ncurses/examples/tclock.pp
  31. 40 0
      packages/ncurses/examples/tevent.pp
  32. 144 0
      packages/ncurses/examples/tmouse.pp
  33. 49 0
      packages/ncurses/examples/tnlshello.pp
  34. 7 0
      packages/ncurses/examples/tnlshello_ru_UTF8.pot
  35. 567 0
      packages/ncurses/examples/tpad.pp
  36. 82 0
      packages/ncurses/examples/twindow.pp
  37. 0 46
      packages/ncurses/src/form.pp
  38. 101 85
      packages/ncurses/src/ncurses.pp
  39. 0 11
      packages/ncurses/src/panel.pp
  40. 297 46
      packages/winunits-base/src/activex.pp
  41. 6 6
      packages/winunits-base/src/shlobj.pp
  42. 2 2
      packages/x11/src/xinerama.pp
  43. 35 35
      packages/x11/src/xlib.pp
  44. 3 3
      packages/x11/src/xutil.pp
  45. 17 1
      rtl/inc/dynlibs.pas
  46. 3 3
      rtl/objpas/sysutils/datih.inc
  47. 13 2
      rtl/objpas/sysutils/sysutils.inc
  48. 1 0
      rtl/win/wininc/base.inc
  49. 11 1
      rtl/win/wininc/defines.inc
  50. 4 3
      rtl/win/wininc/redef.inc

+ 19 - 0
.gitattributes

@@ -889,6 +889,9 @@ packages/cairo/Makefile svneol=native#text/plain
 packages/cairo/Makefile.fpc svneol=native#text/plain
 packages/cairo/fpmake.pp svneol=native#text/plain
 packages/cairo/src/cairo.pp svneol=native#text/plain
+packages/cairo/src/cairoft.pp svneol=native#text/plain
+packages/cairo/src/cairowin32.pp svneol=native#text/plain
+packages/cairo/src/cairoxlib.pp svneol=native#text/plain
 packages/cdrom/Makefile svneol=native#text/plain
 packages/cdrom/Makefile.fpc svneol=native#text/plain
 packages/cdrom/README svneol=native#text/plain
@@ -3108,7 +3111,23 @@ packages/ncurses/examples/edit_demo.pp svneol=native#text/plain
 packages/ncurses/examples/firework.pp svneol=native#text/plain
 packages/ncurses/examples/menu_demo.pp svneol=native#text/plain
 packages/ncurses/examples/ocrt_demo.pp svneol=native#text/plain
+packages/ncurses/examples/ru/messages.mo -text
 packages/ncurses/examples/screen_demo.pp svneol=native#text/plain
+packages/ncurses/examples/t1form.pp svneol=native#text/plain
+packages/ncurses/examples/t1menu.pp svneol=native#text/plain
+packages/ncurses/examples/t1panel.pp svneol=native#text/plain
+packages/ncurses/examples/t2form.pp svneol=native#text/plain
+packages/ncurses/examples/t2menu.pp svneol=native#text/plain
+packages/ncurses/examples/t2panel.pp svneol=native#text/plain
+packages/ncurses/examples/t3form.pp svneol=native#text/plain
+packages/ncurses/examples/tbackground.pp svneol=native#text/plain
+packages/ncurses/examples/tclock.pp svneol=native#text/plain
+packages/ncurses/examples/tevent.pp svneol=native#text/plain
+packages/ncurses/examples/tmouse.pp svneol=native#text/plain
+packages/ncurses/examples/tnlshello.pp svneol=native#text/plain
+packages/ncurses/examples/tnlshello_ru_UTF8.pot svneol=native#text/plain
+packages/ncurses/examples/tpad.pp svneol=native#text/plain
+packages/ncurses/examples/twindow.pp svneol=native#text/plain
 packages/ncurses/fpmake.pp svneol=native#text/plain
 packages/ncurses/src/eti.inc svneol=native#text/plain
 packages/ncurses/src/form.pp svneol=native#text/plain

+ 187 - 137
packages/cairo/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/01/26]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/05/12]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd 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 avr-embedded armeb-linux armeb-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
@@ -167,6 +167,17 @@ OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
 endif
 FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
 FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifeq ($(CPU_TARGET),armeb)
+ARCH=arm
+override FPCOPT+=-Cb
+else
+ifeq ($(CPU_TARGET),armel)
+ARCH=arm
+override FPCOPT+=-CaEABI
+else
+ARCH=$(CPU_TARGET)
+endif
+endif
 ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
 TARGETSUFFIX=$(OS_TARGET)
 SOURCESUFFIX=$(OS_SOURCE)
@@ -188,7 +199,7 @@ endif
 ifeq ($(OS_TARGET),linux)
 linuxHier=1
 endif
-export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+export OS_TARGET OS_SOURCE ARCH CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
 ifdef FPCDIR
 override FPCDIR:=$(subst \,/,$(FPCDIR))
 ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
@@ -243,163 +254,175 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(F
 override PACKAGE_NAME=cairo
 override PACKAGE_VERSION=2.0.4
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairowin32
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft  cairoxlib
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=cairo
+override TARGET_UNITS+=cairo cairoft
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override TARGET_UNITS+=cairo cairoft
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override TARGET_UNITS+=cairo cairoft  cairoxlib
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override TARGET_UNITS+=cairo cairoft
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -537,6 +560,9 @@ endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override COMPILER_INCLUDEDIR+=src
 endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_INCLUDEDIR+=src
+endif
 ifeq ($(FULL_TARGET),arm-wince)
 override COMPILER_INCLUDEDIR+=src
 endif
@@ -561,6 +587,15 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override COMPILER_INCLUDEDIR+=src
 endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_SOURCEDIR+=src tests
 endif
@@ -696,6 +731,9 @@ endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override COMPILER_SOURCEDIR+=src tests
 endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_SOURCEDIR+=src tests
+endif
 ifeq ($(FULL_TARGET),arm-wince)
 override COMPILER_SOURCEDIR+=src tests
 endif
@@ -720,6 +758,15 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 override COMPILER_SOURCEDIR+=src tests
 endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_SOURCEDIR+=src tests
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_SOURCEDIR+=src tests
+endif
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 endif
@@ -1498,19 +1545,18 @@ else
 TAROPT=vz
 TAREXT=.tar.gz
 endif
-override REQUIRE_PACKAGES=rtl x11 fcl-image
+override REQUIRE_PACKAGES=rtl fcl-image
 ifeq ($(FULL_TARGET),i386-linux)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1519,7 +1565,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1530,7 +1575,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1539,16 +1583,15 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1557,25 +1600,24 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1584,7 +1626,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1593,16 +1634,15 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1611,16 +1651,15 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1629,7 +1668,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1638,7 +1676,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1647,7 +1684,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1656,7 +1692,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1665,7 +1700,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1674,34 +1708,33 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1710,7 +1743,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1719,16 +1751,15 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1737,7 +1768,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1746,25 +1776,24 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1773,7 +1802,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1782,16 +1810,15 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1800,7 +1827,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1809,34 +1835,33 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1845,34 +1870,33 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1883,7 +1907,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1892,25 +1915,32 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
-ifeq ($(FULL_TARGET),arm-wince)
+ifeq ($(FULL_TARGET),arm-darwin)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASJPEG=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-IMAGE=1
 REQUIRE_PACKAGES_X11=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1919,7 +1949,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1928,7 +1957,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1937,7 +1965,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1946,7 +1973,6 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -1955,25 +1981,49 @@ REQUIRE_PACKAGES_FCL-IMAGE=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 REQUIRE_PACKAGES_RTL=1
-REQUIRE_PACKAGES_X11=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 REQUIRE_PACKAGES_FCL-IMAGE=1
+REQUIRE_PACKAGES_X11=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASJPEG=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-IMAGE=1
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASJPEG=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-IMAGE=1
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASJPEG=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-IMAGE=1
 REQUIRE_PACKAGES_X11=1
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_PASJPEG=1
 REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -2006,32 +2056,6 @@ ifdef UNITDIR_RTL
 override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
 endif
-ifdef REQUIRE_PACKAGES_X11
-PACKAGEDIR_X11:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /x11/Makefile.fpc,$(PACKAGESDIR))))))
-ifneq ($(PACKAGEDIR_X11),)
-ifneq ($(wildcard $(PACKAGEDIR_X11)/units/$(TARGETSUFFIX)),)
-UNITDIR_X11=$(PACKAGEDIR_X11)/units/$(TARGETSUFFIX)
-else
-UNITDIR_X11=$(PACKAGEDIR_X11)
-endif
-ifdef CHECKDEPEND
-$(PACKAGEDIR_X11)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_X11) $(FPCMADE)
-override ALLDEPENDENCIES+=$(PACKAGEDIR_X11)/$(FPCMADE)
-endif
-else
-PACKAGEDIR_X11=
-UNITDIR_X11:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /x11/Package.fpc,$(UNITSDIR)))))
-ifneq ($(UNITDIR_X11),)
-UNITDIR_X11:=$(firstword $(UNITDIR_X11))
-else
-UNITDIR_X11=
-endif
-endif
-ifdef UNITDIR_X11
-override COMPILER_UNITDIR+=$(UNITDIR_X11)
-endif
-endif
 ifdef REQUIRE_PACKAGES_PASJPEG
 PACKAGEDIR_PASJPEG:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /pasjpeg/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_PASJPEG),)
@@ -2162,6 +2186,32 @@ ifdef UNITDIR_FCL-IMAGE
 override COMPILER_UNITDIR+=$(UNITDIR_FCL-IMAGE)
 endif
 endif
+ifdef REQUIRE_PACKAGES_X11
+PACKAGEDIR_X11:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /x11/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_X11),)
+ifneq ($(wildcard $(PACKAGEDIR_X11)/units/$(TARGETSUFFIX)),)
+UNITDIR_X11=$(PACKAGEDIR_X11)/units/$(TARGETSUFFIX)
+else
+UNITDIR_X11=$(PACKAGEDIR_X11)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_X11)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_X11) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_X11)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_X11=
+UNITDIR_X11:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /x11/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_X11),)
+UNITDIR_X11:=$(firstword $(UNITDIR_X11))
+else
+UNITDIR_X11=
+endif
+endif
+ifdef UNITDIR_X11
+override COMPILER_UNITDIR+=$(UNITDIR_X11)
+endif
+endif
 ifdef REQUIRE_PACKAGES_WINUNITS-BASE
 PACKAGEDIR_WINUNITS-BASE:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /winunits-base/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_WINUNITS-BASE),)
@@ -2215,13 +2265,13 @@ override COMPILER_UNITDIR+=$(UNITDIR_WINUNITS-JEDI)
 endif
 endif
 ifndef NOCPUDEF
-override FPCOPTDEF=$(CPU_TARGET)
+override FPCOPTDEF=$(ARCH)
 endif
 ifneq ($(OS_TARGET),$(OS_SOURCE))
 override FPCOPT+=-T$(OS_TARGET)
 endif
 ifneq ($(CPU_TARGET),$(CPU_SOURCE))
-override FPCOPT+=-P$(CPU_TARGET)
+override FPCOPT+=-P$(ARCH)
 endif
 ifeq ($(OS_SOURCE),openbsd)
 override FPCOPT+=-FD$(NEW_BINUTILS_PATH)

+ 16 - 2
packages/cairo/Makefile.fpc

@@ -2,14 +2,28 @@
 #   Makefile.fpc for cairo
 #
 [require]
-packages=x11 fcl-image
+packages=fcl-image
+#packages_win32=
+packages_linux=x11
+packages_freebsd=x11
+packages_netbsd=x11
+packages_openbsd=x11
+packages_solaris=x11
+packages_darwin=x11
 
 [package]
 name=cairo
 version=2.0.4
 
 [target]
-units=cairo
+units=cairo cairoft
+units_win32=cairowin32
+units_linux=cairoxlib
+units_freebsd=cairoxlib
+units_netbsd=cairoxlib
+units_openbsd=cairoxlib
+units_solaris=cairoxlib
+units_darwin=cairoxlib
 
 [install]
 fpcpackage=y

+ 21 - 4
packages/cairo/fpmake.pp

@@ -19,12 +19,29 @@ begin
     P.Version:='2.2.1';
     P.SourcePath.Add('src');
 
-    P.Dependencies.Add('x11');
+    P.Dependencies.Add('x11',AllUnixOSes);
     P.Dependencies.Add('fcl-image');
-    
-    T:=P.Targets.AddUnit('cairo.pp');
-
 
+    T:=P.Targets.AddUnit('cairo.pp');
+    T:=P.Targets.AddUnit('cairoft.pp');
+    with T.Dependencies do
+      begin
+        AddUnit('cairo');
+        AddUnit('freetypeh');
+      end;
+   T:=P.Targets.AddUnit('cairoxlib.pp',AllUnixOSes);
+    with T.Dependencies do
+      begin
+        AddUnit('cairo');
+        AddUnit('xlib');
+        AddUnit('xrender');
+      end;
+   T:=P.Targets.AddUnit('cairowin32.pp',AllWindowOses);
+    with T.Dependencies do
+      begin
+        AddUnit('cairo');
+        AddUnit('windows');
+      end;
 {$ifndef ALLPACKAGES}
     Run;
     end;

+ 395 - 260
packages/cairo/src/cairo.pp

@@ -1,3 +1,5 @@
+unit Cairo;
+
 (* cairo - a vector graphics library with display and print output
  *
  * Copyright © 2002 University of Southern California
@@ -33,33 +35,27 @@
  *
  * Contributor(s):
  *	Carl D. Worth <[email protected]>
- *)
-
-
 
-(*  
  *  This FreePascal binding generated August 26, 2005 
  *  by Jeffrey Pohlmeyer <[email protected]>
- *)
 
+  - Updated to cairo version 1.4
+  - Grouped OS specific fuctions in separated units
+  - Organized the functions by group and ordered exactly as the c header
+  - Cleared parameter list syntax according to pascal standard
 
+  By Luiz Américo Pereira Câmara
+  October 2007
+*)
 
-unit cairo;
+{$mode ObjFpc}
 
 interface
-uses x, xlib, xrender, freetypeh;
 
-const
-  LIB_CAIRO='cairo';
-
-  CAIRO_HAS_FT_FONT = 1;     
-  CAIRO_HAS_PNG_FUNCTIONS = 1;     
-  CAIRO_HAS_XLIB_SURFACE = 1;     
+Uses CTypes;
 
-  CAIRO_VERSION_MAJOR = 1;     
-  CAIRO_VERSION_MICRO = 0;     
-  CAIRO_VERSION_MINOR = 0;     
-  CAIRO_VERSION_STRING = '1.0.0';     
+const
+  LIB_CAIRO = 'cairo';
 
 {$IFDEF FPC}
   {$PACKRECORDS C}
@@ -186,10 +182,10 @@ type
   cairo_extend_t = (
     CAIRO_EXTEND_NONE,
     CAIRO_EXTEND_REPEAT,
-    CAIRO_EXTEND_REFLECT
+    CAIRO_EXTEND_REFLECT,
+    CAIRO_EXTEND_PAD
   );
 
-
   cairo_filter_t = (
     CAIRO_FILTER_FAST,
     CAIRO_FILTER_GOOD,
@@ -199,19 +195,51 @@ type
     CAIRO_FILTER_GAUSSIAN
   );
 
+  cairo_font_type_t = (
+    CAIRO_FONT_TYPE_TOY,
+    CAIRO_FONT_TYPE_FT,
+    CAIRO_FONT_TYPE_WIN32,
+    CAIRO_FONT_TYPE_ATSUI
+  );
+  
+  cairo_pattern_type_t = (
+    CAIRO_PATTERN_TYPE_SOLID,
+    CAIRO_PATTERN_TYPE_SURFACE,
+    CAIRO_PATTERN_TYPE_LINEAR,
+    CAIRO_PATTERN_TYPE_RADIAL
+  );
+  
+  cairo_surface_type_t = (
+    CAIRO_SURFACE_TYPE_IMAGE,
+    CAIRO_SURFACE_TYPE_PDF,
+    CAIRO_SURFACE_TYPE_PS,
+    CAIRO_SURFACE_TYPE_XLIB,
+    CAIRO_SURFACE_TYPE_XCB,
+    CAIRO_SURFACE_TYPE_GLITZ,
+    CAIRO_SURFACE_TYPE_QUARTZ,
+    CAIRO_SURFACE_TYPE_WIN32,
+    CAIRO_SURFACE_TYPE_BEOS,
+    CAIRO_SURFACE_TYPE_DIRECTFB,
+    CAIRO_SURFACE_TYPE_SVG,
+    CAIRO_SURFACE_TYPE_OS2
+  );
+  
+  cairo_svg_version_t = (
+    CAIRO_SVG_VERSION_1_1,
+    CAIRO_SVG_VERSION_1_2
+  );
+  pcairo_svg_version_t = ^cairo_svg_version_t;
+  ppcairo_svg_version_t = pcairo_svg_version_t;
 
-
-  FcPattern=pointer;
-
-  PFcPattern = ^FcPattern;
   Pcairo_surface_t = ^cairo_surface_t;
+  PPcairo_surface_t = ^Pcairo_surface_t;
   Pcairo_t = ^cairo_t;
   Pcairo_pattern_t = ^cairo_pattern_t;
   Pcairo_font_options_t = ^cairo_font_options_t;
   Pcairo_font_face_t = ^cairo_font_face_t;
   Pcairo_scaled_font_t = ^cairo_scaled_font_t;
   Pcairo_bool_t = ^cairo_bool_t;
-  cairo_bool_t = longint;
+  cairo_bool_t = LongInt;
   Pcairo_matrix_t = ^cairo_matrix_t;
   Pcairo_user_data_key_t = ^cairo_user_data_key_t;
   Pcairo_glyph_t = ^cairo_glyph_t;
@@ -220,10 +248,12 @@ type
   Pcairo_path_data_type_t = ^cairo_path_data_type_t;
   Pcairo_path_data_t = ^cairo_path_data_t;
   Pcairo_path_t = ^cairo_path_t;
+  Pcairo_rectangle_t = ^cairo_rectangle_t;
+  Pcairo_rectangle_list_t =^cairo_rectangle_list_t;
 
-  cairo_destroy_func_t = procedure (data:pointer); cdecl;
-  cairo_write_func_t = function (closure:pointer; data:Pbyte; length:dword):cairo_status_t; cdecl;
-  cairo_read_func_t = function (closure:pointer; data:Pbyte; length:dword):cairo_status_t; cdecl;
+  cairo_destroy_func_t = procedure (data: Pointer); cdecl;
+  cairo_write_func_t = function (closure: Pointer; data: PByte; length: LongWord): cairo_status_t; cdecl;
+  cairo_read_func_t = function (closure: Pointer; data: PByte; length: LongWord): cairo_status_t; cdecl;
 
   cairo_t              = record {OPAQUE} end;
   cairo_surface_t      = record {OPAQUE} end;
@@ -232,270 +262,375 @@ type
   cairo_font_face_t    = record {OPAQUE} end;
   cairo_font_options_t = record {OPAQUE} end;
 
-
   cairo_matrix_t = record
-    xx : double;
-    yx : double;
-    xy : double;
-    yy : double;
-    x0 : double;
-    y0 : double;
+    xx : Double;
+    yx : Double;
+    xy : Double;
+    yy : Double;
+    x0 : Double;
+    y0 : Double;
   end;
 
   cairo_user_data_key_t = record
-    unused : longint;
+    unused : LongInt;
   end;
 
   cairo_glyph_t = record
-    index : dword;
-    x : double;
-    y : double;
+    index : LongWord;
+    x : Double;
+    y : Double;
   end;
 
   cairo_text_extents_t = record
-    x_bearing : double;
-    y_bearing : double;
-    width : double;
-    height : double;
-    x_advance : double;
-    y_advance : double;
+    x_bearing : Double;
+    y_bearing : Double;
+    width : Double;
+    height : Double;
+    x_advance : Double;
+    y_advance : Double;
   end;
 
   cairo_font_extents_t = record
-    ascent : double;
-    descent : double;
-    height : double;
-    max_x_advance : double;
-    max_y_advance : double;
+    ascent : Double;
+    descent : Double;
+    height : Double;
+    max_x_advance : Double;
+    max_y_advance : Double;
   end;
 
-
   cairo_path_data_t = record
-    case longint of
+    case LongInt of
       0 : ( header : record
             _type : cairo_path_data_type_t;
-            length : longint;
+            length : LongInt;
           end );
       1 : ( point : record
-            x : double;
-            y : double;
+            x : Double;
+            y : Double;
           end );
   end;
 
   cairo_path_t = record
     status : cairo_status_t;
     data : Pcairo_path_data_t;
-    num_data : longint;
+    num_data : LongInt;
   end;
-
-
-function  cairo_create(target:Pcairo_surface_t):Pcairo_t; cdecl; external LIB_CAIRO;
-function  cairo_reference(cr:Pcairo_t):Pcairo_t; cdecl; external LIB_CAIRO;
-procedure cairo_destroy(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_save(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_restore(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-
-procedure cairo_set_operator(cr:Pcairo_t; op:cairo_operator_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_source(cr:Pcairo_t; source:Pcairo_pattern_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_source_rgb(cr:Pcairo_t; red:double; green:double; blue:double); cdecl; external LIB_CAIRO;
-procedure cairo_set_source_rgba(cr:Pcairo_t; red:double; green:double; blue:double; alpha:double); cdecl; external LIB_CAIRO;
-procedure cairo_set_source_surface(cr:Pcairo_t; surface:Pcairo_surface_t; x:double; y:double); cdecl; external LIB_CAIRO;
-procedure cairo_set_tolerance(cr:Pcairo_t; tolerance:double); cdecl; external LIB_CAIRO;
-procedure cairo_set_antialias(cr:Pcairo_t; antialias:cairo_antialias_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_fill_rule(cr:Pcairo_t; fill_rule:cairo_fill_rule_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_line_width(cr:Pcairo_t; width:double); cdecl; external LIB_CAIRO;
-procedure cairo_set_line_cap(cr:Pcairo_t; line_cap:cairo_line_cap_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_line_join(cr:Pcairo_t; line_join:cairo_line_join_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_dash(cr:Pcairo_t; dashes:Pdouble; num_dashes:longint; offset:double); cdecl; external LIB_CAIRO;
-procedure cairo_set_miter_limit(cr:Pcairo_t; limit:double); cdecl; external LIB_CAIRO;
-
-procedure cairo_translate(cr:Pcairo_t; tx:double; ty:double); cdecl; external LIB_CAIRO;
-procedure cairo_scale(cr:Pcairo_t; sx:double; sy:double); cdecl; external LIB_CAIRO;
-procedure cairo_rotate(cr:Pcairo_t; angle:double); cdecl; external LIB_CAIRO;
-procedure cairo_transform(cr:Pcairo_t; matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-
-procedure cairo_set_matrix(cr:Pcairo_t; matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-procedure cairo_identity_matrix(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-
-procedure cairo_user_to_device(cr:Pcairo_t; x:Pdouble; y:Pdouble); cdecl; external LIB_CAIRO;
-procedure cairo_user_to_device_distance(cr:Pcairo_t; dx:Pdouble; dy:Pdouble); cdecl; external LIB_CAIRO;
-procedure cairo_device_to_user(cr:Pcairo_t; x:Pdouble; y:Pdouble); cdecl; external LIB_CAIRO;
-procedure cairo_device_to_user_distance(cr:Pcairo_t; dx:Pdouble; dy:Pdouble); cdecl; external LIB_CAIRO;
-
-procedure cairo_new_path(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_move_to(cr:Pcairo_t; x:double; y:double); cdecl; external LIB_CAIRO;
-procedure cairo_line_to(cr:Pcairo_t; x:double; y:double); cdecl; external LIB_CAIRO;
-procedure cairo_curve_to(cr:Pcairo_t; x1:double; y1:double; x2:double; y2:double; x3:double; y3:double); cdecl; external LIB_CAIRO;
-procedure cairo_arc(cr:Pcairo_t; xc:double; yc:double; radius:double; angle1:double; angle2:double); cdecl; external LIB_CAIRO;
-procedure cairo_arc_negative(cr:Pcairo_t; xc:double; yc:double; radius:double; angle1:double; angle2:double); cdecl; external LIB_CAIRO;
-procedure cairo_rel_move_to(cr:Pcairo_t; dx:double; dy:double); cdecl; external LIB_CAIRO;
-procedure cairo_rel_line_to(cr:Pcairo_t; dx:double; dy:double); cdecl; external LIB_CAIRO;
-procedure cairo_rel_curve_to(cr:Pcairo_t; dx1:double; dy1:double; dx2:double; dy2:double; dx3:double; dy3:double); cdecl; external LIB_CAIRO;
-procedure cairo_rectangle(cr:Pcairo_t; x:double; y:double; width:double; height:double); cdecl; external LIB_CAIRO;
-procedure cairo_close_path(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_paint(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_paint_with_alpha(cr:Pcairo_t; alpha:double); cdecl; external LIB_CAIRO;
-
-procedure cairo_mask(cr:Pcairo_t; pattern:Pcairo_pattern_t); cdecl; external LIB_CAIRO;
-procedure cairo_mask_surface(cr:Pcairo_t; surface:Pcairo_surface_t; surface_x:double; surface_y:double); cdecl; external LIB_CAIRO;
-
-procedure cairo_stroke(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_stroke_preserve(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_fill(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_fill_preserve(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_copy_page(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_show_page(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-function  cairo_in_stroke(cr:Pcairo_t; x:double; y:double):cairo_bool_t; cdecl; external LIB_CAIRO;
-function  cairo_in_fill(cr:Pcairo_t; x:double; y:double):cairo_bool_t; cdecl; external LIB_CAIRO;
-procedure cairo_stroke_extents(cr:Pcairo_t; x1:Pdouble; y1:Pdouble; x2:Pdouble; y2:Pdouble); cdecl; external LIB_CAIRO;
-procedure cairo_fill_extents(cr:Pcairo_t; x1:Pdouble; y1:Pdouble; x2:Pdouble; y2:Pdouble); cdecl; external LIB_CAIRO;
-procedure cairo_reset_clip(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_clip(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-procedure cairo_clip_preserve(cr:Pcairo_t); cdecl; external LIB_CAIRO;
-
-function  cairo_font_options_create:Pcairo_font_options_t; cdecl; external LIB_CAIRO;
-function  cairo_font_options_copy(original:Pcairo_font_options_t):Pcairo_font_options_t; cdecl; external LIB_CAIRO;
-procedure cairo_font_options_destroy(options:Pcairo_font_options_t); cdecl; external LIB_CAIRO;
-function  cairo_font_options_status(options:Pcairo_font_options_t):cairo_status_t; cdecl; external LIB_CAIRO;
-procedure cairo_font_options_merge(options:Pcairo_font_options_t; other:Pcairo_font_options_t); cdecl; external LIB_CAIRO;
-function  cairo_font_options_equal(options:Pcairo_font_options_t; other:Pcairo_font_options_t):cairo_bool_t; cdecl; external LIB_CAIRO;
-function  cairo_font_options_hash(options:Pcairo_font_options_t):dword; cdecl; external LIB_CAIRO;
-procedure cairo_font_options_set_antialias(options:Pcairo_font_options_t; antialias:cairo_antialias_t); cdecl; external LIB_CAIRO;
-function  cairo_font_options_get_antialias(options:Pcairo_font_options_t):cairo_antialias_t; cdecl; external LIB_CAIRO;
-procedure cairo_font_options_set_subpixel_order(options:Pcairo_font_options_t; subpixel_order:cairo_subpixel_order_t); cdecl; external LIB_CAIRO;
-function  cairo_font_options_get_subpixel_order(options:Pcairo_font_options_t):cairo_subpixel_order_t; cdecl; external LIB_CAIRO;
-procedure cairo_font_options_set_hint_style(options:Pcairo_font_options_t; hint_style:cairo_hint_style_t); cdecl; external LIB_CAIRO;
-function  cairo_font_options_get_hint_style(options:Pcairo_font_options_t):cairo_hint_style_t; cdecl; external LIB_CAIRO;
-procedure cairo_font_options_set_hint_metrics(options:Pcairo_font_options_t; hint_metrics:cairo_hint_metrics_t); cdecl; external LIB_CAIRO;
-function  cairo_font_options_get_hint_metrics(options:Pcairo_font_options_t):cairo_hint_metrics_t; cdecl; external LIB_CAIRO;
-procedure cairo_select_font_face(cr:Pcairo_t; family:Pchar; slant:cairo_font_slant_t; weight:cairo_font_weight_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_font_size(cr:Pcairo_t; size:double); cdecl; external LIB_CAIRO;
-procedure cairo_set_font_matrix(cr:Pcairo_t; matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-procedure cairo_get_font_matrix(cr:Pcairo_t; matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_font_options(cr:Pcairo_t; options:Pcairo_font_options_t); cdecl; external LIB_CAIRO;
-procedure cairo_get_font_options(cr:Pcairo_t; options:Pcairo_font_options_t); cdecl; external LIB_CAIRO;
-procedure cairo_show_text(cr:Pcairo_t; utf8:Pchar); cdecl; external LIB_CAIRO;
-procedure cairo_show_glyphs(cr:Pcairo_t; glyphs:Pcairo_glyph_t; num_glyphs:longint); cdecl; external LIB_CAIRO;
-function  cairo_get_font_face(cr:Pcairo_t):Pcairo_font_face_t; cdecl; external LIB_CAIRO;
-procedure cairo_font_extents(cr:Pcairo_t; extents:Pcairo_font_extents_t); cdecl; external LIB_CAIRO;
-procedure cairo_set_font_face(cr:Pcairo_t; font_face:Pcairo_font_face_t); cdecl; external LIB_CAIRO;
-procedure cairo_text_extents(cr:Pcairo_t; utf8:Pchar; extents:Pcairo_text_extents_t); cdecl; external LIB_CAIRO;
-procedure cairo_glyph_extents(cr:Pcairo_t; glyphs:Pcairo_glyph_t; num_glyphs:longint; extents:Pcairo_text_extents_t); cdecl; external LIB_CAIRO;
-procedure cairo_text_path(cr:Pcairo_t; utf8:Pchar); cdecl; external LIB_CAIRO;
-procedure cairo_glyph_path(cr:Pcairo_t; glyphs:Pcairo_glyph_t; num_glyphs:longint); cdecl; external LIB_CAIRO;
-function  cairo_font_face_reference(font_face:Pcairo_font_face_t):Pcairo_font_face_t; cdecl; external LIB_CAIRO;
-procedure cairo_font_face_destroy(font_face:Pcairo_font_face_t); cdecl; external LIB_CAIRO;
-function  cairo_font_face_status(font_face:Pcairo_font_face_t):cairo_status_t; cdecl; external LIB_CAIRO;
-function  cairo_font_face_get_user_data(font_face:Pcairo_font_face_t; key:Pcairo_user_data_key_t):pointer; cdecl; external LIB_CAIRO;
-function  cairo_font_face_set_user_data(font_face:Pcairo_font_face_t; key:Pcairo_user_data_key_t; user_data:pointer; destroy:cairo_destroy_func_t):cairo_status_t; cdecl; external LIB_CAIRO;
-function  cairo_scaled_font_create(font_face:Pcairo_font_face_t; font_matrix:Pcairo_matrix_t; ctm:Pcairo_matrix_t; options:Pcairo_font_options_t):Pcairo_scaled_font_t; cdecl; external LIB_CAIRO;
-function  cairo_scaled_font_reference(scaled_font:Pcairo_scaled_font_t):Pcairo_scaled_font_t; cdecl; external LIB_CAIRO;
-procedure cairo_scaled_font_destroy(scaled_font:Pcairo_scaled_font_t); cdecl; external LIB_CAIRO;
-function  cairo_scaled_font_status(scaled_font:Pcairo_scaled_font_t):cairo_status_t; cdecl; external LIB_CAIRO;
-procedure cairo_scaled_font_extents(scaled_font:Pcairo_scaled_font_t; extents:Pcairo_font_extents_t); cdecl; external LIB_CAIRO;
-procedure cairo_scaled_font_glyph_extents(scaled_font:Pcairo_scaled_font_t; glyphs:Pcairo_glyph_t; num_glyphs:longint; extents:Pcairo_text_extents_t); cdecl; external LIB_CAIRO;
-
-function  cairo_get_operator(cr:Pcairo_t):cairo_operator_t; cdecl; external LIB_CAIRO;
-function  cairo_get_source(cr:Pcairo_t):Pcairo_pattern_t; cdecl; external LIB_CAIRO;
-function  cairo_get_tolerance(cr:Pcairo_t):double; cdecl; external LIB_CAIRO;
-function  cairo_get_antialias(cr:Pcairo_t):cairo_antialias_t; cdecl; external LIB_CAIRO;
-procedure cairo_get_current_point(cr:Pcairo_t; x:Pdouble; y:Pdouble); cdecl; external LIB_CAIRO;
-function  cairo_get_fill_rule(cr:Pcairo_t):cairo_fill_rule_t; cdecl; external LIB_CAIRO;
-function  cairo_get_line_width(cr:Pcairo_t):double; cdecl; external LIB_CAIRO;
-function  cairo_get_line_cap(cr:Pcairo_t):cairo_line_cap_t; cdecl; external LIB_CAIRO;
-function  cairo_get_line_join(cr:Pcairo_t):cairo_line_join_t; cdecl; external LIB_CAIRO;
-function  cairo_get_miter_limit(cr:Pcairo_t):double; cdecl; external LIB_CAIRO;
-procedure cairo_get_matrix(cr:Pcairo_t; matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-function  cairo_get_target(cr:Pcairo_t):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-function  cairo_copy_path(cr:Pcairo_t):Pcairo_path_t; cdecl; external LIB_CAIRO;
-function  cairo_copy_path_flat(cr:Pcairo_t):Pcairo_path_t; cdecl; external LIB_CAIRO;
-procedure cairo_append_path(cr:Pcairo_t; path:Pcairo_path_t); cdecl; external LIB_CAIRO;
-procedure cairo_path_destroy(path:Pcairo_path_t); cdecl; external LIB_CAIRO;
-function  cairo_status(cr:Pcairo_t):cairo_status_t; cdecl; external LIB_CAIRO;
-function  cairo_status_to_string(status:cairo_status_t):Pchar; cdecl; external LIB_CAIRO;
-
-function  cairo_surface_create_similar(other:Pcairo_surface_t; content:cairo_content_t; width:longint; height:longint):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-function  cairo_surface_reference(surface:Pcairo_surface_t):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-procedure cairo_surface_destroy(surface:Pcairo_surface_t); cdecl; external LIB_CAIRO;
-function  cairo_surface_status(surface:Pcairo_surface_t):cairo_status_t; cdecl; external LIB_CAIRO;
-procedure cairo_surface_finish(surface:Pcairo_surface_t); cdecl; external LIB_CAIRO;
-function  cairo_surface_write_to_png(surface:Pcairo_surface_t; filename:Pchar):cairo_status_t; cdecl; external LIB_CAIRO;
-function  cairo_surface_write_to_png_stream(surface:Pcairo_surface_t; write_func:cairo_write_func_t; closure:pointer):cairo_status_t; cdecl; external LIB_CAIRO;
-function  cairo_surface_get_user_data(surface:Pcairo_surface_t; key:Pcairo_user_data_key_t):pointer; cdecl; external LIB_CAIRO;
-function  cairo_surface_set_user_data(surface:Pcairo_surface_t; key:Pcairo_user_data_key_t; user_data:pointer; destroy:cairo_destroy_func_t):cairo_status_t; cdecl; external LIB_CAIRO;
-procedure cairo_surface_get_font_options(surface:Pcairo_surface_t; options:Pcairo_font_options_t); cdecl; external LIB_CAIRO;
-procedure cairo_surface_flush(surface:Pcairo_surface_t); cdecl; external LIB_CAIRO;
-procedure cairo_surface_mark_dirty(surface:Pcairo_surface_t); cdecl; external LIB_CAIRO;
-procedure cairo_surface_mark_dirty_rectangle(surface:Pcairo_surface_t; x:longint; y:longint; width:longint; height:longint); cdecl; external LIB_CAIRO;
-procedure cairo_surface_set_device_offset(surface:Pcairo_surface_t; x_offset:double; y_offset:double); cdecl; external LIB_CAIRO;
-
-function  cairo_image_surface_create(format:cairo_format_t; width:longint; height:longint):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-function  cairo_image_surface_create_for_data(data:Pbyte; format:cairo_format_t; width:longint; height:longint; stride:longint):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-function  cairo_image_surface_get_width(surface:Pcairo_surface_t):longint; cdecl; external LIB_CAIRO;
-function  cairo_image_surface_get_height(surface:Pcairo_surface_t):longint; cdecl; external LIB_CAIRO;
-function  cairo_image_surface_create_from_png(filename:Pchar):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-function  cairo_image_surface_create_from_png_stream(read_func:cairo_read_func_t; closure:pointer):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-
-function  cairo_pattern_create_rgb(red:double; green:double; blue:double):Pcairo_pattern_t; cdecl; external LIB_CAIRO;
-function  cairo_pattern_create_rgba(red:double; green:double; blue:double; alpha:double):Pcairo_pattern_t; cdecl; external LIB_CAIRO;
-function  cairo_pattern_create_for_surface(surface:Pcairo_surface_t):Pcairo_pattern_t; cdecl; external LIB_CAIRO;
-function  cairo_pattern_create_linear(x0:double; y0:double; x1:double; y1:double):Pcairo_pattern_t; cdecl; external LIB_CAIRO;
-function  cairo_pattern_create_radial(cx0:double; cy0:double; radius0:double; cx1:double; cy1:double; radius1:double):Pcairo_pattern_t; cdecl; external LIB_CAIRO;
-function  cairo_pattern_reference(pattern:Pcairo_pattern_t):Pcairo_pattern_t; cdecl; external LIB_CAIRO;
-procedure cairo_pattern_destroy(pattern:Pcairo_pattern_t); cdecl; external LIB_CAIRO;
-function  cairo_pattern_status(pattern:Pcairo_pattern_t):cairo_status_t; cdecl; external LIB_CAIRO;
-procedure cairo_pattern_add_color_stop_rgb(pattern:Pcairo_pattern_t; offset:double; red:double; green:double; blue:double); cdecl; external LIB_CAIRO;
-procedure cairo_pattern_add_color_stop_rgba(pattern:Pcairo_pattern_t; offset:double; red:double; green:double; blue:double; alpha:double); cdecl; external LIB_CAIRO;
-procedure cairo_pattern_set_matrix(pattern:Pcairo_pattern_t; matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-procedure cairo_pattern_get_matrix(pattern:Pcairo_pattern_t; matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-procedure cairo_pattern_set_extend(pattern:Pcairo_pattern_t; extend:cairo_extend_t); cdecl; external LIB_CAIRO;
-function  cairo_pattern_get_extend(pattern:Pcairo_pattern_t):cairo_extend_t; cdecl; external LIB_CAIRO;
-procedure cairo_pattern_set_filter(pattern:Pcairo_pattern_t; filter:cairo_filter_t); cdecl; external LIB_CAIRO;
-function  cairo_pattern_get_filter(pattern:Pcairo_pattern_t):cairo_filter_t; cdecl; external LIB_CAIRO;
-
-procedure cairo_matrix_init(matrix:Pcairo_matrix_t; xx:double; yx:double; xy:double; yy:double; x0:double; y0:double); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_init_identity(matrix:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_init_translate(matrix:Pcairo_matrix_t; tx:double; ty:double); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_init_scale(matrix:Pcairo_matrix_t; sx:double; sy:double); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_init_rotate(matrix:Pcairo_matrix_t; radians:double); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_translate(matrix:Pcairo_matrix_t; tx:double; ty:double); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_scale(matrix:Pcairo_matrix_t; sx:double; sy:double); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_rotate(matrix:Pcairo_matrix_t; radians:double); cdecl; external LIB_CAIRO;
-function  cairo_matrix_invert(matrix:Pcairo_matrix_t):cairo_status_t; cdecl; external LIB_CAIRO;
-procedure cairo_matrix_multiply(result:Pcairo_matrix_t; a:Pcairo_matrix_t; b:Pcairo_matrix_t); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_transform_distance(matrix:Pcairo_matrix_t; dx:Pdouble; dy:Pdouble); cdecl; external LIB_CAIRO;
-procedure cairo_matrix_transform_point(matrix:Pcairo_matrix_t; x:Pdouble; y:Pdouble); cdecl; external LIB_CAIRO;
-
-function  cairo_xlib_surface_create(dpy:PDisplay; drawable:TDrawable; visual:PVisual; width:longint; height:longint):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-function  cairo_xlib_surface_create_for_bitmap(dpy:PDisplay; bitmap:TPixmap; screen:PScreen; width:longint; height:longint):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-procedure cairo_xlib_surface_set_size(surface:Pcairo_surface_t; width:longint; height:longint); cdecl; external LIB_CAIRO;
-procedure cairo_xlib_surface_set_drawable(surface:Pcairo_surface_t; drawable:TDrawable; width:longint; height:longint); cdecl; external LIB_CAIRO;
-function  cairo_xlib_surface_create_with_xrender_format(dpy:PDisplay; drawable:TDrawable; screen:PScreen; format:PXRenderPictFormat; width:longint; height:longint):Pcairo_surface_t; cdecl; external LIB_CAIRO;
-
-function  cairo_ft_font_face_create_for_pattern(pattern:PFcPattern):Pcairo_font_face_t; cdecl; external LIB_CAIRO;
-procedure cairo_ft_font_options_substitute(options:Pcairo_font_options_t; pattern:PFcPattern); cdecl; external LIB_CAIRO;
-function  cairo_ft_font_face_create_for_ft_face(face:TFT_Face; load_flags:longint):Pcairo_font_face_t; cdecl; external LIB_CAIRO;
-function  cairo_ft_scaled_font_lock_face(scaled_font:Pcairo_scaled_font_t):TFT_Face; cdecl; external LIB_CAIRO;
-procedure cairo_ft_scaled_font_unlock_face(scaled_font:Pcairo_scaled_font_t); cdecl; external LIB_CAIRO;
-
-// These two functions renamed *_get_* to avoid collision...
-function cairo_get_version:longint; cdecl; external LIB_CAIRO name 'cairo_version';
-function cairo_get_version_string:Pchar; cdecl; external LIB_CAIRO name 'cairo_version_string';
-
-function CAIRO_VERSION : longint;
-function CAIRO_VERSION_ENCODE(major,minor,micro : longint) : longint;  
+  
+  cairo_rectangle_t = record
+    x, y, width, height: Double;
+  end;
+  
+  cairo_rectangle_list_t = record
+    status: cairo_status_t;
+    rectangles: Pcairo_rectangle_t;
+    num_rectangles: LongInt;
+  end;
+  
+function cairo_version: LongInt; cdecl; external LIB_CAIRO;
+function cairo_version_string: PChar; cdecl; external LIB_CAIRO;
+//Helper function to retrieve decoded version
+procedure cairo_version(out major, minor, micro: LongInt);
+
+(* Functions for manipulating state objects *)
+
+function  cairo_create(target: Pcairo_surface_t): Pcairo_t; cdecl; external LIB_CAIRO;
+function  cairo_reference(cr: Pcairo_t): Pcairo_t; cdecl; external LIB_CAIRO;
+procedure cairo_destroy(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+function  cairo_get_reference_count(cr: Pcairo_t): LongWord; cdecl; external LIB_CAIRO;
+function  cairo_get_user_data(cr: Pcairo_t; key: Pcairo_user_data_key_t): pointer; cdecl; external LIB_CAIRO;
+function  cairo_set_user_data(cr:  PCairo_t; key:  Pcairo_user_data_key_t; user_data:  Pointer; destroy:  cairo_destroy_func_t):  cairo_status_t; cdecl; external LIB_CAIRO;
+procedure cairo_save(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_restore(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_push_group (cr:  PCairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_push_group_with_content (cr:  PCairo_t; content:  cairo_content_t); cdecl; external LIB_CAIRO;
+function  cairo_pop_group (cr:  PCairo_t):  Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+procedure cairo_pop_group_to_source (cr:  PCairo_t); cdecl; external LIB_CAIRO;
+
+(* Modify state *)
+
+procedure cairo_set_operator(cr: Pcairo_t; op: cairo_operator_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_source(cr: Pcairo_t; source: Pcairo_pattern_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_source_rgb(cr: Pcairo_t; red, green, blue: Double); cdecl; external LIB_CAIRO;
+procedure cairo_set_source_rgba(cr: Pcairo_t; red, green, blue, alpha: Double); cdecl; external LIB_CAIRO;
+procedure cairo_set_source_surface(cr: Pcairo_t; surface: Pcairo_surface_t; x, y: Double); cdecl; external LIB_CAIRO;
+procedure cairo_set_tolerance(cr: Pcairo_t; tolerance: Double); cdecl; external LIB_CAIRO;
+procedure cairo_set_antialias(cr: Pcairo_t; antialias: cairo_antialias_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_fill_rule(cr: Pcairo_t; fill_rule: cairo_fill_rule_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_line_width(cr: Pcairo_t; width: Double); cdecl; external LIB_CAIRO;
+procedure cairo_set_line_cap(cr: Pcairo_t; line_cap: cairo_line_cap_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_line_join(cr: Pcairo_t; line_join: cairo_line_join_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_dash(cr: Pcairo_t; dashes: PDouble; num_dashes: LongInt; offset: Double); cdecl; external LIB_CAIRO;
+procedure cairo_set_miter_limit(cr: Pcairo_t; limit: Double); cdecl; external LIB_CAIRO;
+procedure cairo_translate(cr: Pcairo_t; tx, ty: Double); cdecl; external LIB_CAIRO;
+procedure cairo_scale(cr: Pcairo_t; sx, sy: Double); cdecl; external LIB_CAIRO;
+procedure cairo_rotate(cr: Pcairo_t; angle: Double); cdecl; external LIB_CAIRO;
+procedure cairo_transform(cr: Pcairo_t; matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_matrix(cr: Pcairo_t; matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_identity_matrix(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_user_to_device(cr: Pcairo_t; x, y: PDouble); cdecl; external LIB_CAIRO;
+procedure cairo_user_to_device_distance(cr: Pcairo_t; dx, dy: PDouble); cdecl; external LIB_CAIRO;
+procedure cairo_device_to_user(cr: Pcairo_t; x, y: PDouble); cdecl; external LIB_CAIRO;
+procedure cairo_device_to_user_distance(cr: Pcairo_t; dx, dy: PDouble); cdecl; external LIB_CAIRO;
+
+(* Path creation functions *)
+
+procedure cairo_new_path(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_move_to(cr: Pcairo_t; x, y: Double); cdecl; external LIB_CAIRO;
+procedure cairo_new_sub_path(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_line_to(cr: Pcairo_t; x, y: Double); cdecl; external LIB_CAIRO;
+procedure cairo_curve_to(cr: Pcairo_t; x1, y1, x2, y2, x3, y3: Double); cdecl; external LIB_CAIRO;
+procedure cairo_arc(cr: Pcairo_t; xc, yc, radius, angle1, angle2: Double); cdecl; external LIB_CAIRO;
+procedure cairo_arc_negative(cr: Pcairo_t; xc, yc, radius, angle1, angle2: Double); cdecl; external LIB_CAIRO;
+procedure cairo_rel_move_to(cr: Pcairo_t; dx, dy: Double); cdecl; external LIB_CAIRO;
+procedure cairo_rel_line_to(cr: Pcairo_t; dx, dy: Double); cdecl; external LIB_CAIRO;
+procedure cairo_rel_curve_to(cr: Pcairo_t; dx1, dy1, dx2, dy2, dx3, dy3: Double); cdecl; external LIB_CAIRO;
+procedure cairo_rectangle(cr: Pcairo_t; x, y, width, height: Double); cdecl; external LIB_CAIRO;
+procedure cairo_close_path(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+
+(* Painting functions *)
+
+procedure cairo_paint(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_paint_with_alpha(cr: Pcairo_t; alpha: Double); cdecl; external LIB_CAIRO;
+procedure cairo_mask(cr: Pcairo_t; pattern: Pcairo_pattern_t); cdecl; external LIB_CAIRO;
+procedure cairo_mask_surface(cr: Pcairo_t; surface: Pcairo_surface_t; surface_x, surface_y: Double); cdecl; external LIB_CAIRO;
+procedure cairo_stroke(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_stroke_preserve(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_fill(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_fill_preserve(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_copy_page(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_show_page(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+
+(* Insideness testing *)
+
+function  cairo_in_stroke(cr: Pcairo_t; x, y: Double): cairo_bool_t; cdecl; external LIB_CAIRO;
+function  cairo_in_fill(cr: Pcairo_t; x, y: Double): cairo_bool_t; cdecl; external LIB_CAIRO;
+
+(* Rectangular extents *)
+
+procedure cairo_stroke_extents(cr: Pcairo_t; x1, y1, x2, y2: PDouble); cdecl; external LIB_CAIRO;
+procedure cairo_fill_extents(cr: Pcairo_t; x1, y1, x2, y2: PDouble); cdecl; external LIB_CAIRO;
+
+(* Clipping *)
+
+procedure cairo_reset_clip(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_clip(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_clip_preserve(cr: Pcairo_t); cdecl; external LIB_CAIRO;
+procedure cairo_clip_extents(cr: Pcairo_t; x1, y1, x2, y2:  PDouble); cdecl; external LIB_CAIRO;
+function  cairo_copy_clip_rectangle_list(cr: Pcairo_t): Pcairo_rectangle_list_t; cdecl; external LIB_CAIRO;
+procedure cairo_rectangle_list_destroy(rectangle_list: Pcairo_rectangle_list_t); cdecl; external LIB_CAIRO;
+
+(* Font/Text functions *)
+
+function  cairo_font_options_create: Pcairo_font_options_t; cdecl; external LIB_CAIRO;
+function  cairo_font_options_copy(original: Pcairo_font_options_t): Pcairo_font_options_t; cdecl; external LIB_CAIRO;
+procedure cairo_font_options_destroy(options: Pcairo_font_options_t); cdecl; external LIB_CAIRO;
+function  cairo_font_options_status(options: Pcairo_font_options_t): cairo_status_t; cdecl; external LIB_CAIRO;
+procedure cairo_font_options_merge(options, other: Pcairo_font_options_t); cdecl; external LIB_CAIRO;
+function  cairo_font_options_equal(options, other: Pcairo_font_options_t): cairo_bool_t; cdecl; external LIB_CAIRO;
+function  cairo_font_options_hash(options: Pcairo_font_options_t): LongWord; cdecl; external LIB_CAIRO;
+procedure cairo_font_options_set_antialias(options: Pcairo_font_options_t; antialias: cairo_antialias_t); cdecl; external LIB_CAIRO;
+function  cairo_font_options_get_antialias(options: Pcairo_font_options_t): cairo_antialias_t; cdecl; external LIB_CAIRO;
+procedure cairo_font_options_set_subpixel_order(options: Pcairo_font_options_t; subpixel_order: cairo_subpixel_order_t); cdecl; external LIB_CAIRO;
+function  cairo_font_options_get_subpixel_order(options: Pcairo_font_options_t): cairo_subpixel_order_t; cdecl; external LIB_CAIRO;
+procedure cairo_font_options_set_hint_style(options: Pcairo_font_options_t; hint_style: cairo_hint_style_t); cdecl; external LIB_CAIRO;
+function  cairo_font_options_get_hint_style(options: Pcairo_font_options_t): cairo_hint_style_t; cdecl; external LIB_CAIRO;
+procedure cairo_font_options_set_hint_metrics(options: Pcairo_font_options_t; hint_metrics: cairo_hint_metrics_t); cdecl; external LIB_CAIRO;
+function  cairo_font_options_get_hint_metrics(options: Pcairo_font_options_t): cairo_hint_metrics_t; cdecl; external LIB_CAIRO;
+
+(* This interface is for dealing with text as text, not caring about the
+   font object inside the the cairo_t. *)
+
+procedure cairo_select_font_face(cr: Pcairo_t; family: Pchar; slant: cairo_font_slant_t; weight: cairo_font_weight_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_font_size(cr: Pcairo_t; size: Double); cdecl; external LIB_CAIRO;
+procedure cairo_set_font_matrix(cr: Pcairo_t; matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_get_font_matrix(cr: Pcairo_t; matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_font_options(cr: Pcairo_t; options: Pcairo_font_options_t); cdecl; external LIB_CAIRO;
+procedure cairo_get_font_options(cr: Pcairo_t; options: Pcairo_font_options_t); cdecl; external LIB_CAIRO;
+procedure cairo_set_font_face(cr: Pcairo_t; font_face: Pcairo_font_face_t); cdecl; external LIB_CAIRO;
+function  cairo_get_font_face(cr: Pcairo_t): Pcairo_font_face_t; cdecl; external LIB_CAIRO;
+procedure cairo_set_scaled_font(cr: PCairo_t; scaled_font:Pcairo_scaled_font_t); cdecl; external LIB_CAIRO;
+function  cairo_get_scaled_font(cr: Pcairo_t): Pcairo_scaled_font_t; cdecl; external LIB_CAIRO;
+procedure cairo_show_text(cr: Pcairo_t; utf8: Pchar); cdecl; external LIB_CAIRO;
+procedure cairo_show_glyphs(cr: Pcairo_t; glyphs: Pcairo_glyph_t; num_glyphs: LongInt); cdecl; external LIB_CAIRO;
+procedure cairo_text_path(cr: Pcairo_t; utf8: Pchar); cdecl; external LIB_CAIRO;
+procedure cairo_glyph_path(cr: Pcairo_t; glyphs: Pcairo_glyph_t; num_glyphs: LongInt); cdecl; external LIB_CAIRO;
+procedure cairo_text_extents(cr: Pcairo_t; utf8: Pchar; extents: Pcairo_text_extents_t); cdecl; external LIB_CAIRO;
+procedure cairo_glyph_extents(cr: Pcairo_t; glyphs: Pcairo_glyph_t; num_glyphs: LongInt; extents: Pcairo_text_extents_t); cdecl; external LIB_CAIRO;
+procedure cairo_font_extents(cr: Pcairo_t; extents: Pcairo_font_extents_t); cdecl; external LIB_CAIRO;
+
+(* Generic identifier for a font style *)
+
+function  cairo_font_face_reference(font_face: Pcairo_font_face_t): Pcairo_font_face_t; cdecl; external LIB_CAIRO;
+procedure cairo_font_face_destroy(font_face: Pcairo_font_face_t); cdecl; external LIB_CAIRO;
+function  cairo_font_face_get_reference_count (font_face: Pcairo_font_face_t):  LongWord; cdecl; external LIB_CAIRO;
+function  cairo_font_face_status(font_face: Pcairo_font_face_t): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_font_face_get_type(font_face: Pcairo_font_face_t): cairo_font_type_t; cdecl; external LIB_CAIRO;
+function  cairo_font_face_get_user_data(font_face: Pcairo_font_face_t; key: Pcairo_user_data_key_t): pointer; cdecl; external LIB_CAIRO;
+function  cairo_font_face_set_user_data(font_face: Pcairo_font_face_t; key: Pcairo_user_data_key_t; user_data: pointer; destroy: cairo_destroy_func_t): cairo_status_t; cdecl; external LIB_CAIRO;
+
+(* Portable interface to general font features *)
+
+function  cairo_scaled_font_create(font_face: Pcairo_font_face_t; font_matrix: Pcairo_matrix_t; ctm: Pcairo_matrix_t; options: Pcairo_font_options_t): Pcairo_scaled_font_t; cdecl; external LIB_CAIRO;
+function  cairo_scaled_font_reference(scaled_font: Pcairo_scaled_font_t): Pcairo_scaled_font_t; cdecl; external LIB_CAIRO;
+procedure cairo_scaled_font_destroy(scaled_font: Pcairo_scaled_font_t); cdecl; external LIB_CAIRO;
+function  cairo_scaled_font_get_reference_count (scaled_font: Pcairo_scaled_font_t): LongWord; cdecl; external LIB_CAIRO;
+function  cairo_scaled_font_status(scaled_font: Pcairo_scaled_font_t): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_scaled_font_get_type(scaled_font: Pcairo_scaled_font_t): cairo_font_type_t; cdecl; external LIB_CAIRO;
+function  cairo_scaled_font_get_user_data (scaled_font: Pcairo_scaled_font_t; key: Pcairo_user_data_key_t): Pointer; cdecl; external LIB_CAIRO;
+function  cairo_scaled_font_set_user_data (scaled_font: Pcairo_scaled_font_t; key: Pcairo_user_data_key_t; user_data: Pointer; destroy: cairo_destroy_func_t): cairo_status_t; cdecl; external LIB_CAIRO;
+procedure cairo_scaled_font_extents(scaled_font: Pcairo_scaled_font_t; extents: Pcairo_font_extents_t); cdecl; external LIB_CAIRO;
+procedure cairo_scaled_font_text_extents(scaled_font: Pcairo_scaled_font_t; utf8: PChar; extents: Pcairo_text_extents_t); cdecl; external LIB_CAIRO;
+procedure cairo_scaled_font_glyph_extents(scaled_font: Pcairo_scaled_font_t; glyphs: Pcairo_glyph_t; num_glyphs: LongInt; extents: Pcairo_text_extents_t); cdecl; external LIB_CAIRO;
+function  cairo_scaled_font_get_font_face (scaled_font: Pcairo_scaled_font_t): Pcairo_font_face_t; cdecl; external LIB_CAIRO;
+procedure cairo_scaled_font_get_font_matrix (scaled_font: Pcairo_scaled_font_t;	font_matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_scaled_font_get_ctm (scaled_font: Pcairo_scaled_font_t;	ctm: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_scaled_font_get_font_options (scaled_font: Pcairo_scaled_font_t; options: Pcairo_font_options_t); cdecl; external LIB_CAIRO;
+
+(* Query functions *)
+
+function  cairo_get_operator(cr: Pcairo_t): cairo_operator_t; cdecl; external LIB_CAIRO;
+function  cairo_get_source(cr: Pcairo_t): Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+function  cairo_get_tolerance(cr: Pcairo_t): Double; cdecl; external LIB_CAIRO;
+function  cairo_get_antialias(cr: Pcairo_t): cairo_antialias_t; cdecl; external LIB_CAIRO;
+procedure cairo_get_current_point(cr: Pcairo_t; x, y: PDouble); cdecl; external LIB_CAIRO;
+function  cairo_get_fill_rule(cr: Pcairo_t): cairo_fill_rule_t; cdecl; external LIB_CAIRO;
+function  cairo_get_line_width(cr: Pcairo_t): Double; cdecl; external LIB_CAIRO;
+function  cairo_get_line_cap(cr: Pcairo_t): cairo_line_cap_t; cdecl; external LIB_CAIRO;
+function  cairo_get_line_join(cr: Pcairo_t): cairo_line_join_t; cdecl; external LIB_CAIRO;
+function  cairo_get_miter_limit(cr: Pcairo_t): Double; cdecl; external LIB_CAIRO;
+function  cairo_get_dash_count(cr: Pcairo_t): LongInt; cdecl; external LIB_CAIRO;
+procedure cairo_get_dash(cr: Pcairo_t; dashes, offset: PDouble); cdecl; external LIB_CAIRO;
+procedure cairo_get_matrix(cr: Pcairo_t; matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+function  cairo_get_target(cr: Pcairo_t): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_get_group_target(cr: Pcairo_t): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+
+function  cairo_copy_path(cr: Pcairo_t): Pcairo_path_t; cdecl; external LIB_CAIRO;
+function  cairo_copy_path_flat(cr: Pcairo_t): Pcairo_path_t; cdecl; external LIB_CAIRO;
+procedure cairo_append_path(cr: Pcairo_t; path: Pcairo_path_t); cdecl; external LIB_CAIRO;
+procedure cairo_path_destroy(path: Pcairo_path_t); cdecl; external LIB_CAIRO;
+
+(* Error status queries *)
+
+function  cairo_status(cr: Pcairo_t): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_status_to_string(status: cairo_status_t): Pchar; cdecl; external LIB_CAIRO;
+
+(* Surface manipulation *)
+
+function  cairo_surface_create_similar(other: Pcairo_surface_t; content: cairo_content_t; width, height: LongInt): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_surface_reference(surface: Pcairo_surface_t): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+procedure cairo_surface_finish(surface: Pcairo_surface_t); cdecl; external LIB_CAIRO;
+procedure cairo_surface_destroy(surface: Pcairo_surface_t); cdecl; external LIB_CAIRO;
+function  cairo_surface_get_reference_count(surface: Pcairo_surface_t): LongWord; cdecl; external LIB_CAIRO;
+function  cairo_surface_status(surface: Pcairo_surface_t): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_surface_get_type(surface: Pcairo_surface_t): cairo_surface_type_t; cdecl; external LIB_CAIRO;
+function  cairo_surface_get_content(surface: Pcairo_surface_t): cairo_content_t; cdecl; external LIB_CAIRO;
+function  cairo_surface_write_to_png(surface: Pcairo_surface_t; filename: Pchar): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_surface_write_to_png_stream(surface: Pcairo_surface_t; write_func: cairo_write_func_t; closure: pointer): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_surface_get_user_data(surface: Pcairo_surface_t; key: Pcairo_user_data_key_t): pointer; cdecl; external LIB_CAIRO;
+function  cairo_surface_set_user_data(surface: Pcairo_surface_t; key: Pcairo_user_data_key_t; user_data: pointer; destroy: cairo_destroy_func_t): cairo_status_t; cdecl; external LIB_CAIRO;
+procedure cairo_surface_get_font_options(surface: Pcairo_surface_t; options: Pcairo_font_options_t); cdecl; external LIB_CAIRO;
+procedure cairo_surface_flush(surface: Pcairo_surface_t); cdecl; external LIB_CAIRO;
+procedure cairo_surface_mark_dirty(surface: Pcairo_surface_t); cdecl; external LIB_CAIRO;
+procedure cairo_surface_mark_dirty_rectangle(surface: Pcairo_surface_t; x, y, width, height: LongInt); cdecl; external LIB_CAIRO;
+procedure cairo_surface_set_device_offset(surface: Pcairo_surface_t; x_offset, y_offset: Double); cdecl; external LIB_CAIRO;
+procedure cairo_surface_get_device_offset(surface: Pcairo_surface_t; x_offset, y_offset: PDouble); cdecl; external LIB_CAIRO;
+procedure cairo_surface_set_fallback_resolution(surface: Pcairo_surface_t; x_pixels_per_inch, y_pixels_per_inch: Double); cdecl; external LIB_CAIRO;
+
+(* Image-surface functions *)
+
+function  cairo_image_surface_create(format: cairo_format_t; width, height: LongInt): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_create_for_data(data: Pbyte; format: cairo_format_t; width, height, stride: LongInt): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_get_data(surface: Pcairo_surface_t): PChar; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_get_format(surface: Pcairo_surface_t): cairo_format_t; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_get_width(surface: Pcairo_surface_t): LongInt; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_get_height(surface: Pcairo_surface_t): LongInt; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_get_stride(surface: Pcairo_surface_t): LongInt; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_create_from_png(filename: Pchar): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_image_surface_create_from_png_stream(read_func: cairo_read_func_t; closure: pointer): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+
+(* Pattern creation functions *)
+
+function  cairo_pattern_create_rgb(red, green, blue: Double): Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_create_rgba(red, green, blue, alpha: Double): Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_create_for_surface(surface: Pcairo_surface_t): Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_create_linear(x0, y0, x1, y1: Double): Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1: Double): Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_reference(pattern: Pcairo_pattern_t): Pcairo_pattern_t; cdecl; external LIB_CAIRO;
+procedure cairo_pattern_destroy(pattern: Pcairo_pattern_t); cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_reference_count (pattern: Pcairo_pattern_t): LongWord; cdecl; external LIB_CAIRO;
+function  cairo_pattern_status(pattern: Pcairo_pattern_t): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_user_data (pattern: Pcairo_pattern_t; key: Pcairo_user_data_key_t): Pointer; cdecl; external LIB_CAIRO;
+function  cairo_pattern_set_user_data (pattern: Pcairo_pattern_t; key: Pcairo_user_data_key_t; user_data: Pointer; destroy: cairo_destroy_func_t): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_type(pattern: Pcairo_pattern_t): cairo_pattern_type_t; cdecl; external LIB_CAIRO;
+procedure cairo_pattern_add_color_stop_rgb(pattern: Pcairo_pattern_t; offset, red, green, blue: Double); cdecl; external LIB_CAIRO;
+procedure cairo_pattern_add_color_stop_rgba(pattern: Pcairo_pattern_t; offset, red, green, blue, alpha: Double); cdecl; external LIB_CAIRO;
+procedure cairo_pattern_set_matrix(pattern: Pcairo_pattern_t; matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_pattern_get_matrix(pattern: Pcairo_pattern_t; matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_pattern_set_extend(pattern: Pcairo_pattern_t; extend: cairo_extend_t); cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_extend(pattern: Pcairo_pattern_t): cairo_extend_t; cdecl; external LIB_CAIRO;
+procedure cairo_pattern_set_filter(pattern: Pcairo_pattern_t; filter: cairo_filter_t); cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_filter(pattern: Pcairo_pattern_t): cairo_filter_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_rgba (pattern: Pcairo_pattern_t; red, green, blue, alpha: PDouble): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_surface (pattern: Pcairo_pattern_t; surface: PPcairo_surface_t): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_color_stop_rgba(pattern: Pcairo_pattern_t; index: LongInt; offset, red, green, blue, alpha: PDouble):cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_color_stop_count(pattern: Pcairo_pattern_t; count: PLongInt):cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_linear_points (pattern: Pcairo_pattern_t; x0, y0, x1, y1: PDouble): cairo_status_t; cdecl; external LIB_CAIRO;
+function  cairo_pattern_get_radial_circles (pattern: Pcairo_pattern_t; x0, y0, r0, x1, y1, r1:PDouble): cairo_status_t; cdecl; external LIB_CAIRO;
+
+(* Matrix functions *)
+
+procedure cairo_matrix_init(matrix: Pcairo_matrix_t; xx, yx, xy, yy, x0, y0: Double); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_init_identity(matrix: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_init_translate(matrix: Pcairo_matrix_t; tx, ty: Double); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_init_scale(matrix: Pcairo_matrix_t; sx, sy: Double); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_init_rotate(matrix: Pcairo_matrix_t; radians: Double); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_translate(matrix: Pcairo_matrix_t; tx, ty: Double); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_scale(matrix: Pcairo_matrix_t; sx, sy: Double); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_rotate(matrix: Pcairo_matrix_t; radians: Double); cdecl; external LIB_CAIRO;
+function  cairo_matrix_invert(matrix: Pcairo_matrix_t): cairo_status_t; cdecl; external LIB_CAIRO;
+procedure cairo_matrix_multiply(result, a, b: Pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_transform_distance(matrix: Pcairo_matrix_t; dx, dy: PDouble); cdecl; external LIB_CAIRO;
+procedure cairo_matrix_transform_point(matrix: Pcairo_matrix_t; x, y: PDouble); cdecl; external LIB_CAIRO;
+
+(* PDF functions *)
+
+function  cairo_pdf_surface_create(filename: PChar; width_in_points, height_in_points: Double): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_pdf_surface_create_for_stream(write_func: cairo_write_func_t; closure: Pointer; width_in_points, height_in_points: Double): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+procedure cairo_pdf_surface_set_size(surface: Pcairo_surface_t; width_in_points, height_in_points: Double); cdecl; external LIB_CAIRO;
+
+(* PS functions *)
+
+function  cairo_ps_surface_create(filename: PChar; width_in_points, height_in_points: Double): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_ps_surface_create_for_stream(write_func: cairo_write_func_t; closure: Pointer; width_in_points, height_in_points: Double): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+procedure cairo_ps_surface_set_size(surface: Pcairo_surface_t; width_in_points, height_in_points: Double); cdecl; external LIB_CAIRO;
+procedure cairo_ps_surface_dsc_comment(surface: Pcairo_surface_t; comment: PChar); cdecl; external LIB_CAIRO;
+procedure cairo_ps_surface_dsc_begin_setup(surface: Pcairo_surface_t); cdecl; external LIB_CAIRO;
+procedure cairo_ps_surface_dsc_begin_page_setup(surface: Pcairo_surface_t); cdecl; external LIB_CAIRO;
+
+(* SVG functions *)
+
+function  cairo_svg_surface_create(filename: PChar; width_in_points, height_in_points: Double): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_svg_surface_create_for_stream(write_func: cairo_write_func_t; closure: Pointer; width_in_points, height_in_points: Double): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+procedure cairo_svg_surface_restrict_to_version(surface: Pcairo_surface_t; version: cairo_svg_version_t); cdecl; external LIB_CAIRO;
+
+procedure cairo_svg_get_versions(versions: ppcairo_svg_version_t;num_versions:pcint);cdecl; external LIB_CAIRO;
+function  cairo_svg_version_to_string(version: cairo_svg_version_t): PChar; cdecl; external LIB_CAIRO;
+
+
+(* Functions to be used while debugging (not intended for use in production code) *)
+
+procedure cairo_debug_reset_static_data; cdecl; external LIB_CAIRO;
 
 implementation
 
-function CAIRO_VERSION : longint;
+procedure cairo_version(out major, minor, micro: LongInt);
+var
+  version: LongInt;
 begin
-  CAIRO_VERSION:=CAIRO_VERSION_ENCODE(CAIRO_VERSION_MAJOR,CAIRO_VERSION_MINOR,CAIRO_VERSION_MICRO);
+  version := cairo_version;
+  major := version div 10000;
+  minor := (version mod (major * 10000)) div 100;
+  micro := (version mod ((major * 10000) + (minor * 100)));
 end;
 
-function CAIRO_VERSION_ENCODE(major,minor,micro : longint) : longint;
-begin
-  CAIRO_VERSION_ENCODE:=((major * 10000) + (minor * 100)) + (micro * 1);
-end;
-
-
 end.

+ 57 - 0
packages/cairo/src/cairoft.pp

@@ -0,0 +1,57 @@
+unit CairoFT; 
+{
+    This file is part of the Free Pascal libraries.
+    Copyright (c) 2003-2008 by the Free Pascal development team
+
+    Translation of cairo-ft.h 
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************
+
+Based on:
+
+ Original translation of cairo-ft.h by Jeffrey Pohlmeyer 
+ updated to version 1.4 by Luiz Américo Pereira Câmara 2007
+
+As per original authors wish, this file is dual licensed LGPL-MPL see the original file
+cairo.pp for the full license.
+}
+
+{$mode objfpc}
+
+interface
+
+uses
+  Cairo, freetypeh;
+
+type
+  //todo: properly define FcPattern:
+  //It will require translate FontConfig header
+  (*
+  typedef struct _XftPattern {
+    int		    num;
+    int		    size;
+    XftPatternElt   *elts;
+   } XftPattern;
+   typedef FcPattern XftPattern;
+  *)
+  FcPattern = Pointer;
+  PFcPattern = ^FcPattern;
+    
+function  cairo_ft_font_face_create_for_pattern(pattern:PFcPattern):Pcairo_font_face_t; cdecl; external LIB_CAIRO;
+procedure cairo_ft_font_options_substitute(options:Pcairo_font_options_t; pattern:PFcPattern); cdecl; external LIB_CAIRO;
+function  cairo_ft_font_face_create_for_ft_face(face:TFT_Face; load_flags:longint):Pcairo_font_face_t; cdecl; external LIB_CAIRO;
+function  cairo_ft_scaled_font_lock_face(scaled_font:Pcairo_scaled_font_t):TFT_Face; cdecl; external LIB_CAIRO;
+procedure cairo_ft_scaled_font_unlock_face(scaled_font:Pcairo_scaled_font_t); cdecl; external LIB_CAIRO;
+
+
+implementation
+
+end.
+

+ 46 - 0
packages/cairo/src/cairowin32.pp

@@ -0,0 +1,46 @@
+unit CairoWin32;
+{
+    This file is part of the Free Pascal libraries.
+    Copyright (c) 2003-2008 by the Free Pascal development team
+
+    Translation of cairo-win32.h 
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************
+
+Translation of cairo-win32.h version 1.4 by Luiz Américo Pereira Câmara 2007
+
+For consistency with the other cairo header files, this file is dual
+licensed LGPL-MPL see the file cairo.pp for the full license.
+}
+
+{$mode ObjFpc}
+
+interface
+
+uses
+  Cairo, windows;
+
+function cairo_win32_surface_create(hdc: HDC): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function cairo_win32_surface_create_with_ddb(hdc: HDC; format: cairo_format_t; width, height: longint): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function cairo_win32_surface_create_with_dib(format: cairo_format_t; width, height: longint): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function cairo_win32_surface_get_dc(surface: pcairo_surface_t): HDC; cdecl; external LIB_CAIRO;
+function cairo_win32_surface_get_image(surface: pcairo_surface_t): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function cairo_win32_font_face_create_for_logfontw(logfont: pLOGFONTW): Pcairo_font_face_t; cdecl; external LIB_CAIRO;
+function cairo_win32_font_face_create_for_hfont(font: HFONT): Pcairo_font_face_t; cdecl; external LIB_CAIRO;
+function cairo_win32_scaled_font_select_font(scaled_font: pcairo_scaled_font_t; hdc: HDC): cairo_status_t; cdecl; external LIB_CAIRO;
+procedure cairo_win32_scaled_font_done_font(scaled_font: pcairo_scaled_font_t); cdecl; external LIB_CAIRO;
+function cairo_win32_scaled_font_get_metrics_factor(scaled_font: pcairo_scaled_font_t): double; cdecl; external LIB_CAIRO;
+procedure cairo_win32_scaled_font_get_logical_to_device(scaled_font: pcairo_scaled_font_t; logical_to_device: pcairo_matrix_t); cdecl; external LIB_CAIRO;
+procedure cairo_win32_scaled_font_get_device_to_logical(scaled_font: pcairo_scaled_font_t; device_to_logical: pcairo_matrix_t); cdecl; external LIB_CAIRO;
+
+implementation
+
+
+end.

+ 47 - 0
packages/cairo/src/cairoxlib.pp

@@ -0,0 +1,47 @@
+unit CairoXlib;
+{
+    This file is part of the Free Pascal libraries.
+    Copyright (c) 2003-2008 by the Free Pascal development team
+
+    Translation of cairo-ft.h 
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************
+
+ Translation of cairo-xlib.h version 1.4
+ by Jeffrey Pohlmeyer 
+ updated to version 1.4 by Luiz Américo Pereira Câmara 2007
+
+ As per original authors wish, this file is dual licensed LGPL-MPL see the original file
+  cairo.pp for the full license.
+}
+
+{$mode ObjFpc}
+
+interface
+
+uses
+  Cairo, x, xlib, xrender;
+  
+function  cairo_xlib_surface_create(dpy: PDisplay; drawable: TDrawable; visual: PVisual; width, height: LongInt): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_create_for_bitmap(dpy: PDisplay; bitmap: TPixmap; screen: PScreen; width, height: LongInt): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_create_with_xrender_format(dpy: PDisplay; drawable: TDrawable; screen: PScreen; format: PXRenderPictFormat; width, height:LongInt): Pcairo_surface_t; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_get_depth(surface: Pcairo_surface_t): LongInt; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_get_display(surface: Pcairo_surface_t): PDisplay; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_get_drawable(surface: Pcairo_surface_t): TDrawable; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_get_height(surface: Pcairo_surface_t): LongInt; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_get_screen(surface: Pcairo_surface_t): PScreen; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_get_visual(surface: Pcairo_surface_t): PVisual; cdecl; external LIB_CAIRO;
+function  cairo_xlib_surface_get_width(surface: Pcairo_surface_t): LongInt; cdecl; external LIB_CAIRO;
+procedure cairo_xlib_surface_set_size(surface: Pcairo_surface_t; width, height: LongInt); cdecl; external LIB_CAIRO;
+procedure cairo_xlib_surface_set_drawable(surface: Pcairo_surface_t; drawable: TDrawable; width, height: LongInt); cdecl; external LIB_CAIRO;
+
+implementation
+
+end.

+ 3 - 0
packages/fcl-registry/src/registry.pp

@@ -192,6 +192,9 @@ ResourceString
   SRegSetDataFailed = 'Failed to set data for value "%s"';
   SRegGetDataFailed = 'Failed to get data for value "%s"';
 
+var
+  GlobalXMLFile : Boolean = False;
+
 implementation
 
 { ---------------------------------------------------------------------

+ 4 - 2
packages/fcl-registry/src/xregreg.inc

@@ -10,9 +10,11 @@ Const
   XFileName = 'reg.xml';
 
 Procedure TRegistry.SysRegCreate;
-
+var s : string;
 begin
-  FSysData:=TXMLRegistry.Create(XFileName);
+  s:=includetrailingpathdelimiter(GetAppConfigDir(GlobalXMLFile));
+  ForceDirectories(s);
+  FSysData:=TXMLRegistry.Create(s+XFileName);
   TXmlRegistry(FSysData).AutoFlush:=False;
 end;
 

+ 4 - 0
packages/gtk2/src/gtk+/gtk/gtkfilechooser.inc

@@ -116,6 +116,10 @@ function gtk_file_chooser_add_shortcut_folder_uri(chooser:PGtkFileChooser; uri:P
 function gtk_file_chooser_remove_shortcut_folder_uri(chooser:PGtkFileChooser; uri:Pchar; error:PPGError):gboolean;cdecl;external gtklib name 'gtk_file_chooser_remove_shortcut_folder_uri';
 function gtk_file_chooser_list_shortcut_folder_uris(chooser:PGtkFileChooser):PGSList;cdecl;external gtklib name 'gtk_file_chooser_list_shortcut_folder_uris';
 
+{$ifdef HasGTK2_8}
+function gtk_file_chooser_get_do_overwrite_confirmation(chooser:PGtkFileChooser): gboolean;  cdecl; external gtklib name 'gtk_file_chooser_get_do_overwrite_confirmation';
+procedure gtk_file_chooser_set_do_overwrite_confirmation(chooser:PGtkFileChooser; do_overwrite_confirmation:gboolean);  cdecl; external gtklib name 'gtk_file_chooser_set_do_overwrite_confirmation';
+{$endif}
 
 {$endif} {read_interface_rest}
 

+ 6 - 6
packages/mysql/src/mysql.inc

@@ -23,21 +23,21 @@ interface
 
 uses
 {$IFDEF LinkDynamically}
-     Dynlibs, sysutils,
+      sysutils,
 {$ENDIF}
-     ctypes;
+     dynlibs,ctypes;
 
 {$IFDEF Unix}
   {$DEFINE extdecl:=cdecl}
   const
-    mysqllib = 'libmysqlclient.so';
+    mysqllib = 'libmysqlclient.'+sharedsuffix;
 
   {$IF DEFINED(mysql50)}
-    mysqlvlib = 'libmysqlclient.so.15';
+    mysqlvlib = 'libmysqlclient.'+sharedsuffix+'.15';
   {$ELSEIF DEFINED(mysql41)}
-    mysqlvlib = 'libmysqlclient.so.14';
+    mysqlvlib = 'libmysqlclient.'+sharedsuffix+'.14';
   {$ELSE}
-    mysqlvlib = 'libmysqlclient.so.12';
+    mysqlvlib = 'libmysqlclient.'+sharedsuffix+'.12';
   {$ENDIF}
 
 {$ENDIF}

+ 1 - 1
packages/mysql/src/mysql3_comdyn.pp

@@ -20,7 +20,7 @@ uses dynlibs, sysutils;
 {$IFDEF Unix}
   {$DEFINE extdecl:=cdecl}
   const
-    Mysqllib = 'libmysqlclient.so';
+    Mysqllib = 'libmysqlclient.'+sharedsuffix;
 {$ENDIF}
 {$IFDEF Windows}
   {$DEFINE extdecl:=stdcall}

+ 1 - 1
packages/mysql/src/mysql3dyn.pp

@@ -20,7 +20,7 @@ uses dynlibs, classes, sysutils, mysql3_comdyn;
 {$IFDEF Unix}
   {$DEFINE extdecl:=cdecl}
   const
-    Mysqllib = 'libmysqlclient.so';
+    Mysqllib = 'libmysqlclient.'+sharedsuffix;
 {$ENDIF}
 {$IFDEF Windows}
   {$DEFINE extdecl:=stdcall}

+ 2 - 2
packages/mysql/src/mysql4.pp

@@ -1,7 +1,7 @@
 unit mysql4;
 interface
 
-uses ctypes,my4_sys,mysql4_com;
+uses ctypes,my4_sys,mysql4_com,dynlibs;
 
 {
   Automatically converted by H2Pas 0.99.15 from mysql.ph
@@ -37,7 +37,7 @@ uses ctypes,my4_sys,mysql4_com;
 {$IFDEF Unix}
   {$DEFINE extdecl:=cdecl}
   const
-    External_library = 'libmysqlclient.so';
+    External_library = 'libmysqlclient.'+sharedsuffix;
 {$ENDIF}
 {$IFDEF Windows}
   {$DEFINE extdecl:=stdcall}

+ 2 - 2
packages/mysql/src/mysql4_com.pp

@@ -6,12 +6,12 @@ unit mysql4_com;
 interface
 
 uses
-  ctypes;
+  ctypes,dynlibs;
 
 {$IFDEF Unix}
   {$DEFINE extdecl:=cdecl}
   const
-    External_library = 'libmysqlclient.so';
+    External_library = 'libmysqlclient.'+sharedsuffix;
 {$ENDIF}
 {$IFDEF Windows}
   {$DEFINE extdecl:=stdcall}

+ 1 - 1
packages/mysql/src/mysql4_comdyn.pp

@@ -16,7 +16,7 @@ uses ctypes,my4_sys,dynlibs, sysutils;
 {$IFDEF Unix}
   {$DEFINE extdecl:=cdecl}
   const
-    Mysqllib = 'libmysqlclient.so';
+    Mysqllib = 'libmysqlclient.'+sharedsuffix;
 {$ENDIF}
 {$IFDEF Windows}
   {$DEFINE extdecl:=stdcall}

+ 1 - 1
packages/mysql/src/mysql4dyn.pp

@@ -45,7 +45,7 @@ uses ctypes,dynlibs, classes, sysutils, my4_sys, mysql4_comdyn;
 {$IFDEF Unix}
   {$DEFINE extdecl:=cdecl}
   const
-    Mysqllib = 'libmysqlclient.so';
+    Mysqllib = 'libmysqlclient.'+sharedsuffix;
 {$ENDIF}
 {$IFDEF Windows}
   {$DEFINE extdecl:=stdcall}

+ 115 - 59
packages/ncurses/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/03/20]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/05/04]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd 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 avr-embedded armeb-linux armeb-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
@@ -167,6 +167,17 @@ OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
 endif
 FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
 FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifeq ($(CPU_TARGET),armeb)
+ARCH=arm
+override FPCOPT+=-Cb
+else
+ifeq ($(CPU_TARGET),armel)
+ARCH=arm
+override FPCOPT+=-CaEABI
+else
+ARCH=$(CPU_TARGET)
+endif
+endif
 ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
 TARGETSUFFIX=$(OS_TARGET)
 SOURCESUFFIX=$(OS_SOURCE)
@@ -188,7 +199,7 @@ endif
 ifeq ($(OS_TARGET),linux)
 linuxHier=1
 endif
-export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+export OS_TARGET OS_SOURCE ARCH CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
 ifdef FPCDIR
 override FPCDIR:=$(subst \,/,$(FPCDIR))
 ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
@@ -377,6 +388,9 @@ endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
+endif
 ifeq ($(FULL_TARGET),arm-wince)
 override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
@@ -404,167 +418,182 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
+endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -702,6 +731,9 @@ endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override COMPILER_INCLUDEDIR+=src
 endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_INCLUDEDIR+=src
+endif
 ifeq ($(FULL_TARGET),arm-wince)
 override COMPILER_INCLUDEDIR+=src
 endif
@@ -729,6 +761,12 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 override COMPILER_INCLUDEDIR+=src
 endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_INCLUDEDIR+=src
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_INCLUDEDIR+=src
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_SOURCEDIR+=src tests examples
 endif
@@ -864,6 +902,9 @@ endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override COMPILER_SOURCEDIR+=src tests examples
 endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_SOURCEDIR+=src tests examples
+endif
 ifeq ($(FULL_TARGET),arm-wince)
 override COMPILER_SOURCEDIR+=src tests examples
 endif
@@ -891,6 +932,12 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 override COMPILER_SOURCEDIR+=src tests examples
 endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_SOURCEDIR+=src tests examples
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_SOURCEDIR+=src tests examples
+endif
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 endif
@@ -1805,6 +1852,9 @@ endif
 ifeq ($(FULL_TARGET),arm-palmos)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),arm-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),arm-wince)
 REQUIRE_PACKAGES_RTL=1
 endif
@@ -1832,6 +1882,12 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),armeb-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_RTL),)
@@ -1859,13 +1915,13 @@ override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
 endif
 ifndef NOCPUDEF
-override FPCOPTDEF=$(CPU_TARGET)
+override FPCOPTDEF=$(ARCH)
 endif
 ifneq ($(OS_TARGET),$(OS_SOURCE))
 override FPCOPT+=-T$(OS_TARGET)
 endif
 ifneq ($(CPU_TARGET),$(CPU_SOURCE))
-override FPCOPT+=-P$(CPU_TARGET)
+override FPCOPT+=-P$(ARCH)
 endif
 ifeq ($(OS_SOURCE),openbsd)
 override FPCOPT+=-FD$(NEW_BINUTILS_PATH)

+ 1 - 1
packages/ncurses/Makefile.fpc

@@ -8,7 +8,7 @@ version=2.0.0
 
 [target]
 units=ncurses panel ncrt ocrt menu form
-examples=firework testn ocrt_demo edit_demo db_demo screen_demo
+examples=firework testn ocrt_demo edit_demo db_demo screen_demo t1form t1menu t1panel t2form t2menu t2panel t3form tbackground tclock tevent tmouse tnlshello tpad twindow
 
 [require]
 libc=y

BIN
packages/ncurses/examples/ru/messages.mo


+ 83 - 0
packages/ncurses/examples/t1form.pp

@@ -0,0 +1,83 @@
+program form_basic;
+{
+  Example 25. Forms Basics
+  from ncurses howto
+
+  Possible bug: moving cursors before first char doesn't seem to work.
+}
+{$MODE OBJFPC}
+
+uses
+  ncurses, form;
+
+var
+  field: array[0..2] of PFIELD;
+  my_form: PFORM;
+  ch: Longint;
+begin
+
+try
+  (* Initialize curses *)
+   initscr();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+  (* Initialize the fields *)
+   field[0] := new_field(1, 10, 4, 18, 0, 0);
+   field[1] := new_field(1, 10, 6, 18, 0, 0);
+   field[2] := nil;
+
+  (* Set field options *)
+    set_field_back(field[0], A_UNDERLINE);  { Print a line for the option }
+    field_opts_off(field[0], O_AUTOSKIP);   { Don't go to next field when this }
+                                            { Field is filled up           }
+    set_field_back(field[1], A_UNDERLINE);
+    field_opts_off(field[1], O_AUTOSKIP);
+
+  (* Create the form and post it *)
+    my_form := new_form(field);
+    post_form(my_form);
+    refresh();
+
+    mvprintw(2, 10, 'Cursor up/down to move, F1 to Exit');
+    mvprintw(4, 10, 'Value 1:');
+    mvprintw(6, 10, 'Value 2:');
+    refresh();
+
+  (* Loop through to get user requests *)
+    ch := getch();
+    while ch <> KEY_F(1) do
+    begin
+      case ch of
+        KEY_DOWN:
+    (* Go to next field *)
+        begin
+          form_driver(my_form, REQ_NEXT_FIELD);
+            { Go to the end of the present buffer
+              Leaves nicely at the last character }
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_UP:
+    (* Go to previous field *)
+        begin
+          form_driver(my_form, REQ_PREV_FIELD);
+          form_driver(my_form, REQ_END_LINE);
+        end;
+      else
+          { If this is a normal character, it gets
+            Printed }
+        form_driver(my_form, ch);
+      end;
+      ch := getch();
+    end
+  finally
+  (* Un post form and free the memory *)
+    unpost_form(my_form);
+    free_form(my_form);
+    free_field(field[0]);
+    free_field(field[1]);
+
+    endwin();
+  end;
+end.

+ 65 - 0
packages/ncurses/examples/t1menu.pp

@@ -0,0 +1,65 @@
+{
+  Example 18. Menu Basics
+  from ncurses howto
+}
+program Menu_Basics;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, menu;
+
+const
+  choices: array[0..4] of PChar  =
+                      (
+                        'Choice 1',
+                        'Choice 2',
+                        'Choice 3',
+                        'Choice 4',
+                        'Exit'
+                      );
+
+
+var
+  my_items: ppITEM;
+  my_menu: pMENU;
+  c, n_choices, i: Longint;
+  cur_item: pITEM;
+begin
+  try
+    initscr();
+    cbreak();
+    noecho();
+    keypad(stdscr, TRUE);
+
+    n_choices := 5;
+    GetMem(my_items, (n_choices+1)*sizeof(pITEM));
+
+    for i := 0 to n_choices - 1 do
+      my_items[i] := new_item(choices[i], choices[i]);
+    my_items[n_choices] := nil;
+
+    my_menu := new_menu(my_items);
+    mvprintw(LINES - 2, 0, 'F1 to Exit');
+    post_menu(my_menu);
+    refresh();
+
+    c := getch();
+    while c <> KEY_F(1) do
+    begin
+      case c of
+        KEY_DOWN: menu_driver(my_menu, REQ_DOWN_ITEM);
+        KEY_UP: menu_driver(my_menu, REQ_UP_ITEM);
+      else
+      end;
+      c := getch();
+    end
+
+  finally
+    free_item(my_items[0]);
+    free_item(my_items[1]);
+    free_menu(my_menu);
+    FreeMem(my_items, (n_choices+1)*sizeof(pITEM));
+    endwin();
+  end;
+end.

+ 190 - 0
packages/ncurses/examples/t1panel.pp

@@ -0,0 +1,190 @@
+{
+  Example 17. Panel Hiding and Showing example
+  from ncurses howto
+}
+
+program test_panel;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, panel, sysutils;
+
+
+Type
+  PANEL_DATA = record
+    hide: Boolean;       (* TRUE if panel is hidden *)
+  end;
+  PPWINDOW = ^PWINDOW;
+
+const
+  NLINES = 10;
+  NCOLS  = 40;
+
+procedure print_in_middle(win: PWINDOW; starty, startx, width: Longint; str: AnsiString; color: chtype);
+var
+  slength, x, y: Longint;
+  temp: Double;
+begin
+
+  if win = nil then
+    win := stdscr;
+  getyx(win, y, x);
+  if startx <> 0 then
+    x := startx;
+  if starty <> 0 then
+    y := starty;
+  if width = 0 then
+    width := 80;
+
+  slength := Length(str);
+  temp := (width - slength)/ 2;
+  x := startx + round(temp);
+  wattron(win, color);
+  mvwaddstr(win, y, x, PChar(str));
+  wattroff(win, color);
+  refresh();
+
+end;
+
+(* Show the window with a border and a label *)
+procedure win_show(win: PWINDOW; lab: AnsiString; label_color: Longint);
+var
+  startx, starty, height, width: Smallint;
+begin
+        getbegyx(win, starty, startx);
+        getmaxyx(win, height, width);
+
+        box(win, 0, 0);
+        mvwaddch(win, 2, 0, ACS_LTEE); 
+        mvwhline(win, 2, 1, ACS_HLINE, width - 2);
+        mvwaddch(win, 2, width - 1, ACS_RTEE);
+
+        print_in_middle(win, 1, 0, width, lab, COLOR_PAIR(label_color));
+end;
+
+(* Put all the windows *)
+procedure init_wins(wins: PPWINDOW; n: Longint);
+var
+  x, y, i: Longint;
+  lab: AnsiString;
+begin
+  y := 2;
+  x := 10;
+  for i := 0 to n - 1 do
+  begin
+    wins[i] := newwin(NLINES, NCOLS, y, x);
+    FmtStr(lab, 'Window Number %d', [i + 1]);
+    win_show(wins[i], lab, i + 1);
+    y += 3;
+    x += 7;
+  end
+end;
+
+var
+  my_wins:   array[0..2] of PWINDOW;
+  my_panels: array[0..2] of PPANEL;
+  panel_datas:  array[0..2] of PANEL_DATA;
+  temp:      ^PANEL_DATA;
+  ch:  chtype;
+begin
+  try
+
+(* Initialize curses *)
+  initscr();
+  start_color();
+  cbreak();
+  noecho();
+  keypad(stdscr, TRUE);
+
+(* Initialize all the colors *)
+  init_pair(1, COLOR_RED, COLOR_BLACK);
+  init_pair(2, COLOR_GREEN, COLOR_BLACK);
+  init_pair(3, COLOR_BLUE, COLOR_BLACK);
+  init_pair(4, COLOR_CYAN, COLOR_BLACK);
+
+  init_wins(my_wins, 3);
+
+(* Attach a panel to each window *)        (* Order is bottom up *)
+  my_panels[0] := new_panel(my_wins[0]);   (* Push 0, order: stdscr-0 *)
+  my_panels[1] := new_panel(my_wins[1]);   (* Push 1, order: stdscr-0-1 *)
+  my_panels[2] := new_panel(my_wins[2]);   (* Push 2, order: stdscr-0-1-2 *)
+
+(* Initialize panel datas saying that nothing is hidden *)
+  panel_datas[0].hide := FALSE;
+  panel_datas[1].hide := FALSE;
+  panel_datas[2].hide := FALSE;
+
+  set_panel_userptr(my_panels[0], @panel_datas[0]);
+  set_panel_userptr(my_panels[1], @panel_datas[1]);
+  set_panel_userptr(my_panels[2], @panel_datas[2]);
+
+(* Update the stacking order. 2nd panel will be on top *)
+  update_panels();
+
+(* Show it on the screen *)
+  attron(COLOR_PAIR(4));
+  mvprintw(LINES - 3, 0, 'Show or Hide a window with "a"(first window)  "b"(Second Window)  "c"(Third Window)');
+  mvprintw(LINES - 2, 0, 'F1 to Exit');
+
+  attroff(COLOR_PAIR(4));
+  doupdate();
+
+
+  ch := getch;
+  while ch <> KEY_F(1) do
+  begin
+    case ch of
+      chtype('a'):
+      begin
+        temp := panel_userptr(my_panels[0]);
+        if temp^.hide = FALSE then
+        begin
+          hide_panel(my_panels[0]);
+          temp^.hide := TRUE;
+        end
+        else
+        begin
+          show_panel(my_panels[0]);
+          temp^.hide := FALSE;
+        end
+      end;
+      chtype('b'):
+      begin
+        temp := panel_userptr(my_panels[1]);
+        if temp^.hide = FALSE then
+        begin
+          hide_panel(my_panels[1]);
+          temp^.hide := TRUE;
+        end
+        else
+        begin
+          show_panel(my_panels[1]);
+          temp^.hide := FALSE;
+        end
+      end;
+      chtype('c'):
+      begin
+        temp := panel_userptr(my_panels[2]);
+        if temp^.hide = FALSE then
+        begin
+          hide_panel(my_panels[2]);
+          temp^.hide := TRUE;
+        end
+        else
+        begin
+          show_panel(my_panels[2]);
+          temp^.hide := FALSE;
+        end
+      end
+      else
+      end;
+    update_panels();
+    doupdate();
+    ch := getch;
+  end;
+
+  finally
+    endwin();
+  end;
+end.

+ 186 - 0
packages/ncurses/examples/t2form.pp

@@ -0,0 +1,186 @@
+program form_test_2;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, form, libc;
+
+
+var
+  my_bg: Smallint = COLOR_BLACK;
+
+  field: array[0..5] of PFIELD;
+  my_form: PFORM;
+  i, ch: Longint;
+begin
+
+try
+  setlocale(LC_ALL, ''); { Tested with Russian UTF-8 locale }
+
+  (* Initialize curses *)
+   initscr();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+  (* Initialize colors *)
+   if has_colors() then
+   begin
+     start_color();
+     if (use_default_colors() = OK) then
+       my_bg := -1
+     else
+       my_bg := COLOR_BLACK;
+
+     init_pair(1, COLOR_YELLOW, my_bg);
+     init_pair(2, COLOR_MAGENTA, my_bg);
+     init_pair(3, COLOR_WHITE, my_bg);
+     init_pair(4, COLOR_WHITE, COLOR_BLUE);
+     init_pair(5, COLOR_WHITE, COLOR_GREEN);
+     init_pair(6, COLOR_YELLOW, COLOR_GREEN);
+     init_pair(7, COLOR_BLACK, COLOR_CYAN);
+   end;
+
+  (* Initialize the fields *)
+    for i := 0 to 3 do
+    begin
+      field[i] := new_field(1, 30, 2 + i * 2, 10, 0, 0);
+      field_opts_off(field[i], O_AUTOSKIP);
+    end;
+
+   field[4] := new_field(7, 30, 2, 42, 0, 0);
+   field[5] := nil;
+
+  (* Set field options *)
+    set_field_fore(field[0], COLOR_PAIR(2));
+    set_field_back(field[0], A_UNDERLINE OR COLOR_PAIR(3));
+
+    set_field_fore(field[1], COLOR_PAIR(1));
+    set_field_back(field[1], A_UNDERLINE OR COLOR_PAIR(1));
+    field_opts_off(field[1], O_ACTIVE);
+
+    set_field_fore(field[2], COLOR_PAIR(4));
+    set_field_back(field[2], A_UNDERLINE OR COLOR_PAIR(4));
+    field_opts_off(field[2], O_PUBLIC);
+
+    set_field_fore(field[3], COLOR_PAIR(5));
+    set_field_back(field[3], A_UNDERLINE OR COLOR_PAIR(5));
+    field_opts_off(field[3], O_STATIC);
+
+    set_field_fore(field[4], COLOR_PAIR(7));
+    set_field_back(field[4], COLOR_PAIR(7));
+
+  (* Create the form and post it *)
+    my_form := new_form(field);
+    post_form(my_form);
+
+  (* Center Justification *)
+    set_field_just(field[0], JUSTIFY_CENTER);
+    set_field_buffer(field[0], 0, 'This is a static Field');
+
+    set_field_just(field[1], JUSTIFY_CENTER);
+    set_field_buffer(field[1], 0, 'This is a inactive Field');
+
+  (* Set focus to the blue field *)
+    set_current_field(my_form, field[0]);
+
+    for i := 0 to 3 do
+      mvprintw(2 + i * 2, 2, 'Value %d:', i + 1);
+    mvaddstr(LINES - 2, 0, 'F1 to Exit');
+    refresh();
+
+  (* Loop through to get user requests *)
+    ch := getch();
+    while (ch <> KEY_F(1)) AND (ch <> 27) do
+    begin
+      case ch of
+        9:   { TAB }
+        begin
+          if form_driver(my_form, REQ_NEXT_WORD) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_NEXT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        end;
+        KEY_NPAGE:
+    (* Go to next field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_NEXT_FIELD);
+            { Go to the end of the present buffer
+              Leaves nicely at the last character }
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_PPAGE:
+    (* Go to previous field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_PREV_FIELD);
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_DOWN:
+          if form_driver(my_form, REQ_DOWN_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_DOWN_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_UP:
+          if form_driver(my_form, REQ_UP_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_UP_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_LEFT:
+          if form_driver(my_form, REQ_LEFT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_LEFT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_RIGHT:
+          if form_driver(my_form, REQ_RIGHT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_RIGHT_FIELD);
+          end;
+        KEY_BACKSPACE: form_driver(my_form, REQ_DEL_PREV);
+        10: { ENTER }
+          begin
+            form_driver(my_form, 10);
+            if form_driver(my_form, REQ_NEXT_LINE) <> E_OK then
+            begin
+              form_driver(my_form, REQ_VALIDATION);
+              form_driver(my_form, REQ_NEXT_FIELD);
+              form_driver(my_form, REQ_END_LINE);
+            end;
+          end;
+      else
+          { If this is a normal character, it gets
+            Printed }
+        form_driver(my_form, ch);
+      end;
+      ch := getch();
+    end;
+
+  refresh();
+
+  finally
+    unpost_form(my_form);
+    free_form(my_form);
+    endwin();
+
+    for i := 0 to 4 do
+    begin
+      if field_status(field[i]) then
+      begin
+        writeln;
+        writeln('Value ', i,':');
+        writeln(field_buffer(field[i], 0));
+      end;
+      free_field(field[i]);
+    end
+  end;
+end.

+ 433 - 0
packages/ncurses/examples/t2menu.pp

@@ -0,0 +1,433 @@
+{$MODE OBJFPC}
+program Menu_Example;
+
+
+uses
+  ncurses, menu, panel, sysutils;
+
+
+function st_middle(scrlen, itemlen: Smallint): Smallint; inline;
+begin
+  st_middle := (scrlen - itemlen) div 2;
+end;
+
+procedure print_in_middle(win: PWINDOW; starty, startx: Smallint;
+                          width: Longint; pair: Smallint;
+                          const fmt: AnsiString; args: array of const);
+var
+  tstr: AnsiString;
+  my, mx: Smallint;
+begin
+  FmtStr(tstr, fmt, args);
+  getmaxyx(win, my, mx);
+  mx -= startx;
+
+  if (width > length(tstr)) OR  (width < 2) then
+    width := length(tstr);
+
+  if width > mx then
+    width := mx;
+
+  wattron(win,COLOR_PAIR(pair));
+  mvwaddnstr(win,starty,startx + st_middle(mx,width),PChar(tstr),width);
+  wattroff(win,COLOR_PAIR(pair));
+end;
+
+
+type
+  PMinfo = ^TMinfo;
+  TMinfo = record
+    n, d: PChar;
+  end;
+
+
+type
+  TSubmenu = class
+  private
+    _win: PWINDOW;
+    _pan: PPANEL;
+    _items: ppITEM;
+    _exit, _sitem: pITEM;
+    _menu: pMENU;
+  public
+    function doevent: chtype;
+    constructor create(szy,szx,nch: Smallint; choices: PMinfo;
+                        pair: Smallint;const name: AnsiString);
+    destructor destroy; override;
+    property menu: pMENU read _menu;
+    property items: ppITEM read _items;
+    property sitem: pITEM read _sitem write _sitem ;
+    property win: PWINDOW read _win;
+    property pan: PPANEL read _pan;
+  end;
+
+function TSubmenu.doevent: chtype;
+
+function doenter(var ch: chtype): Boolean;
+begin
+        if current_item(_menu) = _exit then
+        begin
+          doenter := false;
+          ch := -1
+        end
+        else
+        if current_item(_menu) = sitem then
+        begin
+          doenter := false;
+          ch := 10
+        end
+        else
+          doenter := true;
+end;
+
+var
+  ch: chtype = 0;
+  doiter: Boolean = true;
+begin
+  while doiter do
+  begin
+    ch := wgetch(_win);
+    case ch of
+      KEY_DOWN:    menu_driver(_menu, REQ_DOWN_ITEM);
+      KEY_UP:      menu_driver(_menu, REQ_UP_ITEM);
+      KEY_LEFT:    menu_driver(_menu, REQ_LEFT_ITEM);
+      KEY_RIGHT:   menu_driver(_menu, REQ_RIGHT_ITEM);
+      KEY_NPAGE:   menu_driver(_menu, REQ_SCR_DPAGE);
+      KEY_PPAGE:   menu_driver(_menu, REQ_SCR_UPAGE);
+      chtype(' '): menu_driver(_menu, REQ_TOGGLE_ITEM);
+      10: doiter := doenter(ch);             (* Enter *)
+    else
+      if menu_driver(_menu, ch) <> E_OK then
+      begin
+        doiter := false;
+        if (ch <> chtype('q')) AND  (ch <> KEY_F(10)) then
+          ch := -1;                    (* Close menu *)
+      end
+      else
+        if (ch = KEY_MOUSE) then
+          doiter := doenter(ch);
+    end;
+  end;
+  update_panels();
+  doupdate();
+  doevent := ch;
+end;
+
+constructor TSubmenu.create(szy,szx,nch: Smallint; choices: PMinfo;
+                             pair: Smallint;const name: AnsiString);
+var
+  i: Longint = 0;
+begin
+  GetMem(_items, (nch+1)*sizeof(pITEM));
+  for i := 0 to nch - 1 do
+    _items[i] := new_item(choices[i].n, choices[i].d);
+  _items[nch] := nil;
+  _exit := _items[i];
+  sitem := nil;
+
+  _menu := new_menu(_items);
+
+  //scale_menu(_menu, @mrows, @mcols);
+  _win := newwin(szy,szx,st_middle(LINES,szy),st_middle(COLS,szx));
+  //_win := newwin(mrows + 2, mcols + 2, st_middle(LINES,mrows+2),st_middle(COLS,mcols+2));
+  _pan := new_panel(_win);
+
+  keypad(_win, TRUE);
+  box(_win, ACS_VLINE, ACS_HLINE);
+
+  wbkgd(_win, COLOR_PAIR(pair));
+  set_menu_back(_menu, COLOR_PAIR(pair));
+
+  print_in_middle(_win,0,0,szx-2,pair,name,[]);
+
+  set_menu_win(_menu, _win);
+  set_menu_sub(_menu, derwin(_win, szy-2, szx-2, 1, 1));
+  //set_menu_sub(_menu, derwin(_win, mrows, mcols, 1, 1));
+  set_menu_mark(_menu, '-');
+end;
+
+destructor TSubmenu.destroy;
+var
+  i: Longint = 0;
+begin
+  unpost_menu(_menu);
+  free_menu(_menu);
+  while _items[i] <> nil do
+  begin
+    free_item(_items[i]); Inc(i);
+  end;
+  FreeMem(_items, (i+1)*sizeof(pITEM));
+
+  del_panel(_pan);
+  delwin(_win);
+  update_panels();
+  doupdate();
+end;
+
+
+type
+  Tmainptr = function: chtype;
+
+const
+  EXIT_PROGRAM = KEY_MAX + 100;
+
+function confirm_menu: chtype;
+const
+  choices: array[0..2] of TMinfo =
+                       (
+                         (n:'    Yes    ';d:nil),
+                         (n:'I dont know';d:nil),
+                         (n:'    No     ';d:nil)
+                       );
+var
+  smenu: TSubmenu;
+begin
+  smenu := TSubmenu.create(3, 41,3,choices,5,'Do you really want to quit?');
+
+  menu_opts_off(smenu.menu, O_SHOWDESC);
+  set_menu_format(smenu.menu, 1, 3);
+  post_menu(smenu.menu);
+
+  smenu.sitem := smenu.items[0];
+
+  confirm_menu := smenu.doevent;
+
+  if (confirm_menu = 10) OR (confirm_menu = chtype('q')) OR (confirm_menu = KEY_F(10)) then
+    confirm_menu := EXIT_PROGRAM
+  else
+    confirm_menu := -1;
+  smenu.destroy;
+end;
+
+
+(* Scrolling Menus example *)
+
+function scroll_menu: chtype;
+const
+  choices: array[0..9] of TMinfo =
+                    (
+                      (n: '1_'; d: 'Choice'),
+                      (n: '2_'; d: 'Choice'),
+                      (n: '3_'; d: 'Choice'),
+                      (n: '4_'; d: 'Choice'),
+                      (n: '5_'; d: 'Choice'),
+                      (n: '6_'; d: 'Choice'),
+                      (n: '7_'; d: 'Choice'),
+                      (n: '8_'; d: 'Choice'),
+                      (n: '9_'; d: 'Choice'),
+                      (n: '..'; d: 'Close')
+                    );
+var
+  smenu: TSubmenu;
+begin
+  mvaddstr(LINES - 3, COLS - 30, '"PAGEUP" "PAGEDOWN" - scroll');
+  refresh();
+  smenu := TSubmenu.create(8, 13,10,choices,6,'Scrolling');
+
+  set_menu_format(smenu.menu, 6, 1);
+  post_menu(smenu.menu);
+
+  scroll_menu := smenu.doevent;
+  smenu.destroy;
+  mvaddstr(LINES - 3, COLS - 30, '                            ');
+  refresh();
+end;
+
+
+(* Milt Columnar Menus Example *)
+
+function multicol_menu: chtype;
+const
+  choices: array[0..24] of TMinfo =
+  (
+    (n:'1_';d:nil),(n:'2_';d:nil),(n:'3_';d:nil),(n:'4_';d:nil),(n:'5_';d:nil),
+    (n:'6_';d:nil),(n:'7_';d:nil),(n:'8_';d:nil),(n:'9_';d:nil),(n:'10';d:nil),
+    (n:'11';d:nil),(n:'12';d:nil),(n:'13';d:nil),(n:'14';d:nil),(n:'15';d:nil),
+    (n:'16';d:nil),(n:'17';d:nil),(n:'18';d:nil),(n:'19';d:nil),(n:'20';d:nil),
+    (n:'21';d:nil),(n:'22';d:nil),(n:'23';d:nil),(n:'24';d:nil),(n:'..';d:nil)
+  );
+var
+  smenu: TSubmenu;
+  i: Longint;
+begin
+  smenu := TSubmenu.create(7, 22,25,choices,5,'Multicol');
+
+(* Set menu option not to show the description *)
+  menu_opts_off(smenu.menu, O_SHOWDESC);
+  set_menu_format(smenu.menu, 5, 5);
+  post_menu(smenu.menu);
+
+  multicol_menu := smenu.doevent;
+  smenu.destroy;
+end;
+
+
+(* Multi Valued Menus example *)
+
+function multival_menu: chtype;
+const
+  choices: array[0..5] of TMinfo =
+                    (
+                      (n: '1_'; d: 'Choice'),
+                      (n: '2_'; d: 'Choice'),
+                      (n: '3_'; d: 'Choice'),
+                      (n: '4_'; d: 'Choice'),
+                      (n: '5_'; d: 'Choice'),
+                      (n: '..'; d: 'Close')
+                    );
+var
+  smenu: TSubmenu;
+begin
+  mvaddstr(LINES - 3, COLS - 30, '"SPACE" - toggle choice');
+  refresh();
+  smenu := TSubmenu.create(8, 13,6,choices,7,'Multival');
+
+  menu_opts_off(smenu.menu, O_ONEVALUE);
+  post_menu(smenu.menu);
+
+  multival_menu := smenu.doevent;
+  smenu.destroy;
+  mvaddstr(LINES - 3, COLS - 30, '                       ');
+  refresh();
+end;
+
+
+const
+  n_choices = 4;
+  choices: array[0..3] of TMinfo =
+                    (
+                      (n: '1_'; d: 'Scrolling Menus'),
+                      (n: '2_'; d: 'Multi Columnar Menus'),
+                      (n: '3_'; d: 'Multi Valued Menus'),
+                      (n: '..'; d: 'Exit')
+                    );
+
+var
+  main_menu_win: PWINDOW;
+  main_menu_panel: PPANEL;
+
+function mgetch: chtype;
+begin
+  mgetch :=   wgetch(main_menu_win);
+end;
+
+var
+  my_bg: Smallint = COLOR_BLACK;
+
+  main_items: ppITEM;
+  cur_item: pITEM;
+  main_menu: pMENU;
+  ptr: Tmainptr = @mgetch;
+
+  ch: chtype = -1;
+  i: Longint;
+begin
+  try
+   (* Initialize curses *)
+    initscr();
+    noecho();
+    cbreak();
+    keypad(stdscr, TRUE);
+    curs_set(0);
+    clear();
+    mousemask(ALL_MOUSE_EVENTS, nil);
+
+    if has_colors() then
+    begin
+      start_color();
+      if (use_default_colors() = OK) then
+        my_bg := -1
+      else
+        my_bg := COLOR_BLACK;
+
+      init_pair(1, COLOR_YELLOW, my_bg);
+      init_pair(2, COLOR_RED, my_bg);
+      init_pair(3, COLOR_MAGENTA, my_bg);
+      init_pair(4, COLOR_CYAN, my_bg);
+      init_pair(5, COLOR_WHITE, COLOR_RED);
+      init_pair(6, COLOR_WHITE, COLOR_BLUE);
+      init_pair(7, COLOR_WHITE, COLOR_GREEN);
+    end;
+
+    main_menu_win := newwin(8, 40, st_middle(LINES, 8) - 2, st_middle(COLS, 40) - 10);
+    main_menu_panel := new_panel(main_menu_win);
+    keypad(main_menu_win, TRUE);
+
+   (* Create items *)
+    GetMem(main_items, (n_choices+1)*sizeof(pITEM));
+    for i := 0 to n_choices-1 do
+      main_items[i] := new_item(choices[i].n, choices[i].d);
+    main_items[n_choices] := nil;
+
+   (* Set the user pointers *)
+     set_item_userptr(main_items[0], @scroll_menu);
+     set_item_userptr(main_items[1], @multicol_menu);
+     set_item_userptr(main_items[2], @multival_menu);
+     set_item_userptr(main_items[3], @confirm_menu);
+
+   (* Crate menu *)
+     main_menu := new_menu(main_items);
+
+   (* Set main window and sub window *)
+     set_menu_win(main_menu, main_menu_win);
+     set_menu_sub(main_menu, derwin(main_menu_win, 4, 38, 3, 1));
+
+   (* Set menu mark to the string "=>" *)
+     set_menu_mark(main_menu, '=>');
+
+   (* Print a border around the main window and print a title *)
+     box(main_menu_win, 0, 0);
+     wbkgd(main_menu_win, COLOR_PAIR(6));
+     set_menu_back(main_menu, COLOR_PAIR(6));
+
+     print_in_middle(main_menu_win, 1, 0, 40, COLOR_PAIR(6), 'Main Menu', []);
+     mvwaddch(main_menu_win, 2, 0, ACS_LTEE);
+     mvwhline(main_menu_win, 2, 1, ACS_HLINE, 38);
+     mvwaddch(main_menu_win, 2, 39, ACS_RTEE);
+     attron(COLOR_PAIR(4));
+     mvaddstr(LINES - 1, COLS - 30, 'Press "F10" or "q" to exit  ');
+     attroff(COLOR_PAIR(4));
+     refresh();
+
+   (* Post the menu *)
+     post_menu(main_menu);
+     wrefresh(main_menu_win);
+
+     while ch <> EXIT_PROGRAM do
+     begin
+       case ch of
+         KEY_DOWN: menu_driver(main_menu, REQ_DOWN_ITEM);
+         KEY_UP: menu_driver(main_menu, REQ_UP_ITEM);
+         -1: ptr := @mgetch;              (* Restore ptr *)
+         10:                              (* Enter *)
+         begin
+           cur_item := current_item(main_menu);     (* get current item *)
+           ptr := Tmainptr(item_userptr(cur_item)); (* set ptr to current item *)
+         end;
+       else
+       (* Process mouse and others events *)
+         if (menu_driver(main_menu, ch) = E_OK) AND (ch = KEY_MOUSE) then
+         begin
+           cur_item := current_item(main_menu);
+           ptr := Tmainptr(item_userptr(cur_item));
+           wrefresh(main_menu_win);
+         end;
+       end;
+       ch := ptr(); (* Call ptr function *)
+
+       if (ch = chtype('q')) OR  (ch = KEY_F(10)) then
+         ch := confirm_menu();
+     end;
+
+  finally
+    unpost_menu(main_menu);
+    free_menu(main_menu);
+    for i := 0 to n_choices - 1 do
+      free_item(main_items[i]);
+    FreeMem(main_items, (n_choices+1)*sizeof(pITEM));
+    del_panel(main_menu_panel);
+    delwin(main_menu_win);
+    curs_set(1);
+    endwin();
+  end;
+end.

+ 169 - 0
packages/ncurses/examples/t2panel.pp

@@ -0,0 +1,169 @@
+program test_panel;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, panel, sysutils;
+
+
+Type
+  PPWINDOW = ^PWINDOW;
+  PPPANEL  = ^PPANEL;
+
+const
+  NLINES = 8;
+  NCOLS  = 32;
+
+procedure print_in_middle(win: PWINDOW; starty, startx, width: Longint; str: AnsiString; color: chtype);
+var
+  slength: Longint;
+  x, y: Longint;
+  temp: Double;
+begin
+
+  if win = nil then
+    win := stdscr;
+  getyx(win, y, x);
+  if startx <> 0 then
+    x := startx;
+  if starty <> 0 then
+    y := starty;
+  if width = 0 then
+    width := 80;
+
+  slength := Length(str);
+  temp := (width - slength)/ 2;
+  x := startx + round(temp);
+  wattron(win, color);
+  mvwaddstr(win, y, x, PChar(str));
+  wattroff(win, color);
+  refresh();
+
+end;
+
+
+procedure win_show(win: PWINDOW; lab: AnsiString; label_color: Longint);
+var
+  startx, starty, height, width: Longint;
+begin
+        getbegyx(win, starty, startx);
+        getmaxyx(win, height, width);
+
+        box(win, 0, 0);
+        mvwaddch(win, 2, 0, ACS_LTEE); 
+        mvwhline(win, 2, 1, ACS_HLINE, width - 2);
+        mvwaddch(win, 2, width - 1, ACS_RTEE);
+
+        print_in_middle(win, 1, 0, width, lab, COLOR_PAIR(label_color));
+end;
+
+procedure init_panels(pans: PPPANEL; n: Longint);
+var
+  x, y, i: Longint;
+  lab: AnsiString;
+  win: PWINDOW;
+begin
+  y := 2;
+  x := 3;
+  for i := 0 to n - 1 do
+  begin
+    win := newwin(NLINES, NCOLS, y, x);
+    FmtStr(lab, 'Window Number %d', [i + 1]);
+    win_show(win, lab, i + 1);
+    pans[i] := new_panel(win);
+    y += 2;
+    x += 4;
+  end
+end;
+
+procedure select(var oldp: PPANEL; newp: PPANEL);
+var
+  win: PWINDOW;
+begin
+  win := panel_window(oldp);
+  wattroff(win,A_BOLD);
+  box(win,0,0);
+
+  win := panel_window(newp);
+  wattron(win,A_BOLD);
+  box(win,0,0);
+
+  oldp := newp;
+end;
+
+var
+  my_panels: array[0..4] of PPANEL;
+  selected:  PPANEL;
+  ch:  chtype;
+begin
+  try
+
+(* Initialize curses *)
+  initscr();
+  start_color();
+  cbreak();
+  noecho();
+  keypad(stdscr, TRUE);
+
+(* Initialize all the colors *)
+  init_pair(1, COLOR_RED, COLOR_BLACK);
+  init_pair(2, COLOR_GREEN, COLOR_BLACK);
+  init_pair(3, COLOR_BLUE, COLOR_BLACK);
+  init_pair(4, COLOR_CYAN, COLOR_BLACK);
+  init_pair(5, COLOR_YELLOW, COLOR_BLACK);
+
+  init_panels(my_panels, 5);
+
+  set_panel_userptr(my_panels[0], my_panels[4]);
+  set_panel_userptr(my_panels[1], my_panels[3]);
+  set_panel_userptr(my_panels[2], my_panels[1]);
+  set_panel_userptr(my_panels[3], my_panels[0]);
+  set_panel_userptr(my_panels[4], my_panels[2]);
+
+  select(selected,my_panels[4]);
+
+(* Update the stacking order. 2nd panel will be on top *)
+  update_panels();
+
+(* Show it on the screen *)
+  attron(COLOR_PAIR(4));
+  mvprintw(LINES - 5, 1, 't : top');
+  mvprintw(LINES - 4, 1, 'h : show or hide toggle');
+  mvprintw(LINES - 3, 1, '1..5, home, end, up, down, tab : navigate ');
+  mvprintw(LINES - 2, 1, 'F1 : to Exit');
+  attroff(COLOR_PAIR(4));
+  doupdate();
+
+  ch := getch;
+  while ch <> KEY_F(1) do
+  begin
+    case ch of
+      chtype('1'): select(selected,my_panels[0]);
+      chtype('2'): select(selected,my_panels[1]);
+      chtype('3'): select(selected,my_panels[2]);
+      chtype('4'): select(selected,my_panels[3]);
+      chtype('5'): select(selected,my_panels[4]);
+      KEY_HOME: select(selected,panel_above(nil));
+      KEY_END: select(selected,panel_below(nil));
+      KEY_UP: select(selected,panel_above(selected));
+      KEY_DOWN: select(selected,panel_below(selected));
+      9: select(selected,panel_userptr(selected));
+      chtype('t'): top_panel(selected);
+      chtype('h'):
+      begin
+        if panel_hidden(selected) = OK then
+          hide_panel(selected)
+        else
+          show_panel(selected);
+      end;
+      else
+      end;
+    update_panels();
+    doupdate();
+    ch := getch;
+  end;
+
+  finally
+    endwin();
+  end;
+end.

+ 241 - 0
packages/ncurses/examples/t3form.pp

@@ -0,0 +1,241 @@
+{
+   Author: Vitaliy Trifonov
+}
+program form_test_3;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, form, libc;
+
+
+
+function st_middle(scrlen, itemlen: Smallint): Smallint; inline;
+begin
+  st_middle := (scrlen - itemlen) div 2;
+end;
+
+
+procedure draw;
+
+function randomchar: chtype;
+var
+  ch: Char = #0;
+begin
+  while not (ch in ['0'..'9','A'..'Z','a'..'z']) do
+    ch := Char(Random(123));
+  randomchar := chtype(ch);
+end;
+
+function randompair: longint;
+var
+  pair: longint = 0;
+begin
+  while not (pair in [1..5]) do
+    pair := Random(6);
+  randompair := pair;
+end;
+
+var
+  y, x:  Smallint;
+begin
+  for y := 0 to LINES - 1 do
+    for x := 0 to COLS - 1 do
+      mvaddch(y, x, randomchar OR COLOR_PAIR(randompair));
+end;
+
+const
+  enumval: array[0..2] of PChar = ('one', 'two', 'three');
+  desc: array[0..5] of PChar =
+              (
+                'TYPE_ALPHA    Char data, a min width 8',
+                'TYPE_ENUM      one, two, three',
+                'TYPE_INTEGER     -300 .. 300',
+                'TYPE_NUMERIC    -30.0 .. 30.0',
+                'TYPE_REGEXP ^http://.+\.(ru|net|com)\s*$',
+                'TYPE_IPV4     An IP Version 4 address.'
+              );
+var
+  my_bg: Smallint = COLOR_BLACK;
+  form_win: PWINDOW;
+
+  pair: Smallint;
+  field: array[0..6] of PFIELD;
+  my_form: PFORM;
+  i, frows, fcols, ch: Longint;
+begin
+
+try
+  setlocale(LC_ALL, '');
+
+  (* Initialize curses *)
+   initscr();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+  (* Initialize colors *)
+   if has_colors() then
+   begin
+     start_color();
+     if (use_default_colors() = OK) then
+       my_bg := -1
+     else
+       my_bg := COLOR_BLACK;
+
+     init_pair(1, COLOR_YELLOW, my_bg);
+     init_pair(2, COLOR_MAGENTA, my_bg);
+     init_pair(3, COLOR_WHITE, my_bg);
+     init_pair(4, COLOR_CYAN, my_bg);
+     init_pair(5, COLOR_GREEN, my_bg);
+     init_pair(6, COLOR_WHITE, COLOR_BLUE);
+     init_pair(7, COLOR_BLACK, COLOR_CYAN);
+   end;
+
+
+   for i := 0 to 5 do
+   begin
+     field[i] := new_field(1, 30, 2 + i * 3, 10, 0, 0);
+     field_opts_off(field[i], O_AUTOSKIP);
+     if i AND 1 = 0 then
+       pair := 7
+     else
+       pair := 6;
+     set_field_fore(field[i], COLOR_PAIR(pair));
+     set_field_back(field[i], A_UNDERLINE OR COLOR_PAIR(pair));
+     //set_field_pad(field[i],chtype(' '));
+   end;
+   draw;
+   refresh();
+
+   field[6] := nil;
+
+   set_field_type(field[0],TYPE_ALPHA,8);
+   set_field_type(field[1],TYPE_ENUM,PPChar(enumval),0,0);
+   set_field_type(field[2],TYPE_INTEGER,3,-300,300);
+   set_field_type(field[3],TYPE_NUMERIC,8,-30.0,30.0);
+   set_field_type(field[4],TYPE_REGEXP,'^http://.+\.(ru|net|com)\s*$');
+   set_field_type(field[5],TYPE_IPV4);
+
+
+   my_form := new_form(field);
+
+(* Calculate the area required for the form *)
+   scale_form(my_form, @frows, @fcols);
+
+(* Create the window to be associated with the form *)
+   //form_win := newwin(rows + 4, cols + 4, 4, 4);
+   form_win := newwin(frows + 4, fcols + 4, st_middle(LINES,frows+4), st_middle(COLS,fcols+4));
+   keypad(form_win, TRUE);
+
+(* Set main window and sub window *)
+   set_form_win(my_form, form_win);
+   set_form_sub(my_form, derwin(form_win, frows, fcols, 2, 2));
+
+(* Print a border around the main window and print a title *)
+   box(form_win, 0, 0);
+   //print_in_middle(my_form_win, 1, 0, cols + 4, "My Form", COLOR_PAIR(1));
+
+   post_form(my_form);
+   wrefresh(form_win);
+
+   for i := 0 to 5 do
+     mvwaddstr(form_win, 3 + i * 3, 1,desc[i]);
+   wrefresh(form_win);
+
+   //set_field_buffer(field[0], 0, 'Test Field');
+   //refresh();
+
+  (* Loop through to get user requests *)
+    ch := wgetch(form_win);
+    while (ch <> KEY_F(1)) AND (ch <> 27) do
+    begin
+      case ch of
+        9:   { TAB }
+        begin
+          if form_driver(my_form, REQ_NEXT_WORD) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_NEXT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        end;
+        KEY_NPAGE:
+    (* Go to next field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_NEXT_FIELD);
+            { Go to the end of the present buffer
+              Leaves nicely at the last character }
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_PPAGE:
+    (* Go to previous field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_PREV_FIELD);
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_DOWN:
+          if form_driver(my_form, REQ_DOWN_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_DOWN_FIELD);
+          end;
+        KEY_UP:
+          if form_driver(my_form, REQ_UP_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_UP_FIELD);
+          end;
+        KEY_LEFT:
+          if form_driver(my_form, REQ_LEFT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_LEFT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_RIGHT:
+          if form_driver(my_form, REQ_RIGHT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_RIGHT_FIELD);
+          end;
+        KEY_BACKSPACE: form_driver(my_form, REQ_DEL_PREV);
+        10: { ENTER }
+          begin
+            form_driver(my_form, 10);
+            if form_driver(my_form, REQ_NEXT_LINE) <> E_OK then
+            begin
+              form_driver(my_form, REQ_VALIDATION);
+              form_driver(my_form, REQ_NEXT_FIELD);
+              form_driver(my_form, REQ_END_LINE);
+            end;
+          end;
+      else
+          { If this is a normal character, it gets
+            Printed }
+        form_driver(my_form, ch);
+      end;
+      ch := wgetch(form_win);
+    end;
+
+  finally
+
+    unpost_form(my_form);
+    free_form(my_form);
+    delwin(form_win);
+    endwin();
+
+    for i := 0 to 5 do
+    begin
+      if field_status(field[i]) then
+      begin
+        writeln;
+        writeln('Value ', i,':');
+        writeln(field_buffer(field[i], 0));
+      end;
+      free_field(field[i]);
+    end
+  end;
+end.

+ 67 - 0
packages/ncurses/examples/tbackground.pp

@@ -0,0 +1,67 @@
+
+uses
+   ncurses, sysutils;
+
+var
+    f, b: Smallint;
+begin
+
+ initscr();
+ cbreak();
+ noecho();
+
+ if (has_colors()) then
+  begin
+	start_color();
+
+	pair_content(0, @f, @b);
+	printw(PChar('pair 0 contains (%d,%d)'#10), f, b);
+	getch();
+
+	printw('Initializing pair 1 to red/black'#10);
+	init_pair(1, COLOR_RED, COLOR_BLACK);
+	bkgdset(chtype(' ') OR COLOR_PAIR(1));
+	printw('RED/BLACK'#10);
+	getch();
+
+	printw('Initializing pair 2 to white/blue'#10);
+	init_pair(2, COLOR_WHITE, COLOR_BLUE);
+	bkgdset(chtype(' ') OR COLOR_PAIR(2));
+	printw('WHITE/BLUE'#10);
+	getch();
+
+	printw('Resetting colors to pair 0'#10);
+	bkgdset(chtype(' ') OR COLOR_PAIR(0));
+	printw('Default Colors'#10);
+	getch();
+
+	printw('Resetting colors to pair 1'#10);
+	bkgdset(chtype(' ') OR COLOR_PAIR(1));
+	printw('RED/BLACK'#10);
+	getch();
+
+	printw('Setting screen to pair 0'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(0));
+	getch();
+
+	printw('Setting screen to pair 1'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(1));
+	getch();
+
+	printw('Setting screen to pair 2'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(2));
+	getch();
+
+	printw('Setting screen to pair 0'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(0));
+	getch();
+
+ end
+ else
+ begin
+	printw('This demo requires a color terminal'#10);
+
+	getch();
+    end;
+    endwin();
+end.

+ 267 - 0
packages/ncurses/examples/tclock.pp

@@ -0,0 +1,267 @@
+program tclock;
+{$MODE OBJFPC}
+
+uses
+  libc, ncurses, sysutils;
+
+const
+  ASPECT = 2.2;
+  _2PI = 2.0 * PI;
+
+function sign(_x: Integer): Integer;
+begin
+  if _x < 0 then
+    sign := -1
+  else
+    sign := 1
+end;
+
+function A2X(angle,radius: Double): Integer; inline;
+begin
+  A2X := round(ASPECT * radius * sin(angle))
+end;
+
+function A2Y(angle,radius: Double): Integer; inline;
+begin
+  A2Y := round(radius * cos(angle))
+end;
+
+type
+  PRchar = ^TRchar;
+  TRchar = record
+    ry,rx: Smallint;
+    rch: chtype;
+  end;
+
+procedure restore( rest: PRchar );
+var
+  i: Longint = 0;
+begin
+  while rest[i].rch <> 0 do
+  begin
+    with rest[i] do
+      mvaddch(ry, rx, rch);
+    Inc(i);
+  end;
+  freemem(rest)
+end;
+
+(* Draw a diagonal(arbitrary) line using Bresenham's alogrithm. *)
+procedure dline(from_y, from_x, end_y,  end_x: Smallint; ch: chtype; var rest: PRchar);
+var
+  dx, dy: Smallint;
+  ax, ay: Smallint;
+  sx, sy: Smallint;
+  x, y, d, i: Smallint;
+begin
+  dx := end_x - from_x;
+  dy := end_y - from_y;
+
+  ax := abs(dx * 2);
+  ay := abs(dy * 2);
+
+  sx := sign(dx);
+  sy := sign(dy);
+
+  x := from_x;
+  y := from_y;
+
+  i := 0;
+  if (ax > ay) then
+  begin
+    getmem(rest, sizeof(TRchar)*(abs(dx)+3));
+    d := ay - (ax DIV 2);
+
+    while true do
+    begin
+      move(y, x);
+      with rest[i] do
+      begin
+        rch := inch;
+        ry := y;
+        rx := x;
+        Inc(i)
+      end;
+      addch(ch);
+      if (x = end_x) then
+      begin
+        rest[i].rch := 0;
+        exit;
+      end;
+
+      if (d >= 0) then
+      begin
+        y += sy;
+        d -= ax;
+      end;
+      x += sx;
+      d += ay;
+    end
+  end
+  else
+  begin
+    getmem(rest, sizeof(TRchar)*(abs(dy)+3));
+    d := ax - (ay DIV 2);
+
+    while true do
+    begin
+      move(y, x);
+      with rest[i] do
+      begin
+        rch := inch;
+        ry := y;
+        rx := x;
+        Inc(i)
+      end;
+      addch(ch);
+      if (y = end_y) then
+      begin
+        rest[i].rch := 0;
+        exit;
+      end;
+
+      if (d >= 0) then
+      begin
+        x += sx;
+        d -= ay;
+      end;
+      y += sy;
+      d += ax;
+    end
+  end
+end;
+
+
+var
+  cx, cy: Integer;
+  cr, sradius, mradius, hradius: Double;
+
+
+procedure clockinit;
+const
+  title1 = 'Free pascal';
+  title2 = 'ncurses clock';
+  title3 = 'Press F10 or q to exit';
+var
+  i: Integer;
+  vstr, tstr: AnsiString;
+  angle: Double;
+begin
+  cx := (COLS - 1) DIV 2;
+  cy := LINES DIV 2;
+  if (cx / ASPECT < cy) then
+  cr := cx / ASPECT
+    else
+  cr := cy;
+
+  sradius := (8 * cr) / 9;
+  mradius := (3 * cr) / 4;
+  hradius := cr / 2;
+
+
+  for i := 1 to 24 do
+  begin
+    angle := i * _2PI / 24.0;
+
+
+    if (i MOD 2) = 0 then
+    begin
+      Str (i DIV 2, tstr);
+      attron(A_BOLD OR COLOR_PAIR(5));
+      mvaddstr(cy - A2Y(angle, sradius), cx + A2X(angle, sradius), @tstr[1]);
+      attroff(A_BOLD OR COLOR_PAIR(5));
+    end
+    else
+    begin
+      attron(COLOR_PAIR(1));
+      mvaddch(cy - A2Y(angle, sradius), cx + A2X(angle, sradius), chtype('.'));
+      attroff(COLOR_PAIR(1));
+    end
+  end;
+
+  vstr := curses_version;
+
+  attron(A_DIM OR COLOR_PAIR(2));
+  mvhline(cy , cx - round(sradius * ASPECT) + 1, ACS_HLINE,  round(sradius * ASPECT) * 2 - 1);
+  mvvline(cy - round(sradius) + 1, cx , ACS_VLINE,  round(sradius) * 2 - 1);
+  attroff(A_DIM OR COLOR_PAIR(1));
+  attron(COLOR_PAIR(3));
+  mvaddstr(cy - 5, cx - Length(title1) DIV 2, title1);
+  mvaddstr(cy - 4, cx - Length(title2) DIV 2, title2);
+  mvaddstr(cy - 3, cx - Length(vstr) DIV 2, PChar(vstr));
+  attroff(COLOR_PAIR(3));
+  attron(A_UNDERLINE);
+  mvaddstr(cy + 2, cx - Length(title3) DIV 2, title3);
+  attroff(A_UNDERLINE);
+end;
+
+
+var
+  angle: Double;
+  ch: chtype = 0;
+  Hour, Min, Sec, Msec: Word;
+  Hrest, Mrest, Srest: PRchar;
+  timestr: AnsiString;
+  my_bg: Smallint = COLOR_BLACK;
+begin
+  setlocale(LC_ALL, '');
+
+  try
+    initscr();
+    noecho();
+    cbreak();
+
+    halfdelay(10);
+    keypad(stdscr, TRUE);
+    curs_set(0);
+
+    if (has_colors()) then
+    begin
+      start_color();
+      if (use_default_colors() = OK) then
+        my_bg := -1;
+
+      init_pair(1, COLOR_YELLOW, my_bg);
+      init_pair(2, COLOR_RED, my_bg);
+      init_pair(3, COLOR_GREEN, my_bg);
+      init_pair(4, COLOR_CYAN, my_bg);
+      init_pair(5, COLOR_YELLOW, COLOR_BLACK) ;
+    end;
+
+    clockinit;
+    repeat
+      if (ch = KEY_RESIZE) then
+      begin
+        flash();
+        erase();
+        wrefresh(curscr);
+        clockinit;
+      end;
+
+      decodeTime(Time, Hour, Min, Sec, Msec);
+      Hour := Hour MOD 12;
+
+      timestr := DateTimeToStr(Now);
+      mvaddstr(cy + round(sradius) - 4, cx - Length(timestr) DIV 2, PChar(timestr));
+
+      angle := Hour * _2PI / 12;
+      dline(cy, cx, cy - A2Y(angle, hradius), cx + A2X(angle, hradius), chtype('*'),Hrest);
+
+      angle := Min * _2PI / 60;
+      dline(cy, cx, cy - A2Y(angle, mradius), cx + A2X(angle, mradius), chtype('*'),Mrest);
+
+      angle := Sec * _2PI / 60;
+      dline(cy, cx, cy - A2Y(angle, sradius), cx + A2X(angle, sradius), chtype('.'),Srest);
+
+      ch := getch();
+
+      restore(Srest);
+      restore(Mrest);
+      restore(Hrest);
+
+    until (ch = chtype('q')) OR (ch = KEY_F(10));
+  finally
+    curs_set(1);
+    endwin();
+  end;
+end.

+ 40 - 0
packages/ncurses/examples/tevent.pp

@@ -0,0 +1,40 @@
+program test_event;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, sysutils;
+
+
+var
+  ch: chtype;
+begin
+  try
+    initscr();
+    noecho();
+    clear();
+    cbreak();
+    keypad(stdscr, TRUE);
+    meta(stdscr, TRUE);
+    mousemask(1, nil);
+
+    mvaddstr(1, 1,'press F10 or q to exit');
+    mvaddstr(2, 1,'press 1 to cbreak mode');
+    mvaddstr(3, 1,'press 2 to raw mode');
+    mvaddstr(4, 1,'press 3 to halfdelay(10) mode');
+    repeat
+      ch := getch;
+      mvaddstr(LINES - 1, 1,'                                ');
+      case ch of
+        ERR: mvaddstr(LINES - 1, 1,'timeout: 1 sec');
+        chtype('1'): cbreak();
+        chtype('2'): raw();
+        chtype('3'): halfdelay(10);
+      else
+        mvaddstr(LINES - 1, 1,PChar(Format('name:%-14s code:%d', [ keyname(ch), ch ] )));
+      end;
+    until (ch = chtype('q')) OR (ch = KEY_F(10));
+  finally
+    endwin();
+  end;
+end.

+ 144 - 0
packages/ncurses/examples/tmouse.pp

@@ -0,0 +1,144 @@
+program mouse_test;
+{$MODE OBJFPC}
+{$COPERATORS ON}
+
+
+uses
+  ncurses, panel, sysutils;
+
+procedure draw;
+
+function randomchar: chtype;
+var
+  ch: Char = #0;
+begin
+  while not (ch in ['0'..'9','A'..'Z','a'..'z']) do
+    ch := Char(Random(123));
+  randomchar := chtype(ch);
+end;
+
+function randompair: longint;
+var
+  pair: longint = 0;
+begin
+  while not (pair in [1..5]) do
+    pair := Random(6);
+  randompair := pair;
+end;
+
+var
+  y, x:  Smallint;
+begin
+  for y := 0 to 2 do
+    for x := 0 to COLS - 7 do
+      mvaddch(y, x, randomchar OR COLOR_PAIR(randompair));
+  attron(A_BOLD OR COLOR_PAIR(7));
+  mvaddstr(0, COLS - 6, '      ');
+  mvaddstr(1, COLS - 6, ' QUIT ');
+  mvaddstr(2, COLS - 6, '      ');
+  attroff(A_BOLD OR COLOR_PAIR(7));
+  for y := 3 to LINES - 1 do
+    for x := 0 to COLS - 1 do
+      mvaddch(y, x, randomchar OR COLOR_PAIR(randompair));
+end;
+
+
+var
+  win: PWINDOW;
+  pan: PPANEL;
+  str: AnsiString;
+function doevent: chtype;
+var
+  event: MEVENT;
+begin
+  getmouse(@event);
+  if (event.y > 2) OR (event.x < COLS - 6) then
+  begin
+    mvwaddstr(win, 1, 1, '                  ');
+    str := Format('y := %D, x := %D', [event.y, event.x]);
+    mvwaddstr(win, 1, 2, PChar(str));
+    wattron(win,A_BOLD);
+    mvwaddch(win, 3, 9, mvinch(event.y,event.x ));
+    wattroff(win,A_BOLD);
+    halfdelay(12);
+
+    show_panel(pan);
+
+    if event.bstate AND  BUTTON1_RELEASED<> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON1_RELEASED')
+    else if event.bstate AND BUTTON2_RELEASED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON2_RELEASED')
+    else if event.bstate AND BUTTON3_RELEASED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON3_RELEASED')
+    else if event.bstate AND BUTTON1_PRESSED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON1_PRESSED ')
+    else if event.bstate AND BUTTON2_PRESSED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON2_PRESSED ')
+    else if event.bstate AND BUTTON3_PRESSED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON3_PRESSED ')
+    else if event.bstate AND BUTTON1_CLICKED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON1_CLICKED ')
+    else if event.bstate AND BUTTON2_CLICKED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON2_CLICKED ')
+    else if event.bstate AND BUTTON3_CLICKED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON3_CLICKED ');
+
+    doevent := wgetch(win);
+    cbreak();
+    hide_panel(pan);
+  end
+  else
+    doevent := chtype('q')
+end;
+
+var
+  ch: chtype = 0;
+  my_bg: Smallint = COLOR_BLACK;
+begin
+  try
+    initscr();
+    noecho();
+    clear();
+    cbreak();
+    keypad(stdscr, TRUE);
+    curs_set(0);
+    mousemask(ALL_MOUSE_EVENTS, nil);
+
+    if (has_colors()) then
+    begin
+      start_color();
+      if (use_default_colors() = OK) then
+        my_bg := -1
+      else
+        my_bg := COLOR_BLACK;
+
+      init_pair(1, COLOR_YELLOW, my_bg);
+      init_pair(2, COLOR_RED, my_bg);
+      init_pair(3, COLOR_MAGENTA, my_bg);
+      init_pair(4, COLOR_CYAN, my_bg);
+      init_pair(5, COLOR_GREEN, my_bg);
+      init_pair(6, COLOR_WHITE, COLOR_BLUE);
+      init_pair(7, COLOR_WHITE, COLOR_RED);
+    end;
+
+    win:= newwin(7, 20, (LINES - 7) DIV 2 , (COLS - 20) DIV 2);
+    pan := new_panel(win);
+    box(win, ACS_VLINE, ACS_HLINE);
+    wbkgd(win, COLOR_PAIR(6));
+
+    draw;
+    repeat
+      if ch = KEY_MOUSE then
+        ch := doevent
+      else
+        ch := getch();
+    until  (ch = chtype('q')) OR (ch = KEY_F(10));
+
+  finally
+    del_panel(pan);
+    delwin(win);
+    curs_set(1);
+    endwin();
+  end;
+end.
+

+ 49 - 0
packages/ncurses/examples/tnlshello.pp

@@ -0,0 +1,49 @@
+{
+  rstconv -i tnlshello.rst -o tnlshello_ru_UTF8.pot
+  msgfmt tnlshello_ru_UTF8.pot
+  mv messages.mo ru
+}
+
+program nlshello;
+{$mode objfpc}
+
+uses
+  gettext, libc, ncurses;
+
+resourcestring
+  hello_world = 'Hello world!';
+  press_key = 'Press any key to continue!';
+
+
+var
+  win : pWINDOW;
+begin
+  setlocale(LC_ALL, '');
+
+  try
+    initscr();
+    start_color;
+    noecho;
+    win:= newwin ( 10, COLS - 20, 5, 10);
+
+    init_pair(1,COLOR_WHITE,COLOR_BLUE);
+    init_pair(2,COLOR_RED,COLOR_BLUE);
+    wbkgd(win, COLOR_PAIR(1));
+    erase;
+    refresh;
+
+    box(win, ACS_VLINE, ACS_HLINE);
+    wrefresh(win);
+    mvwaddstr(win,1,3, curses_version);
+
+    TranslateResourcestrings('%s/messages.mo');
+    wattron(win,A_BLINK OR A_BOLD OR COLOR_PAIR(2));
+    mvwaddstr(win,3,3, PChar(hello_world));
+    wattroff(win,A_BLINK OR A_BOLD OR COLOR_PAIR(2));
+    mvwaddstr(win,5,3, PChar(press_key));
+    wrefresh(win);
+    getch();
+  finally
+    endwin();
+  end;
+end.

+ 7 - 0
packages/ncurses/examples/tnlshello_ru_UTF8.pot

@@ -0,0 +1,7 @@
+#: nlshello:hello_world
+msgid "Hello world!"
+msgstr "Здравствуй мир!"
+
+#: nlshello:press_key
+msgid "Press any key to continue!"
+msgstr "Нажмите любую клавишу для продолжения!"

+ 567 - 0
packages/ncurses/examples/tpad.pp

@@ -0,0 +1,567 @@
+{
+   Author: Vitaliy Trifonov
+}
+program pad_demo;
+
+{$MODE OBJFPC}
+
+{$IFDEF DEBUG}
+{$ASSERTIONS ON}
+{$OVERFLOWCHECKS ON}
+{$RANGECHECKS ON}
+{$CHECKPOINTER ON}
+{$ENDIF}
+
+uses
+  ncurses, panel, sysutils;
+
+type
+  TNcCoord = array[0..1] of Smallint;
+
+  TNcStr = packed record
+    str: AnsiString;
+    attr: attr_t;
+    coord: TNcCoord;
+  end;
+
+const y = 0; x = 1;
+
+function CTRL( ch: chtype ): chtype; inline;
+begin
+  CTRL := ch AND $001F
+end;
+
+function randomchar: chtype;
+var
+  ch: Char = #0;
+begin
+  while not (ch in ['0'..'9','A'..'Z','a'..'z']) do
+    ch := Char(Random(123));
+  randomchar := chtype(ch);
+end;
+
+function randompair: longint;
+var
+  pair: longint = 0;
+begin
+  while not (pair in [1..5]) do
+    pair := Random(6);
+  randompair := pair;
+end;
+
+
+procedure draw;
+var
+  y, x:  Smallint;
+begin
+  for y := 0 to LINES - 1 do
+    for x := 0 to COLS - 1 do
+      mvaddch(y, x, randomchar OR COLOR_PAIR(randompair));
+end;
+
+procedure draw_pad(win: PWINDOW);
+
+var
+  y, x, my, mx:  Smallint;
+begin
+  getmaxyx(win,my,mx);
+  wborder(win, ACS_CKBOARD,ACS_CKBOARD,ACS_CKBOARD,ACS_CKBOARD,
+          ACS_CKBOARD,ACS_CKBOARD,ACS_CKBOARD,ACS_CKBOARD);
+  for y := 1 to my - 2 do
+    if (y mod 5) = 1 then
+      for x := 1 to mx - 2 do
+        if (x mod 10) = 1 then
+          mvwaddch(win, y, x, randomchar OR COLOR_PAIR(randompair))
+        else
+          mvwaddch(win, y, x, ACS_HLINE)
+    else
+      for x := 1 to mx - 2 do
+        if (x mod 10) = 1 then
+          mvwaddch(win, y, x, ACS_VLINE)
+        else
+          mvwaddch(win, y, x, chtype(' '))
+end;
+
+
+function st_middle(scrlen, itemlen: Smallint): Smallint; inline;
+begin
+  st_middle := (scrlen - itemlen) div 2;
+end;
+
+procedure print_in_middle(win: PWINDOW; var nstr: TNcStr; width: Longint);
+var
+  my, mx: Smallint;
+begin
+  getmaxyx(win, my, mx);
+  mx -= nstr.coord[1];
+
+  if (width > length(nstr.str)) OR  (width < 1) then
+    width := length(nstr.str);
+
+  if width > mx then
+    width := mx;
+
+  nstr.coord[x] += st_middle(mx,width);
+
+  wattron(win,nstr.attr);
+  mvwaddnstr(win,nstr.coord[y],nstr.coord[x],PChar(nstr.str),width);
+  wattroff(win,nstr.attr);
+end;
+
+type
+  TBarData = packed record
+    beg, len, slen: Smallint;
+  end;
+
+  TPad = class
+  private
+    wyx, pyx, ppos, grid: TNcCoord;
+    hbar, vbar: TBarData;
+    padwin, projwin: PWINDOW;
+    panel: PPANEL;
+    header: TNcStr;
+    changed: Boolean;
+    procedure init_bars;
+    procedure draw_hbar;
+    procedure draw_vbar;
+  public
+    function scroll_right: Boolean;
+    function scroll_left: Boolean;
+    function scroll_down: Boolean;
+    function scroll_up: Boolean;
+    function  doevent: chtype;
+    procedure dorefresh;
+    function  move(const ncoord: array of Smallint): Boolean; inline;
+    function  hide: Boolean; inline;
+    function  show: Boolean; inline;
+    procedure resize;
+    function  resize(const nsize: array of Smallint): Boolean;
+    constructor create(const parm: array of TNcCoord; const hdr: TNcStr);
+    destructor destroy; override;
+    property win: PWINDOW read padwin;
+    property ysize: Smallint read wyx[y];
+    property xsize: Smallint read wyx[x];
+  end;
+
+
+procedure TPad.init_bars;
+
+function get_scrl_len(blen, wsz, psz: Smallint): Smallint; inline;
+begin
+  get_scrl_len := (blen * wsz) div psz;
+end;
+
+begin
+  hbar.beg  := 4;
+  hbar.len  := wyx[x] - hbar.beg * 2;
+  hbar.slen := get_scrl_len(hbar.len, wyx[x], pyx[x]);
+
+  vbar.beg  := 2;
+  vbar.len  := wyx[y] - vbar.beg * 2;
+  vbar.slen := get_scrl_len(vbar.len, wyx[y], pyx[y]);
+end;
+
+function get_scrl_beg(ind, slen, blen, wsz, psz, bbeg: Smallint): Smallint;
+begin
+  if psz <> wsz then
+    get_scrl_beg := (ind * (blen - slen)) div (psz - wsz) + bbeg
+  else
+    get_scrl_beg := bbeg;
+end;
+
+procedure TPad.draw_hbar;
+var
+  i, sbeg: Smallint;
+begin
+  with hbar do
+  begin
+    sbeg := get_scrl_beg(ppos[x],hbar.slen,hbar.len,wyx[x], pyx[x],hbar.beg);
+    wattron(projwin,header.attr);
+    for i :=  beg to beg + len - 1 do
+    if (i < sbeg) OR (i > sbeg + slen) then
+      mvwaddch(projwin,wyx[y]-1,i  ,ACS_CKBOARD)
+    else
+      mvwaddch(projwin,wyx[y]-1,i,ACS_BLOCK);
+    wattroff(projwin,header.attr);
+  end
+end;
+
+procedure TPad.draw_vbar;
+var
+  i, sbeg: Smallint;
+begin
+  with vbar do
+  begin
+    sbeg := get_scrl_beg(ppos[y],vbar.slen,vbar.len,wyx[y], pyx[y],vbar.beg);
+    wattron(projwin,header.attr);
+    for i :=  beg to beg + len - 1 do
+    if (i < sbeg) OR (i > sbeg + slen) then
+      mvwaddch(projwin,i,wyx[x]-1,ACS_CKBOARD)
+    else
+      mvwaddch(projwin,i,wyx[x]-1,ACS_BLOCK);
+    wattroff(projwin,header.attr);
+  end
+end;
+
+function TPad.scroll_right: Boolean;
+begin
+  if ppos[x] > 0 then
+  begin
+    if (ppos[x] < grid[x]) then
+      ppos[x] := 0
+    else
+      ppos[x] -= grid[x];
+    draw_hbar;
+    changed := true;
+    scroll_right := true
+  end
+  else
+    scroll_right := false
+end;
+
+function TPad.scroll_left: Boolean;
+var
+  dwidth: Longint;
+begin
+  dwidth := pyx[x] - wyx[x] + 2;
+  if ppos[x] < dwidth then
+  begin
+    if ppos[x] > (dwidth - grid[x]) then
+      ppos[x] := dwidth
+    else
+      ppos[x] += grid[x];
+    draw_hbar;
+    changed := true;
+    scroll_left := true
+  end
+  else
+    scroll_left := false
+end;
+
+function TPad.scroll_down: Boolean;
+begin
+  if ppos[y] > 0 then
+  begin
+    if ppos[y] < grid[y] then
+      ppos[y] := 0
+    else
+      ppos[y] -= grid[y];
+    draw_vbar;
+    changed := true;
+    scroll_down := true
+  end
+  else
+    scroll_down := false
+end;
+
+function TPad.scroll_up: Boolean;
+var
+  dheight: Longint;
+begin
+  dheight := pyx[y] - wyx[y] + 2;
+  if ppos[y] < dheight then
+  begin
+    if ppos[y] > (dheight - grid[x]) then
+      ppos[y] := dheight
+    else
+      ppos[y] += grid[x];
+    draw_vbar;
+    changed := true;
+    scroll_up := true
+  end
+  else
+    scroll_up := false
+end;
+
+function  TPad.doevent: chtype;
+var
+  ch: chtype;
+  rval: Boolean = true;
+begin
+  ch := wgetch(projwin);
+  case ch of
+    KEY_DOWN:  rval := scroll_up;
+    KEY_UP:    rval := scroll_down;
+    KEY_LEFT:  rval := scroll_right;
+    KEY_RIGHT: rval := scroll_left;
+  end;
+  if not rval then
+  begin
+    ncurses.beep();
+    flash();
+  end;
+  doevent := ch
+end;
+
+procedure TPad.dorefresh;
+var
+  rval: Longint = OK;
+begin
+  if changed then
+  begin
+    rval := copywin(padwin,projwin,ppos[y],ppos[x],1,1,wyx[y]-2,wyx[x]-2, 0);
+    assert(rval=OK,'copywin error');
+    if rval = OK then
+      changed := false;
+  end
+end;
+
+function TPad.move(const ncoord: array of Smallint): Boolean;
+begin
+  move :=  move_panel(panel, ncoord[y], ncoord[x]) = OK
+end;
+
+function TPad.hide: Boolean;
+begin
+  hide := hide_panel(panel) = OK
+end;
+
+function TPad.show: Boolean;
+begin
+  show := show_panel(panel) = OK
+end;
+
+procedure TPad.resize;
+var
+  nsize: TNcCoord;
+  doresize: Boolean = false;
+begin
+  getbegyx(projwin,nsize[y],nsize[x]);
+
+  nsize[y] += wyx[y];
+  nsize[x] += wyx[x];
+
+  if nsize[y] > LINES then
+  begin
+    nsize[y] := LINES; doresize := true
+  end
+  else
+    nsize[y] := wyx[y];
+
+  if nsize[x] > COLS then
+  begin
+    nsize[x] := COLS; doresize := true
+  end
+  else
+    nsize[x] := wyx[x];
+
+  if doresize then
+    resize(nsize)
+end;
+
+function TPad.resize(const nsize: array of Smallint): Boolean;
+var
+  by, bx: Smallint;
+  domove: Boolean = false;
+  tcoord: TNcCoord;
+begin
+
+  if (nsize[y] <= LINES)AND(nsize[x] <= COLS) then
+  begin
+    if nsize[y] > pyx[y] + 2 then
+      tcoord[y] := pyx[y] + 2
+    else
+      tcoord[y] := nsize[y];
+
+    if nsize[x] > pyx[x] + 2 then
+      tcoord[x] := pyx[x] + 2
+    else
+      tcoord[x] := nsize[x];
+
+
+    getbegyx(projwin, by, bx);
+
+    if tcoord[y] + by >= LINES then
+    begin
+      by := LINES - tcoord[y]; domove := true
+    end;
+
+    if tcoord[x] + bx >= COLS then
+    begin
+      bx := COLS - tcoord[x]; domove := true
+    end;
+
+    if tcoord[x] > (pyx[x] - ppos[x]) then
+      scroll_right;
+    if tcoord[y] > (pyx[y] - ppos[y]) then
+      scroll_down;
+
+    hide_panel(panel);
+    wresize(projwin, tcoord[y], tcoord[x]);
+
+    if domove then
+      move_panel(panel, by, bx);
+    show_panel(panel);
+
+    box(projwin, ACS_VLINE, ACS_HLINE);
+
+    getmaxyx(projwin,wyx[y],wyx[x]);
+    header.coord[y] := 0; header.coord[x] := 0;
+
+    print_in_middle(projwin, header, 0);
+    init_bars;
+    draw_hbar;
+    draw_vbar;
+
+    changed := true;
+    resize := true
+  end
+  else
+    resize := false
+end;
+
+constructor TPad.create(const parm: array of TNcCoord; const hdr: TNcStr);
+{$IFDEF DEBUG}
+var
+  tysz, txsz: Smallint;
+{$ENDIF}
+begin
+  if parm[0,y] >= parm[1,y] + 2 then
+    wyx[y] := parm[1,y] + 2
+  else
+    wyx[y] := parm[0,y];
+
+  if parm[0,x] >= parm[1,x] + 2  then
+    wyx[x] := parm[1,x] + 2
+  else
+    wyx[x] := parm[0,x];
+
+  projwin := newwin(wyx[y], wyx[x], (LINES - wyx[y]) div 2, (COLS - wyx[x]) div 2);
+  intrflush(projwin, FALSE);
+  keypad(projwin, TRUE);
+  box(projwin, ACS_VLINE, ACS_HLINE);
+
+  panel := new_panel(projwin);
+  padwin := newpad(parm[1,y], parm[1,x]);
+
+  header := hdr;
+  pyx := parm[1];
+  grid := parm[2];
+
+{$IFDEF DEBUG}
+  getmaxyx(projwin,tysz, txsz);
+  assert((wyx[y]=tysz)AND(wyx[x]=txsz), 'Invalid window');
+
+  getmaxyx(padwin,tysz, txsz);
+  assert((pyx[y]=tysz)AND(pyx[x]=txsz), 'Invalid pad');
+{$ENDIF}
+  FmtStr(header.str, '%s, pad: h=%d w=%d, win: h=%d w=%d', [hdr.str,pyx[y],pyx[x],wyx[y],wyx[x]]);
+
+
+  print_in_middle(projwin, header, 0);
+
+  init_bars;
+  draw_hbar;
+  draw_vbar;
+
+  changed := true;
+end;
+
+destructor TPad.destroy;
+begin
+  del_panel(panel);
+  delwin(padwin);
+  delwin(projwin);
+end;
+
+procedure init_stdscr;
+begin
+  draw;
+  attron(COLOR_PAIR(7));
+  mvaddstr(LINES - 3, 0,'press "+" "-" to resize              ');
+  mvaddstr(LINES - 2, 0,'press UP, DOWN, LEFT, RIGHT to scroll');
+  mvaddstr(LINES - 1, 0,'press F10 or q to exit               ');
+  attroff(COLOR_PAIR(7));
+end;
+
+
+
+var
+  ch: chtype;
+  ncpad: TPad;
+  my_bg: Smallint = COLOR_BLACK;
+  wnd, pad, grid: TNcCoord;
+  code: Word;
+  header: TNcStr = (str:'Pad demo';attr:A_NORMAL;coord:(0,0));
+begin
+  try
+    initscr();
+    noecho();
+    clear();
+    cbreak();
+    curs_set(0);
+    keypad(stdscr, TRUE);
+    meta(stdscr, TRUE);
+    mousemask(1, nil);
+
+   if has_colors() then
+   begin
+     start_color();
+     if (use_default_colors() = OK) then
+       my_bg := -1
+     else
+       my_bg := COLOR_BLACK;
+
+     init_pair(1, COLOR_YELLOW, my_bg);
+     init_pair(2, COLOR_MAGENTA, my_bg);
+     init_pair(3, COLOR_WHITE, my_bg);
+     init_pair(4, COLOR_CYAN, my_bg);
+     init_pair(5, COLOR_GREEN, my_bg);
+     init_pair(6, COLOR_WHITE, COLOR_BLUE);
+     init_pair(7, COLOR_BLACK, COLOR_YELLOW);
+   end;
+
+    init_stdscr;
+    //refresh();
+
+    wnd[y]  := LINES - 6;
+    wnd[x]  := COLS - 12;
+    pad[y]  := wnd[y] + 6;
+    pad[x]  := wnd[x] + 6;
+    grid[y] := 3;
+    grid[x] := 3;
+
+
+    if paramcount > 1 then
+    begin
+      val(ParamStr(1),pad[y],code);
+      val(ParamStr(2),pad[x],code);
+    end;
+
+    if paramcount > 3 then
+    begin
+      val(ParamStr(3),wnd[y],code);
+      val(ParamStr(4),wnd[x],code);
+    end;
+
+    header.attr := COLOR_PAIR(6);
+    ncpad := TPad.create([wnd,pad,grid],header);
+    draw_pad(ncpad.win);
+    ncpad.dorefresh;
+    update_panels();
+    doupdate();
+
+    repeat
+      ch := ncpad.doevent;
+      case ch of
+        chtype('+'): ncpad.resize([ncpad.ysize + 1,ncpad.xsize + 1]);
+        chtype('='): ncpad.resize([ncpad.ysize + 1,ncpad.xsize + 1]);
+        chtype('-'): ncpad.resize([ncpad.ysize - 1,ncpad.xsize - 1]);
+        chtype(' '): ncpad.resize([wnd[y],wnd[x]]);
+        KEY_RESIZE:
+        begin
+          flash();
+          init_stdscr;
+          ncpad.resize;
+        end;
+      end;
+      ncpad.dorefresh;
+      update_panels();
+      doupdate();
+    until (ch = chtype('q')) OR (ch = KEY_F(10));
+  finally
+    ncpad.destroy;
+    curs_set(1);
+    endwin();
+  end;
+end.

+ 82 - 0
packages/ncurses/examples/twindow.pp

@@ -0,0 +1,82 @@
+program test_window;
+{$mode objfpc}
+
+uses
+  ncurses, panel, sysutils;
+
+procedure printw(win: PWINDOW; y,x: Smallint; fmt: AnsiString; args: Array of const);
+var
+  tstr: AnsiString;
+begin
+  FmtStr(tstr, fmt, args);
+  mvwaddstr(win,y,x, PChar(tstr));
+end;
+
+procedure printinfo(win: PWINDOW);
+begin
+  with win^ do
+  begin
+    printw(win,1 ,1,'_cury=%-3d, _curx=%-3d : cursor position',[_cury,_curx]);
+    printw(win,2 ,1,'_maxy=%-3d, _maxx=%-3d : maximums of x and y, NOT window size',[_maxy,_maxx]);
+    printw(win,3 ,1,'_begy=%-3d, _begx=%-3d : screen coords of upper-left-hand corner',[_begy,_begx]);
+    printw(win,4 ,1,'_flags=%-3d           : window state flags',[_flags]);
+    printw(win,5 ,1,'_attrs=%-4d          : current attribute for non-space character',[_attrs]);
+    printw(win,6 ,1,'_bkgd=%-3d            : current background char/attribute pair',[_bkgd]);
+    printw(win,7 ,1,'_notimeout=%-1d         :  no time out on function-key entry?', [Byte(_notimeout)]);
+    printw(win,8 ,1,'_clear=%-1d             : consider all data in the window invalid?',[Byte(_clear)]);
+    printw(win,9 ,1,'_leaveok=%-1d           : OK to not reset cursor on exit?',[Byte(_leaveok)]);
+    printw(win,10,1,'_scroll=%-1d            : OK to scroll this window?',[Byte(_scroll)]);
+    printw(win,11,1,'_idlok=%-1d             : OK to use insert/delete line?',[Byte(_idlok)]);
+    printw(win,12,1,'_idcok=%-1d             : OK to use insert/delete char?',[Byte(_idcok)]);
+    printw(win,13,1,'_immed=%-1d             : window in immed mode? (not yet used)',[Byte(_immed)]);
+    printw(win,14,1,'_sync=%-1d              : window in sync mode?',[Byte(_sync)]);
+    printw(win,15,1,'_use_keypad=%-1d        : process function keys into KEY_ symbols?',[Byte(_use_keypad)]);
+    printw(win,16,1,'_delay=%-3d           : 0 = nodelay, <0 = blocking, >0 = delay',[_delay]);
+    printw(win,17,1,'_parx=%-3d            : x coordinate of this window in parent',[_parx]);
+    printw(win,18,1,'_pary=%-3d            : y coordinate of this window in parent',[_pary]);
+    printw(win,19,1,'_yoffset=%-3d         : real begy is _begy + _yoffset',[_yoffset]);
+    printw(win,20,1,'_bkgrnd.attr=%-4d    : current background char/attribute pair',[_bkgrnd.attr]);
+  end;
+end;
+
+var
+  win : pWINDOW;
+  cy, cx, by, bx, my, mx: Longint;
+begin
+
+  try
+    initscr();
+    start_color;
+    noecho;
+    init_pair(1,COLOR_WHITE,COLOR_BLUE);
+    init_pair(2,COLOR_RED,COLOR_BLUE);
+
+    win:= newwin( LINES - 2, COLS - 6, 1, 3);
+
+    wbkgd(win, COLOR_PAIR(1));
+    erase;
+    refresh;
+
+    box(win, ACS_VLINE, ACS_HLINE);
+
+    wmove(win,12,24);
+    printinfo(win);
+
+    wrefresh(win);
+    getch;
+
+    getyx(win,cy,cx);
+    getbegyx(win,by,bx);
+    getmaxyx(win,my,mx);
+    delwin(win);
+    clear();
+
+    printw(stdscr,1 ,1,'getyx(win,%d,%d)',[cy,cx]);
+    printw(stdscr,2 ,1,'getbegyx(win,%d,%d);',[by,bx]);
+    printw(stdscr,3 ,1,'getmaxyx(win,%d,%d);',[my,mx]);
+    getch;
+
+  finally
+    endwin();
+  end;
+end.

+ 0 - 46
packages/ncurses/src/form.pp

@@ -12,16 +12,12 @@ const
 {$PACKRECORDS C}
 {$INCLUDE eti.inc}
 
-
 type
-   //Pva_list = ^va_list;
-   //va_list = char;
   Pva_list  = Pointer;
   FIELD_CELL = Pointer;
   Form_Options = Longint;
   Field_Options = Longint;
 
-
 (* _PAGE  *)
 
   _PAGE = record
@@ -31,8 +27,6 @@ type
     smax : Smallint;  { index of bottom rightmost field on page  }
   end;
 
-
-
 (*  FIELD  *)
 
   PPFIELD = ^PFIELD;
@@ -77,8 +71,6 @@ type
   opaque for that reason.
 }
 
-
-
 (*  FIELDTYPE  *)
 
   TFieldCheck = function (_para1:PFIELD; _para2:Pointer):Bool; cdecl;
@@ -92,23 +84,14 @@ type
     ref : clong;                                        { reference count  }
     left : PFIELDTYPE;                                  { ptr to operand for |  }
     right : PFIELDTYPE;                                 { ptr to operand for |  }
-    //makearg : function (_para1:Pva_list):Pointer;cdecl;
     makearg : TMakearg;                                 { make fieldtype arg  }
-    //copyarg : function (_para1:Pointer):Pointer;
     copyarg : TCopy_arg;                                { copy fieldtype arg   }
-    //freearg : procedure (_para1:Pointer);
     freearg : TFree_arg;                                { field validation  }
-    //fcheck : function (_para1:PFIELD; _para2:Pointer):bool;
     fcheck : TFieldCheck;                               { free fieldtype arg  }
-    //ccheck : function (_para1:Longint; _para2:Pointer):bool;
     ccheck : TCharCheck;                                { character validation  }
-    //next : function (_para1:PFIELD; _para2:Pointer):bool;
     next : TFieldCheck;                                 { enumerate next value  }
-    //prev : function (_para1:PFIELD;  _para2:Pointer):bool;
     prev : TFieldCheck;                                 { enumerate prev value  }
   end;
-  //typenode = FIELDTYPE;
-
 
 (* FORM  *)
 
@@ -132,18 +115,11 @@ type
     current : PFIELD;       { current field     }
     page : ^_PAGE;          { page [maxpage]     }
     usrptr : Pointer;       { user pointer      }
-    //forminit : procedure (_para1:PFORM); cdecl;
     forminit : Form_Hook;
-    //formterm : procedure (_para1:PFORM); cdecl;
     formterm : Form_Hook;
-    //fieldinit : procedure (_para1:PFORM); cdecl;
     fieldinit : Form_Hook;
-    //fieldterm : procedure (_para1:PFORM); cdecl;
     fieldterm : Form_Hook;
   end;
-  //formnode = TFORM;
-
-
 
 (* field justification *)
 const
@@ -152,7 +128,6 @@ const
   JUSTIFY_CENTER = 2;
   JUSTIFY_RIGHT = 3;
 
-
 (* field options *)
   O_VISIBLE = $0001;
   O_ACTIVE = $0002;
@@ -167,7 +142,6 @@ const
   O_NL_OVERLOAD = $0001;
   O_BS_OVERLOAD = $0002;
 
-
 (* form driver commands *)
    REQ_NEXT_PAGE = KEY_MAX + 1;     { move to next page    }
    REQ_PREV_PAGE = KEY_MAX + 2;     { move to previous page  }
@@ -229,7 +203,6 @@ const
    MIN_FORM_COMMAND = KEY_MAX + 1;  { used by form_driver     }
    MAX_FORM_COMMAND = KEY_MAX + 57; { used by form_driver    }
 
-
 (* standard field types *)
 
 var
@@ -269,12 +242,6 @@ var
 {$endif darwin}
 
 (* FIELDTYPE routines *)
-(* Const before declarator ignored *)
-(* Const before type ignored *)
-{
-function new_fieldtype(field_check:function (_para1:PFIELD;_para2:Pointer):bool; char_check:function (_para1:Longint;_para2:Pointer):bool):PFIELDTYPE;cdecl;external;
-}
-
 function new_fieldtype(field_check: TFieldCheck; char_check:TCharCheck):PFIELDTYPE; cdecl;external libform;
 
 function link_fieldtype(_para1:PFIELDTYPE; _para2:PFIELDTYPE):PFIELDTYPE; cdecl;external libform;
@@ -290,22 +257,9 @@ function set_fieldtype_arg(_para1:PFIELDTYPE; make_arg:function (_para1:Pva_list
 }
 function set_fieldtype_arg(fieldtype: PFIELDTYPE; make_arg: TMakearg; copy_arg: TCopy_arg; free_arg: TFree_arg): Longint;cdecl;external libform;
 
-{
-extern int set_fieldtype_choice (FIELDTYPE *,
-      bool (* const next_choice)(FIELD *,const void *),
-            bool (* const prev_choice)(FIELD *,const void *));
-
-(* Const before declarator ignored *)
-(* Const before type ignored *)
-(* Const before declarator ignored *)
-(* Const before type ignored *)
-function set_fieldtype_choice(_para1:PFIELDTYPE; next_choice:function (_para1:PFIELD; _para2:Pointer):bool; prev_choice:function (_para1:PFIELD; _para2:Pointer):bool):Longint;cdecl;external;
-}
-
 function set_fieldtype_choice(_para1:PFIELDTYPE; next_choice:TFieldCheck; prev_choice:TFieldCheck):Longint; cdecl;external libform;
 
 (* FIELD routines *)
-
 function new_field(_pa1,_pa2,_pa3,_pa4,_pa5,_pa6:Longint):PFIELD; cdecl;external libform;
 function dup_field(_para1:PFIELD; _para2:Longint; _para3:Longint):PFIELD; cdecl;external libform;
 function link_field(_para1:PFIELD; _para2:Longint; _para3:Longint):PFIELD; cdecl;external libform;

+ 101 - 85
packages/ncurses/src/ncurses.pp

@@ -4,10 +4,9 @@
 unit ncurses;
 interface
 
-
 {$PACKRECORDS C}
 {$LINKLIB ncursesw}
-{$LINKLIB c}
+{$LINKLIB c} // should be uses initc ?
 
 {$DEFINE USE_FPC_BYTEBOOL}
 
@@ -22,9 +21,7 @@ type
    Bool = Byte;
 {$ENDIF USE_FPC_BYTEBOOL}
 
-
 type
-   //cint = Longint;
    wchar_t = Widechar;
    pwchar_t = ^wchar_t;
 
@@ -44,18 +41,13 @@ const
    NCURSES_VERSION = '5.6';
    NCURSES_MOUSE_VERSION = 1;
 
-
 type
    pchtype = ^chtype;
-   //chtype  = Longword;
-   chtype  = Longint;
+   chtype  = Longint; {longword}
    pmmask_t = ^mmask_t;
-   //mmask_t  = Longword;
-   mmask_t  = Longint;
-
+   mmask_t  = Longint; {longword}
 
 { colors  }
-
 var
 {$IFNDEF darwin}
    COLORS : Longint cvar; external;
@@ -65,7 +57,6 @@ var
    COLOR_PAIRS : Longint external libncurses name 'COLOR_PAIRS';
 {$ENDIF darwin}
 
-
 const
    COLOR_BLACK = 0;
    COLOR_RED = 1;
@@ -76,7 +67,6 @@ const
    COLOR_CYAN = 6;
    COLOR_WHITE = 7;
 
-
 type
    pNC_FPC_COLOR = ^NC_FPC_COLOR;
    NC_FPC_COLOR = Smallint;
@@ -93,7 +83,6 @@ var
    acs_map : tacs_map external libncurses name 'acs_map';
 {$ENDIF darwin}
 
-
 //function NCURSES_ACS(c : Longint) : Longint;
 (* VT100 symbols begin here  *)
 function ACS_ULCORNER : chtype; inline; { upper left corner }
@@ -159,7 +148,7 @@ property ACS_SSSS : chtype read ACS_PLUS;
 const
    ERR = -(1);
    OK = 0;
-   _SUBWIN     = $01; { is this a sub-window? }
+   _SUBWIN    = $01; { is this a sub-window? }
    _ENDLINE   = $02;  { is the window flush right? }
    _FULLWIN   = $04;  { is the window full-screen? }
    _SCROLLWIN = $08;  { bottom edge is at screen bottom? }
@@ -265,7 +254,6 @@ type
        ESCDELAY: Longint external libncurses name 'ESCDELAY';
 {$ENDIF darwin}
 
-
 (*
  * These functions are extensions - not in XSI Curses.
  *)
@@ -365,7 +353,11 @@ function raw:Longint; cdecl;external libncurses;
 function resetty:Longint; cdecl;external libncurses;
 function reset_prog_mode:Longint; cdecl;external libncurses;
 function reset_shell_mode:Longint; cdecl;external libncurses;
-{function ripoffline(_para1:Longint; _para2:function (_para1:PWINDOW; _para2:Longint):Longint):Longint; cdecl;external libncurses;}//   ->???
+
+type TWinInit = function (win: PWINDOW; ncols: Longint): Longint; cdecl;
+
+function ripoffline(line: Longint; init: TWinInit):Longint; cdecl;external libncurses;
+
 function savetty:Longint; cdecl;external libncurses;
 function scr_dump(_para1:PChar):Longint; cdecl;external libncurses;
 function scr_init(_para1:PChar):Longint; cdecl;external libncurses;
@@ -439,7 +431,6 @@ procedure wtimeout(_para1:PWINDOW; _para2:Longint);cdecl;external libncurses;
 function wtouchln(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint):Longint; cdecl;external libncurses;
 function wvline(_para1:PWINDOW; _para2:chtype; _para3:Longint):Longint; cdecl;external libncurses;
 
-
 (*
  * These are also declared in <ncursesw/term.h>:
  *)
@@ -449,7 +440,6 @@ function tigetnum(_para1:PChar):Longint; cdecl;external libncurses;
 function tigetstr(_para1:PChar):PChar;cdecl;external libncurses;
 function putp(_para1:PChar):Longint; cdecl;external libncurses;
 
-
 var
 {$IFNDEF darwin}
    ttytype : array of PChar cvar; external;  { needed for backward compatibility  }
@@ -457,8 +447,6 @@ var
    ttytype : array of PChar external libncurses  name 'ttytype';
 {$ENDIF darwin}
 
-
-
 (*
  * Function prototypes for wide-character operations.
  *)
@@ -499,8 +487,6 @@ function winwstr(_para1:PWINDOW; _para2:Pwchar_t):longint; cdecl;external libncu
 function wunctrl(_para1:Pcchar_t):Pwchar_t;cdecl;external libncurses;
 function wvline_set(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
 
-
-
 const
    A_NORMAL = 0;
    A_ATTRIBUTES = (not 0) shl 8;
@@ -541,16 +527,10 @@ const
    WA_TOP = A_TOP;
    WA_VERTICAL = A_VERTICAL;
 
-
-
-
-
 function COLOR_PAIR(n: longint): longint; inline;
 function PAIR_NUMBER(attr: attr_t): longint; inline;
 function color_set(color_pair_number: Smallint; opts: Pointer): longint; inline;
 
-
-
 (*  pseudo functions  *)
 
 function wgetstr(win: PWINDOW; s: PChar): Longint;
@@ -561,11 +541,20 @@ function resetterm: Longint; inline;
 function saveterm: Longint; inline;
 function crmode: Longint; inline;
 function nocrmode: Longint; inline;
-procedure getyx   (win: PWINDOW; var y,x); inline;
-procedure getbegyx(win: PWINDOW; var y,x); inline;
-procedure getmaxyx(win: PWINDOW; var y,x); inline;
-procedure getparyx(win: PWINDOW; var y,x); inline;
-procedure getsyx  (var y,x); inline;
+
+// formal parameter versions not endiansafe?
+procedure getyx   (win: PWINDOW; var y,x: Smallint); inline; overload;
+procedure getbegyx(win: PWINDOW; var y,x: Smallint); inline; overload;
+procedure getmaxyx(win: PWINDOW; var y,x: Smallint); inline; overload;
+procedure getparyx(win: PWINDOW; var y,x: Smallint); inline; overload;
+procedure getsyx  (var y,x: Smallint); inline; overload;
+
+procedure getyx   (win: PWINDOW; var y,x: Longint); inline; overload;
+procedure getbegyx(win: PWINDOW; var y,x: Longint); inline; overload;
+procedure getmaxyx(win: PWINDOW; var y,x: Longint); inline; overload;
+procedure getparyx(win: PWINDOW; var y,x: Longint); inline; overload;
+procedure getsyx  (var y,x: Longint); inline; overload;
+
 procedure setsyx  (y,x: Smallint); inline;
 function getattrs(win: PWINDOW): attr_t; inline;
 function getcurx(win: PWINDOW): Smallint; inline;
@@ -741,7 +730,6 @@ const
    KEY_F11 = KEY_F0 + 11;
    KEY_F12 = KEY_F0 + 12;
 
-
 function KEY_F(n : Byte) : chtype; inline;
 
 const
@@ -829,7 +817,6 @@ const
    KEY_EVENT = 411;     { We were interrupted by an event    &0633 }
    KEY_MAX = 511;       { Maximum key value is 0633    &0777 }
 
-
 type
    //tnc_wacs= array [char] of cchar_t;
    tnc_wacs= array of cchar_t;
@@ -893,12 +880,8 @@ property WACS_VLINE : cchar_t read WACS_SBSB;
 property WACS_PLUS : cchar_t read WACS_SSSS;
 {$ENDIF FPC_OBJFPC}
 
-
 (* mouse interface *)
 
-
-
-
 (*  event masks  *)
 
 const
@@ -938,8 +921,6 @@ const
 
    ALL_MOUSE_EVENTS       = REPORT_MOUSE_POSITION - 1;
 
-
-
 (* macros to extract single event-bits from masks *)
 
 function BUTTON_RELEASE(e,x: longint): longint; inline;
@@ -950,8 +931,6 @@ function BUTTON_TRIPLE_CLICK(e,x: longint): longint; inline;
 function BUTTON_RESERVED_EVENT(e,x: longint): longint; inline;
 function mouse_trafo(pY,pX: PLongint; to_screen: Bool): Bool; inline;
 
-
-
 type
    PMEVENT = ^MEVENT;
    MEVENT = record
@@ -960,7 +939,6 @@ type
    bstate : mmask_t;     { button state bits }
 end;
 
-
 function getmouse(_para1:PMEVENT):longint; cdecl;external libncurses;
 function ungetmouse(_para1:PMEVENT):longint; cdecl;external libncurses;
 function mousemask(_para1:mmask_t; _para2:Pmmask_t):mmask_t;cdecl;external;
@@ -968,8 +946,6 @@ function wenclose(_para1:PWINDOW; _para2:Longint; _para3:Longint):Bool;cdecl;ext
 function mouseinterval(_para1:Longint):longint; cdecl;external libncurses;
 function wmouse_trafo(_para1:PWINDOW; _para2:PLongint; _para3:PLongint; _para4:Bool):Bool;cdecl;external;
 
-
-
 {
  wide-character (enhanced) functionality
 }
@@ -1040,7 +1016,6 @@ function mvwins_wstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint; inl
 function mvwinwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint; inline;
 function mvwvline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint) : longint; inline;
 
-
 function wmove(win: PWINDOW; y,x: Smallint): Longint; inline;
 
 (* C varargs  procedures*)
@@ -1072,7 +1047,6 @@ function printw(_para1:PChar; args:array of const):Longint; cdecl;external libnc
 
 {$ENDIF}
 
-
 implementation
 
 function ACS_ULCORNER : chtype;
@@ -1235,8 +1209,6 @@ begin
   ACS_STERLING:=acs_map['}'];
 end;
 
-
-
 function COLOR_PAIR(n : longint): longint;
 begin
   COLOR_PAIR:=n shl 8;
@@ -1253,8 +1225,6 @@ begin
   color_set:=wcolor_set(stdscr,color_pair_number,opts);
 end;
 
-(*  pseudo functions  *)
-
 function wgetstr(win: PWINDOW; s: PChar): Longint;
 begin
   wgetstr := wgetnstr(win, s, -1);
@@ -1301,80 +1271,131 @@ begin
   nocrmode:=nocbreak;
 end;
 
-
-
-
-procedure getyx(win: PWINDOW; var y,x);
+procedure getyx(win: PWINDOW; var y,x: Smallint);
 begin
    if win<>nil then
    begin
-      Smallint(y) :=win^._cury; Smallint(x) :=win^._curx
+      y := win^._cury; x := win^._curx
    end
    else
    begin
-      Smallint(y) :=ERR; Smallint(x) :=ERR
+      y := ERR; x := ERR
    end
 end;
 
-procedure getbegyx(win: PWINDOW; var y,x);
+procedure getbegyx(win: PWINDOW; var y,x: Smallint);
 begin
    if win<>nil then
    begin
-      Smallint(y) :=win^._begy; Smallint(x) :=win^._begx
+      y := win^._begy; x := win^._begx
    end
    else
    begin
-      Smallint(y) :=ERR; Smallint(x) :=ERR
+      y := ERR; x := ERR
    end
 end;
 
-procedure getmaxyx(win: PWINDOW; var y,x);
+procedure getmaxyx(win: PWINDOW; var y,x: Smallint);
 begin
    if win<>nil then
    begin
-     Smallint(y) :=win^._maxy+1; Smallint(x) :=win^._maxx+1
+     y := win^._maxy+1; x := win^._maxx+1
    end
    else
    begin
-      Smallint(y) :=ERR; Smallint(x) :=ERR
+     y := ERR; x := ERR
    end
 end;
 
-procedure getparyx(win: PWINDOW; var y,x);
+procedure getparyx(win: PWINDOW; var y,x: Smallint);
 begin
-{#define getparyx(win,y,x) (y = getpary(win), x = getparx(win))}
   if win<>nil then
    begin
-     Smallint(y) :=win^._pary; Smallint(x) :=win^._parx
+     y := win^._pary; x :=win^._parx
+   end
+   else
+   begin
+     y := ERR; x := ERR
+   end
+end;
+
+procedure getsyx(var y,x: Smallint);
+begin
+{$IFNDEF USE_FPC_BYTEBOOL}
+   if newscr^._leaveok = NC_FPC_TRUE then
+{$ELSE USE_FPC_BYTEBOOL}
+   if newscr^._leaveok then
+{$ENDIF USE_FPC_BYTEBOOL}
+   begin
+     y := -1; x := -1
+   end
+   else
+   begin
+     y := newscr^._cury; x := newscr^._curx
+   end
+end;
+
+procedure getyx(win: PWINDOW; var y,x: Longint);
+begin
+   if win<>nil then
+   begin
+      y := win^._cury; x := win^._curx
    end
    else
    begin
-      Smallint(y) :=ERR; Smallint(x) :=ERR
+      y := ERR; x := ERR
    end
 end;
 
+procedure getbegyx(win: PWINDOW; var y,x: Longint);
+begin
+   if win<>nil then
+   begin
+      y := win^._begy; x := win^._begx
+   end
+   else
+   begin
+      y := ERR; x := ERR
+   end
+end;
 
+procedure getmaxyx(win: PWINDOW; var y,x: Longint);
+begin
+   if win<>nil then
+   begin
+     y := win^._maxy+1; x := win^._maxx+1
+   end
+   else
+   begin
+     y := ERR; x := ERR
+   end
+end;
 
+procedure getparyx(win: PWINDOW; var y,x: Longint);
+begin
+  if win<>nil then
+   begin
+     y := win^._pary; x :=win^._parx
+   end
+   else
+   begin
+     y := ERR; x := ERR
+   end
+end;
 
-procedure getsyx(var y,x);
+procedure getsyx(var y,x: Longint);
 begin
-(*
-C macros:
-#define getsyx(y,x) do { if(newscr->_leaveok) (y)=(x)=-1; \
-       else getyx(newscr,(y),(x)); \
-        } while(0)
-*)
 {$IFNDEF USE_FPC_BYTEBOOL}
    if newscr^._leaveok = NC_FPC_TRUE then
 {$ELSE USE_FPC_BYTEBOOL}
    if newscr^._leaveok then
 {$ENDIF USE_FPC_BYTEBOOL}
    begin
-      Smallint(y) := -1; Smallint(x) := -1
+     y := -1; x := -1
    end
    else
    begin
-      Smallint(y) := newscr^._cury; Smallint(x) := newscr^._curx
+     y := newscr^._cury; x := newscr^._curx
    end
 end;
 
@@ -1386,7 +1407,7 @@ C macros:
        else {newscr->_leaveok=FALSE;wmove(newscr,(y),(x));} \
         } while(0)
 *)
-   if (x OR y >=0)AND(x<=newscr^._maxx)AND(y<=newscr^._maxy) then
+   if (x>=0) and (y >=0) AND (x<=newscr^._maxx) AND (y<=newscr^._maxy) then
    begin
       newscr^._curx := x;
       newscr^._cury := y;
@@ -2780,15 +2801,10 @@ begin
 end;
 
 
-
-
-
-
-
 function wmove(win: PWINDOW; y,x: Smallint): Longint;
 begin
   //if (win!=nil)AND(x>=0)AND(x<=win^._maxx)AND(y>=0)AND(y<=win^._maxy) then
-  if (x OR y >=0)AND(x<=win^._maxx)AND(y<=win^._maxy) then
+  if (x>=0) and ( y>=0)AND(x<=win^._maxx)AND(y<=win^._maxy) then
   begin
     win^._curx := x;
     win^._cury := y;

+ 0 - 11
packages/ncurses/src/panel.pp

@@ -12,7 +12,6 @@ uses
 const
    libpanel = 'panelw';
 
-(* Const before type ignored *)
 type
    PPANEL  = ^TPANEL;
    TPANEL = record
@@ -22,8 +21,6 @@ type
         user : Pointer;
      end;
 
-(* Const before type ignored *)
-
 function panel_window(_para1:PPANEL):PWINDOW; cdecl;external libpanel;
 procedure update_panels; cdecl;external libpanel;
 function hide_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
@@ -32,21 +29,13 @@ function del_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
 function top_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
 function bottom_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
 function new_panel(_para1:PWINDOW):PPANEL; cdecl;external libpanel;
-(* Const before type ignored *)
 function panel_above(_para1:PPANEL):PPANEL; cdecl;external libpanel;
-(* Const before type ignored *)
 function panel_below(_para1:PPANEL):PPANEL; cdecl;external libpanel;
-(* Const before type ignored *)
 function set_panel_userptr(_para1:PPANEL; _para2:pointer):Longint; cdecl;external libpanel;
-(* Const before type ignored *)
-(* Const before type ignored *)
 function panel_userptr(_para1:PPANEL):pointer; cdecl;external libpanel;
 function move_panel(_para1:PPANEL; _para2:Longint; _para3:Longint):Longint; cdecl;external libpanel;
 function replace_panel(_para1:PPANEL; _para2:PWINDOW):Longint; cdecl;external libpanel;
-(* Const before type ignored *)
 function panel_hidden(_para1:PPANEL):Longint; cdecl;external libpanel;
 
 implementation
-
-
 end.

+ 297 - 46
packages/winunits-base/src/activex.pp

@@ -38,19 +38,21 @@ type
    FMTID  =  TGUID;
    pFMTID = pGUID;
 
-{Glue types, should be linked to the proper windows unit types}
-     Size_t              = DWord;       {??, probably, like Unix, typecastable to pointer?!?}
-     OleChar             = WChar;
-     LPOLESTR            = ^OLECHAR;
-     PLPOLESTR		 = ^LPOLESTR;
-     PROPID = ULONG;
-     TPROPID= PROPID;
-     PPROPID= ^PROPID;
-     VARIANT_BOOL        = wordbool;
-     _VARIANT_BOOL       = VARIANT_BOOL;
-     CY			 = CURRENCY;
-     DATE		 = DOUBLE;
-     BSTR		 = POLESTR;
+   { Glue types, should be linked to the proper windows unit types}
+   Size_t              = DWord;       {??, probably, like Unix, typecastable to pointer?!?}
+   OleChar             = WChar;
+   LPOLESTR            = ^OLECHAR;
+   POLECHAR            = LPOLESTR;
+   PLPOLESTR	       = ^LPOLESTR;
+   PROPID = ULONG;
+   TPROPID= PROPID;
+   PPROPID= ^PROPID;
+   VARIANT_BOOL        = wordbool;
+   _VARIANT_BOOL       = VARIANT_BOOL;
+   PVARIANT_BOOL       = ^VARIANT_BOOL;
+   CY		       = CURRENCY;
+   DATE	               = DOUBLE;
+   BSTR	               = POLESTR;
 
 CONST
    GUID_NULL  : TGUID =  '{00000000-0000-0000-0000-000000000000}';
@@ -753,7 +755,7 @@ Const
     PIDSI_THUMBNAIL        = DWORD($00000011); // VT_CF
     PIDSI_APPNAME          = DWORD($00000012); // VT_LPSTR
     PIDSI_DOC_SECURITY     = DWORD($00000013); // VT_I4
-    PIDDSI_CATEGORY        = $00000002; // VT_LPSTR 
+    PIDDSI_CATEGORY        = $00000002; // VT_LPSTR
     PIDDSI_PRESFORMAT      = $00000003; // VT_LPSTR
     PIDDSI_BYTECOUNT       = $00000004; // VT_I4
     PIDDSI_LINECOUNT       = $00000005; // VT_I4
@@ -762,7 +764,7 @@ Const
     PIDDSI_NOTECOUNT       = $00000008; // VT_I4
     PIDDSI_HIDDENCOUNT     = $00000009; // VT_I4
     PIDDSI_MMCLIPCOUNT     = $0000000A; // VT_I4
-    PIDDSI_SCALE           = $0000000B; // VT_BOOL 
+    PIDDSI_SCALE           = $0000000B; // VT_BOOL
     PIDDSI_HEADINGPAIR     = $0000000C; // VT_VARIANT |VT_VECTOR
     PIDDSI_DOCPARTS        = $0000000D; // VT_LPSTR |VT_VECTOR
     PIDDSI_MANAGER         = $0000000E; // VT_LPSTR
@@ -1625,13 +1627,13 @@ TYPE
                   ulKind : ULONG ;
                   case boolean of
                     false : ( propid:propid);
-                    true  :  (lpwstr: LPOLEStr);	   
-                    end; 
-         
+                    true  :  (lpwstr: LPOLEStr);	
+                    end;
+
   PROPSPEC= tagPROPSPEC;
   TPROPSPEC = PROPSPEC;
   PPROPSPEC = ^TPROPSPEC;
-              
+
   tagSTATPROPSTG = record
                     lpwstrName : LPOLESTR ;
                     propid:PROPID ;
@@ -1653,7 +1655,7 @@ TYPE
   STATPROPSETSTG = tagSTATPROPSETSTG;
   TSTATPROPSETSTG = STATPROPSETSTG;
   PSTATPROPSETSTG = ^STATPROPSETSTG;
-      
+
    tagVersionedStream = record
         guidVersion : TGUID;
         pStream : pointer; {IStream}
@@ -1918,7 +1920,7 @@ TYPE
 
 
 
-   AsyncIUnknown = Interface( IUnknown)
+   AsyncIUnknown = Interface(IUnknown)
       ['{000e0000-0000-0000-C000-000000000046}']
         Function Begin_QueryInterface(Const riid : TIID): HResult; StdCall;
         Function Finish_QueryInterface(Out ppvObject : Pointer):HResult;StdCall;
@@ -3093,15 +3095,16 @@ TYPE
   LPOLEMENUGROUPWIDTHS = ^OLEMENUGROUPWIDTHS;
   POleMenuGroupWidths = LPOLEMENUGROUPWIDTHS;
 
+  IProvideClassInfo = Interface (IUnknown)
+    ['{B196B283-BAB4-101A-B69C-00AA00341D07}']
+    function GetClassInfo(out pptti : ITypeInfo):HResult; StdCall;
+  end;
+
 
-    IProvideClassInfo = Interface (IUnknown)
-       ['{B196B283-BAB4-101A-B69C-00AA00341D07}']
-         function GetClassInfo(out pptti : ITypeInfo):HResult; StdCall;
-			 end;
-    IProvideClassInfo2 = Interface (IProvideClassInfo)
-       ['{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}']
-         function GetGUID(dwguid:DWord;out pguid:TGUID):HResult; StdCall;
-	end;
+  IProvideClassInfo2 = Interface (IProvideClassInfo)
+    ['{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}']
+    function GetGUID(dwguid:DWord;out pguid:TGUID):HResult; StdCall;
+  end;
 
 { ******************************************************************************************************************
                                                           stuff from objbase.h
@@ -3218,12 +3221,12 @@ type
     function TranslateAccelerator(var msg: TMsg; wID: Word): HResult;StdCall;
   end;
 
-  IOleLink = interface(IUnknown) 
+  IOleLink = interface(IUnknown)
      ['{0000011d-0000-0000-C000-000000000046}']
     function SetUpdateOptions(dwupdateopt:dword):HResult; stdcall;
     function GetUpdateOptions(dwupdateopt:pdword):HResult; stdcall;
     function SetSourceMoniker(pmk : IMoniker;const clsid: TCLSID):HRESULT; stdcall;
-    function GetSourceMoniker(out pmk : IMoniker):HRESULT; stdcall;           
+    function GetSourceMoniker(out pmk : IMoniker):HRESULT; stdcall;
     function SetSourceDisplayName(ppszDisplayName:lpolestr):HResult; stdcall;
     function GetSourceDisplayName(out ppszDisplayName:lpolestr):HResult; stdcall;
     function BindToSource(bindflags:DWord;pbc: IBindCTX):HResult; stdcall;
@@ -3244,7 +3247,7 @@ type
       function OnInPlaceDeactivate :hresult; stdcall;
       function DiscardUndoState :hresult; stdcall;
       function DeactivateAndUndo :hresult; stdcall;
-      function OnPosRectChange(lprcPosRect:LPRect):hresult; stdcall;   
+      function OnPosRectChange(lprcPosRect:LPRect):hresult; stdcall;
       end;
 
     IOleInPlaceObject = interface(IOleWindow)
@@ -3254,7 +3257,7 @@ type
       function SetObjectRects(lprcPosRect:LPRect;lprcClipRect:LPRect):hresult; stdcall;
       function ReactivateAndUndo : HResult;
      end;
-  
+
     IOleDocumentView = interface(IUnknown)
         ['{b722bcc6-4e68-101b-a2bc-00aa00404770}']
         function SetInPlaceSite(ppipsite:IOleInPlaceSite):hresult; stdcall;
@@ -3301,7 +3304,7 @@ type
 
 { ObjSafe.idl}
   IObjectSafety = interface(IUnknown)
-    ['{CB5BDC81-93C1-11cf-8F20-00805F2CD064}']             
+    ['{CB5BDC81-93C1-11cf-8F20-00805F2CD064}']
     function GetInterfaceSafetyOptions(const riid:Tiid; out pdwsupportedoptions: dword;out pdwenabledoptions: dword):HRESULT; stdcall;
     function SetInterfaceSafetyOptions(const riid:Tiid; const dwoptionsetmask: dword;const dwenabledoptions : dword):HRESULT; stdcall;
     end;
@@ -3317,8 +3320,8 @@ type
     function Unfreeze(dwfreeze:dword):HResult; stdcall;
     function SetAdvise(aspects:DWORD;advf:DWORD;padvSink:IAdviseSink):HRESULT;stdcall;
     function Getadvise(paspects:pdword;padvf:pdword;out ppadvsink: IADviseSink):HRESULT;stdcall;
-    end;     
-        
+    end;
+
   IViewObject2 = interface(IViewObject)
     ['{00000127-0000-0000-C000-000000000046}']
     function GetExtent(dwDrawAspect:dword;lindex:DWord;ptd:pDVTARGETDEVICE;lpsizel:LPSIZEL):HRESULT;stdcall;
@@ -3330,7 +3333,7 @@ type
 
 Const CATDESC_MAX = 128;
 
-Type 
+Type
     CATID  = TGUID;
     TCATID = TGUID;
     PCATID = PGUID;
@@ -3339,7 +3342,7 @@ Type
 	LCID  : lcid;
         szDescription : array[0..CATDESC_MAX-1] of WideChar;
         end;
-  
+
    CATEGORYINFO   = tagCATEGORYINFO;
    TCATEGORYINFO  = tagCATEGORYINFO;
    LPCATEGORYINFO = ^tagCATEGORYINFO;
@@ -3347,8 +3350,8 @@ Type
 
    IEnumCLSID = IEnumGUID;
    IEnumCategoryInfo = interface(IUnknown)
-          ['{0002E011-0000-0000-C000-000000000046}'] 
-          function Next(celt: ULONG; out rgelt: TCategoryInfo; out pceltFetched: ULONG): HResult; stdcall;      
+          ['{0002E011-0000-0000-C000-000000000046}']
+          function Next(celt: ULONG; out rgelt: TCategoryInfo; out pceltFetched: ULONG): HResult; stdcall;
           function Skip(celt:ULONG):HResult; StdCall;
           function Reset:HResult; StdCall;
           function CLone(Out ppenum : IEnumCategoryInfo):HResult;StdCall;
@@ -3358,12 +3361,12 @@ Type
      ['{0002E012-0000-0000-C000-000000000046}']
      function RegisterCategories   (cCategories:ULONG;rgCategoryInfo : PCategoryInfo):HResult;Stdcall;
      function UnRegisterCategories (cCategories:ULONG;PCatid :PCATID):HResult;Stdcall;
-     function RegisterClassImplCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;     
-     function UnRegisterClassImplCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;       
-     function RegisterClassReqCategories  (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;     
-     function UnRegisterClassReqCategories  (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;       
+     function RegisterClassImplCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
+     function UnRegisterClassImplCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
+     function RegisterClassReqCategories  (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
+     function UnRegisterClassReqCategories  (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
     end;
-         
+
    ICatInformation = interface(IUnknown)
      ['{0002E013-0000-0000-C000-000000000046}']
      function EnumCategories(lcid:lcid;out ppenumCategoryInfo : ICatInformation):HResult; StdCall;
@@ -3381,7 +3384,7 @@ Type
      function Delete(const rfmtid:FMTID):HRESULT; StdCall;
      function Enum(out ppenum:IEnumSTATPROPSETSTG):HRESULT; StdCall;
      end;
- 
+
    IEnumSTATPROPSTG = interface( IUnknown)
      ['{00000139-0000-0000-C000-000000000046}']
      function Next(celt:ULONG; var rgelt:STATPROPSTG; pceltFetched:pULONG):HRESULT; StdCall;
@@ -3944,6 +3947,254 @@ function VariantTimeToDosDateTime( vtime:DOUBLE;pwdosdate:PUSHORT;pwDosTime:PUSH
 function SystemTimeToVariantTime(LPSYSTEMTIME:lpSystemTime;pvtime: PDOUBLE):LONGINT; stdcall; external oleaut32dll name 'SystemTimeToVariantTime';
 function VariantTimeToSystemTime(vtime:DOUBLE; lpsystemtime: LPSYSTEMTIME):LONGINT; stdcall; external oleaut32dll name 'VariantTimeToSystemTime';
 
+
+{--------------------------------------------------------------------- }
+{                     VARTYPE Coercion API                             }
+{--------------------------------------------------------------------- }
+{ Note: The routines that convert *from* a string are defined
+ * to take a OLECHAR* rather than a BSTR because no allocation is
+ * required, and this makes the routines a bit more generic.
+ * They may of course still be passed a BSTR as the strIn param.
+  }
+
+function VarUI1FromI2(sIn:SHORT; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI2';
+function VarUI1FromI4(lIn:LONG; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI4';
+function VarUI1FromI8(i64In:LONG64; pbOut:PBYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI8';
+function VarUI1FromR4(fltIn:Single; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromR4';
+function VarUI1FromR8(dblIn:DOUBLE; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromR8';
+function VarUI1FromCy(cyIn:CY; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromCy';
+function VarUI1FromDate(dateIn:DATE; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromDate';
+function VarUI1FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromStr';
+function VarUI1FromDisp(pdispIn:IDispatch; lcid:LCID; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromDisp';
+function VarUI1FromBool(boolIn:VARIANT_BOOL; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromBool';
+function VarUI1FromI1(cIn:CHAR; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI1';
+function VarUI1FromUI2(uiIn:USHORT; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromUI2';
+function VarUI1FromUI4(ulIn:ULONG; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromUI4';
+function VarUI1FromUI8(ui64In:ULONG64; pbOut:PBYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromUI8';
+function VarUI1FromDec(var pdecIn:TDecimal; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromDec';
+function VarI2FromUI1(bIn:BYTE; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI1';
+function VarI2FromI4(lIn:LONG; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromI4';
+
+function VarI2FromI8(i64In:LONG64; psOut:PSHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromI8';
+function VarI2FromR4(fltIn:Single; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromR4';
+function VarI2FromR8(dblIn:DOUBLE; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromR8';
+function VarI2FromCy(cyIn:CY; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromCy';
+function VarI2FromDate(dateIn:DATE; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromDate';
+function VarI2FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromStr';
+function VarI2FromDisp(pdispIn:IDispatch; lcid:LCID; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromDisp';
+function VarI2FromBool(boolIn:VARIANT_BOOL; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromBool';
+function VarI2FromI1(cIn:CHAR; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromI1';
+function VarI2FromUI2(uiIn:USHORT; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI2';
+function VarI2FromUI4(ulIn:ULONG; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI4';
+
+function VarI2FromUI8(ui64In:ULONG64; psOut:PSHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI8';
+function VarI2FromDec(var pdecIn:TDecimal; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromDec';
+function VarI4FromUI1(bIn:BYTE; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI1';
+function VarI4FromI2(sIn:SHORT; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromI2';
+
+function VarI4FromI8(i64In:LONG64; plOut:PLONG):HResult;stdcall;external oleaut32dll name 'VarI4FromI8';
+function VarI4FromR4(fltIn:Single; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromR4';
+function VarI4FromR8(dblIn:DOUBLE; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromR8';
+function VarI4FromCy(cyIn:CY; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromCy';
+function VarI4FromDate(dateIn:DATE; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromDate';
+function VarI4FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromStr';
+function VarI4FromDisp(dispIn:IDispatch; lcid:LCID; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromDisp';
+function VarI4FromBool(boolIn:VARIANT_BOOL; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromBool';
+function VarI4FromI1(cIn:CHAR; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromI1';
+function VarI4FromUI2(uiIn:USHORT; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI2';
+function VarI4FromUI4(ulIn:ULONG; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI4';
+
+function VarI4FromUI8(ui64In:ULONG64; plOut:PLONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI8';
+function VarI4FromDec(var pdecIn:TDecimal; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromDec';
+function VarI4FromInt(intIn:cint; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromInt';
+
+function VarI8FromUI1(bIn:BYTE; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI1';
+function VarI8FromI2(sIn:SHORT; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromI2';
+function VarI8FromI4(lIn:LONG; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromI4';
+function VarI8FromR4(fltIn:Single; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromR4';
+function VarI8FromR8(dblIn:DOUBLE; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromR8';
+function VarI8FromCy(cyIn:CY; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromCy';
+function VarI8FromDate(dateIn:DATE; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromDate';
+function VarI8FromStr(strIn:POLECHAR; lcid:LCID; dwFlags:dword; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromStr';
+function VarI8FromDisp(pdispIn:IDispatch; lcid:LCID; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromDisp';
+function VarI8FromBool(boolIn:VARIANT_BOOL; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromBool';
+function VarI8FromI1(cIn:CHAR; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromI1';
+
+function VarI8FromUI2(uiIn:USHORT; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI2';
+function VarI8FromUI4(ulIn:ULONG; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI4';
+function VarI8FromUI8(ui64In:ULONG64; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI8';
+function VarI8FromDec(var pdecIn:TDecimal; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromDec';
+function VarI8FromInt(intIn:cint; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromInt';
+
+{******************* }
+function VarR4FromUI1(bIn:BYTE; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromUI1';
+function VarR4FromI2(sIn:SHORT; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromI2';
+function VarR4FromI4(lIn:LONG; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromI4';
+
+function VarR4FromI8(i64In:LONG64; pfltOut:PSingle):HResult;stdcall;external oleaut32dll name 'VarR4FromI8';
+function VarR4FromR8(dblIn:DOUBLE; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromR8';
+function VarR4FromCy(cyIn:CY; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromCy';
+function VarR4FromDate(dateIn:DATE; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromDate';
+function VarR4FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromStr';
+function VarR4FromDisp(pdispIn:IDispatch; lcid:LCID; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromDisp';
+function VarR4FromBool(boolIn:VARIANT_BOOL; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromBool';
+function VarR4FromI1(cIn:CHAR; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromI1';
+function VarR4FromUI2(uiIn:USHORT; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromUI2';
+function VarR4FromUI4(ulIn:ULONG; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromUI4';
+
+function VarR4FromUI8(ui64In:ULONG64; pfltOut:PSingle):HResult;stdcall;external oleaut32dll name 'VarR4FromUI8';
+function VarR4FromDec(var pdecIn:TDecimal; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromDec';
+function VarR8FromUI1(bIn:BYTE; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI1';
+function VarR8FromI2(sIn:SHORT; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI2';
+function VarR8FromI4(lIn:LONG; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI4';
+
+function VarR8FromI8(i64In:LONG64; pdblOut:PDOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI8';
+function VarR8FromR4(fltIn:Single; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromR4';
+function VarR8FromCy(cyIn:CY; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromCy';
+function VarR8FromDate(dateIn:DATE; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromDate';
+function VarR8FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromStr';
+function VarR8FromDisp(pdispIn:IDispatch; lcid:LCID; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromDisp';
+function VarR8FromBool(boolIn:VARIANT_BOOL; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromBool';
+function VarR8FromI1(cIn:CHAR; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI1';
+function VarR8FromUI2(uiIn:USHORT; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI2';
+function VarR8FromUI4(ulIn:ULONG; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI4';
+
+function VarR8FromUI8(ui64In:ULONG64; pdblOut:PDOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI8';
+function VarR8FromDec(var pdecIn:TDecimal; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromDec';
+function VarDateFromUI1(bIn:BYTE; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI1';
+function VarDateFromI2(sIn:SHORT; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI2';
+function VarDateFromI4(lIn:LONG; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI4';
+
+function VarDateFromI8(i64In:LONG64; pdateOut:PDATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI8';
+function VarDateFromR4(fltIn:Single; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromR4';
+function VarDateFromR8(dblIn:DOUBLE; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromR8';
+function VarDateFromCy(cyIn:CY; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromCy';
+function VarDateFromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromStr';
+
+function VarDateFromDisp(pdispIn:IDispatch; lcid:LCID; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromDisp';
+function VarDateFromBool(boolIn:VARIANT_BOOL; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromBool';
+function VarDateFromI1(cIn:CHAR; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI1';
+function VarDateFromUI2(uiIn:USHORT; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI2';
+function VarDateFromUI4(ulIn:ULONG; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI4';
+
+function VarDateFromUI8(ui64In:ULONG64; pdateOut:PDATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI8';
+function VarDateFromDec(var pdecIn:TDecimal; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromDec';
+function VarCyFromUI1(bIn:BYTE; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromUI1';
+function VarCyFromI2(sIn:SHORT; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromI2';
+function VarCyFromI4(lIn:LONG; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromI4';
+
+function VarCyFromI8(i64In:LONG64; pcyOut:PCurrency):HResult;stdcall;external oleaut32dll name 'VarCyFromI8';
+function VarCyFromR4(fltIn:Single; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromR4';
+function VarCyFromR8(dblIn:DOUBLE; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromR8';
+function VarCyFromDate(dateIn:DATE; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromDate';
+function VarCyFromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromStr';
+function VarCyFromDisp(pdispIn:IDispatch; lcid:LCID; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromDisp';
+function VarCyFromBool(boolIn:VARIANT_BOOL; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromBool';
+function VarCyFromI1(cIn:CHAR; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromI1';
+function VarCyFromUI2(uiIn:USHORT; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromUI2';
+function VarCyFromUI4(ulIn:ULONG; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromUI4';
+
+function VarCyFromUI8(ui64In:ULONG64; pcyOut:PCurrency):HResult;stdcall;external oleaut32dll name 'VarCyFromUI8';
+function VarCyFromDec(var pdecIn:TDecimal; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromDec';
+function VarBstrFromUI1(bVal:BYTE; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI1';
+function VarBstrFromI2(iVal:SHORT; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI2';
+function VarBstrFromI4(lIn:LONG; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI4';
+
+function VarBstrFromI8(i64In:LONG64; lcid:LCID; dwFlags:dword; pbstrOut:PBSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI8';
+function VarBstrFromR4(fltIn:Single; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromR4';
+function VarBstrFromR8(dblIn:DOUBLE; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromR8';
+function VarBstrFromCy(cyIn:CY; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromCy';
+function VarBstrFromDate(dateIn:DATE; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromDate';
+function VarBstrFromDisp(pdispIn:IDispatch; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromDisp';
+function VarBstrFromBool(boolIn:VARIANT_BOOL; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromBool';
+function VarBstrFromI1(cIn:CHAR; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI1';
+function VarBstrFromUI2(uiIn:USHORT; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI2';
+function VarBstrFromUI4(ulIn:ULONG; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI4';
+
+function VarBstrFromUI8(ui64In:ULONG64; lcid:LCID; dwFlags:dword; pbstrOut:PBSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI8';
+function VarBstrFromDec(var pdecIn:TDecimal; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromDec';
+function VarBoolFromUI1(bIn:BYTE; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI1';
+function VarBoolFromI2(sIn:SHORT; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI2';
+function VarBoolFromI4(lIn:LONG; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI4';
+
+function VarBoolFromI8(i64In:LONG64; pboolOut:PVARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI8';
+function VarBoolFromR4(fltIn:Single; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromR4';
+function VarBoolFromR8(dblIn:DOUBLE; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromR8';
+function VarBoolFromDate(dateIn:DATE; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromDate';
+function VarBoolFromCy(cyIn:CY; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromCy';
+function VarBoolFromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromStr';
+function VarBoolFromDisp(pdispIn:IDispatch; lcid:LCID; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromDisp';
+function VarBoolFromI1(cIn:CHAR; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI1';
+function VarBoolFromUI2(uiIn:USHORT; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI2';
+function VarBoolFromUI4(ulIn:ULONG; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI4';
+
+function VarBoolFromUI8(i64In:ULONG64; pboolOut:PVARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI8';
+function VarBoolFromDec(var pdecIn:TDecimal; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromDec';
+function VarI1FromUI1(bIn:BYTE; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI1';
+function VarI1FromI2(uiIn:SHORT; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromI2';
+function VarI1FromI4(lIn:LONG; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromI4';
+function VarI1FromI8(i64In:LONG64; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromI8';
+function VarI1FromR4(fltIn:Single; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromR4';
+function VarI1FromR8(dblIn:DOUBLE; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromR8';
+function VarI1FromDate(dateIn:DATE; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromDate';
+function VarI1FromCy(cyIn:CY; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromCy';
+function VarI1FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromStr';
+function VarI1FromDisp(pdispIn:IDispatch; lcid:LCID; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromDisp';
+function VarI1FromBool(boolIn:VARIANT_BOOL; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromBool';
+function VarI1FromUI2(uiIn:USHORT; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI2';
+function VarI1FromUI4(ulIn:ULONG; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI4';
+function VarI1FromUI8(i64In:ULONG64; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI8';
+function VarI1FromDec(var pdecIn:TDecimal; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromDec';
+function VarUI2FromUI1(bIn:BYTE; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromUI1';
+function VarUI2FromI2(uiIn:SHORT; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI2';
+function VarUI2FromI4(lIn:LONG; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI4';
+
+function VarUI2FromI8(i64In:LONG64; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI8';
+function VarUI2FromR4(fltIn:Single; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromR4';
+function VarUI2FromR8(dblIn:DOUBLE; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromR8';
+function VarUI2FromDate(dateIn:DATE; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromDate';
+function VarUI2FromCy(cyIn:CY; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromCy';
+function VarUI2FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromStr';
+function VarUI2FromDisp(pdispIn:IDispatch; lcid:LCID; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromDisp';
+function VarUI2FromBool(boolIn:VARIANT_BOOL; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromBool';
+function VarUI2FromI1(cIn:CHAR; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI1';
+function VarUI2FromUI4(ulIn:ULONG; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromUI4';
+function VarUI2FromUI8(i64In:ULONG64; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromUI8';
+function VarUI2FromDec(var pdecIn:TDecimal; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromDec';
+function VarUI4FromUI1(bIn:BYTE; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromUI1';
+function VarUI4FromI2(uiIn:SHORT; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI2';
+function VarUI4FromI4(lIn:LONG; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI4';
+function VarUI4FromI8(i64In:LONG64; var plOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI8';
+function VarUI4FromR4(fltIn:Single; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromR4';
+function VarUI4FromR8(dblIn:DOUBLE; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromR8';
+function VarUI4FromDate(dateIn:DATE; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromDate';
+function VarUI4FromCy(cyIn:CY; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromCy';
+function VarUI4FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromStr';
+function VarUI4FromDisp(pdispIn:IDispatch; lcid:LCID; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromDisp';
+function VarUI4FromBool(boolIn:VARIANT_BOOL; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromBool';
+function VarUI4FromI1(cIn:CHAR; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI1';
+function VarUI4FromUI2(uiIn:USHORT; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromUI2';
+function VarUI4FromUI8(ui64In:ULONG64; var plOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromUI8';
+function VarUI4FromDec(var pdecIn:TDecimal; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromDec';
+
+{**************************************** }
+function VarUI8FromUI1(bIn:BYTE; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromUI1';
+function VarUI8FromI2(sIn:SHORT; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI2';
+function VarUI8FromI4(lIn:LONG; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI4';
+function VarUI8FromI8(ui64In:LONG64; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI8';
+function VarUI8FromR4(fltIn:Single; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromR4';
+function VarUI8FromR8(dblIn:DOUBLE; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromR8';
+function VarUI8FromCy(cyIn:CY; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromCy';
+function VarUI8FromDate(dateIn:DATE; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromDate';
+function VarUI8FromStr(strIn:POLECHAR; lcid:LCID; dwFlags:dword; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromStr';
+function VarUI8FromDisp(pdispIn:IDispatch; lcid:LCID; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromDisp';
+function VarUI8FromBool(boolIn:VARIANT_BOOL; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromBool';
+function VarUI8FromI1(cIn:CHAR; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI1';
+function VarUI8FromUI2(uiIn:USHORT; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromUI2';
+function VarUI8FromUI4(ulIn:ULONG; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromUI4';
+function VarUI8FromDec(var pdecIn:TDecimal; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromDec';
+function VarUI8FromInt(intIn:cint; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromInt';
+
 implementation
 
 function Succeeded(Res: HResult) : Boolean;inline;

+ 6 - 6
packages/winunits-base/src/shlobj.pp

@@ -923,9 +923,9 @@ Type
           pszDisplayName : LPSTR;    { Return display name of item selected. }
           lpszTitle : LPCSTR;        { text to go in the banner over the tree. }
           ulFlags : UINT;            { Flags that control the return stuff }
-          lpfn : BFFCALLBACK;        { extra info that's passed back in callbacks }
-          lParam : LPARAM;           { output var: where to return the Image index. }
-          iImage : longint;
+          lpfn : BFFCALLBACK;        
+          lParam : LPARAM;           { extra info that's passed back in callbacks }
+          iImage : longint;          { output var: where to return the Image index. }
        end;
      BROWSEINFOA = _browseinfoA;
      PBROWSEINFOA = ^BROWSEINFOA;
@@ -940,9 +940,9 @@ Type
           pszDisplayName : LPWSTR;    { Return display name of item selected. }
           lpszTitle : LPCWSTR;        { text to go in the banner over the tree. }
           ulFlags : UINT;             { Flags that control the return stuff }
-          lpfn : BFFCALLBACK;         { extra info that's passed back in callbacks }
-          lParam : LPARAM;            { output var: where to return the Image index. }
-          iImage : longint;
+          lpfn : BFFCALLBACK;         
+          lParam : LPARAM;            { extra info that's passed back in callbacks }
+          iImage : longint;           { output var: where to return the Image index. }
        end;
      BROWSEINFOW = _browseinfoW;
      PBROWSEINFOW = ^BROWSEINFOW;

+ 2 - 2
packages/x11/src/xinerama.pp

@@ -18,9 +18,9 @@ type
         height        : cshort;
      end;
 
-function XineramaQueryExtension(dpy:PDisplay; event_base:Pcint; error_base:Pcint):TBool;cdecl;external 'Xinerama';
+function XineramaQueryExtension(dpy:PDisplay; event_base:Pcint; error_base:Pcint):TBoolResult;cdecl;external 'Xinerama';
 function XineramaQueryVersion(dpy:PDisplay; major:Pcint; minor:Pcint):TStatus;cdecl;external 'Xinerama';
-function XineramaIsActive(dpy:PDisplay):TBool;cdecl;external 'Xinerama';
+function XineramaIsActive(dpy:PDisplay):TBoolResult;cdecl;external 'Xinerama';
 function XineramaQueryScreens(dpy:PDisplay; number:Pcint):PXineramaScreenInfo;cdecl;external 'Xinerama';
 
 implementation

+ 35 - 35
packages/x11/src/xlib.pp

@@ -1283,25 +1283,25 @@ function XInternAtom(para1:PDisplay; para2:Pchar; para3:TBool):TAtom;cdecl;exter
 function XInternAtoms(para1:PDisplay; para2:PPchar; para3:cint; para4:TBool; para5:PAtom):TStatus;cdecl;external libX11;
 function XCopyColormapAndFree(para1:PDisplay; para2:TColormap):TColormap;cdecl;external libX11;
 function XCreateColormap(para1:PDisplay; para2:TWindow; para3:PVisual; para4:cint):TColormap;cdecl;external libX11;
-function XCreatePixmapCursor(para1:PDisplay; para2:TPixmap; para3:TPixmap; para4:PXColor; para5:PXColor;
-           para6:cuint; para7:cuint):TCursor;cdecl;external libX11;
-function XCreateGlyphCursor(para1:PDisplay; para2:TFont; para3:TFont; para4:cuint; para5:cuint;
-           para6:PXColor; para7:PXColor):TCursor;cdecl;external libX11;
-function XCreateFontCursor(para1:PDisplay; para2:cuint):TCursor;cdecl;external libX11;
+function XCreatePixmapCursor(ADisplay:PDisplay; ASource:TPixmap; AMask:TPixmap; AForegroundColor:PXColor; ABackgroundColor:PXColor;
+           AX:cuint; AY:cuint):TCursor;cdecl;external libX11;
+function XCreateGlyphCursor(ADisplay:PDisplay; ASourceFont:TFont; AMaskFont:TFont; ASourceChar:cuint; AMaskChar:cuint;
+           AForegroundColor:PXColor; ABackgroundColor:PXColor):TCursor;cdecl;external libX11;
+function XCreateFontCursor(ADisplay:PDisplay; AShape:cuint):TCursor;cdecl;external libX11;
 function XLoadFont(para1:PDisplay; para2:Pchar):TFont;cdecl;external libX11;
 function XCreateGC(para1:PDisplay; para2:TDrawable; para3:culong; para4:PXGCValues):TGC;cdecl;external libX11;
 function XGContextFromGC(para1:TGC):TGContext;cdecl;external libX11;
 procedure XFlushGC(para1:PDisplay; para2:TGC);cdecl;external libX11;
-function XCreatePixmap(para1:PDisplay; para2:TDrawable; para3:cuint; para4:cuint; para5:cuint):TPixmap;cdecl;external libX11;
-function XCreateBitmapFromData(para1:PDisplay; para2:TDrawable; para3:Pchar; para4:cuint; para5:cuint):TPixmap;cdecl;external libX11;
+function XCreatePixmap(ADisplay:PDisplay; ADrawable:TDrawable; AWidth:cuint; AHeight:cuint; ADepth:cuint):TPixmap;cdecl;external libX11;
+function XCreateBitmapFromData(ADiplay:PDisplay; ADrawable:TDrawable; AData:Pchar; AWidth:cuint; AHeight:cuint):TPixmap;cdecl;external libX11;
 function XCreatePixmapFromBitmapData(para1:PDisplay; para2:TDrawable; para3:Pchar; para4:cuint; para5:cuint;
            para6:culong; para7:culong; para8:cuint):TPixmap;cdecl;external libX11;
-function XCreateSimpleWindow(para1:PDisplay; para2:TWindow; para3:cint; para4:cint; para5:cuint;
-           para6:cuint; para7:cuint; para8:culong; para9:culong):TWindow;cdecl;external libX11;
+function XCreateSimpleWindow(ADisplay:PDisplay; AParent:TWindow; AX:cint; AY:cint; AWidth:cuint;
+           AHeight:cuint; ABorderWidth:cuint; ABorder:culong; ABackground:culong):TWindow;cdecl;external libX11;
 function XGetSelectionOwner(para1:PDisplay; para2:TAtom):TWindow;cdecl;external libX11;
-function XCreateWindow(para1:PDisplay; para2:TWindow; para3:cint; para4:cint; para5:cuint;
-           para6:cuint; para7:cuint; para8:cint; para9:cuint; para10:PVisual;
-           para11:culong; para12:PXSetWindowAttributes):TWindow;cdecl;external libX11;
+function XCreateWindow(ADisplay:PDisplay; AParent:TWindow; AX:cint; AY:cint; AWidth:cuint;
+           AHeight:cuint; ABorderWidth:cuint; ADepth:cint; AClass:cuint; AVisual:PVisual;
+           AValueMask:culong; AAttributes:PXSetWindowAttributes):TWindow;cdecl;external libX11;
 function XListInstalledColormaps(para1:PDisplay; para2:TWindow; para3:Pcint):PColormap;cdecl;external libX11;
 function XListFonts(para1:PDisplay; para2:Pchar; para3:cint; para4:Pcint):PPChar;cdecl;external libX11;
 function XListFontsWithInfo(para1:PDisplay; para2:Pchar; para3:cint; para4:Pcint; para5:PPXFontStruct):PPChar;cdecl;external libX11;
@@ -1326,15 +1326,15 @@ function XInitExtension(para1:PDisplay; para2:Pchar):PXExtCodes;cdecl;external l
 function XAddExtension(para1:PDisplay):PXExtCodes;cdecl;external libX11;
 function XFindOnExtensionList(para1:PPXExtData; para2:cint):PXExtData;cdecl;external libX11;
 function XEHeadOfExtensionList(para1:TXEDataObject):PPXExtData;cdecl;external libX11;
-function XRootWindow(para1:PDisplay; para2:cint):TWindow;cdecl;external libX11;
-function XDefaultRootWindow(para1:PDisplay):TWindow;cdecl;external libX11;
+function XRootWindow(ADisplay:PDisplay; AScreenNumber:cint):TWindow;cdecl;external libX11;
+function XDefaultRootWindow(ADisplay:PDisplay):TWindow;cdecl;external libX11;
 function XRootWindowOfScreen(para1:PScreen):TWindow;cdecl;external libX11;
 function XDefaultVisual(para1:PDisplay; para2:cint):PVisual;cdecl;external libX11;
 function XDefaultVisualOfScreen(para1:PScreen):PVisual;cdecl;external libX11;
 function XDefaultGC(para1:PDisplay; para2:cint):TGC;cdecl;external libX11;
 function XDefaultGCOfScreen(para1:PScreen):TGC;cdecl;external libX11;
-function XBlackPixel(para1:PDisplay; para2:cint):culong;cdecl;external libX11;
-function XWhitePixel(para1:PDisplay; para2:cint):culong;cdecl;external libX11;
+function XBlackPixel(ADisplay:PDisplay; AScreenNumber:cint):culong;cdecl;external libX11;
+function XWhitePixel(ADisplay:PDisplay; AScreenNumber:cint):culong;cdecl;external libX11;
 function XAllPlanes:culong;cdecl;external libX11;
 function XBlackPixelOfScreen(para1:PScreen):culong;cdecl;external libX11;
 function XWhitePixelOfScreen(para1:PScreen):culong;cdecl;external libX11;
@@ -1370,7 +1370,7 @@ function XGetCommand(para1:PDisplay; para2:TWindow; para3:PPPchar; para4:Pcint):
 function XGetWMColormapWindows(para1:PDisplay; para2:TWindow; para3:PPWindow; para4:Pcint):TStatus;cdecl;external libX11;
 function XSetWMColormapWindows(para1:PDisplay; para2:TWindow; para3:PWindow; para4:cint):TStatus;cdecl;external libX11;
 procedure XFreeStringList(para1:PPchar);cdecl;external libX11;
-function XSetTransientForHint(para1:PDisplay; para2:TWindow; para3:TWindow):cint;cdecl;external libX11;
+function XSetTransientForHint(ADisplay:PDisplay; AWindow:TWindow; APropWindow:TWindow):cint;cdecl;external libX11;
 function XActivateScreenSaver(para1:PDisplay):cint;cdecl;external libX11;
 function XAddHost(para1:PDisplay; para2:PXHostAddress):cint;cdecl;external libX11;
 function XAddHosts(para1:PDisplay; para2:PXHostAddress; para3:cint):cint;cdecl;external libX11;
@@ -1426,10 +1426,10 @@ function XCopyPlane(para1:PDisplay; para2:TDrawable; para3:TDrawable; para4:TGC;
 function XDefaultDepth(para1:PDisplay; para2:cint):cint;cdecl;external libX11;
 function XDefaultDepthOfScreen(para1:PScreen):cint;cdecl;external libX11;
 function XDefaultScreen(para1:PDisplay):cint;cdecl;external libX11;
-function XDefineCursor(para1:PDisplay; para2:TWindow; para3:TCursor):cint;cdecl;external libX11;
+function XDefineCursor(ADisplay:PDisplay; AWindow:TWindow; ACursor:TCursor):cint;cdecl;external libX11;
 function XDeleteProperty(para1:PDisplay; para2:TWindow; para3:TAtom):cint;cdecl;external libX11;
-function XDestroyWindow(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
-function XDestroySubwindows(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
+function XDestroyWindow(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
+function XDestroySubwindows(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
 function XDoesBackingStore(para1:PScreen):cint;cdecl;external libX11;
 function XDoesSaveUnders(para1:PScreen):TBool;cdecl;external libX11;
 function XDisableAccessControl(para1:PDisplay):cint;cdecl;external libX11;
@@ -1482,7 +1482,7 @@ function XForceScreenSaver(para1:PDisplay; para2:cint):cint;cdecl;external libX1
 function XFree(para1:pointer):cint;cdecl;external libX11;
 function XFreeColormap(para1:PDisplay; para2:TColormap):cint;cdecl;external libX11;
 function XFreeColors(para1:PDisplay; para2:TColormap; para3:Pculong; para4:cint; para5:culong):cint;cdecl;external libX11;
-function XFreeCursor(para1:PDisplay; para2:TCursor):cint;cdecl;external libX11;
+function XFreeCursor(ADisplay:PDisplay; ACursor:TCursor):cint;cdecl;external libX11;
 function XFreeExtensionList(para1:PPchar):cint;cdecl;external libX11;
 function XFreeFont(para1:PDisplay; para2:PXFontStruct):cint;cdecl;external libX11;
 function XFreeFontInfo(para1:PPchar; para2:PXFontStruct; para3:cint):cint;cdecl;external libX11;
@@ -1529,21 +1529,21 @@ function XInstallColormap(para1:PDisplay; para2:TColormap):cint;cdecl;external l
 function XKeysymToKeycode(para1:PDisplay; para2:TKeySym):TKeyCode;cdecl;external libX11;
 function XKillClient(para1:PDisplay; para2:TXID):cint;cdecl;external libX11;
 function XLookupColor(para1:PDisplay; para2:TColormap; para3:Pchar; para4:PXColor; para5:PXColor):TStatus;cdecl;external libX11;
-function XLowerWindow(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
-function XMapRaised(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
-function XMapSubwindows(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
-function XMapWindow(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
+function XLowerWindow(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
+function XMapRaised(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
+function XMapSubwindows(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
+function XMapWindow(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
 function XMaskEvent(para1:PDisplay; para2:clong; para3:PXEvent):cint;cdecl;external libX11;
 function XMaxCmapsOfScreen(para1:PScreen):cint;cdecl;external libX11;
 function XMinCmapsOfScreen(para1:PScreen):cint;cdecl;external libX11;
-function XMoveResizeWindow(para1:PDisplay; para2:TWindow; para3:cint; para4:cint; para5:cuint;
-           para6:cuint):cint;cdecl;external libX11;
-function XMoveWindow(para1:PDisplay; para2:TWindow; para3:cint; para4:cint):cint;cdecl;external libX11;
-function XNextEvent(para1:PDisplay; para2:PXEvent):cint;cdecl;external libX11;
+function XMoveResizeWindow(ADisplay:PDisplay; AWindow:TWindow; AX:cint; AY:cint; AWidth:cuint;
+           AHeight:cuint):cint;cdecl;external libX11;
+function XMoveWindow(ADisplay:PDisplay; AWindow:TWindow; AX:cint; AY:cint):cint;cdecl;external libX11;
+function XNextEvent(ADisplay:PDisplay; AEvent:PXEvent):cint;cdecl;external libX11;
 function XNoOp(para1:PDisplay):cint;cdecl;external libX11;
 function XParseColor(para1:PDisplay; para2:TColormap; para3:Pchar; para4:PXColor):TStatus;cdecl;external libX11;
 function XParseGeometry(para1:Pchar; para2:Pcint; para3:Pcint; para4:Pcuint; para5:Pcuint):cint;cdecl;external libX11;
-function XPeekEvent(para1:PDisplay; para2:PXEvent):cint;cdecl;external libX11;
+function XPeekEvent(ADisplay:PDisplay; AEvent:PXEvent):cint;cdecl;external libX11;
 function XPeekIfEvent(para1:PDisplay; para2:PXEvent; para3:funcifevent; para4:TXPointer):cint;cdecl;external libX11;
 function XPending(para1:PDisplay):cint;cdecl;external libX11;
 function XPlanesOfScreen(para1:PScreen):cint;cdecl;external libX11;
@@ -1593,7 +1593,7 @@ function XRestackWindows(para1:PDisplay; para2:PWindow; para3:cint):cint;cdecl;e
 function XRotateBuffers(para1:PDisplay; para2:cint):cint;cdecl;external libX11;
 function XRotateWindowProperties(para1:PDisplay; para2:TWindow; para3:PAtom; para4:cint; para5:cint):cint;cdecl;external libX11;
 function XScreenCount(para1:PDisplay):cint;cdecl;external libX11;
-function XSelectInput(para1:PDisplay; para2:TWindow; para3:clong):cint;cdecl;external libX11;
+function XSelectInput(ADisplay:PDisplay; AWindow:TWindow; AEventMask:clong):cint;cdecl;external libX11;
 function XSendEvent(para1:PDisplay; para2:TWindow; para3:TBool; para4:clong; para5:PXEvent):TStatus;cdecl;external libX11;
 function XSetAccessControl(para1:PDisplay; para2:cint):cint;cdecl;external libX11;
 function XSetArcMode(para1:PDisplay; para2:TGC; para3:cint):cint;cdecl;external libX11;
@@ -1646,8 +1646,8 @@ function XTextExtents16(para1:PXFontStruct; para2:PXChar2b; para3:cint; para4:Pc
            para6:Pcint; para7:PXCharStruct):cint;cdecl;external libX11;
 function XTextWidth(para1:PXFontStruct; para2:Pchar; para3:cint):cint;cdecl;external libX11;
 function XTextWidth16(para1:PXFontStruct; para2:PXChar2b; para3:cint):cint;cdecl;external libX11;
-function XTranslateCoordinates(para1:PDisplay; para2:TWindow; para3:TWindow; para4:cint; para5:cint;
-           para6:Pcint; para7:Pcint; para8:PWindow):TBool;cdecl;external libX11;
+function XTranslateCoordinates(ADisplay:PDisplay; ASrcWindow:TWindow; ADestWindow:TWindow; ASrcX:cint; ASrcY:cint;
+           ADestXReturn:Pcint; ADestYReturn:Pcint; AChildReturn:PWindow):TBool;cdecl;external libX11;
 function XUndefineCursor(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
 function XUngrabButton(para1:PDisplay; para2:cuint; para3:cuint; para4:TWindow):cint;cdecl;external libX11;
 function XUngrabKey(para1:PDisplay; para2:cint; para3:cuint; para4:TWindow):cint;cdecl;external libX11;
@@ -1656,8 +1656,8 @@ function XUngrabPointer(para1:PDisplay; para2:TTime):cint;cdecl;external libX11;
 function XUngrabServer(para1:PDisplay):cint;cdecl;external libX11;
 function XUninstallColormap(para1:PDisplay; para2:TColormap):cint;cdecl;external libX11;
 function XUnloadFont(para1:PDisplay; para2:TFont):cint;cdecl;external libX11;
-function XUnmapSubwindows(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
-function XUnmapWindow(para1:PDisplay; para2:TWindow):cint;cdecl;external libX11;
+function XUnmapSubwindows(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
+function XUnmapWindow(ADisplay:PDisplay; AWindow:TWindow):cint;cdecl;external libX11;
 function XVendorRelease(para1:PDisplay):cint;cdecl;external libX11;
 function XWarpPointer(para1:PDisplay; para2:TWindow; para3:TWindow; para4:cint; para5:cint;
            para6:cuint; para7:cuint; para8:cint; para9:cint):cint;cdecl;external libX11;

+ 3 - 3
packages/x11/src/xutil.pp

@@ -259,9 +259,9 @@ procedure XSetWMClientMachine(para1:PDisplay; para2:TWindow; para3:PXTextPropert
 function XSetWMHints(para1:PDisplay; para2:TWindow; para3:PXWMHints):cint;cdecl;external libX11;
 procedure XSetWMIconName(para1:PDisplay; para2:TWindow; para3:PXTextProperty);cdecl;external libX11;
 procedure XSetWMName(para1:PDisplay; para2:TWindow; para3:PXTextProperty);cdecl;external libX11;
-procedure XSetWMNormalHints(para1:PDisplay; para2:TWindow; para3:PXSizeHints);cdecl;external libX11;
-procedure XSetWMProperties(para1:PDisplay; para2:TWindow; para3:PXTextProperty; para4:PXTextProperty; para5:PPchar;
-            para6:cint; para7:PXSizeHints; para8:PXWMHints; para9:PXClassHint);cdecl;external libX11;
+procedure XSetWMNormalHints(ADisplay:PDisplay; AWindow:TWindow; AHints:PXSizeHints);cdecl;external libX11;
+procedure XSetWMProperties(ADisplay:PDisplay; AWindow:TWindow; AWindowName:PXTextProperty; AIconName:PXTextProperty; AArgv:PPchar;
+            AArgc:cint; ANormalHints:PXSizeHints; AWMHints:PXWMHints; AClassHints:PXClassHint);cdecl;external libX11;
 procedure XmbSetWMProperties(para1:PDisplay; para2:TWindow; para3:Pchar; para4:Pchar; para5:PPchar;
             para6:cint; para7:PXSizeHints; para8:PXWMHints; para9:PXClassHint);cdecl;external libX11;
 procedure Xutf8SetWMProperties(para1:PDisplay; para2:TWindow; para3:Pchar; para4:Pchar; para5:PPchar;

+ 17 - 1
rtl/inc/dynlibs.pas

@@ -45,7 +45,23 @@ Function GetProcAddress(Lib : TlibHandle; ProcName : AnsiString) : Pointer;
 
 Type
   HModule = TLibHandle; 
-  
+
+// these are for easier crossplatform construction of dll names in dynloading libs.
+Const
+ {$ifdef Windows}
+  SharedSuffix  = 'dll';
+ {$else}
+   {$ifdef Darwin}
+     SharedSuffix = 'dylib';
+   {$else}
+     {$ifdef OS2}
+       SharedSuffix = 'dll';
+     {$else}
+       SharedSuffix = 'so';  
+     {$endif}
+   {$endif}
+ {$endif}      
+      
 Implementation
 
 { ---------------------------------------------------------------------

+ 3 - 3
rtl/objpas/sysutils/datih.inc

@@ -54,7 +54,7 @@ var
                                age-detection.}
 
    {  date time formatting characters:
-      c      : shortdateformat + ' ' + shorttimeformat
+      c      : shortdateformat + ' ' + longtimeformat
       d      : day of month
       dd     : day of month (leading zero)
       ddd    : day of week (abbreviation)
@@ -65,9 +65,9 @@ var
       mm     : month (leading zero)
       mmm    : month (abbreviation)
       mmmm   : month (full)
-      y      : year (four digits)
+      y      : year (two digits)
       yy     : year (two digits)
-      yyyy   : year (with century)
+      yyyy   : year (four digits, with century)
       h      : hour
       hh     : hour (leading zero)
       n      : minute

+ 13 - 2
rtl/objpas/sysutils/sysutils.inc

@@ -531,22 +531,33 @@ var
 function DoForceDirectories(Const Dir: string): Boolean;
 var
   ADir : String;
+  APath: String;
 begin
   Result:=True;
   ADir:=ExcludeTrailingPathDelimiter(Dir);
   if (ADir='') then Exit;
   if Not DirectoryExists(ADir) then
     begin
-    Result:=DoForceDirectories(ExtractFilePath(ADir));
+      APath := ExtractFilePath(ADir);
+      //this can happen on Windows if user specifies Dir like \user\name/test/
+      //and would, if not checked for, cause an infinite recusrsion and a stack overflow
+      if (APath = ADir) then Result := False
+        else Result:=DoForceDirectories(APath);
     If Result then
       Result := CreateDir(ADir);
     end;
 end;
 
+function IsUncDrive(const Drv: String): Boolean;
+begin
+  Result := (Length(Drv) > 2) and (Drv[1] = PathDelim) and (Drv[2] = PathDelim);
+end;
+
 begin
   Result := False;
   ADrv := ExtractFileDrive(Dir);
-  if (ADrv<>'') and (not DirectoryExists(ADrv)) then Exit;
+  if (ADrv<>'') and (not DirectoryExists(ADrv))
+  {$IFNDEF FORCEDIR_NO_UNC_SUPPORT} and (not IsUncDrive(ADrv)){$ENDIF} then Exit;
   if Dir='' then
     begin
       E:=EInOutError.Create(SCannotCreateEmptyDir);

+ 1 - 0
rtl/win/wininc/base.inc

@@ -91,6 +91,7 @@
      PULONG64    = ^ULONG64;
      PULONG32    = ^ULONG32;
      PULONG_PTR  = ^ULONG_PTR;
+     PLONG64     = ^LONG64;
 
      DWORDLONG  = qword;  { was unsigned long  }
      PDWORDLONG = ^DWORDLONG;

+ 11 - 1
rtl/win/wininc/defines.inc

@@ -205,6 +205,9 @@
      DM_PELSHEIGHT = $100000;
      DM_DISPLAYFLAGS = $200000;
      DM_DISPLAYFREQUENCY = $400000;
+     DM_DISPLAYORIENTATION = LONGWORD($80);
+     DM_DISPLAYQUERYORIENTATION= DWORD($01000000);
+     DM_DISPLAYFIXEDOUTPUT = LONGWORD($20000000);
      CDS_UPDATEREGISTRY = 1;
      CDS_TEST = 2;
      CDS_FULLSCREEN = 4;
@@ -1131,7 +1134,9 @@
      SB_BOTTOM = 7;
      SB_TOP = 6;
   { EnumCalendarInfo  }
-     ENUM_ALL_CALENDARS = -(1);
+     ENUM_ALL_CALENDARS     = dword(-1);
+     ENUM_CURRENT_SETTINGS  = dword(-1);
+     ENUM_REGISTRY_SETTINGS = dword(-2);     
   { EnumDateFormats  }
      DATE_SHORTDATE = 1;
      DATE_LONGDATE = 2;
@@ -5625,6 +5630,11 @@ const
   AC_SRC_OVER = $00;     
   AC_SRC_ALPHA = $01;     
 
+  DMDO_DEFAULT    = 0;
+  DMDO_90         = 1;
+  DMDO_180        = 2;
+  DMDO_270        = 3;
+
 {$endif read_interface}
 
 {$ifdef read_implementation}

+ 4 - 3
rtl/win/wininc/redef.inc

@@ -580,6 +580,7 @@ function GetProcessShutdownParameters(var lpdwLevel, lpdwFlags: DWORD): BOOL; ex
 function GetProcessTimes(hProcess: THandle; var lpCreationTime, lpExitTime, lpKernelTime, lpUserTime: TFileTime): BOOL; external 'kernel32' name 'GetProcessTimes';
 function GetProcessWorkingSetSize(hProcess: THandle; var lpMinimumWorkingSetSize, lpMaximumWorkingSetSize: DWORD): BOOL; external 'kernel32' name 'GetProcessWorkingSetSize';
 function GetQueuedCompletionStatus(CompletionPort: THandle; var lpNumberOfBytesTransferred, lpCompletionKey: DWORD; var lpOverlapped: POverlapped; dwMilliseconds: DWORD): BOOL; external 'kernel32' name 'GetQueuedCompletionStatus';
+function PostQueuedCompletionStatus(CompletionPort: THandle; NumberOfBytesTransferred:dword; dwCompletionKey: ULONG_PTR; lpOverlapped: POverlapped): BOOL; external 'kernel32' name 'PostQueuedCompletionStatus';
 function GetRasterizerCaps(var p1: TRasterizerStatus; p2: UINT): BOOL; external 'gdi32' name 'GetRasterizerCaps';
 function GetRgnBox(RGN: HRGN; var p2: TRect): Integer; external 'gdi32' name 'GetRgnBox';
 function GetScrollInfo(hWnd: HWND; BarFlag: Integer; var ScrollInfo: TScrollInfo): BOOL; external 'user32' name 'GetScrollInfo';
@@ -790,9 +791,9 @@ function RegCreateKeyW(hKey: HKEY; lpSubKey: LPWSTR; var phkResult: HKEY): Longi
 function RegEnumKeyEx(hKey: HKEY; dwIndex: DWORD; lpName: PChar; var lpcbName: DWORD; lpReserved: Pointer; lpClass: PChar; lpcbClass: PDWORD; lpftLastWriteTime: PFileTime): Longint;external 'advapi32' name 'RegEnumKeyExA';
 function RegEnumKeyExA(hKey: HKEY; dwIndex: DWORD; lpName: LPCSTR; var lpcbName: DWORD; lpReserved: Pointer; lpClass: LPCSTR; lpcbClass: PDWORD; lpftLastWriteTime: PFileTime): Longint; external 'advapi32' name 'RegEnumKeyExA';
 function RegEnumKeyExW(hKey: HKEY; dwIndex: DWORD; lpName: LPWSTR; var lpcbName: DWORD; lpReserved: Pointer; lpClass: LPWSTR; lpcbClass: PDWORD; lpftLastWriteTime: PFileTime): Longint; external 'advapi32' name 'RegEnumKeyExW';
-function RegEnumValue(hKey: HKEY; dwIndex: DWORD; lpValueName: PChar; var lpcbValueName: DWORD; lpReserved: Pointer; lpType: PDWORD; lpData: PByte; lpcbData: PDWORD): Longint;external 'advapi32' name 'RegEnumValueA';
-function RegEnumValueA(hKey: HKEY; dwIndex: DWORD; lpValueName: PChar; var lpcbValueName: DWORD; lpReserved: Pointer; lpType: PDWORD; lpData: PByte; lpcbData: PDWORD): Longint; external 'advapi32' name 'RegEnumValueA';
-function RegEnumValueW(hKey: HKEY; dwIndex: DWORD; lpValueName: PChar; var lpcbValueName: DWORD; lpReserved: Pointer; lpType: PDWORD; lpData: PByte; lpcbData: PDWORD): Longint; external 'advapi32' name 'RegEnumValueW';
+function RegEnumValue(hKey: HKEY; dwIndex: DWORD; lpValueName: LPCSTR; var lpcbValueName: DWORD; lpReserved: Pointer; lpType: PDWORD; lpData: PByte; lpcbData: PDWORD): Longint;external 'advapi32' name 'RegEnumValueA';
+function RegEnumValueA(hKey: HKEY; dwIndex: DWORD; lpValueName: LPCSTR; var lpcbValueName: DWORD; lpReserved: Pointer; lpType: PDWORD; lpData: PByte; lpcbData: PDWORD): Longint; external 'advapi32' name 'RegEnumValueA';
+function RegEnumValueW(hKey: HKEY; dwIndex: DWORD; lpValueName: LPWSTR; var lpcbValueName: DWORD; lpReserved: Pointer; lpType: PDWORD; lpData: PByte; lpcbData: PDWORD): Longint; external 'advapi32' name 'RegEnumValueW';
 function RegGetKeySecurity(hKey: HKEY; SecurityInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; var lpcbSecurityDescriptor: DWORD): Longint; external 'advapi32' name 'RegGetKeySecurity';
 function RegSetValueEx(hKey:HKEY; lpValueName:LPCSTR; Reserved:DWORD; dwType:DWORD; lpData:pointer;cbData:DWORD):LONG; external 'advapi32' name 'RegSetValueExA';
 function RegSetValueExA(hKey:HKEY; lpValueName:LPCSTR; Reserved:DWORD; dwType:DWORD; lpData:pointer;cbData:DWORD):LONG; external 'advapi32' name 'RegSetValueExA';